diff options
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlcompiler.cpp | 16 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontextwrapper.cpp | 26 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontextwrapper_p.h | 7 | ||||
-rw-r--r-- | src/qml/qml/qqmlscript.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/qqmlscript_p.h | 2 |
5 files changed, 55 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index 57114ebead..0462c0b61a 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -3654,7 +3654,21 @@ bool QQmlCompiler::completeComponentBuild() const QString &sourceCode = jsEngine->code(); AST::UiProgram *qmlRoot = parser.qmlRoot(); - const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, qmlRoot, compileState->functionsToCompile); + JSCodeGen::ObjectIdMapping idMapping; + if (compileState->ids.count() > 0) { + idMapping.reserve(compileState->ids.count()); + for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o)) { + JSCodeGen::IdMapping m; + m.name = o->id; + m.idIndex = o->idIndex; + idMapping << m; + } + } + + const QVector<int> runtimeFunctionIndices = jsCodeGen.generateJSCodeForFunctionsAndBindings(unit->finalUrlString(), sourceCode, jsModule.data(), jsEngine, + qmlRoot, compileState->root->astNode, + compileState->functionsToCompile, + idMapping); compileState->runtimeFunctionIndices = runtimeFunctionIndices; for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) { diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index d3bcf6d3fd..5e798e20ee 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -47,9 +47,10 @@ #include <private/qv4engine_p.h> #include <private/qv4value_p.h> -#include <private/qv4functionobject_p.h> #include <private/qv4objectproto_p.h> #include <private/qv4mm_p.h> +#include <private/qv4function_p.h> +#include <private/qv4compileddata_p.h> #include <private/qqmltypewrapper_p.h> #include <private/qqmllistwrapper_p.h> @@ -357,4 +358,27 @@ void QmlContextWrapper::destroy(Managed *that) static_cast<QmlContextWrapper *>(that)->~QmlContextWrapper(); } +void QmlContextWrapper::registerQmlDependencies(ExecutionEngine *engine, const CompiledData::Function *compiledFunction) +{ + // Let the caller check and avoid the function call :) + Q_ASSERT(compiledFunction->hasQmlDependencies()); + + QQmlEnginePrivate *ep = engine->v8Engine->engine() ? QQmlEnginePrivate::get(engine->v8Engine->engine()) : 0; + if (!ep) + return; + QQmlEnginePrivate::PropertyCapture *capture = ep->propertyCapture; + if (!capture) + return; + + QV4::Scope scope(engine); + QV4::Scoped<QmlContextWrapper> contextWrapper(scope, engine->qmlContextObject()->getPointer()->as<QmlContextWrapper>()); + QQmlContextData *qmlContext = contextWrapper->getContext(); + + const quint32 *dependency = compiledFunction->qmlIdObjectDependencyTable(); + const int dependencyCount = compiledFunction->nDependingIdObjects; + for (int i = 0; i < dependencyCount; ++i, ++dependency) + capture->captureProperty(&qmlContext->idValues[*dependency].bindings); + +} + QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h index 86ad4e5616..d85f440b15 100644 --- a/src/qml/qml/qqmlcontextwrapper_p.h +++ b/src/qml/qml/qqmlcontextwrapper_p.h @@ -59,11 +59,16 @@ #include <private/qv4value_p.h> #include <private/qv4object_p.h> #include <private/qqmlcontext_p.h> +#include <private/qv4functionobject_p.h> QT_BEGIN_NAMESPACE namespace QV4 { +namespace CompiledData { +struct Function; +} + struct Q_QML_EXPORT QmlContextWrapper : Object { Q_MANAGED @@ -86,6 +91,8 @@ struct Q_QML_EXPORT QmlContextWrapper : Object static void put(Managed *m, const StringRef name, const ValueRef value); static void destroy(Managed *that); + static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction); + QV8Engine *v8; // ### temporary, remove bool readOnly; diff --git a/src/qml/qml/qqmlscript.cpp b/src/qml/qml/qqmlscript.cpp index 9fd06aa934..6cb23ec07c 100644 --- a/src/qml/qml/qqmlscript.cpp +++ b/src/qml/qml/qqmlscript.cpp @@ -500,7 +500,7 @@ public: protected: - QQmlScript::Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment, + QQmlScript::Object *defineObjectBinding(AST::Node *node, AST::UiQualifiedId *propertyName, bool onAssignment, const QString &objectType, AST::SourceLocation typeLocation, LocationSpan location, @@ -659,7 +659,8 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const } QQmlScript::Object * -ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName, +ProcessAST::defineObjectBinding(AST::Node *node, + AST::UiQualifiedId *propertyName, bool onAssignment, const QString &objectType, AST::SourceLocation typeLocation, @@ -731,6 +732,7 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName, obj->type = _parser->findOrCreateTypeId(objectType, obj); obj->typeReference = _parser->_refTypes.at(obj->type); obj->location = location; + obj->astNode = node; if (propertyCount) { Property *prop = currentProperty(); @@ -1130,7 +1132,7 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node) const QString objectType = asString(node->qualifiedTypeNameId); const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken; - defineObjectBinding(/*propertyName = */ 0, false, objectType, + defineObjectBinding(node, /*propertyName = */ 0, false, objectType, typeLocation, l, node->initializer); return false; @@ -1146,7 +1148,7 @@ bool ProcessAST::visit(AST::UiObjectBinding *node) const QString objectType = asString(node->qualifiedTypeNameId); const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken; - defineObjectBinding(node->qualifiedId, node->hasOnToken, objectType, + defineObjectBinding(node, node->qualifiedId, node->hasOnToken, objectType, typeLocation, l, node->initializer); return false; diff --git a/src/qml/qml/qqmlscript_p.h b/src/qml/qml/qqmlscript_p.h index 86bbc1fb3a..b36fdc8861 100644 --- a/src/qml/qml/qqmlscript_p.h +++ b/src/qml/qml/qqmlscript_p.h @@ -335,6 +335,8 @@ public: QQmlPropertyCache *metatype; + QQmlJS::AST::Node *astNode; // responsible for the creation of this object + // The synthesized metaobject, if QML added signals or properties to // this type. Otherwise null QByteArray synthdata; // Generated by compiler |