diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-14 15:48:12 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-10-14 15:48:12 +0200 |
commit | 7063fefe4b5e866b27001bb9b911fc2f68034e40 (patch) | |
tree | 1ce35139475d83399572a3265414c2da3443a321 /src/qml | |
parent | f3446071da8357620d0c8593a04e3b4fbba88f21 (diff) | |
parent | 4f3379352a265bab00a7265f85ffc38a9ca4ffe4 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Change-Id: I11ea57222ba5aa683b7bfd7735fbc1d2cf86e875
Diffstat (limited to 'src/qml')
129 files changed, 1465 insertions, 363 deletions
diff --git a/src/qml/animations/qabstractanimationjob_p.h b/src/qml/animations/qabstractanimationjob_p.h index 5a3e9d2025..14dbf85a3d 100644 --- a/src/qml/animations/qabstractanimationjob_p.h +++ b/src/qml/animations/qabstractanimationjob_p.h @@ -34,6 +34,17 @@ #ifndef QABSTRACTANIMATIONJOB_P_H #define QABSTRACTANIMATIONJOB_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> #include <QtCore/QObject> #include <QtCore/private/qabstractanimation_p.h> diff --git a/src/qml/animations/qanimationgroupjob_p.h b/src/qml/animations/qanimationgroupjob_p.h index fa8fc08bfe..c97a18f089 100644 --- a/src/qml/animations/qanimationgroupjob_p.h +++ b/src/qml/animations/qanimationgroupjob_p.h @@ -34,6 +34,17 @@ #ifndef QANIMATIONGROUPJOB_P_H #define QANIMATIONGROUPJOB_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qabstractanimationjob_p.h" QT_BEGIN_NAMESPACE diff --git a/src/qml/animations/qanimationjobutil_p.h b/src/qml/animations/qanimationjobutil_p.h index 3c38fc1599..d2aceb72d0 100644 --- a/src/qml/animations/qanimationjobutil_p.h +++ b/src/qml/animations/qanimationjobutil_p.h @@ -34,6 +34,17 @@ #ifndef QANIMATIONJOBUTIL_P_H #define QANIMATIONJOBUTIL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #define RETURN_IF_DELETED(func) \ { \ bool *prevWasDeleted = m_wasDeleted; \ diff --git a/src/qml/animations/qcontinuinganimationgroupjob_p.h b/src/qml/animations/qcontinuinganimationgroupjob_p.h index 3df0e676a7..b9827ab936 100644 --- a/src/qml/animations/qcontinuinganimationgroupjob_p.h +++ b/src/qml/animations/qcontinuinganimationgroupjob_p.h @@ -34,6 +34,17 @@ #ifndef QCONTINUINGANIMATIONGROUPJOB_P_H #define QCONTINUINGANIMATIONGROUPJOB_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qanimationgroupjob_p.h" QT_BEGIN_NAMESPACE diff --git a/src/qml/animations/qparallelanimationgroupjob_p.h b/src/qml/animations/qparallelanimationgroupjob_p.h index 1ac7709f21..83e5457cdd 100644 --- a/src/qml/animations/qparallelanimationgroupjob_p.h +++ b/src/qml/animations/qparallelanimationgroupjob_p.h @@ -34,6 +34,17 @@ #ifndef QPARALLELANIMATIONGROUPJOB_P_H #define QPARALLELANIMATIONGROUPJOB_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qanimationgroupjob_p.h" QT_BEGIN_NAMESPACE diff --git a/src/qml/animations/qpauseanimationjob_p.h b/src/qml/animations/qpauseanimationjob_p.h index b909c71f49..725e9b62e9 100644 --- a/src/qml/animations/qpauseanimationjob_p.h +++ b/src/qml/animations/qpauseanimationjob_p.h @@ -34,6 +34,17 @@ #ifndef QPAUSEANIMATIONJOB_P_H #define QPAUSEANIMATIONJOB_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qanimationgroupjob_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/animations/qsequentialanimationgroupjob_p.h b/src/qml/animations/qsequentialanimationgroupjob_p.h index 5286fda28a..dab086e851 100644 --- a/src/qml/animations/qsequentialanimationgroupjob_p.h +++ b/src/qml/animations/qsequentialanimationgroupjob_p.h @@ -34,6 +34,17 @@ #ifndef QSEQUENTIALANIMATIONGROUPJOB_P_H #define QSEQUENTIALANIMATIONGROUPJOB_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qanimationgroupjob_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 7b0d4240c4..6fef1ae372 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1615,10 +1615,10 @@ static QV4::IR::Type resolveQmlType(QQmlEnginePrivate *qmlEngine, QV4::IR::Membe member->kind = QV4::IR::Member::MemberOfSingletonObject; return resolver->resolveMember(qmlEngine, resolver, member); } - } else if (const QMetaObject *attachedMeta = type->attachedPropertiesType()) { + } else if (const QMetaObject *attachedMeta = type->attachedPropertiesType(qmlEngine)) { QQmlPropertyCache *cache = qmlEngine->cache(attachedMeta); initMetaObjectResolver(resolver, cache); - member->setAttachedPropertiesId(type->attachedPropertiesId()); + member->setAttachedPropertiesId(type->attachedPropertiesId(qmlEngine)); return resolver->resolveMember(qmlEngine, resolver, member); } diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 5617912081..9a659f4d72 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -33,6 +33,17 @@ #ifndef QQMLIRBUILDER_P_H #define QQMLIRBUILDER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qqmljsast_p.h> #include <private/qqmljsengine_p.h> #include <private/qv4compiler_p.h> diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index e36ba76326..cde7a2acb4 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -520,7 +520,24 @@ bool QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, int r } else if (instantiatingBinding && instantiatingBinding->isAttachedProperty()) { QQmlCompiledData::TypeReference *typeRef = resolvedTypes->value(instantiatingBinding->propertyNameIndex); Q_ASSERT(typeRef); - const QMetaObject *attachedMo = typeRef->type ? typeRef->type->attachedPropertiesType() : 0; + QQmlType *qmltype = typeRef->type; + if (!qmltype) { + QString propertyName = stringAt(instantiatingBinding->propertyNameIndex); + if (imports->resolveType(propertyName, &qmltype, 0, 0, 0)) { + if (qmltype->isComposite()) { + QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype->sourceUrl()); + Q_ASSERT(tdata); + Q_ASSERT(tdata->isComplete()); + + QQmlCompiledData *data = tdata->compiledData(); + qmltype = QQmlMetaType::qmlType(data->metaTypeId); + + tdata->release(); + } + } + } + + const QMetaObject *attachedMo = qmltype ? qmltype->attachedPropertiesType(enginePrivate) : 0; if (!attachedMo) { recordError(instantiatingBinding->location, tr("Non-existent attached object")); return false; @@ -880,7 +897,9 @@ bool QQmlPropertyCacheCreator::createMetaObject(int objectIndex, const QmlIR::Ob SignalHandlerConverter::SignalHandlerConverter(QQmlTypeCompiler *typeCompiler) : QQmlCompilePass(typeCompiler) + , enginePrivate(typeCompiler->enginePrivate()) , qmlObjects(*typeCompiler->qmlObjects()) + , imports(typeCompiler->imports()) , customParsers(typeCompiler->customParserCache()) , resolvedTypes(*typeCompiler->resolvedTypes()) , illegalNames(QV8Engine::get(QQmlEnginePrivate::get(typeCompiler->enginePrivate()))->illegalNames()) @@ -918,7 +937,22 @@ bool SignalHandlerConverter::convertSignalHandlerExpressionsToFunctionDeclaratio const QmlIR::Object *attachedObj = qmlObjects.at(binding->value.objectIndex); QQmlCompiledData::TypeReference *typeRef = resolvedTypes.value(binding->propertyNameIndex); QQmlType *type = typeRef ? typeRef->type : 0; - const QMetaObject *attachedType = type ? type->attachedPropertiesType() : 0; + if (!type) { + if (imports->resolveType(propertyName, &type, 0, 0, 0)) { + if (type->isComposite()) { + QQmlTypeData *tdata = enginePrivate->typeLoader.getType(type->sourceUrl()); + Q_ASSERT(tdata); + Q_ASSERT(tdata->isComplete()); + + QQmlCompiledData *data = tdata->compiledData(); + type = QQmlMetaType::qmlType(data->metaTypeId); + + tdata->release(); + } + } + } + + const QMetaObject *attachedType = type ? type->attachedPropertiesType(enginePrivate) : 0; if (!attachedType) COMPILE_EXCEPTION(binding, tr("Non-existent attached object")); QQmlPropertyCache *cache = compiler->enginePrivate()->cache(attachedType); diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h index 09ef7aad67..c5be92d256 100644 --- a/src/qml/compiler/qqmltypecompiler_p.h +++ b/src/qml/compiler/qqmltypecompiler_p.h @@ -33,6 +33,17 @@ #ifndef QQMLTYPECOMPILER_P_H #define QQMLTYPECOMPILER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qglobal.h> #include <qqmlerror.h> #include <qhash.h> @@ -158,7 +169,9 @@ public: private: bool convertSignalHandlerExpressionsToFunctionDeclarations(const QmlIR::Object *obj, const QString &typeName, QQmlPropertyCache *propertyCache); + QQmlEnginePrivate *enginePrivate; const QList<QmlIR::Object*> &qmlObjects; + const QQmlImports *imports; const QHash<int, QQmlCustomParser*> &customParsers; const QHash<int, QQmlCompiledData::TypeReference*> &resolvedTypes; const QSet<QString> &illegalNames; diff --git a/src/qml/compiler/qv4codegen_p.h b/src/qml/compiler/qv4codegen_p.h index aec51cc19c..a7b0b06fe2 100644 --- a/src/qml/compiler/qv4codegen_p.h +++ b/src/qml/compiler/qv4codegen_p.h @@ -33,6 +33,17 @@ #ifndef QV4CODEGEN_P_H #define QV4CODEGEN_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qv4global_p.h" #include "qv4jsir_p.h" #include <private/qqmljsastvisitor_p.h> diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 48324fbbc4..0d6e4b15a7 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -33,6 +33,17 @@ #ifndef QV4COMPILEDDATA_P_H #define QV4COMPILEDDATA_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qstring.h> #include <QVector> #include <QStringList> diff --git a/src/qml/compiler/qv4compiler_p.h b/src/qml/compiler/qv4compiler_p.h index 3cf80a9791..d999a93f4f 100644 --- a/src/qml/compiler/qv4compiler_p.h +++ b/src/qml/compiler/qv4compiler_p.h @@ -33,6 +33,17 @@ #ifndef QV4COMPILER_P_H #define QV4COMPILER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qstring.h> #include "qv4jsir_p.h" diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 6839c7f609..1eebcbbe7f 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -34,6 +34,17 @@ #ifndef QV4INSTR_MOTH_P_H #define QV4INSTR_MOTH_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qglobal.h> #include <private/qv4value_p.h> #include <private/qv4function_p.h> diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h index ac1eaba740..947461f98e 100644 --- a/src/qml/compiler/qv4isel_moth_p.h +++ b/src/qml/compiler/qv4isel_moth_p.h @@ -34,6 +34,17 @@ #ifndef QV4ISEL_MOTH_P_H #define QV4ISEL_MOTH_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qv4global_p.h> #include <private/qv4isel_p.h> #include <private/qv4isel_util_p.h> diff --git a/src/qml/compiler/qv4isel_p.h b/src/qml/compiler/qv4isel_p.h index 2b8aa7eb33..50ee955378 100644 --- a/src/qml/compiler/qv4isel_p.h +++ b/src/qml/compiler/qv4isel_p.h @@ -34,6 +34,17 @@ #ifndef QV4ISEL_P_H #define QV4ISEL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qv4global_p.h" #include "qv4jsir_p.h" #include <private/qv4compileddata_p.h> diff --git a/src/qml/compiler/qv4isel_util_p.h b/src/qml/compiler/qv4isel_util_p.h index 521c345228..9c4ab63ba6 100644 --- a/src/qml/compiler/qv4isel_util_p.h +++ b/src/qml/compiler/qv4isel_util_p.h @@ -34,6 +34,17 @@ #ifndef QV4ISEL_UTIL_P_H #define QV4ISEL_UTIL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qv4value_p.h" #include "qv4jsir_p.h" diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp index 32169f3352..bc4068085a 100644 --- a/src/qml/compiler/qv4ssa.cpp +++ b/src/qml/compiler/qv4ssa.cpp @@ -2038,6 +2038,7 @@ public: EliminateDeadCode(DefUses &defUses, StatementWorklist &worklist) : _defUses(defUses) , _worklist(worklist) + , _sideEffect(false) { _collectedTemps.reserve(8); } diff --git a/src/qml/compiler/qv4ssa_p.h b/src/qml/compiler/qv4ssa_p.h index 3cfacaee27..d06774e803 100644 --- a/src/qml/compiler/qv4ssa_p.h +++ b/src/qml/compiler/qv4ssa_p.h @@ -34,6 +34,17 @@ #ifndef QV4SSA_P_H #define QV4SSA_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4jsir_p.h" #include <QtCore/QSharedPointer> diff --git a/src/qml/doc/src/javascript/qmlglobalobject.qdoc b/src/qml/doc/src/javascript/qmlglobalobject.qdoc index e37b35451c..b3d8a2b2a5 100644 --- a/src/qml/doc/src/javascript/qmlglobalobject.qdoc +++ b/src/qml/doc/src/javascript/qmlglobalobject.qdoc @@ -45,9 +45,11 @@ additional imports: \li \l{XMLHttpRequest}, DOMException: These objects implement a subset of the \l{http://www.w3.org/TR/XMLHttpRequest/}{W3C XMLHttpRequest specification}. \endlist +\note The \l {QJSEngine::}{globalObject()} function cannot be used to modify +the global object of a \l QQmlEngine. For more information about this, see +\l {JavaScript Environment Restrictions}. - -\keyword XMLHttpRequest +\target XMLHttpRequest \section1 XMLHttpRequest The XMLHttpRequest object, which can be used to asynchronously obtain diff --git a/src/qml/doc/src/qmllanguageref/syntax/basics.qdoc b/src/qml/doc/src/qmllanguageref/syntax/basics.qdoc index ddb307cf75..50767bfc8f 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/basics.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/basics.qdoc @@ -73,7 +73,7 @@ Please see the \l{qtqml-syntax-imports.html}{QML Syntax - Import Statements} documentation for in-depth information about QML imports. -\keyword qml-object-declarations +\target qml-object-declarations \section1 Object Declarations Syntactically, a block of QML code defines a tree of QML objects to be created. Objects are diff --git a/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc b/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc index 3aa228c8eb..f28ff5082a 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/propertybinding.qdoc @@ -130,7 +130,7 @@ and maintainability. It may be a good idea to redesign components that have complex bindings, or at least factor the binding out into a separate function. -\keyword qml-javascript-assignment +\target qml-javascript-assignment \section1 Creating Property Bindings from JavaScript A property with a binding is automatically updated as necessary. However, if the diff --git a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc index e7d75a89bc..602b202ed4 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc @@ -42,7 +42,7 @@ and the signal is responded to through a \e {signal handler}. When a signal is emitted, the corresponding signal handler is invoked. Placing logic such as scripts or other operations in the handler allows the component to respond to the event. -\keyword qml-signals-and-handlers +\target qml-signals-and-handlers \section1 Receiving Signals with Signal Handlers To receive a notification when a particular signal is emitted for a particular object, the object definition should declare a signal handler named \e on<Signal> where \e <Signal> is the name of the signal, with the first letter capitalized. The signal handler should contain the JavaScript code to be executed when the signal handler is invoked. @@ -208,7 +208,7 @@ SquareButton { See \l {Signal Attributes} for more details on writing signals for custom QML types. -\keyword qml-connect-signals-to-method +\target qml-connect-signals-to-method \section1 Connecting Signals to Methods and Signals Signal objects have a \c connect() method to a connect a signal either to a diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc index 64d6bb9ac4..33bb0c0750 100644 --- a/src/qml/doc/src/qtqml.qdoc +++ b/src/qml/doc/src/qtqml.qdoc @@ -106,8 +106,8 @@ JavaScript expressions allow QML code to contain application logic. Qt QML provides the framework for running JavaScript expressions in QML and from C++. These sections are from \l{The QML Reference}. -\l{qtqml-javascript-topic.html}{Integrating QML and JavaScript} \list + \li \l{qtqml-javascript-topic.html}{Integrating QML and JavaScript} \li \l{qtqml-javascript-expressions.html}{Using JavaScript Expressions with QML} \li \l{qtqml-javascript-dynamicobjectcreation.html}{Dynamic QML Object Creation from JavaScript} \li \l{qtqml-javascript-resources.html}{Defining JavaScript Resources In QML} @@ -140,8 +140,6 @@ Further information for writing QML applications: - essential information for application development with QML and Qt Quick \li \l{Qt Quick} - a module which provides a set of QML types and C++ classes for building user interfaces and applications with QML -\li \l{Qt QML Release Notes} - list of changes and - additions in the Qt QML module \endlist \section2 Reference diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4assembler_p.h index ab74211d23..effae64967 100644 --- a/src/qml/jit/qv4assembler_p.h +++ b/src/qml/jit/qv4assembler_p.h @@ -33,6 +33,17 @@ #ifndef QV4ASSEMBLER_P_H #define QV4ASSEMBLER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qv4global_p.h" #include "private/qv4jsir_p.h" #include "private/qv4isel_p.h" diff --git a/src/qml/jit/qv4binop_p.h b/src/qml/jit/qv4binop_p.h index 4fa2369312..96c8281d57 100644 --- a/src/qml/jit/qv4binop_p.h +++ b/src/qml/jit/qv4binop_p.h @@ -33,6 +33,17 @@ #ifndef QV4BINOP_P_H #define QV4BINOP_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qv4jsir_p.h> #include <qv4isel_masm_p.h> #include <qv4assembler_p.h> diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index 5dfd891b80..782b0c8659 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -195,7 +195,7 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize) if (name.isEmpty()) { name = QByteArray::number(quintptr(_function), 16); name.prepend("IR::Function(0x"); - name.append(")"); + name.append(')'); } codeRef = linkBuffer.finalizeCodeWithDisassembly("%s", name.data()); @@ -236,7 +236,7 @@ JSC::MacroAssemblerCodeRef Assembler::link(int *codeSize) if (name.isEmpty()) { name = QByteArray::number(quintptr(_function), 16); name.prepend("IR::Function(0x"); - name.append(")"); + name.append(')'); } } diff --git a/src/qml/jit/qv4isel_masm_p.h b/src/qml/jit/qv4isel_masm_p.h index 6e842f5fb4..29749f7492 100644 --- a/src/qml/jit/qv4isel_masm_p.h +++ b/src/qml/jit/qv4isel_masm_p.h @@ -33,6 +33,17 @@ #ifndef QV4ISEL_MASM_P_H #define QV4ISEL_MASM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "private/qv4global_p.h" #include "private/qv4jsir_p.h" #include "private/qv4isel_p.h" diff --git a/src/qml/jit/qv4regalloc_p.h b/src/qml/jit/qv4regalloc_p.h index f0d78cf0d3..1b6eb34e0b 100644 --- a/src/qml/jit/qv4regalloc_p.h +++ b/src/qml/jit/qv4regalloc_p.h @@ -33,6 +33,17 @@ #ifndef QV4REGALLOC_P_H #define QV4REGALLOC_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4isel_p.h" #include "qv4ssa_p.h" diff --git a/src/qml/jit/qv4registerinfo_p.h b/src/qml/jit/qv4registerinfo_p.h index ebd8537a85..cfd7bcb071 100644 --- a/src/qml/jit/qv4registerinfo_p.h +++ b/src/qml/jit/qv4registerinfo_p.h @@ -34,6 +34,17 @@ #ifndef QV4REGISTERINFO_P_H #define QV4REGISTERINFO_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/QString> QT_BEGIN_NAMESPACE diff --git a/src/qml/jit/qv4targetplatform_p.h b/src/qml/jit/qv4targetplatform_p.h index 76c768e4f9..1e62b23fe4 100644 --- a/src/qml/jit/qv4targetplatform_p.h +++ b/src/qml/jit/qv4targetplatform_p.h @@ -34,6 +34,17 @@ #ifndef QV4TARGETPLATFORM_P_H #define QV4TARGETPLATFORM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <config.h> #if ENABLE(ASSEMBLER) diff --git a/src/qml/jit/qv4unop_p.h b/src/qml/jit/qv4unop_p.h index f96898ce1b..69a70062b8 100644 --- a/src/qml/jit/qv4unop_p.h +++ b/src/qml/jit/qv4unop_p.h @@ -33,6 +33,17 @@ #ifndef QV4UNOP_P_H #define QV4UNOP_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qv4jsir_p.h> #include <qv4isel_masm_p.h> diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index b217d3fb4c..5ccbccebad 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -160,8 +160,82 @@ Q_DECLARE_METATYPE(QList<int>) \snippet code/src_script_qjsengine.cpp 5 - \sa QJSValue, {Making Applications Scriptable} + \section1 Extensions + QJSEngine provides a compliant ECMAScript implementation. By default, + familiar utilities like logging are not available, but they can can be + installed via the \l installExtensions() function. + + \sa QJSValue, {Making Applications Scriptable}, + {List of JavaScript Objects and Functions} + +*/ + +/*! + \enum QJSEngine::Extension + + This enum is used to specify extensions to be installed via + \l installExtensions(). + + \value TranslationExtension Indicates that translation functions (\c qsTr(), + for example) should be installed. + + \value ConsoleExtension Indicates that console functions (\c console.log(), + for example) should be installed. + + \value GarbageCollectionExtension Indicates that garbage collection + functions (\c gc(), for example) should be installed. + + \value AllExtensions Indicates that all extension should be installed. + + \b TranslationExtension + + The relation between script translation functions and C++ translation + functions is described in the following table: + + \table + \header \li Script Function \li Corresponding C++ Function + \row \li qsTr() \li QObject::tr() + \row \li QT_TR_NOOP() \li QT_TR_NOOP() + \row \li qsTranslate() \li QCoreApplication::translate() + \row \li QT_TRANSLATE_NOOP() \li QT_TRANSLATE_NOOP() + \row \li qsTrId() \li qtTrId() + \row \li QT_TRID_NOOP() \li QT_TRID_NOOP() + \endtable + + This flag also adds an \c arg() function to the string prototype. + + For more information, see the \l {Internationalization with Qt} + documentation. + + \b ConsoleExtension + + The \l {Console API}{console} object implements a subset of the + \l {https://developer.mozilla.org/en-US/docs/Web/API/Console}{Console API}, + which provides familiar logging functions, such as \c console.log(). + + The list of functions added is as follows: + + \list + \li \c console.assert() + \li \c console.debug() + \li \c console.exception() + \li \c console.info() + \li \c console.log() (equivalent to \c console.debug()) + \li \c console.error() + \li \c console.time() + \li \c console.timeEnd() + \li \c console.trace() + \li \c console.count() + \li \c console.warn() + \li \c {print()} (equivalent to \c console.debug()) + \endlist + + For more information, see the \l {Console API} documentation. + + \b GarbageCollectionExtension + + The \c gc() function is equivalent to calling \l collectGarbage(). */ QT_BEGIN_NAMESPACE @@ -234,8 +308,11 @@ void QJSEngine::collectGarbage() d->m_v4Engine->memoryManager->runGC(); } +#if QT_DEPRECATED_SINCE(5, 6) + /*! \since 5.4 + \obsolete Installs translator functions on the given \a object, or on the Global Object if no object is specified. @@ -259,11 +336,37 @@ void QJSEngine::collectGarbage() */ void QJSEngine::installTranslatorFunctions(const QJSValue &object) { + installExtensions(TranslationExtension, object); +} + +#endif // QT_DEPRECATED_SINCE(5, 6) + + +/*! + \since 5.6 + + Installs JavaScript \a extensions to add functionality that is not + available in a standard ECMAScript implementation. + + The extensions are installed on the given \a object, or on the + \l {globalObject()}{Global Object} if no object is specified. + + Several extensions can be installed at once by \c {OR}-ing the enum values: + + \code + installExtensions(QJSEngine::TranslationExtension | QJSEngine::ConsoleExtension); + \endcode + + \sa Extension +*/ +void QJSEngine::installExtensions(QJSEngine::Extensions extensions, const QJSValue &object) +{ QV4::ExecutionEngine *otherEngine = QJSValuePrivate::engine(&object); if (otherEngine && otherEngine != d->m_v4Engine) { - qWarning("QJSEngine: Trying to install a translator function from a different engine"); + qWarning("QJSEngine: Trying to install extensions from a different engine"); return; } + QV4::Scope scope(d->m_v4Engine); QV4::ScopedObject obj(scope); QV4::Value *val = QJSValuePrivate::getValue(&object); @@ -271,18 +374,8 @@ void QJSEngine::installTranslatorFunctions(const QJSValue &object) obj = val; if (!obj) obj = scope.engine->globalObject; -#ifndef QT_NO_TRANSLATION - obj->defineDefaultProperty(QStringLiteral("qsTranslate"), QV4::GlobalExtensions::method_qsTranslate); - obj->defineDefaultProperty(QStringLiteral("QT_TRANSLATE_NOOP"), QV4::GlobalExtensions::method_qsTranslateNoOp); - obj->defineDefaultProperty(QStringLiteral("qsTr"), QV4::GlobalExtensions::method_qsTr); - obj->defineDefaultProperty(QStringLiteral("QT_TR_NOOP"), QV4::GlobalExtensions::method_qsTrNoOp); - obj->defineDefaultProperty(QStringLiteral("qsTrId"), QV4::GlobalExtensions::method_qsTrId); - obj->defineDefaultProperty(QStringLiteral("QT_TRID_NOOP"), QV4::GlobalExtensions::method_qsTrIdNoOp); - - // string prototype extension - scope.engine->stringPrototype()->defineDefaultProperty(QStringLiteral("arg"), - QV4::GlobalExtensions::method_string_arg); -#endif + + QV4::GlobalExtensions::init(obj, extensions); } /*! diff --git a/src/qml/jsapi/qjsengine.h b/src/qml/jsapi/qjsengine.h index 123eb727df..40b0a60369 100644 --- a/src/qml/jsapi/qjsengine.h +++ b/src/qml/jsapi/qjsengine.h @@ -81,7 +81,19 @@ public: void collectGarbage(); - void installTranslatorFunctions(const QJSValue &object = QJSValue()); +#if QT_DEPRECATED_SINCE(5, 6) + QT_DEPRECATED void installTranslatorFunctions(const QJSValue &object = QJSValue()); +#endif + + enum Extension { + TranslationExtension = 0x1, + ConsoleExtension = 0x2, + GarbageCollectionExtension = 0x4, + AllExtensions = 0xffffffff + }; + Q_DECLARE_FLAGS(Extensions, Extension) + + void installExtensions(Extensions extensions, const QJSValue &object = QJSValue()); QV8Engine *handle() const { return d; } @@ -102,6 +114,8 @@ private: friend class QV8Engine; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QJSEngine::Extensions) + inline bool qjsvalue_cast_helper(const QJSValue &value, int type, void *ptr) { return QJSEngine::convertV2(value, type, ptr); diff --git a/src/qml/jsapi/qjsvalueiterator_p.h b/src/qml/jsapi/qjsvalueiterator_p.h index b0d0b2efda..dfc5e18cd6 100644 --- a/src/qml/jsapi/qjsvalueiterator_p.h +++ b/src/qml/jsapi/qjsvalueiterator_p.h @@ -34,6 +34,17 @@ #ifndef QJSVALUEITERATOR_P_H #define QJSVALUEITERATOR_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qjsvalue.h" #include "private/qv4objectiterator_p.h" diff --git a/src/qml/jsruntime/qv4alloca_p.h b/src/qml/jsruntime/qv4alloca_p.h index a4537868e2..df40a018ba 100644 --- a/src/qml/jsruntime/qv4alloca_p.h +++ b/src/qml/jsruntime/qv4alloca_p.h @@ -34,6 +34,17 @@ #ifndef QV4_ALLOCA_H #define QV4_ALLOCA_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qglobal.h> #if defined(Q_OS_WIN) diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index 98a600fab6..7a9c4b1d51 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4ARGUMENTSOBJECTS_H #define QV4ARGUMENTSOBJECTS_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h index 19fd74465c..56f45b5a72 100644 --- a/src/qml/jsruntime/qv4arraybuffer_p.h +++ b/src/qml/jsruntime/qv4arraybuffer_p.h @@ -33,6 +33,17 @@ #ifndef QV4ARRAYBUFFER_H #define QV4ARRAYBUFFER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index cca5bf7f20..48d2b9dbbf 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -33,6 +33,17 @@ #ifndef QV4ARRAYDATA_H #define QV4ARRAYDATA_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4managed_p.h" #include "qv4property_p.h" diff --git a/src/qml/jsruntime/qv4arrayobject_p.h b/src/qml/jsruntime/qv4arrayobject_p.h index 422a0de675..afd8080fa3 100644 --- a/src/qml/jsruntime/qv4arrayobject_p.h +++ b/src/qml/jsruntime/qv4arrayobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4ARRAYOBJECT_H #define QV4ARRAYOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4booleanobject_p.h b/src/qml/jsruntime/qv4booleanobject_p.h index 77b5a74fde..203c8ba4ea 100644 --- a/src/qml/jsruntime/qv4booleanobject_p.h +++ b/src/qml/jsruntime/qv4booleanobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4BOOLEANOBJECT_H #define QV4BOOLEANOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 2807d1e29c..6c360e7dda 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -33,6 +33,17 @@ #ifndef QMLJS_ENVIRONMENT_H #define QMLJS_ENVIRONMENT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4managed_p.h" diff --git a/src/qml/jsruntime/qv4dataview_p.h b/src/qml/jsruntime/qv4dataview_p.h index 37a8363645..26347766d3 100644 --- a/src/qml/jsruntime/qv4dataview_p.h +++ b/src/qml/jsruntime/qv4dataview_p.h @@ -33,6 +33,17 @@ #ifndef QV4DATAVIEW_H #define QV4DATAVIEW_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index a324e216e4..2eaa837666 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4DATEOBJECT_P_H #define QV4DATEOBJECT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4debugging_p.h b/src/qml/jsruntime/qv4debugging_p.h index 94f7d04725..14bff238cc 100644 --- a/src/qml/jsruntime/qv4debugging_p.h +++ b/src/qml/jsruntime/qv4debugging_p.h @@ -34,6 +34,17 @@ #ifndef DEBUGGING_H #define DEBUGGING_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4engine_p.h" #include "qv4context_p.h" diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index ffcd904013..e94b417908 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -33,6 +33,17 @@ #ifndef QV4ENGINE_H #define QV4ENGINE_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "private/qv4isel_p.h" #include "qv4managed_p.h" diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index 7f3babaa79..336050ab2b 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4ERROROBJECT_H #define QV4ERROROBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include "qv4string_p.h" diff --git a/src/qml/jsruntime/qv4executableallocator_p.h b/src/qml/jsruntime/qv4executableallocator_p.h index 0d07e3c1bd..bb63d423a6 100644 --- a/src/qml/jsruntime/qv4executableallocator_p.h +++ b/src/qml/jsruntime/qv4executableallocator_p.h @@ -34,6 +34,17 @@ #ifndef QV4EXECUTABLEALLOCATOR_H #define QV4EXECUTABLEALLOCATOR_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include <QMultiMap> diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 534aa1b750..0e1216a45b 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -33,6 +33,17 @@ #ifndef QV4FUNCTION_H #define QV4FUNCTION_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include <private/qv4compileddata_p.h> diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index a94c3f6db5..2944c7b421 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -263,7 +263,7 @@ ReturnedValue FunctionCtor::construct(const Managed *that, CallData *callData) if (scope.engine->hasException) return Encode::undefined(); - QString function = QLatin1String("function(") + arguments + QLatin1String("){") + body + QLatin1String("}"); + QString function = QLatin1String("function(") + arguments + QLatin1String("){") + body + QLatin1Char('}'); QQmlJS::Engine ee, *engine = ⅇ QQmlJS::Lexer lexer(engine); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 182f06f74e..896bd2a4d2 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4FUNCTIONOBJECT_H #define QV4FUNCTIONOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4function_p.h" #include "qv4context_p.h" diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 759c6795e2..01a21ea06d 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -34,6 +34,17 @@ #ifndef QV4GLOBAL_H #define QV4GLOBAL_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) #define V4_BOOTSTRAP #endif diff --git a/src/qml/jsruntime/qv4globalobject_p.h b/src/qml/jsruntime/qv4globalobject_p.h index ba1d5d2e0b..ced85621de 100644 --- a/src/qml/jsruntime/qv4globalobject_p.h +++ b/src/qml/jsruntime/qv4globalobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4GLOBALOBJECT_H #define QV4GLOBALOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4functionobject_p.h" diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h index 7937391ff7..605b06c685 100644 --- a/src/qml/jsruntime/qv4identifier_p.h +++ b/src/qml/jsruntime/qv4identifier_p.h @@ -33,6 +33,17 @@ #ifndef QV4IDENTIFIER_H #define QV4IDENTIFIER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qstring.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4identifiertable_p.h b/src/qml/jsruntime/qv4identifiertable_p.h index d91ce623c1..3af9db963e 100644 --- a/src/qml/jsruntime/qv4identifiertable_p.h +++ b/src/qml/jsruntime/qv4identifiertable_p.h @@ -33,6 +33,17 @@ #ifndef QV4IDENTIFIERTABLE_H #define QV4IDENTIFIERTABLE_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4identifier_p.h" #include "qv4string_p.h" #include "qv4engine_p.h" diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index 342870fcd6..5b91925ede 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -33,6 +33,17 @@ #ifndef QV4INTERNALCLASS_H #define QV4INTERNALCLASS_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include <QHash> diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index f4f87f3aea..2e5283c639 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -801,10 +801,11 @@ QString Stringify::JO(Object *o) if (partial.isEmpty()) { result = QStringLiteral("{}"); } else if (gap.isEmpty()) { - result = QStringLiteral("{") + partial.join(QLatin1Char(',')) + QStringLiteral("}"); + result = QStringLiteral("{") + partial.join(QLatin1Char(',')) + QLatin1Char('}'); } else { QString separator = QStringLiteral(",\n") + indent; - result = QStringLiteral("{\n") + indent + partial.join(separator) + QStringLiteral("\n") + stepback + QStringLiteral("}"); + result = QStringLiteral("{\n") + indent + partial.join(separator) + QLatin1Char('\n') + + stepback + QLatin1Char('}'); } indent = stepback; diff --git a/src/qml/jsruntime/qv4jsonobject_p.h b/src/qml/jsruntime/qv4jsonobject_p.h index 61d44f206e..6a6e863bf6 100644 --- a/src/qml/jsruntime/qv4jsonobject_p.h +++ b/src/qml/jsruntime/qv4jsonobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4JSONOBJECT_H #define QV4JSONOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include <qjsonarray.h> #include <qjsonobject.h> diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index 232e909c48..77ad1a7b65 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -33,6 +33,17 @@ #ifndef QV4LOOKUP_H #define QV4LOOKUP_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4runtime_p.h" #include "qv4engine_p.h" diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 6f5564300f..94df30944b 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -33,6 +33,17 @@ #ifndef QMLJS_MANAGED_H #define QMLJS_MANAGED_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4value_p.h" #include <private/qv4heap_p.h> @@ -60,7 +71,7 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} #define V4_NEEDS_DESTROY static void destroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->~Data(); } -#define V4_MANAGED(DataClass, superClass) \ +#define V4_MANAGED_ITSELF(DataClass, superClass) \ public: \ Q_MANAGED_CHECK \ typedef QV4::Heap::DataClass Data; \ @@ -70,6 +81,12 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} V4_MANAGED_SIZE_TEST \ QV4::Heap::DataClass *d() const { return static_cast<QV4::Heap::DataClass *>(m()); } +#define V4_MANAGED(DataClass, superClass) \ + private: \ + DataClass() Q_DECL_EQ_DELETE; \ + Q_DISABLE_COPY(DataClass) \ + V4_MANAGED_ITSELF(DataClass, superClass) + #define Q_MANAGED_TYPE(type) \ public: \ enum { MyType = Type_##type }; @@ -100,7 +117,7 @@ const QV4::VTable classname::static_vtbl = DEFINE_MANAGED_VTABLE_INT(classname, struct Q_QML_PRIVATE_EXPORT Managed : Value { - V4_MANAGED(Base, Managed) + V4_MANAGED_ITSELF(Base, Managed) enum { IsExecutionContext = false, IsString = false, diff --git a/src/qml/jsruntime/qv4math_p.h b/src/qml/jsruntime/qv4math_p.h index 4f550752aa..cf627bcc5d 100644 --- a/src/qml/jsruntime/qv4math_p.h +++ b/src/qml/jsruntime/qv4math_p.h @@ -33,6 +33,17 @@ #ifndef QMLJS_MATH_H #define QMLJS_MATH_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qglobal.h> #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4mathobject_p.h b/src/qml/jsruntime/qv4mathobject_p.h index ff4fb12ee6..a233f74367 100644 --- a/src/qml/jsruntime/qv4mathobject_p.h +++ b/src/qml/jsruntime/qv4mathobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4MATHOBJECT_H #define QV4MATHOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h index 50b8ddb3d1..12f407e869 100644 --- a/src/qml/jsruntime/qv4memberdata_p.h +++ b/src/qml/jsruntime/qv4memberdata_p.h @@ -33,6 +33,17 @@ #ifndef QV4MEMBERDATA_H #define QV4MEMBERDATA_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4managed_p.h" diff --git a/src/qml/jsruntime/qv4numberobject_p.h b/src/qml/jsruntime/qv4numberobject_p.h index 04798d31fc..cc5033531e 100644 --- a/src/qml/jsruntime/qv4numberobject_p.h +++ b/src/qml/jsruntime/qv4numberobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4NUMBEROBJECT_H #define QV4NUMBEROBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 58dab9691f..5c660f7e3f 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -33,6 +33,17 @@ #ifndef QV4_OBJECT_H #define QV4_OBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4managed_p.h" #include "qv4memberdata_p.h" #include "qv4arraydata_p.h" @@ -73,6 +84,9 @@ struct Object : Base { Data *d() const { return static_cast<Data *>(m()); } #define V4_OBJECT2(DataClass, superClass) \ + private: \ + DataClass() Q_DECL_EQ_DELETE; \ + Q_DISABLE_COPY(DataClass) \ public: \ Q_MANAGED_CHECK \ typedef QV4::Heap::DataClass Data; \ diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index e34b641be9..877b34c22d 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -33,6 +33,17 @@ #ifndef QV4OBJECTITERATOR_H #define QV4OBJECTITERATOR_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4object_p.h" diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h index d571e50cd4..ec829e4bd2 100644 --- a/src/qml/jsruntime/qv4objectproto_p.h +++ b/src/qml/jsruntime/qv4objectproto_p.h @@ -33,6 +33,17 @@ #ifndef QV4ECMAOBJECTS_P_H #define QV4ECMAOBJECTS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4persistent_p.h b/src/qml/jsruntime/qv4persistent_p.h index 67a76742d1..80b4ecdea8 100644 --- a/src/qml/jsruntime/qv4persistent_p.h +++ b/src/qml/jsruntime/qv4persistent_p.h @@ -33,6 +33,17 @@ #ifndef QV4PERSISTENT_H #define QV4PERSISTENT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4value_p.h" #include "qv4managed_p.h" diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h index 505d393a3d..6c54fc9bbd 100644 --- a/src/qml/jsruntime/qv4profiling_p.h +++ b/src/qml/jsruntime/qv4profiling_p.h @@ -34,6 +34,17 @@ #ifndef QV4PROFILING_H #define QV4PROFILING_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4engine_p.h" #include "qv4function_p.h" diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index db8c6017e1..8ddb4cf6f7 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -33,6 +33,17 @@ #ifndef QV4PROPERTYDESCRIPTOR_H #define QV4PROPERTYDESCRIPTOR_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4value_p.h" diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index af6e346ea8..928362a995 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -33,6 +33,17 @@ #ifndef QV4REGEXP_H #define QV4REGEXP_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QString> #include <QVector> diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 4f803df9c8..81ea9cf14b 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4REGEXPOBJECT_H #define QV4REGEXPOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4runtime_p.h" #include "qv4engine_p.h" #include "qv4context_p.h" diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index f597e4b2e3..571abac21e 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -33,6 +33,17 @@ #ifndef QMLJS_RUNTIME_H #define QMLJS_RUNTIME_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4value_p.h" #include "qv4context_p.h" diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 0c79897015..101d3dcb3c 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -33,6 +33,17 @@ #ifndef QV4SCOPEDVALUE_P_H #define QV4SCOPEDVALUE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4engine_p.h" #include "qv4value_p.h" #include "qv4persistent_p.h" diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h index 63e8239342..4fecf62082 100644 --- a/src/qml/jsruntime/qv4script_p.h +++ b/src/qml/jsruntime/qv4script_p.h @@ -33,6 +33,17 @@ #ifndef QV4SCRIPT_H #define QV4SCRIPT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include "qv4engine_p.h" #include "qv4functionobject_p.h" diff --git a/src/qml/jsruntime/qv4sparsearray_p.h b/src/qml/jsruntime/qv4sparsearray_p.h index 8496fc32e7..136f26a25c 100644 --- a/src/qml/jsruntime/qv4sparsearray_p.h +++ b/src/qml/jsruntime/qv4sparsearray_p.h @@ -34,6 +34,17 @@ #ifndef QV4SPARSEARRAY_H #define QV4SPARSEARRAY_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" #include <QtCore/qlist.h> diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 93a25d7ed5..85433369fc 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -33,6 +33,17 @@ #ifndef QV4STRING_H #define QV4STRING_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qstring.h> #include "qv4managed_p.h" diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index 86d77c726a..7d4f78d3c5 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -33,6 +33,17 @@ #ifndef QV4STRINGOBJECT_P_H #define QV4STRINGOBJECT_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include <QtCore/qnumeric.h> diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h index 74ee285da4..67e04c8ac0 100644 --- a/src/qml/jsruntime/qv4typedarray_p.h +++ b/src/qml/jsruntime/qv4typedarray_p.h @@ -33,6 +33,17 @@ #ifndef QV4TYPEDARRAY_H #define QV4TYPEDARRAY_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4object_p.h" #include "qv4functionobject_p.h" #include "qv4arraybuffer_p.h" diff --git a/src/qml/jsruntime/qv4util_p.h b/src/qml/jsruntime/qv4util_p.h index f9ae37855e..329831f134 100644 --- a/src/qml/jsruntime/qv4util_p.h +++ b/src/qml/jsruntime/qv4util_p.h @@ -33,6 +33,17 @@ #ifndef QV4UTIL_H #define QV4UTIL_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qv4global_p.h" QT_BEGIN_NAMESPACE diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 14094878d8..5e38873b49 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -33,6 +33,17 @@ #ifndef QV4VALUE_P_H #define QV4VALUE_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <limits.h> #include <QtCore/QString> diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h index 55cac75a66..c0421022d2 100644 --- a/src/qml/jsruntime/qv4vme_moth_p.h +++ b/src/qml/jsruntime/qv4vme_moth_p.h @@ -34,6 +34,17 @@ #ifndef QV4VME_MOTH_P_H #define QV4VME_MOTH_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qv4runtime_p.h> #include <private/qv4instr_moth_p.h> diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h index a93e4191b0..a3db71fee1 100644 --- a/src/qml/memory/qv4heap_p.h +++ b/src/qml/memory/qv4heap_p.h @@ -33,6 +33,17 @@ #ifndef QV4HEAP_P_H #define QV4HEAP_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/QString> #include <private/qv4global_p.h> diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h index c77d5e503d..3543da0907 100644 --- a/src/qml/memory/qv4mm_p.h +++ b/src/qml/memory/qv4mm_p.h @@ -34,6 +34,17 @@ #ifndef QV4GC_H #define QV4GC_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qv4global_p.h> #include <private/qv4value_p.h> #include <private/qv4scopedvalue_p.h> diff --git a/src/qml/parser/qqmljsglobal_p.h b/src/qml/parser/qqmljsglobal_p.h index fe2cbe7d1d..48ba2b034b 100644 --- a/src/qml/parser/qqmljsglobal_p.h +++ b/src/qml/parser/qqmljsglobal_p.h @@ -33,6 +33,17 @@ #ifndef QQMLJSGLOBAL_P_H #define QQMLJSGLOBAL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qglobal.h> #ifdef QT_CREATOR diff --git a/src/qml/qml/qqmlaccessors_p.h b/src/qml/qml/qqmlaccessors_p.h index 24cd0b60cb..8b0a587740 100644 --- a/src/qml/qml/qqmlaccessors_p.h +++ b/src/qml/qml/qqmlaccessors_p.h @@ -34,6 +34,17 @@ #ifndef QQMLACCESSORS_P_H #define QQMLACCESSORS_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> #include <QtCore/qbytearray.h> #include <QtCore/qvector.h> diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index be482b4639..040089db20 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -777,8 +777,8 @@ QObject *QQmlComponent::create(QQmlContext *context) /*! This method provides advanced control over component instance creation. - In general, programmers should use QQmlComponent::create() to create a - component. + In general, programmers should use QQmlComponent::create() to create object + instances. Create an object instance from this component. Returns 0 if creation failed. \a publicContext specifies the context within which to create the object diff --git a/src/qml/qml/qqmlcomponentattached_p.h b/src/qml/qml/qqmlcomponentattached_p.h index b6ad3dec00..fa103e7fce 100644 --- a/src/qml/qml/qqmlcomponentattached_p.h +++ b/src/qml/qml/qqmlcomponentattached_p.h @@ -34,6 +34,17 @@ #ifndef QQMLCOMPONENTATTACHED_P_H #define QQMLCOMPONENTATTACHED_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtQml/qqml.h> #include <private/qtqmlglobal_p.h> #include <QtCore/QObject> diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 47cd36b8f6..56252ec1ab 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -913,7 +913,7 @@ QQuickWorkerScriptEngine *QQmlEnginePrivate::getWorkerScriptEngine() Note that the \l {Qt Quick 1} version is called QDeclarativeEngine. - \sa QQmlComponent, QQmlContext + \sa QQmlComponent, QQmlContext, {QML Global Object} */ /*! @@ -1435,7 +1435,8 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre if (rv || !create) return rv; - QQmlAttachedPropertiesFunc pf = QQmlMetaType::attachedPropertiesFuncById(id); + QQmlEnginePrivate *engine = QQmlEnginePrivate::get(data->context); + QQmlAttachedPropertiesFunc pf = QQmlMetaType::attachedPropertiesFuncById(engine, id); if (!pf) return 0; @@ -1450,8 +1451,10 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object, const QMetaObject *attachedMetaObject, bool create) { - if (*idCache == -1) - *idCache = QQmlMetaType::attachedPropertiesFuncId(attachedMetaObject); + if (*idCache == -1) { + QQmlEngine *engine = object ? qmlEngine(object) : 0; + *idCache = QQmlMetaType::attachedPropertiesFuncId(engine ? QQmlEnginePrivate::get(engine) : 0, attachedMetaObject); + } if (*idCache == -1 || !object) return 0; diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index d09ae21f56..b7212648ab 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -34,6 +34,17 @@ #ifndef QQMLGLOBAL_H #define QQMLGLOBAL_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> #include <QtCore/QObject> #include <private/qqmlpropertycache_p.h> diff --git a/src/qml/qml/qqmlinfo.h b/src/qml/qml/qqmlinfo.h index b56f74198c..90ac1dd777 100644 --- a/src/qml/qml/qqmlinfo.h +++ b/src/qml/qml/qqmlinfo.h @@ -48,7 +48,11 @@ namespace QtQml { Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QQmlError &error); Q_QML_EXPORT QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors); } +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wheader-hygiene") +// This is necessary to allow for QtQuick1 and QtQuick2 scenes in a single application. using namespace QtQml; +QT_WARNING_POP class QQmlInfoPrivate; class Q_QML_EXPORT QQmlInfo : public QDebug diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index 3d2ed307d1..0c2fbbdb14 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -34,6 +34,17 @@ #ifndef QQMLLOCALE_H #define QQMLLOCALE_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> #include <QtCore/qlocale.h> diff --git a/src/qml/qml/qqmlmemoryprofiler_p.h b/src/qml/qml/qqmlmemoryprofiler_p.h index 98977f9db5..77008bd448 100644 --- a/src/qml/qml/qqmlmemoryprofiler_p.h +++ b/src/qml/qml/qqmlmemoryprofiler_p.h @@ -34,6 +34,17 @@ #ifndef QQMLMEMORYPROFILER_H #define QQMLMEMORYPROFILER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 04c001d305..26271e3f03 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -474,18 +474,24 @@ QQmlType *QQmlType::superType() const return d->superType; } -int QQmlType::resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const +QQmlType *QQmlType::resolveCompositeBaseType(QQmlEnginePrivate *engine) const { Q_ASSERT(isComposite()); - *ok = false; if (!engine) - return -1; + return 0; QQmlTypeData *td = engine->typeLoader.getType(sourceUrl()); if (!td || !td->isComplete()) - return -1; + return 0; QQmlCompiledData *cd = td->compiledData(); const QMetaObject *mo = cd->rootPropertyCache->firstCppMetaObject(); - QQmlType *type = QQmlMetaType::qmlType(mo); + return QQmlMetaType::qmlType(mo); +} + +int QQmlType::resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const +{ + Q_ASSERT(isComposite()); + *ok = false; + QQmlType *type = resolveCompositeBaseType(engine); if (!type) return -1; return type->enumValue(engine, name, ok); @@ -856,18 +862,26 @@ int QQmlType::metaObjectRevision() const return d->revision; } -QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction() const +QQmlAttachedPropertiesFunc QQmlType::attachedPropertiesFunction(QQmlEnginePrivate *engine) const { - if (d->regType != CppType) - return 0; - return d->extraData.cd->attachedPropertiesFunc; + if (d->regType == CppType) + return d->extraData.cd->attachedPropertiesFunc; + + QQmlType *base = 0; + if (d->regType == CompositeType) + base = resolveCompositeBaseType(engine); + return base ? base->attachedPropertiesFunction(engine) : 0; } -const QMetaObject *QQmlType::attachedPropertiesType() const +const QMetaObject *QQmlType::attachedPropertiesType(QQmlEnginePrivate *engine) const { - if (d->regType != CppType) - return 0; - return d->extraData.cd->attachedPropertiesType; + if (d->regType == CppType) + return d->extraData.cd->attachedPropertiesType; + + QQmlType *base = 0; + if (d->regType == CompositeType) + base = resolveCompositeBaseType(engine); + return base ? base->attachedPropertiesType(engine) : 0; } /* @@ -875,11 +889,15 @@ This is the id passed to qmlAttachedPropertiesById(). This is different from th for the case that a single class is registered under two or more names (eg. Item in Qt 4.7 and QtQuick 1.0). */ -int QQmlType::attachedPropertiesId() const +int QQmlType::attachedPropertiesId(QQmlEnginePrivate *engine) const { - if (d->regType != CppType) - return 0; - return d->extraData.cd->attachedPropertiesId; + if (d->regType == CppType) + return d->extraData.cd->attachedPropertiesId; + + QQmlType *base = 0; + if (d->regType == CompositeType) + base = resolveCompositeBaseType(engine); + return base ? base->attachedPropertiesId(engine) : 0; } int QQmlType::parserStatusCast() const @@ -1560,25 +1578,25 @@ int QQmlMetaType::listType(int id) return 0; } -int QQmlMetaType::attachedPropertiesFuncId(const QMetaObject *mo) +int QQmlMetaType::attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMetaObject *mo) { QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); QQmlType *type = data->metaObjectToType.value(mo); - if (type && type->attachedPropertiesFunction()) - return type->attachedPropertiesId(); + if (type && type->attachedPropertiesFunction(engine)) + return type->attachedPropertiesId(engine); else return -1; } -QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(int id) +QQmlAttachedPropertiesFunc QQmlMetaType::attachedPropertiesFuncById(QQmlEnginePrivate *engine, int id) { if (id < 0) return 0; QMutexLocker lock(metaTypeDataLock()); QQmlMetaTypeData *data = metaTypeData(); - return data->types.at(id)->attachedPropertiesFunction(); + return data->types.at(id)->attachedPropertiesFunction(engine); } QMetaProperty QQmlMetaType::defaultProperty(const QMetaObject *metaObject) diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index 40765d461a..c120941a03 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -92,8 +92,8 @@ public: static QObject *toQObject(const QVariant &, bool *ok = 0); static int listType(int); - static int attachedPropertiesFuncId(const QMetaObject *); - static QQmlAttachedPropertiesFunc attachedPropertiesFuncById(int); + static int attachedPropertiesFuncId(QQmlEnginePrivate *engine, const QMetaObject *); + static QQmlAttachedPropertiesFunc attachedPropertiesFuncById(QQmlEnginePrivate *, int); enum TypeCategory { Unknown, Object, List }; static TypeCategory typeCategory(int); @@ -169,9 +169,9 @@ public: int metaObjectRevision() const; bool containsRevisionedAttributes() const; - QQmlAttachedPropertiesFunc attachedPropertiesFunction() const; - const QMetaObject *attachedPropertiesType() const; - int attachedPropertiesId() const; + QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const; + const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const; + int attachedPropertiesId(QQmlEnginePrivate *engine) const; int parserStatusCast() const; const char *interfaceIId() const; @@ -212,6 +212,7 @@ public: int enumValue(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; private: QQmlType *superType() const; + QQmlType *resolveCompositeBaseType(QQmlEnginePrivate *engine) const; int resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const; friend class QQmlTypePrivate; friend struct QQmlMetaTypeData; diff --git a/src/qml/qml/qqmlnotifier_p.h b/src/qml/qml/qqmlnotifier_p.h index 90902c089d..ac0aab892f 100644 --- a/src/qml/qml/qqmlnotifier_p.h +++ b/src/qml/qml/qqmlnotifier_p.h @@ -34,6 +34,17 @@ #ifndef QQMLNOTIFIER_P_H #define QQMLNOTIFIER_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qqmldata_p.h" #include <QtCore/qmetaobject.h> #include <private/qmetaobject_p.h> diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 765437b423..f096dfeea9 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -706,7 +706,12 @@ bool QQmlObjectCreator::setPropertyBinding(const QQmlPropertyData *property, con QQmlCompiledData::TypeReference *tr = resolvedTypes.value(binding->propertyNameIndex); Q_ASSERT(tr); QQmlType *attachedType = tr->type; - const int id = attachedType->attachedPropertiesId(); + if (!attachedType) { + QQmlTypeNameCache::Result res = context->imports->query(stringAt(binding->propertyNameIndex)); + if (res.isValid()) + attachedType = res.type; + } + const int id = attachedType->attachedPropertiesId(QQmlEnginePrivate::get(engine)); QObject *qmlObject = qmlAttachedPropertiesObjectById(id, _qobject); if (!populateInstance(binding->value.objectIndex, qmlObject, qmlObject, /*value type property*/0)) return false; diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index 433bbf5bf2..620ae75f53 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -33,6 +33,17 @@ #ifndef QQMLOBJECTCREATOR_P_H #define QQMLOBJECTCREATOR_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qqmlimport_p.h> #include <private/qqmltypenamecache_p.h> #include <private/qv4compileddata_p.h> diff --git a/src/qml/qml/qqmlopenmetaobject.cpp b/src/qml/qml/qqmlopenmetaobject.cpp index 16138508dd..9188ba6174 100644 --- a/src/qml/qml/qqmlopenmetaobject.cpp +++ b/src/qml/qml/qqmlopenmetaobject.cpp @@ -261,8 +261,10 @@ void QQmlOpenMetaObject::emitPropertyNotification(const QByteArray &propertyName activate(d->object, *iter + d->type->d->signalOffset, 0); } -int QQmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) +int QQmlOpenMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void **a) { + Q_ASSERT(d->object == o); + if (( c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) && id >= d->type->d->propertyOffset) { int propId = id - d->type->d->propertyOffset; @@ -276,15 +278,15 @@ int QQmlOpenMetaObject::metaCall(QMetaObject::Call c, int id, void **a) prop.first = propertyWriteValue(propId, *reinterpret_cast<QVariant *>(a[0])); prop.second = true; propertyWritten(propId); - activate(d->object, d->type->d->signalOffset + propId, 0); + activate(o, d->type->d->signalOffset + propId, 0); } } return -1; } else { if (d->parent) - return d->parent->metaCall(c, id, a); + return d->parent->metaCall(o, c, id, a); else - return d->object->qt_metacall(c, id, a); + return o->qt_metacall(c, id, a); } } diff --git a/src/qml/qml/qqmlopenmetaobject_p.h b/src/qml/qml/qqmlopenmetaobject_p.h index 75ce9addd6..9728220b5a 100644 --- a/src/qml/qml/qqmlopenmetaobject_p.h +++ b/src/qml/qml/qqmlopenmetaobject_p.h @@ -34,6 +34,17 @@ #ifndef QQMLOPENMETAOBJECT_H #define QQMLOPENMETAOBJECT_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/QMetaObject> #include <QtCore/QObject> @@ -105,7 +116,7 @@ public: void emitPropertyNotification(const QByteArray &propertyName); protected: - virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); + virtual int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a); virtual int createProperty(const char *, const char *); virtual void propertyRead(int); diff --git a/src/qml/qml/qqmlplatform_p.h b/src/qml/qml/qqmlplatform_p.h index 363341c89e..c1a481a439 100644 --- a/src/qml/qml/qqmlplatform_p.h +++ b/src/qml/qml/qqmlplatform_p.h @@ -34,6 +34,17 @@ #ifndef QQMLPLATFORM_P_H #define QQMLPLATFORM_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/QObject> #include <qqml.h> #include <private/qtqmlglobal_p.h> diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index d3f7070528..1b78ada698 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -248,10 +248,11 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) QQmlTypeNameCache::Result r = typeNameCache->query(pathName); if (r.isValid()) { if (r.type) { - QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction(); + QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); + QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction(enginePrivate); if (!func) return; // Not an attachable type - currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject); + currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(enginePrivate), currentObject); if (!currentObject) return; // Something is broken with the attachable type } else if (r.importNamespace) { if ((ii + 1) == path.count()) return; // No type following the namespace @@ -259,10 +260,11 @@ void QQmlPropertyPrivate::initProperty(QObject *obj, const QString &name) ++ii; r = typeNameCache->query(path.at(ii), r.importNamespace); if (!r.type) return; // Invalid type in namespace - QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction(); + QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine); + QQmlAttachedPropertiesFunc func = r.type->attachedPropertiesFunction(enginePrivate); if (!func) return; // Not an attachable type - currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(), currentObject); + currentObject = qmlAttachedPropertiesObjectById(r.type->attachedPropertiesId(enginePrivate), currentObject); if (!currentObject) return; // Something is broken with the attachable type } else if (r.scriptIndex != -1) { diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 9a935ed55f..e8c9989fdf 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -346,25 +346,6 @@ void QQmlPropertyCache::appendProperty(const QString &name, setNamedProperty(name, index + propertyOffset(), propertyIndexCache.data() + index, (old != 0)); } -void QQmlPropertyCache::appendProperty(const QHashedCStringRef &name, - quint32 flags, int coreIndex, int propType, int notifyIndex) -{ - QQmlPropertyData data; - data.propType = propType; - data.coreIndex = coreIndex; - data.notifyIndex = notifyIndex; - data.flags = flags; - - QQmlPropertyData *old = findNamedProperty(name); - if (old) - data.markAsOverrideOf(old); - - int index = propertyIndexCache.count(); - propertyIndexCache.append(data); - - setNamedProperty(name, index + propertyOffset(), propertyIndexCache.data() + index, (old != 0)); -} - void QQmlPropertyCache::appendSignal(const QString &name, quint32 flags, int coreIndex, const int *types, const QList<QByteArray> &names) { @@ -402,43 +383,6 @@ void QQmlPropertyCache::appendSignal(const QString &name, quint32 flags, int cor setNamedProperty(handlerName, signalHandlerIndex + signalOffset(), signalHandlerIndexCache.data() + signalHandlerIndex, (old != 0)); } -void QQmlPropertyCache::appendSignal(const QHashedCStringRef &name, quint32 flags, int coreIndex, - const int *types, const QList<QByteArray> &names) -{ - QQmlPropertyData data; - data.propType = QVariant::Invalid; - data.coreIndex = coreIndex; - data.flags = flags; - data.arguments = 0; - - QQmlPropertyData handler = data; - handler.flags |= QQmlPropertyData::IsSignalHandler; - - if (types) { - int argumentCount = *types; - QQmlPropertyCacheMethodArguments *args = createArgumentsObject(argumentCount, names); - ::memcpy(args->arguments, types, (argumentCount + 1) * sizeof(int)); - args->argumentsValid = true; - data.arguments = args; - } - - QQmlPropertyData *old = findNamedProperty(name); - if (old) - data.markAsOverrideOf(old); - - int methodIndex = methodIndexCache.count(); - methodIndexCache.append(data); - - int signalHandlerIndex = signalHandlerIndexCache.count(); - signalHandlerIndexCache.append(handler); - - QString handlerName = QLatin1String("on") + name.toUtf16(); - handlerName[2] = handlerName[2].toUpper(); - - setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != 0)); - setNamedProperty(handlerName, signalHandlerIndex + signalOffset(), signalHandlerIndexCache.data() + signalHandlerIndex, (old != 0)); -} - void QQmlPropertyCache::appendMethod(const QString &name, quint32 flags, int coreIndex, const QList<QByteArray> &names) { @@ -466,33 +410,6 @@ void QQmlPropertyCache::appendMethod(const QString &name, quint32 flags, int cor setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != 0)); } -void QQmlPropertyCache::appendMethod(const QHashedCStringRef &name, quint32 flags, int coreIndex, - const QList<QByteArray> &names) -{ - int argumentCount = names.count(); - - QQmlPropertyData data; - data.propType = QMetaType::QVariant; - data.coreIndex = coreIndex; - - QQmlPropertyCacheMethodArguments *args = createArgumentsObject(argumentCount, names); - for (int ii = 0; ii < argumentCount; ++ii) - args->arguments[ii + 1] = QMetaType::QVariant; - args->argumentsValid = true; - data.arguments = args; - - data.flags = flags; - - QQmlPropertyData *old = findNamedProperty(name); - if (old) - data.markAsOverrideOf(old); - - int methodIndex = methodIndexCache.count(); - methodIndexCache.append(data); - - setNamedProperty(name, methodIndex + methodOffset(), methodIndexCache.data() + methodIndex, (old != 0)); -} - // Returns this property cache's metaObject. May be null if it hasn't been created yet. const QMetaObject *QQmlPropertyCache::metaObject() const { @@ -893,19 +810,17 @@ void QQmlPropertyCache::invalidate(const QMetaObject *metaObject) This is different from QMetaMethod::methodIndex(). */ QQmlPropertyData * -QQmlPropertyCache::signal(int index, QQmlPropertyCache **c) const +QQmlPropertyCache::signal(int index) const { if (index < 0 || index >= (signalHandlerIndexCacheStart + signalHandlerIndexCache.count())) return 0; if (index < signalHandlerIndexCacheStart) - return _parent->signal(index, c); + return _parent->signal(index); QQmlPropertyData *rv = const_cast<QQmlPropertyData *>(&methodIndexCache.at(index - signalHandlerIndexCacheStart)); - if (rv->notFullyResolved()) resolve(rv); Q_ASSERT(rv->isSignal() || rv->coreIndex == -1); - if (c) *c = const_cast<QQmlPropertyCache *>(this); - return rv; + return ensureResolved(rv); } int QQmlPropertyCache::methodIndexToSignalIndex(int index) const @@ -1101,52 +1016,6 @@ QQmlPropertyCacheMethodArguments *QQmlPropertyCache::createArgumentsObject(int a return args; } -/*! \internal - \a index MUST be in the signal index range (see QObjectPrivate::signalIndex()). - This is different from QMetaMethod::methodIndex(). -*/ -QString QQmlPropertyCache::signalParameterStringForJS(int index, QString *errorString) -{ - QQmlPropertyCache *c = 0; - QQmlPropertyData *signalData = signal(index, &c); - if (!signalData) - return QString(); - - typedef QQmlPropertyCacheMethodArguments A; - - if (signalData->arguments) { - A *arguments = static_cast<A *>(signalData->arguments); - if (arguments->signalParameterStringForJS) { - if (arguments->parameterError) { - if (errorString) - *errorString = *arguments->signalParameterStringForJS; - return QString(); - } - return *arguments->signalParameterStringForJS; - } - } - - QList<QByteArray> parameterNameList = signalParameterNames(index); - - if (!signalData->arguments) { - A *args = c->createArgumentsObject(parameterNameList.count(), parameterNameList); - signalData->arguments = args; - } - - QString error; - QString parameters = signalParameterStringForJS(engine, parameterNameList, &error); - - A *arguments = static_cast<A *>(signalData->arguments); - arguments->signalParameterStringForJS = new QString(!error.isEmpty() ? error : parameters); - if (!error.isEmpty()) { - arguments->parameterError = true; - if (errorString) - *errorString = *arguments->signalParameterStringForJS; - return QString(); - } - return *arguments->signalParameterStringForJS; -} - QString QQmlPropertyCache::signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList<QByteArray> ¶meterNameList, QString *errorString) { bool unnamedParameter = false; @@ -1405,19 +1274,19 @@ void QQmlPropertyCache::toMetaObjectBuilder(QMetaObjectBuilder &builder) if (data->propType != 0) returnType = QMetaType::typeName(data->propType); - QByteArray signature = methods.at(ii).first.toUtf8() + "("; + QByteArray signature = methods.at(ii).first.toUtf8() + '('; QQmlPropertyCacheMethodArguments *arguments = 0; if (data->hasArguments()) { arguments = (QQmlPropertyCacheMethodArguments *)data->arguments; Q_ASSERT(arguments->argumentsValid); for (int ii = 0; ii < arguments->arguments[0]; ++ii) { - if (ii != 0) signature.append(","); + if (ii != 0) signature.append(','); signature.append(QMetaType::typeName(arguments->arguments[1 + ii])); } } - signature.append(")"); + signature.append(')'); QMetaMethodBuilder method; if (data->isSignal()) { diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 2ee399c496..610709ef7f 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -267,16 +267,10 @@ public: int methodCount, int signalCount); void appendProperty(const QString &, quint32 flags, int coreIndex, int propType, int notifyIndex); - void appendProperty(const QHashedCStringRef &, - quint32 flags, int coreIndex, int propType, int notifyIndex); void appendSignal(const QString &, quint32, int coreIndex, const int *types = 0, const QList<QByteArray> &names = QList<QByteArray>()); - void appendSignal(const QHashedCStringRef &, quint32, int coreIndex, const int *types = 0, - const QList<QByteArray> &names = QList<QByteArray>()); void appendMethod(const QString &, quint32 flags, int coreIndex, const QList<QByteArray> &names = QList<QByteArray>()); - void appendMethod(const QHashedCStringRef &, quint32 flags, int coreIndex, - const QList<QByteArray> &names = QList<QByteArray>()); const QMetaObject *metaObject() const; const QMetaObject *createMetaObject(); @@ -290,7 +284,7 @@ public: QQmlPropertyData *property(int) const; QQmlPropertyData *method(int) const; - QQmlPropertyData *signal(int index) const { return signal(index, 0); } + QQmlPropertyData *signal(int index) const; int methodIndexToSignalIndex(int) const; QStringList propertyNames() const; @@ -313,7 +307,6 @@ public: static int originalClone(QObject *, int index); QList<QByteArray> signalParameterNames(int index) const; - QString signalParameterStringForJS(int index, QString *errorString = 0); static QString signalParameterStringForJS(QV4::ExecutionEngine *engine, const QList<QByteArray> ¶meterNameList, QString *errorString = 0); const char *className() const; @@ -347,9 +340,7 @@ private: QQmlPropertyData::Flag methodFlags = QQmlPropertyData::NoFlags, QQmlPropertyData::Flag signalFlags = QQmlPropertyData::NoFlags); - QQmlPropertyCacheMethodArguments *createArgumentsObject(int count, - const QList<QByteArray> &names); - QQmlPropertyData *signal(int, QQmlPropertyCache **) const; + QQmlPropertyCacheMethodArguments *createArgumentsObject(int count, const QList<QByteArray> &names); typedef QVector<QQmlPropertyData> IndexCache; typedef QStringMultiHash<QPair<int, QQmlPropertyData *> > StringCache; diff --git a/src/qml/qml/qqmlproxymetaobject.cpp b/src/qml/qml/qqmlproxymetaobject.cpp index bf735a9f0c..ba5215b831 100644 --- a/src/qml/qml/qqmlproxymetaobject.cpp +++ b/src/qml/qml/qqmlproxymetaobject.cpp @@ -59,8 +59,10 @@ QQmlProxyMetaObject::~QQmlProxyMetaObject() proxies = 0; } -int QQmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) +int QQmlProxyMetaObject::metaCall(QObject *o, QMetaObject::Call c, int id, void **a) { + Q_ASSERT(object == o); + if ((c == QMetaObject::ReadProperty || c == QMetaObject::WriteProperty) && id >= metaObjects->last().propertyOffset) { @@ -108,7 +110,7 @@ int QQmlProxyMetaObject::metaCall(QMetaObject::Call c, int id, void **a) } if (parent) - return parent->metaCall(c, id, a); + return parent->metaCall(o, c, id, a); else return object->qt_metacall(c, id, a); } diff --git a/src/qml/qml/qqmlproxymetaobject_p.h b/src/qml/qml/qqmlproxymetaobject_p.h index 862b0fb7c2..6ae35fe11f 100644 --- a/src/qml/qml/qqmlproxymetaobject_p.h +++ b/src/qml/qml/qqmlproxymetaobject_p.h @@ -71,7 +71,7 @@ public: virtual ~QQmlProxyMetaObject(); protected: - virtual int metaCall(QMetaObject::Call _c, int _id, void **_a); + virtual int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a); private: QList<ProxyData> *metaObjects; diff --git a/src/qml/qml/qqmlscriptstring_p.h b/src/qml/qml/qqmlscriptstring_p.h index 24bfdcdd4e..aa0a1e5695 100644 --- a/src/qml/qml/qqmlscriptstring_p.h +++ b/src/qml/qml/qqmlscriptstring_p.h @@ -34,6 +34,17 @@ #ifndef QQMLSCRIPTSTRING_P_H #define QQMLSCRIPTSTRING_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include "qqmlscriptstring.h" #include <QtQml/qqmlcontext.h> diff --git a/src/qml/qml/qqmltypenotavailable_p.h b/src/qml/qml/qqmltypenotavailable_p.h index f69a4f8732..324e07b80c 100644 --- a/src/qml/qml/qqmltypenotavailable_p.h +++ b/src/qml/qml/qqmltypenotavailable_p.h @@ -34,6 +34,17 @@ #ifndef QQMLTYPENOTAVAILABLE_H #define QQMLTYPENOTAVAILABLE_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index d70a4019b2..6c29f2fbb5 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -185,7 +185,7 @@ ReturnedValue QmlTypeWrapper::get(const Managed *m, String *name, bool *hasPrope // Fall through to base implementation } else if (w->d()->object) { - QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object); + QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(QQmlEnginePrivate::get(v4->qmlEngine())), object); if (ao) return QV4::QObjectWrapper::getQmlProperty(v4, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty); @@ -241,7 +241,8 @@ void QmlTypeWrapper::put(Managed *m, String *name, const Value &value) QQmlType *type = w->d()->type; if (type && !type->isSingleton() && w->d()->object) { QObject *object = w->d()->object; - QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object); + QQmlEngine *e = scope.engine->qmlEngine(); + QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(QQmlEnginePrivate::get(e)), object); if (ao) QV4::QObjectWrapper::setQmlProperty(v4, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value); } else if (type && type->isSingleton()) { diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index 509bbf7039..b1f2549035 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -63,18 +63,19 @@ QQmlVMEVariantQObjectPtr::~QQmlVMEVariantQObjectPtr() void QQmlVMEVariantQObjectPtr::objectDestroyed(QObject *) { - if (m_target && m_index >= 0) { - if (m_target->propertiesInitialized && !m_target->properties.isUndefined()) { - QV4::ExecutionEngine *v4 = m_target->cache->engine; - if (v4) { - QV4::Scope scope(v4); - QV4::Scoped<QV4::MemberData> sp(scope, m_target->properties.value()); + if (!m_target || QQmlData::wasDeleted(m_target->object)) + return; + + if (m_index >= 0) { + QV4::ExecutionEngine *v4 = m_target->properties.engine(); + if (v4) { + QV4::Scope scope(v4); + QV4::Scoped<QV4::MemberData> sp(scope, m_target->properties.value()); + if (sp) *(sp->data() + m_index) = QV4::Primitive::nullValue(); - } } - if (!QQmlData::wasDeleted(m_target->object)) - m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0); + m_target->activate(m_target->object, m_target->methodOffset() + m_index, 0); } } @@ -147,12 +148,14 @@ QAbstractDynamicMetaObject *QQmlVMEMetaObject::toDynamicMetaObject(QObject *o) QQmlVMEMetaObject::QQmlVMEMetaObject(QObject *obj, QQmlPropertyCache *cache, - const QQmlVMEMetaData *meta, QV4::ExecutionContext *qmlBindingContext, QQmlCompiledData *compiledData) -: object(obj), - ctxt(QQmlData::get(obj, true)->outerContext), cache(cache), metaData(meta), - hasAssignedMetaObjectData(false), aliasEndpoints(0), - propertiesInitialized(false), interceptors(0), methods(0) + const QQmlVMEMetaData *meta) + : object(obj), + ctxt(QQmlData::get(obj, true)->outerContext), cache(cache), metaData(meta), + hasAssignedMetaObjectData(false), aliasEndpoints(0), + interceptors(0), methods(0) { + cache->addref(); + QObjectPrivate *op = QObjectPrivate::get(obj); if (op->metaObject) { @@ -165,8 +168,6 @@ QQmlVMEMetaObject::QQmlVMEMetaObject(QObject *obj, op->metaObject = this; QQmlData::get(obj)->hasVMEMetaObject = true; - aConnected.resize(metaData->aliasCount); - int list_type = qMetaTypeId<QQmlListProperty<QObject> >(); int qobject_type = qMetaTypeId<QObject*>(); int variant_type = qMetaTypeId<QVariant>(); // Need JS wrapper to ensure properties are marked. @@ -177,31 +178,14 @@ QQmlVMEMetaObject::QQmlVMEMetaObject(QObject *obj, // ### Optimize for (int ii = 0; ii < metaData->propertyCount; ++ii) { int t = (metaData->propertyData() + ii)->propertyType; - if (t == list_type) { - listProperties.append(List(methodOffset() + ii, this)); - writeProperty(ii, listProperties.count() - 1); - } else if (!needsJSWrapper && (t == qobject_type || t == variant_type)) { + if (t == qobject_type || t == variant_type) { needsJSWrapper = true; + break; } } if (needsJSWrapper) ensureQObjectWrapper(); - - if (qmlBindingContext && metaData->methodCount) { - methods = new QV4::PersistentValue[metaData->methodCount]; - - QV4::CompiledData::CompilationUnit *compilationUnit = compiledData->compilationUnit; - QV4::Scope scope(cache->engine); - QV4::ScopedObject o(scope); - for (int index = 0; index < metaData->methodCount; ++index) { - QQmlVMEMetaData::MethodData *data = metaData->methodData() + index; - - QV4::Function *runtimeFunction = compilationUnit->runtimeFunctions[data->runtimeFunctionIndex]; - o = QV4::FunctionObject::createScriptFunction(qmlBindingContext, runtimeFunction); - methods[index].set(qmlBindingContext->engine(), o); - } - } } QQmlVMEMetaObject::~QQmlVMEMetaObject() @@ -211,12 +195,21 @@ QQmlVMEMetaObject::~QQmlVMEMetaObject() delete [] methods; qDeleteAll(varObjectGuards); + + cache->release(); } QV4::MemberData *QQmlVMEMetaObject::propertiesAsMemberData() { - if (!ensurePropertiesAllocated()) - return 0; + if (properties.isUndefined()) { + if (properties.valueRef()) + // in some situations, the QObject wrapper (and associated data, + // such as the varProperties array) will have been cleaned up, but the + // QObject ptr will not yet have been deleted (eg, waiting on deleteLater). + // In this situation, return 0. + return 0; + allocateProperties(); + } return static_cast<QV4::MemberData*>(properties.asManaged()); } @@ -442,6 +435,22 @@ QObject* QQmlVMEMetaObject::readPropertyAsQObject(int id) return wrapper->object(); } +QList<QObject *> *QQmlVMEMetaObject::readPropertyAsList(int id) +{ + QV4::MemberData *md = propertiesAsMemberData(); + if (!md) + return 0; + + QV4::Scope scope(cache->engine); + QV4::Scoped<QV4::VariantObject> v(scope, *(md->data() + id)); + if (!v || (int)v->d()->data.userType() != qMetaTypeId<QList<QObject *> >()) { + QVariant variant(qVariantFromValue(QList<QObject*>())); + v = cache->engine->newVariantObject(variant); + *(md->data() + id) = v; + } + return static_cast<QList<QObject *> *>(v->d()->data.data()); +} + QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id) { QV4::MemberData *md = propertiesAsMemberData(); @@ -601,23 +610,25 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * break; default: { - QV4::MemberData *md = propertiesAsMemberData(); - if (md) { - QV4::VariantObject *v = (md->data() + id)->as<QV4::VariantObject>(); - if (v) - QQml_valueTypeProvider()->readValueType(v->d()->data, a[0], t); + if (t == qMetaTypeId<QQmlListProperty<QObject> >()) { + QList<QObject *> *list = readPropertyAsList(id); + QQmlListProperty<QObject> *p = static_cast<QQmlListProperty<QObject> *>(a[0]); + *p = QQmlListProperty<QObject>(object, list, + list_append, list_count, list_at, + list_clear); + p->dummy1 = this; + p->dummy2 = reinterpret_cast<void *>(quintptr(methodOffset() + id)); + } else { + QV4::MemberData *md = propertiesAsMemberData(); + if (md) { + QV4::VariantObject *v = (md->data() + id)->as<QV4::VariantObject>(); + if (v) + QQml_valueTypeProvider()->readValueType(v->d()->data, a[0], t); + } } break; } } - if (t == qMetaTypeId<QQmlListProperty<QObject> >()) { - const int listIndex = readPropertyAsInt(id); - const List *list = &listProperties.at(listIndex); - *reinterpret_cast<QQmlListProperty<QObject> *>(a[0]) = - QQmlListProperty<QObject>(object, const_cast<List *>(list), - list_append, list_count, list_at, - list_clear); - } } else if (c == QMetaObject::WriteProperty) { @@ -826,11 +837,11 @@ QV4::ReturnedValue QQmlVMEMetaObject::method(int index) { if (!ctxt || !ctxt->isValid()) { qWarning("QQmlVMEMetaObject: Internal error - attempted to evaluate a function in an invalid context"); - return QV4::Primitive::undefinedValue().asReturnedValue(); + return QV4::Encode::undefined(); } if (!methods) - methods = new QV4::PersistentValue[metaData->methodCount]; + return QV4::Encode::undefined(); return methods[index].value(); } @@ -959,26 +970,28 @@ void QQmlVMEMetaObject::listChanged(int id) void QQmlVMEMetaObject::list_append(QQmlListProperty<QObject> *prop, QObject *o) { - List *list = static_cast<List *>(prop->data); + QList<QObject *> *list = static_cast<QList<QObject *> *>(prop->data); list->append(o); - list->mo->activate(prop->object, list->notifyIndex, 0); + static_cast<QQmlVMEMetaObject *>(prop->dummy1)->activate(prop->object, reinterpret_cast<quintptr>(prop->dummy2), 0); } int QQmlVMEMetaObject::list_count(QQmlListProperty<QObject> *prop) { - return static_cast<List *>(prop->data)->count(); + QList<QObject *> *list = static_cast<QList<QObject *> *>(prop->data); + return list->count(); } QObject *QQmlVMEMetaObject::list_at(QQmlListProperty<QObject> *prop, int index) { - return static_cast<List *>(prop->data)->at(index); + QList<QObject *> *list = static_cast<QList<QObject *> *>(prop->data); + return list->at(index); } void QQmlVMEMetaObject::list_clear(QQmlListProperty<QObject> *prop) { - List *list = static_cast<List *>(prop->data); + QList<QObject *> *list = static_cast<QList<QObject *> *>(prop->data); list->clear(); - list->mo->activate(prop->object, list->notifyIndex, 0); + static_cast<QQmlVMEMetaObject *>(prop->dummy1)->activate(prop->object, reinterpret_cast<quintptr>(prop->dummy2), 0); } void QQmlVMEMetaObject::registerInterceptor(int index, int valueIndex, QQmlPropertyValueInterceptor *interceptor) @@ -1052,19 +1065,6 @@ void QQmlVMEMetaObject::setVMEProperty(int index, const QV4::Value &v) return writeVarProperty(index - propOffset(), v); } -bool QQmlVMEMetaObject::ensurePropertiesAllocated() -{ - if (!propertiesInitialized) - allocateProperties(); - - // in some situations, the QObject's v8object (and associated v8 data, - // such as the varProperties array) will have been cleaned up, but the - // QObject ptr will not yet have been deleted (eg, waiting on deleteLater). - // In this situation, the varProperties handle will be (and should remain) - // empty. - return !properties.isUndefined(); -} - void QQmlVMEMetaObject::ensureQObjectWrapper() { Q_ASSERT(cache && cache->engine); @@ -1087,12 +1087,12 @@ void QQmlVMEMetaObject::mark(QV4::ExecutionEngine *e) void QQmlVMEMetaObject::allocateProperties() { Q_ASSERT(cache && cache->engine); + Q_ASSERT(!properties.valueRef()); QV4::ExecutionEngine *v4 = cache->engine; QV4::Heap::MemberData *data = QV4::MemberData::allocate(v4, metaData->propertyCount); properties.set(v4, data); for (uint i = 0; i < data->size; ++i) data->data[i] = QV4::Encode::undefined(); - propertiesInitialized = true; } bool QQmlVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const @@ -1127,22 +1127,21 @@ bool QQmlVMEMetaObject::aliasTarget(int index, QObject **target, int *coreIndex, void QQmlVMEMetaObject::connectAlias(int aliasId) { - if (!aConnected.testBit(aliasId)) { - - if (!aliasEndpoints) - aliasEndpoints = new QQmlVMEMetaObjectEndpoint[metaData->aliasCount]; + if (!aliasEndpoints) + aliasEndpoints = new QQmlVMEMetaObjectEndpoint[metaData->aliasCount]; - aConnected.setBit(aliasId); + QQmlVMEMetaData::AliasData *d = metaData->aliasData() + aliasId; - QQmlVMEMetaData::AliasData *d = metaData->aliasData() + aliasId; - - QQmlVMEMetaObjectEndpoint *endpoint = aliasEndpoints + aliasId; - endpoint->metaObject = this; - - endpoint->connect(&ctxt->idValues[d->contextIdx].bindings); - - endpoint->tryConnect(); + QQmlVMEMetaObjectEndpoint *endpoint = aliasEndpoints + aliasId; + if (endpoint->metaObject.data()) { + // already connected + Q_ASSERT(endpoint->metaObject.data() == this); + return; } + + endpoint->metaObject = this; + endpoint->connect(&ctxt->idValues[d->contextIdx].bindings); + endpoint->tryConnect(); } void QQmlVMEMetaObject::connectAliasSignal(int index, bool indexInSignalRange) diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h index dcf95b0c69..413eca8a68 100644 --- a/src/qml/qml/qqmlvmemetaobject_p.h +++ b/src/qml/qml/qqmlvmemetaobject_p.h @@ -155,8 +155,7 @@ class QQmlVMEMetaObjectEndpoint; class Q_QML_PRIVATE_EXPORT QQmlVMEMetaObject : public QAbstractDynamicMetaObject { public: - QQmlVMEMetaObject(QObject *obj, QQmlPropertyCache *cache, const QQmlVMEMetaData *data, - QV4::ExecutionContext *qmlBindingContext = 0, QQmlCompiledData *compiledData = 0); + QQmlVMEMetaObject(QObject *obj, QQmlPropertyCache *cache, const QQmlVMEMetaData *data); ~QQmlVMEMetaObject(); bool aliasTarget(int index, QObject **target, int *coreIndex, int *valueTypeIndex) const; @@ -201,9 +200,7 @@ public: QQmlVMEMetaObjectEndpoint *aliasEndpoints; QV4::WeakValue properties; - bool propertiesInitialized; inline void allocateProperties(); - inline bool ensurePropertiesAllocated(); QV4::MemberData *propertiesAsMemberData(); int readPropertyAsInt(int id); @@ -216,7 +213,8 @@ public: QDate readPropertyAsDate(int id); QDateTime readPropertyAsDateTime(int id); QRectF readPropertyAsRectF(int id); - QObject* readPropertyAsQObject(int id); + QObject *readPropertyAsQObject(int id); + QList<QObject *> *readPropertyAsList(int id); void writeProperty(int id, int v); void writeProperty(int id, bool v); @@ -235,7 +233,6 @@ public: void mark(QV4::ExecutionEngine *e); void connectAlias(int aliasId); - QBitArray aConnected; QQmlPropertyValueInterceptor *interceptors; @@ -252,14 +249,6 @@ public: inline QQmlVMEMetaObject *parentVMEMetaObject() const; void listChanged(int); - class List : public QList<QObject*> - { - public: - List(int lpi, QQmlVMEMetaObject *mo) : notifyIndex(lpi), mo(mo) {} - int notifyIndex; - QQmlVMEMetaObject *mo; - }; - QList<List> listProperties; static void list_append(QQmlListProperty<QObject> *, QObject *); static int list_count(QQmlListProperty<QObject> *); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 8666c0db01..043113bc31 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -314,10 +314,6 @@ struct Node : public Object static ReturnedValue create(ExecutionEngine *v4, NodeImpl *); bool isNull() const; - -private: - Node &operator=(const Node &); - Node(const Node &o); }; Heap::Node::Node(NodeImpl *data) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 5986fdbdfa..89088e5b3e 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1380,37 +1380,40 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *c result.append(QLatin1Char(' ')); if (ctx->args()[i].as<ArrayObject>()) - result.append(QStringLiteral("[") + ctx->args()[i].toQStringNoThrow() + QStringLiteral("]")); + result.append(QLatin1Char('[') + ctx->args()[i].toQStringNoThrow() + QLatin1Char(']')); else result.append(ctx->args()[i].toQStringNoThrow()); } if (printStack) { - result.append(QLatin1String("\n")); + result.append(QLatin1Char('\n')); result.append(jsStack(v4)); } - static QLoggingCategory loggingCategory("qml"); + static QLoggingCategory qmlLoggingCategory("qml"); + static QLoggingCategory jsLoggingCategory("js"); + + QLoggingCategory *loggingCategory = v4->qmlEngine() ? &qmlLoggingCategory : &jsLoggingCategory; QV4::StackFrame frame = v4->currentStackFrame(); const QByteArray baSource = frame.source.toUtf8(); const QByteArray baFunction = frame.function.toUtf8(); - QMessageLogger logger(baSource.constData(), frame.line, baFunction.constData(), loggingCategory.categoryName()); + QMessageLogger logger(baSource.constData(), frame.line, baFunction.constData(), loggingCategory->categoryName()); switch (logType) { case Log: - if (loggingCategory.isDebugEnabled()) + if (loggingCategory->isDebugEnabled()) logger.debug("%s", result.toUtf8().constData()); break; case Info: - if (loggingCategory.isInfoEnabled()) + if (loggingCategory->isInfoEnabled()) logger.info("%s", result.toUtf8().constData()); break; case Warn: - if (loggingCategory.isWarningEnabled()) + if (loggingCategory->isWarningEnabled()) logger.warning("%s", result.toUtf8().constData()); break; case Error: - if (loggingCategory.isCriticalEnabled()) + if (loggingCategory->isCriticalEnabled()) logger.critical("%s", result.toUtf8().constData()); break; default: @@ -1442,6 +1445,9 @@ QV4::ReturnedValue ConsoleObject::method_profile(CallContext *ctx) { QV4::ExecutionEngine *v4 = ctx->d()->engine; + if (!v4->qmlEngine()) + return QV4::Encode::undefined(); // Not yet implemented for JavaScript. + QV4::StackFrame frame = v4->currentStackFrame(); const QByteArray baSource = frame.source.toUtf8(); const QByteArray baFunction = frame.function.toUtf8(); @@ -1461,6 +1467,9 @@ QV4::ReturnedValue ConsoleObject::method_profileEnd(CallContext *ctx) { QV4::ExecutionEngine *v4 = ctx->d()->engine; + if (!v4->qmlEngine()) + return QV4::Encode::undefined(); // Not yet implemented for JavaScript. + QV4::StackFrame frame = v4->currentStackFrame(); const QByteArray baSource = frame.source.toUtf8(); const QByteArray baFunction = frame.function.toUtf8(); @@ -1590,31 +1599,36 @@ QV4::ReturnedValue ConsoleObject::method_exception(CallContext *ctx) -void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject) +void QV4::GlobalExtensions::init(Object *globalObject, QJSEngine::Extensions extensions) { ExecutionEngine *v4 = globalObject->engine(); Scope scope(v4); -#ifndef QT_NO_TRANSLATION - globalObject->defineDefaultProperty(QStringLiteral("qsTranslate"), method_qsTranslate); - globalObject->defineDefaultProperty(QStringLiteral("QT_TRANSLATE_NOOP"), method_qsTranslateNoOp); - globalObject->defineDefaultProperty(QStringLiteral("qsTr"), method_qsTr); - globalObject->defineDefaultProperty(QStringLiteral("QT_TR_NOOP"), method_qsTrNoOp); - globalObject->defineDefaultProperty(QStringLiteral("qsTrId"), method_qsTrId); - globalObject->defineDefaultProperty(QStringLiteral("QT_TRID_NOOP"), method_qsTrIdNoOp); -#endif + if (extensions.testFlag(QJSEngine::TranslationExtension)) { + #ifndef QT_NO_TRANSLATION + globalObject->defineDefaultProperty(QStringLiteral("qsTranslate"), QV4::GlobalExtensions::method_qsTranslate); + globalObject->defineDefaultProperty(QStringLiteral("QT_TRANSLATE_NOOP"), QV4::GlobalExtensions::method_qsTranslateNoOp); + globalObject->defineDefaultProperty(QStringLiteral("qsTr"), QV4::GlobalExtensions::method_qsTr); + globalObject->defineDefaultProperty(QStringLiteral("QT_TR_NOOP"), QV4::GlobalExtensions::method_qsTrNoOp); + globalObject->defineDefaultProperty(QStringLiteral("qsTrId"), QV4::GlobalExtensions::method_qsTrId); + globalObject->defineDefaultProperty(QStringLiteral("QT_TRID_NOOP"), QV4::GlobalExtensions::method_qsTrIdNoOp); + + // string prototype extension + scope.engine->stringPrototype()->defineDefaultProperty(QStringLiteral("arg"), QV4::GlobalExtensions::method_string_arg); + #endif + } - globalObject->defineDefaultProperty(QStringLiteral("print"), ConsoleObject::method_log); - globalObject->defineDefaultProperty(QStringLiteral("gc"), method_gc); + if (extensions.testFlag(QJSEngine::ConsoleExtension)) { + globalObject->defineDefaultProperty(QStringLiteral("print"), QV4::ConsoleObject::method_log); - ScopedObject console(scope, v4->memoryManager->allocObject<QV4::ConsoleObject>()); - globalObject->defineDefaultProperty(QStringLiteral("console"), console); - ScopedObject qt(scope, v4->memoryManager->allocObject<QV4::QtObject>(qmlEngine)); - globalObject->defineDefaultProperty(QStringLiteral("Qt"), qt); + QV4::ScopedObject console(scope, globalObject->engine()->memoryManager->allocObject<QV4::ConsoleObject>()); + globalObject->defineDefaultProperty(QStringLiteral("console"), console); + } - // string prototype extension - v4->stringPrototype()->defineDefaultProperty(QStringLiteral("arg"), method_string_arg); + if (extensions.testFlag(QJSEngine::GarbageCollectionExtension)) { + globalObject->defineDefaultProperty(QStringLiteral("gc"), QV4::GlobalExtensions::method_gc); + } } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index bb05376fc0..d373fb6ee6 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -47,6 +47,7 @@ #include <private/qqmlglobal_p.h> #include <private/qv4functionobject_p.h> +#include <private/qjsengine_p.h> QT_BEGIN_NAMESPACE @@ -142,7 +143,7 @@ struct ConsoleObject : Object }; struct GlobalExtensions { - static void init(QQmlEngine *qmlEngine, Object *globalObject); + static void init(Object *globalObject, QJSEngine::Extensions extensions); #ifndef QT_NO_TRANSLATION static ReturnedValue method_qsTranslate(CallContext *ctx); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index effc37a0eb..dae932e705 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -174,7 +174,10 @@ const QSet<QString> &QV8Engine::illegalNames() const void QV8Engine::initializeGlobal() { QV4::Scope scope(m_v4Engine); - QV4::GlobalExtensions::init(m_engine, m_v4Engine->globalObject); + QV4::GlobalExtensions::init(m_v4Engine->globalObject, QJSEngine::AllExtensions); + + QV4::ScopedObject qt(scope, m_v4Engine->memoryManager->allocObject<QV4::QtObject>(m_engine)); + m_v4Engine->globalObject->defineDefaultProperty(QStringLiteral("Qt"), qt); QQmlLocale::registerStringLocaleCompare(m_v4Engine); QQmlDateExtension::registerExtension(m_v4Engine); diff --git a/src/qml/types/qqmlbind_p.h b/src/qml/types/qqmlbind_p.h index 6d7eea4014..ac1cb0f32f 100644 --- a/src/qml/types/qqmlbind_p.h +++ b/src/qml/types/qqmlbind_p.h @@ -34,6 +34,17 @@ #ifndef QQMLBIND_H #define QQMLBIND_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> #include <QtCore/qobject.h> diff --git a/src/qml/types/qqmlconnections_p.h b/src/qml/types/qqmlconnections_p.h index e9eb593c6b..d330b772cc 100644 --- a/src/qml/types/qqmlconnections_p.h +++ b/src/qml/types/qqmlconnections_p.h @@ -34,6 +34,17 @@ #ifndef QQMLCONNECTIONS_H #define QQMLCONNECTIONS_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> #include <private/qqmlcustomparser_p.h> diff --git a/src/qml/types/qqmldelegatemodel_p.h b/src/qml/types/qqmldelegatemodel_p.h index e222fadec2..6af052c1b4 100644 --- a/src/qml/types/qqmldelegatemodel_p.h +++ b/src/qml/types/qqmldelegatemodel_p.h @@ -34,6 +34,17 @@ #ifndef QQMLDATAMODEL_P_H #define QQMLDATAMODEL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> #include <private/qqmllistcompositor_p.h> #include <private/qqmlobjectmodel_p.h> diff --git a/src/qml/types/qqmlinstantiator_p.h b/src/qml/types/qqmlinstantiator_p.h index aa098817cd..842a0b947b 100644 --- a/src/qml/types/qqmlinstantiator_p.h +++ b/src/qml/types/qqmlinstantiator_p.h @@ -34,6 +34,17 @@ #ifndef QQMLINSTANTIATOR_P_H #define QQMLINSTANTIATOR_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtQml/qqmlcomponent.h> #include <QtQml/qqmlparserstatus.h> diff --git a/src/qml/types/qqmlitemselectionmodel.qdoc b/src/qml/types/qqmlitemselectionmodel.qdoc index 441d219de8..b4da0c63f3 100644 --- a/src/qml/types/qqmlitemselectionmodel.qdoc +++ b/src/qml/types/qqmlitemselectionmodel.qdoc @@ -38,7 +38,7 @@ This page only enumerates the properties, methods, and signals available in QML. See \l QItemSelectionModel for the actual documentation of this class. - \sa ItemModels + \sa QItemSelectionModel, {Models and Views in Qt Quick} */ diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h index 21de392234..b3ae806c5e 100644 --- a/src/qml/types/qqmllistmodel_p.h +++ b/src/qml/types/qqmllistmodel_p.h @@ -34,6 +34,17 @@ #ifndef QQMLLISTMODEL_H #define QQMLLISTMODEL_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> #include <private/qqmlcustomparser_p.h> diff --git a/src/qml/types/qqmlmodelsmodule_p.h b/src/qml/types/qqmlmodelsmodule_p.h index 7fd02b600a..3471a16684 100644 --- a/src/qml/types/qqmlmodelsmodule_p.h +++ b/src/qml/types/qqmlmodelsmodule_p.h @@ -34,6 +34,17 @@ #ifndef QQMLMODELSMODULE_H #define QQMLMODELSMODULE_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/types/qqmlobjectmodel_p.h b/src/qml/types/qqmlobjectmodel_p.h index f6ab2a19e2..868f736147 100644 --- a/src/qml/types/qqmlobjectmodel_p.h +++ b/src/qml/types/qqmlobjectmodel_p.h @@ -34,6 +34,17 @@ #ifndef QQMLINSTANCEMODEL_P_H #define QQMLINSTANCEMODEL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <private/qtqmlglobal_p.h> #include <QtQml/qqml.h> #include <QtCore/qobject.h> diff --git a/src/qml/types/qqmltimer_p.h b/src/qml/types/qqmltimer_p.h index 0da81b481f..2dcf827926 100644 --- a/src/qml/types/qqmltimer_p.h +++ b/src/qml/types/qqmltimer_p.h @@ -34,6 +34,17 @@ #ifndef QQMLTIMER_H #define QQMLTIMER_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> #include <QtCore/qobject.h> diff --git a/src/qml/types/qquickpackage_p.h b/src/qml/types/qquickpackage_p.h index 6398e6a4fa..1c7f255eb4 100644 --- a/src/qml/types/qquickpackage_p.h +++ b/src/qml/types/qquickpackage_p.h @@ -34,6 +34,17 @@ #ifndef QQUICKPACKAGE_H #define QQUICKPACKAGE_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <qqml.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index 29398ff98c..c61144dd8f 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -788,8 +788,11 @@ public: m_type->release(); } - int metaCall(QMetaObject::Call call, int id, void **arguments) + int metaCall(QObject *o, QMetaObject::Call call, int id, void **arguments) { + Q_ASSERT(o == m_data); + Q_UNUSED(o); + static const int objectPropertyOffset = QObject::staticMetaObject.propertyCount(); if (id >= m_type->propertyOffset && (call == QMetaObject::ReadProperty diff --git a/src/qml/util/qqmladaptormodel_p.h b/src/qml/util/qqmladaptormodel_p.h index b0f211a0f2..9da04462aa 100644 --- a/src/qml/util/qqmladaptormodel_p.h +++ b/src/qml/util/qqmladaptormodel_p.h @@ -34,6 +34,17 @@ #ifndef QQMLADAPTORMODEL_P_H #define QQMLADAPTORMODEL_P_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/qabstractitemmodel.h> #include "private/qqmllistaccessor_p.h" diff --git a/src/qml/util/qqmllistaccessor_p.h b/src/qml/util/qqmllistaccessor_p.h index cf0ec52be4..1d9069118a 100644 --- a/src/qml/util/qqmllistaccessor_p.h +++ b/src/qml/util/qqmllistaccessor_p.h @@ -34,6 +34,17 @@ #ifndef QQMLLISTACCESSOR_H #define QQMLLISTACCESSOR_H +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + #include <QtCore/QVariant> QT_BEGIN_NAMESPACE |