diff options
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 7 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 2 | ||||
-rw-r--r-- | src/qml/doc/src/whatsnew.qdoc | 130 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4numberobject.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 3 | ||||
-rw-r--r-- | src/qml/memory/memory.pri | 6 | ||||
-rw-r--r-- | src/qml/qml/ftw/ftw.pri | 1 | ||||
-rw-r--r-- | src/qml/qml/ftw/qqmlnullablevalue_p.h (renamed from src/qml/qml/qqmlnullablevalue_p_p.h) | 0 | ||||
-rw-r--r-- | src/qml/qml/ftw/qqmlpool_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/ftw/qqmlrefcount_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qml.pri | 17 | ||||
-rw-r--r-- | src/qml/qml/qqmldirparser.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmldirparser_p.h | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetype.cpp | 33 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetype_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 76 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 | ||||
-rw-r--r-- | src/qml/types/qqmlbind.cpp | 2 |
22 files changed, 136 insertions, 208 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 27aecdd3ed..02274ca793 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2448,7 +2448,8 @@ bool Codegen::visit(SwitchStatement *ast) IR::BasicBlock *switchend = _function->newBasicBlock(exceptionHandler()); if (ast->block) { - Result lhs = expression(ast->expression); + int lhs = _block->newTemp(); + move(_block->TEMP(lhs), *expression(ast->expression)); IR::BasicBlock *switchcond = _function->newBasicBlock(exceptionHandler()); _block->JUMP(switchcond); IR::BasicBlock *previousBlock = 0; @@ -2510,7 +2511,7 @@ bool Codegen::visit(SwitchStatement *ast) Result rhs = expression(clause->expression); IR::BasicBlock *iftrue = blockMap[clause]; IR::BasicBlock *iffalse = _function->newBasicBlock(exceptionHandler()); - setLocation(cjump(binop(IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse), clause->caseToken); + setLocation(cjump(binop(IR::OpStrictEqual, _block->TEMP(lhs), *rhs), iftrue, iffalse), clause->caseToken); _block = iffalse; } @@ -2519,7 +2520,7 @@ bool Codegen::visit(SwitchStatement *ast) Result rhs = expression(clause->expression); IR::BasicBlock *iftrue = blockMap[clause]; IR::BasicBlock *iffalse = _function->newBasicBlock(exceptionHandler()); - setLocation(cjump(binop(IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse), clause->caseToken); + setLocation(cjump(binop(IR::OpStrictEqual, _block->TEMP(lhs), *rhs), iftrue, iffalse), clause->caseToken); _block = iffalse; } diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index d6d43418f7..7b40fa849a 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -42,7 +42,7 @@ #include <private/qv4value_p.h> #include <private/qv4executableallocator_p.h> #include <private/qqmlrefcount_p.h> -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/doc/src/whatsnew.qdoc b/src/qml/doc/src/whatsnew.qdoc deleted file mode 100644 index 6abfe8c579..0000000000 --- a/src/qml/doc/src/whatsnew.qdoc +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\title Qt QML Release Notes -\page qtqml-releasenotes.html - -\section1 Qt QML in Qt 5.1 - -Qt 5.1 introduces several bug fixes and new functionalities to Qt QML. This is -a summary of the new changes: -\list -\li New QQmlApplicationEngine convenience class for QML applications. -\li New Instantiatior type for generic, dynamic object creation. -\li New properties for \l {Qt::application}{Qt.application}: arguments, name, and version. -\li The 'with' statement has been deprecated and is slated for removal in a - future version of the language. -\li New \l {Qt::platform}{Qt.platform} object with an \c os property -\li New \l qmlClearTypeRegistrations() function drops all data from qmlRegisterType() calls -\li New \l qmlRegisterType() function for registering composite types. -\endlist - -\section2 New Submodule - -The \l{Qt QML Models QML Types}{Qt QML Models} is a new submodule in Qt 5.1 and -provides several QML types for handling data with models and lists. These types -replace types such as \l VisualItemModel, \l VisualDataModel, and \l VisualDataGroup. - -\list -\li \l{Qt QML Models QML Types}{Models} -\endlist - -The \l{What's New in Qt 5.1} has more information about the Qt 5.1 release. - -\section1 Qt QML in Qt 5.0 - -The \l{Qt QML} module is new in Qt 5.0. It provides the QML engine and -implements the QML language supporting infrastructure. - -(Prior to Qt 5, this functionality was provided by the \l {Qt Quick 1}{QtDeclarative} module, which -has now been replaced by the new \l {Qt QML} and \l {Qt Quick} modules. See the -\l {Porting QML Applications to Qt 5} page for more information.) - -\section2 QML Engine - -\list -\li JavaScript engine has changed to V8. -\li Various parser and compiler optimizations have been implemented, as well as a new bindings optimizer. -\li New QQmlEngine::trimComponentCache() method safely discards unused data in the engine's component cache to free memory. -\endlist - -\section2 Component and Object Creation - -\list -\li QML objects can now be created asynchronously to improve application performance. - \list - \li New QQmlIncubator and QQmlIncubationController C++ classes can be used to create objects asynchronously. - \li From QML code, this behavior can enabled by: - \list - \li Calling the new Component \l{Component::incubateObject} method - \li Passing the \c Component.Asynchronous parameter to \c Qt.createComponent() - \li Loading a \l Loader object asynchronously using the \l{Loader::}{asynchronous} property - \endlist - \endlist -\li The component returned by \c Qt.createComponent() is no longer parented to the engine. Be sure to hold a reference, or provide a parent. -\endlist - -\section2 Type System - -\list -\li New \l var property type. This is a general-purpose property type which obsoletes the \l variant type. - Properties of the \l var type may hold JavaScript references. -\li QML properties of type \l var and \l variant can now hold pixmaps. -\li Value type improvements: - \list - \li QML now supports defining properties of value type basic types within QML documents. Supported types include - QSizeF, QPointF and QRectF as \c size, \c point and \c rect respectively. - \li QColor is now a value type provided by the \c QtQuick module. The red, green, blue and alpha channels - of a \l color property can be accessed via \c r, \c g, \c b and \c a properties. - \li Factory functions for various value types have been added to the \c Qt object exposed to QML. - Some of those functions require the \c QtQuick module to be imported in order to return valid values. - See the \l {Qt Quick Release Notes} for more information about these functions. - \endlist -\li Support for sequence types QList<int>, QList<qreal>, QList<bool>, QList<QUrl>, - QList<QString> and QStringList has been improved. QObjects can define Q_PROPERTYs of - these types which can be accessed transparently from JavaScript. -\endlist - -\section2 Modules and Imports - -\list -\li Arbitrary functionality may be provided in a namespace through a singleton type. See qmlRegisterSingletonType() for more information. -\li JavaScript (.js) files may now import QML modules and other JavaScript files using the ".import" syntax. -\li Plugins may now use QQmlExtensionPlugin::baseUrl to get the directory from which the plugin is loaded. - This will be useful if the plugin needs to load QML or other assets from the same directory. -\endlist - -\section2 Other - -\list -\li QQmlExpression can now be constructed directly (and more efficiently) from a QQmlScriptString. -\li The \l {QtQml::Qt}{Qt} global object now provides an \l{QtQml::Qt::inputMethod}{inputMethod} property to access the active - text input method for an application. -\endlist - -*/ diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index a3c48fb378..0ace88b01f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -582,6 +582,16 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(InternalClass *ic, Object *pr return object->d(); } +Heap::ArrayBuffer *ExecutionEngine::newArrayBuffer(const QByteArray &array) +{ + Scope scope(this); + Scoped<ArrayBuffer> object(scope, memoryManager->alloc<ArrayBuffer>(this, array.size())); + if (!hasException) { + memcpy(object->d()->data->data(), array.data(), array.size()); + } + return object->d(); +} + Heap::DateObject *ExecutionEngine::newDateObject(const Value &value) { diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 098510e91a..bcb74ab694 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -268,6 +268,8 @@ public: Heap::ArrayObject *newArrayObject(const QStringList &list); Heap::ArrayObject *newArrayObject(InternalClass *ic, Object *prototype); + Heap::ArrayBuffer *newArrayBuffer(const QByteArray &array); + Heap::DateObject *newDateObject(const Value &value); Heap::DateObject *newDateObject(const QDateTime &dt); diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 9769940a77..a79f71ff64 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -34,10 +34,19 @@ #ifndef QV4GLOBAL_H #define QV4GLOBAL_H +#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) +#define V4_BOOTSTRAP +#endif + #include <QtCore/qglobal.h> #include <QString> + +#ifdef V4_BOOTSTRAP +#include <private/qtqmldevtoolsglobal_p.h> +#else #include <qtqmlglobal.h> #include <private/qtqmlglobal_p.h> +#endif #if defined(Q_CC_MSVC) #include <float.h> @@ -59,10 +68,6 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } #define qOffsetOf(s, m) ((size_t)((((char *)&(((s *)64)->m)) - 64))) -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) -#define V4_BOOTSTRAP -#endif - // Decide whether to enable or disable the JIT // White list architectures diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index d8c9d89369..89ff110b20 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -204,9 +204,15 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) str = QString::fromLatin1("NaN"); else if (qIsInf(v)) str = QString::fromLatin1(v < 0 ? "-Infinity" : "Infinity"); - else if (v < 1.e21) - str = QString::number(v, 'f', int (fdigits)); - else + else if (v < 1.e21) { + char buf[100]; + double_conversion::StringBuilder builder(buf, sizeof(buf)); + double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToFixed(v, fdigits, &builder); + str = QString::fromLatin1(builder.Finalize()); + // At some point, the 3rd party double-conversion code should be moved to qtcore. + // When that's done, we can use: +// str = QString::number(v, 'f', int (fdigits)); + } else return RuntimeHelpers::stringFromNumber(ctx->engine(), v)->asReturnedValue(); return scope.engine->newString(str)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 7853b5fac6..a7e3b22cd2 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -527,6 +527,8 @@ Heap::QQmlSequence<Container>::QQmlSequence(QV4::ExecutionEngine *engine, QObjec } +namespace QV4 { + typedef QQmlSequence<QStringList> QQmlQStringList; template<> DEFINE_OBJECT_VTABLE(QQmlQStringList); @@ -546,6 +548,8 @@ typedef QQmlSequence<QList<qreal> > QQmlRealList; template<> DEFINE_OBJECT_VTABLE(QQmlRealList); +} + #define REGISTER_QML_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType<SequenceType>(#SequenceType); void SequencePrototype::init() { diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index ea98adc0c8..8ed6c1459c 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -370,6 +370,9 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value static inline Primitive fromDouble(double d); static inline Primitive fromUInt32(uint i); + using Value::toInt32; + using Value::toUInt32; + static double toInteger(double fromNumber); static int toInt32(double value); static unsigned int toUInt32(double value); diff --git a/src/qml/memory/memory.pri b/src/qml/memory/memory.pri index 194df06e85..04b7566ccc 100644 --- a/src/qml/memory/memory.pri +++ b/src/qml/memory/memory.pri @@ -6,7 +6,9 @@ SOURCES += \ $$PWD/qv4mm.cpp \ HEADERS += \ - $$PWD/qv4heap_p.h \ - $$PWD/qv4mm_p.h \ + $$PWD/qv4mm_p.h } + +HEADERS += \ + $$PWD/qv4heap_p.h diff --git a/src/qml/qml/ftw/ftw.pri b/src/qml/qml/ftw/ftw.pri index 74a922dc5e..4b109107f9 100644 --- a/src/qml/qml/ftw/ftw.pri +++ b/src/qml/qml/ftw/ftw.pri @@ -15,6 +15,7 @@ HEADERS += \ $$PWD/qflagpointer_p.h \ $$PWD/qpointervaluepair_p.h \ $$PWD/qlazilyallocated_p.h \ + $$PWD/qqmlnullablevalue_p.h \ SOURCES += \ $$PWD/qintrusivelist.cpp \ diff --git a/src/qml/qml/qqmlnullablevalue_p_p.h b/src/qml/qml/ftw/qqmlnullablevalue_p.h index 202c2b79d7..202c2b79d7 100644 --- a/src/qml/qml/qqmlnullablevalue_p_p.h +++ b/src/qml/qml/ftw/qqmlnullablevalue_p.h diff --git a/src/qml/qml/ftw/qqmlpool_p.h b/src/qml/qml/ftw/qqmlpool_p.h index 31d7082cf3..4956cd81d8 100644 --- a/src/qml/qml/ftw/qqmlpool_p.h +++ b/src/qml/qml/ftw/qqmlpool_p.h @@ -45,7 +45,7 @@ // We mean it. // -#include <private/qtqmlglobal_p.h> +#include <private/qv4global_p.h> #include <QtCore/qstring.h> #include <QtCore/qurl.h> diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h index 8a268807d7..59ed77b580 100644 --- a/src/qml/qml/ftw/qqmlrefcount_p.h +++ b/src/qml/qml/ftw/qqmlrefcount_p.h @@ -47,7 +47,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qatomic.h> -#include <private/qtqmlglobal_p.h> +#include <private/qv4global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri index cad839ba9d..e733bcec05 100644 --- a/src/qml/qml/qml.pri +++ b/src/qml/qml/qml.pri @@ -1,12 +1,4 @@ SOURCES += \ - $$PWD/qqmldirparser.cpp \ - -HEADERS += \ - $$PWD/qqmldirparser_p.h \ - -!qmldevtools_build { - -SOURCES += \ $$PWD/qqmlopenmetaobject.cpp \ $$PWD/qqmlvmemetaobject.cpp \ $$PWD/qqmlengine.cpp \ @@ -59,7 +51,8 @@ SOURCES += \ $$PWD/qqmlvaluetypewrapper.cpp \ $$PWD/qqmltypewrapper.cpp \ $$PWD/qqmlfileselector.cpp \ - $$PWD/qqmlobjectcreator.cpp + $$PWD/qqmlobjectcreator.cpp \ + $$PWD/qqmldirparser.cpp HEADERS += \ $$PWD/qqmlglobal_p.h \ @@ -111,7 +104,6 @@ HEADERS += \ $$PWD/qqmlextensioninterface.h \ $$PWD/qqmlimport_p.h \ $$PWD/qqmlextensionplugin.h \ - $$PWD/qqmlnullablevalue_p_p.h \ $$PWD/qqmlscriptstring_p.h \ $$PWD/qqmllocale_p.h \ $$PWD/qqmlcomponentattached_p.h \ @@ -133,9 +125,8 @@ HEADERS += \ $$PWD/qqmltypewrapper_p.h \ $$PWD/qqmlfileselector_p.h \ $$PWD/qqmlfileselector.h \ - $$PWD/qqmlobjectcreator_p.h + $$PWD/qqmlobjectcreator_p.h \ + $$PWD/qqmldirparser_p.h include(ftw/ftw.pri) include(v8/v8.pri) - -} diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index 2c126a996d..7f6310d58e 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -294,17 +294,6 @@ bool QQmlDirParser::hasError() const return false; } -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) -QList<QQmlJS::DiagnosticMessage> QQmlDirParser::errors(const QString &uri) const -{ - QList<QQmlJS::DiagnosticMessage> errors = _errors; - for (int i = 0; i < errors.size(); ++i) { - QQmlJS::DiagnosticMessage &msg = errors[i]; - msg.message.replace(QLatin1String("$$URI$$"), uri); - } - return errors; -} -#else void QQmlDirParser::setError(const QQmlError &e) { _errors.clear(); @@ -328,7 +317,6 @@ QList<QQmlError> QQmlDirParser::errors(const QString &uri) const } return errors; } -#endif QString QQmlDirParser::typeNamespace() const { diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h index 0486187a5c..c2f47f49b6 100644 --- a/src/qml/qml/qqmldirparser_p.h +++ b/src/qml/qml/qqmldirparser_p.h @@ -49,7 +49,7 @@ #include <QtCore/QHash> #include <QtCore/QDebug> #include <private/qqmljsengine_p.h> -#include <private/qtqmlglobal_p.h> +#include <private/qv4global_p.h> QT_BEGIN_NAMESPACE @@ -66,12 +66,8 @@ public: bool parse(const QString &source); bool hasError() const; -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) - QList<QQmlJS::DiagnosticMessage> errors(const QString &uri) const; -#else void setError(const QQmlError &); QList<QQmlError> errors(const QString &uri) const; -#endif QString typeNamespace() const; void setTypeNamespace(const QString &s); diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index d3142af75e..2b3f78b676 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -58,30 +58,6 @@ struct QQmlValueTypeFactoryImpl QMutex mutex; }; - -namespace { -// This should be removed once the QPersistentModelIndex as built-in type is merged in qtbase -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) -#error Please, someone remove this. QPersistentModelIndex should be a built-in meta-type by now. -#else -template <typename T, bool builtin = QMetaTypeId2<T>::IsBuiltIn> -struct QPMIConvertersRegistrer { - void registerConverters() - { - } -}; - -template <typename T> struct QPMIConvertersRegistrer<T, false> { - void registerConverters() - { - qRegisterMetaType<QPersistentModelIndex>(); - QMetaType::registerConverter<QModelIndex, QPersistentModelIndex>(&QQmlModelIndexValueType::toPersistentModelIndex); - QMetaType::registerConverter<QPersistentModelIndex, QModelIndex>(&QQmlPersistentModelIndexValueType::toModelIndex); - } -}; -#endif -} - QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl() { for (unsigned int ii = 0; ii < QVariant::UserType; ++ii) @@ -91,9 +67,6 @@ QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl() qRegisterMetaType<QModelIndexList>(); qRegisterMetaType<QItemSelectionRange>(); qRegisterMetaType<QItemSelection>(); - - QPMIConvertersRegistrer<QPersistentModelIndex> conv; - conv.registerConverters(); } QQmlValueTypeFactoryImpl::~QQmlValueTypeFactoryImpl() @@ -136,15 +109,15 @@ const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t) return &QQmlEasingValueType::staticMetaObject; case QVariant::ModelIndex: return &QQmlModelIndexValueType::staticMetaObject; + case QVariant::PersistentModelIndex: + return &QQmlPersistentModelIndexValueType::staticMetaObject; default: if (const QMetaObject *mo = QQml_valueTypeProvider()->metaObjectForMetaType(t)) return mo; break; } - if (t == qMetaTypeId<QPersistentModelIndex>()) - return &QQmlPersistentModelIndexValueType::staticMetaObject; - else if (t == qMetaTypeId<QModelIndexList>()) + if (t == qMetaTypeId<QModelIndexList>()) return &QQmlModelIndexListValueType::staticMetaObject; else if (t == qMetaTypeId<QItemSelectionRange>()) return &QQmlItemSelectionRangeValueType::staticMetaObject; diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index 0d896364e1..f534fedf5d 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -48,7 +48,7 @@ #include "qqml.h" #include "qqmlproperty.h" #include "qqmlproperty_p.h" -#include "qqmlnullablevalue_p_p.h" +#include <private/qqmlnullablevalue_p.h> #include <QtCore/qobject.h> #include <QtCore/qrect.h> diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index afa79ee6b1..a2c5f09061 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -59,6 +59,7 @@ #include <private/qv4objectproto_p.h> #include <private/qv4scopedvalue_p.h> +#include <private/qv4arraybuffer_p.h> using namespace QV4; @@ -1022,6 +1023,9 @@ public: QString responseBody(); const QByteArray & rawResponseBody() const; bool receivedXml() const; + + const QString & responseType() const; + void setResponseType(const QString &); private slots: void readyRead(); void error(QNetworkReply::NetworkError); @@ -1070,12 +1074,15 @@ private: QNetworkAccessManager *m_nam; QNetworkAccessManager *networkAccessManager() { return m_nam; } + + QString m_responseType; }; QQmlXMLHttpRequest::QQmlXMLHttpRequest(ExecutionEngine *engine, QNetworkAccessManager *manager) : v4(engine) , m_state(Unsent), m_errorFlag(false), m_sendFlag(false) , m_redirectCount(0), m_gotXml(false), m_textCodec(0), m_network(0), m_nam(manager) + , m_responseType() { } @@ -1461,6 +1468,16 @@ bool QQmlXMLHttpRequest::receivedXml() const return m_gotXml; } +const QString & QQmlXMLHttpRequest::responseType() const +{ + return m_responseType; +} + +void QQmlXMLHttpRequest::setResponseType(const QString &responseType) +{ + m_responseType = responseType; +} + #ifndef QT_NO_TEXTCODEC QTextCodec* QQmlXMLHttpRequest::findTextCodec() const @@ -1640,6 +1657,9 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject static ReturnedValue method_get_statusText(CallContext *ctx); static ReturnedValue method_get_responseText(CallContext *ctx); static ReturnedValue method_get_responseXML(CallContext *ctx); + static ReturnedValue method_get_response(CallContext *ctx); + static ReturnedValue method_get_responseType(CallContext *ctx); + static ReturnedValue method_set_responseType(CallContext *ctx); }; } @@ -1686,6 +1706,10 @@ void QQmlXMLHttpRequestCtor::setupProto() p->defineAccessorProperty(QStringLiteral("statusText"),method_get_statusText, 0); p->defineAccessorProperty(QStringLiteral("responseText"),method_get_responseText, 0); p->defineAccessorProperty(QStringLiteral("responseXML"),method_get_responseXML, 0); + p->defineAccessorProperty(QStringLiteral("response"),method_get_response, 0); + + // Read-write properties + p->defineAccessorProperty(QStringLiteral("responseType"), method_get_responseType, method_set_responseType); // State values p->defineReadonlyProperty(QStringLiteral("UNSENT"), Primitive::fromInt32(0)); @@ -1945,6 +1969,58 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) } } +ReturnedValue QQmlXMLHttpRequestCtor::method_get_response(CallContext *ctx) +{ + Scope scope(ctx); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); + if (!w) + V4THROW_REFERENCE("Not an XMLHttpRequest object"); + QQmlXMLHttpRequest *r = w->d()->request; + + if (r->readyState() != QQmlXMLHttpRequest::Loading && + r->readyState() != QQmlXMLHttpRequest::Done) + return QV4::Encode(scope.engine->newString(QString())); + + const QString& responseType = r->responseType(); + if (responseType.compare(QLatin1String("text"), Qt::CaseInsensitive) == 0) { + return QV4::Encode(scope.engine->newString(r->responseBody())); + } else if (responseType.compare(QLatin1String("arraybuffer"), Qt::CaseInsensitive) == 0) { + return QV4::Encode(scope.engine->newArrayBuffer(r->rawResponseBody())); + } else { + return QV4::Encode(scope.engine->newString(QString())); + } + + return Encode::undefined(); +} + + +ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseType(CallContext *ctx) +{ + Scope scope(ctx); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); + if (!w) + V4THROW_REFERENCE("Not an XMLHttpRequest object"); + QQmlXMLHttpRequest *r = w->d()->request; + return QV4::Encode(scope.engine->newString(r->responseType())); +} + +ReturnedValue QQmlXMLHttpRequestCtor::method_set_responseType(CallContext *ctx) +{ + Scope scope(ctx); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); + if (!w) + V4THROW_REFERENCE("Not an XMLHttpRequest object"); + QQmlXMLHttpRequest *r = w->d()->request; + + if (ctx->argc() < 1) + V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); + + // Argument 0 - response type + r->setResponseType(ctx->args()[0].toQStringNoThrow()); + + return Encode::undefined(); +} + void qt_rem_qmlxmlhttprequest(ExecutionEngine * /* engine */, void *d) { QQmlXMLHttpRequestData *data = (QQmlXMLHttpRequestData *)d; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 8e5cbb8e96..0522e4c0ed 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1483,7 +1483,7 @@ QV4::ReturnedValue ConsoleObject::method_time(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_timeEnd(CallContext *ctx) { if (ctx->argc() != 1) - V4THROW_ERROR("console.time(): Invalid arguments"); + V4THROW_ERROR("console.timeEnd(): Invalid arguments"); QV8Engine *v8engine = ctx->d()->engine->v8Engine; diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 8e28439804..7814fa6d56 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -33,7 +33,7 @@ #include "qqmlbind_p.h" -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> #include <private/qqmlproperty_p.h> #include <private/qqmlbinding_p.h> |