diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-06-22 16:33:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-08-12 07:29:44 +0000 |
commit | 1a1f10806c901bc10483370a932d41af0c9629cd (patch) | |
tree | 65b5c359e03098fd72aa1b04fe7ca12caf2ec4b8 /src/qml/jsruntime | |
parent | 92624025eab667e096eb13993fa7ca7c5534e0ff (diff) |
Access the id objects through a specialized runtime method
This brings us one step closer to getting rid of the
QQmlContextWrapper.
Change-Id: Ied57f4c174c2ebd95096310a4ad4c0c28787e7a4
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 23 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 8 |
3 files changed, 23 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index e9311cf7f3..089922d03e 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -47,6 +47,8 @@ #include "qv4scopedvalue_p.h" #include <private/qqmlcontextwrapper_p.h> #include <private/qqmltypewrapper_p.h> +#include <private/qqmlengine_p.h> +#include <private/qqmljavascriptexpression_p.h> #include "qv4qobjectwrapper_p.h" #include <private/qv8engine_p.h> #endif @@ -1361,12 +1363,6 @@ ReturnedValue Runtime::regexpLiteral(ExecutionEngine *engine, int id) return engine->currentContext()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); } -ReturnedValue Runtime::getQmlIdArray(NoThrowEngine *engine) -{ - Q_ASSERT(engine->qmlContextObject()); - return engine->qmlContextObject()->asReturnedValue(); -} - ReturnedValue Runtime::getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired) { Scope scope(engine); @@ -1411,6 +1407,21 @@ ReturnedValue Runtime::getQmlSingletonQObjectProperty(ExecutionEngine *engine, c return QV4::QObjectWrapper::getProperty(scope.engine, wrapper->singletonObject(), propertyIndex, captureRequired); } +ReturnedValue Runtime::getQmlIdObject(ExecutionEngine *engine, const Value &c, uint index) +{ + Scope scope(engine); + const QmlContext &qmlContext = static_cast<const QmlContext &>(c); + QQmlContextData *context = qmlContext.d()->qml->context; + if (!context || index >= (uint)context->idValueCount) + return Encode::undefined(); + + QQmlEnginePrivate *ep = engine->qmlEngine() ? QQmlEnginePrivate::get(engine->qmlEngine()) : 0; + if (ep && ep->propertyCapture) + ep->propertyCapture->captureProperty(&context->idValues[index].bindings); + + return QObjectWrapper::wrap(engine, context->idValues[index].data()); +} + void Runtime::setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value) { const QmlContext &c = static_cast<const QmlContext &>(context); diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h index cdf7f018ff..f597e4b2e3 100644 --- a/src/qml/jsruntime/qv4runtime_p.h +++ b/src/qml/jsruntime/qv4runtime_p.h @@ -210,7 +210,6 @@ struct Q_QML_PRIVATE_EXPORT Runtime { // qml static ReturnedValue getQmlContext(NoThrowEngine *engine); - static ReturnedValue getQmlIdArray(NoThrowEngine *engine); static ReturnedValue getQmlImportedScripts(NoThrowEngine *engine); static ReturnedValue getQmlSingleton(NoThrowEngine *engine, int nameIndex); static ReturnedValue getQmlAttachedProperty(ExecutionEngine *engine, int attachedPropertiesId, int propertyIndex); @@ -218,6 +217,8 @@ struct Q_QML_PRIVATE_EXPORT Runtime { static ReturnedValue getQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex); static ReturnedValue getQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); static ReturnedValue getQmlSingletonQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, bool captureRequired); + static ReturnedValue getQmlIdObject(ExecutionEngine *engine, const Value &context, uint index); + static void setQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value); static void setQmlContextObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, const Value &value); static void setQmlQObjectProperty(ExecutionEngine *engine, const Value &object, int propertyIndex, const Value &value); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 7caebe33b6..d0ae44ccea 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -531,6 +531,10 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code STOREVALUE(instr.result, Runtime::getQmlContextObjectProperty(engine, VALUE(instr.base), instr.propertyIndex)); MOTH_END_INSTR(LoadContextObjectProperty) + MOTH_BEGIN_INSTR(LoadIdObject) + STOREVALUE(instr.result, Runtime::getQmlIdObject(engine, VALUE(instr.base), instr.index)); + MOTH_END_INSTR(LoadIdObject) + MOTH_BEGIN_INSTR(LoadAttachedQObjectProperty) STOREVALUE(instr.result, Runtime::getQmlAttachedProperty(engine, instr.attachedPropertiesId, instr.propertyIndex)); MOTH_END_INSTR(LoadAttachedQObjectProperty) @@ -907,10 +911,6 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code VALUE(instr.result) = Runtime::getQmlContext(static_cast<QV4::NoThrowEngine*>(engine)); MOTH_END_INSTR(LoadQmlContext) - MOTH_BEGIN_INSTR(LoadQmlIdArray) - VALUE(instr.result) = Runtime::getQmlIdArray(static_cast<QV4::NoThrowEngine*>(engine)); - MOTH_END_INSTR(LoadQmlIdArray) - MOTH_BEGIN_INSTR(LoadQmlImportedScripts) VALUE(instr.result) = Runtime::getQmlImportedScripts(static_cast<QV4::NoThrowEngine*>(engine)); MOTH_END_INSTR(LoadQmlImportedScripts) |