aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4script.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2015-08-20 22:02:11 +0200
committerLars Knoll <lars.knoll@theqtcompany.com>2015-09-09 14:28:31 +0000
commit1079dbbdd96c517eed3269e4a5e18f18a6808be0 (patch)
tree6e0aa988e2996196701c5728323b86ea49f5074d /src/qml/jsruntime/qv4script.cpp
parent08a7ae47c24c1378cb39d0c796fcc37cc0c62b32 (diff)
Pass a QmlContext to QV4::Script instead of a contextwrapper
Change-Id: Ia8db166aacbbe6e8f588179dffa04e2dce9566cb Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4script.cpp')
-rw-r--r--src/qml/jsruntime/qv4script.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 41cb6309f8..32a15fdf5e 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -130,10 +130,13 @@ ReturnedValue QmlBindingWrapper::call(const Managed *that, CallData *callData)
return result->asReturnedValue();
}
-Script::Script(ExecutionEngine *v4, Object *qml, CompiledData::CompilationUnit *compilationUnit)
+Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit)
: line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)
- , qml(v4, qml), vmFunction(0), parseAsBinding(true)
+ , vmFunction(0), parseAsBinding(true)
{
+ if (qml)
+ qmlContext.set(v4, *qml);
+
parsed = true;
vmFunction = compilationUnit ? compilationUnit->linkToEngine(v4) : 0;
@@ -231,7 +234,7 @@ ReturnedValue Script::run()
QV4::ExecutionEngine *engine = scope->engine();
QV4::Scope valueScope(engine);
- if (qml.isUndefined()) {
+ if (qmlContext.isUndefined()) {
TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);
ExecutionContextSaver ctxSaver(valueScope, scope);
@@ -242,9 +245,8 @@ ReturnedValue Script::run()
return Q_V4_PROFILE(engine, vmFunction);
} else {
- Scoped<QmlContextWrapper> qmlObj(valueScope, qml.value());
- Scoped<QmlContext> qmlContext(valueScope, scope->newQmlContext(qmlObj));
- ScopedFunctionObject f(valueScope, engine->memoryManager->alloc<QmlBindingWrapper>(qmlContext, vmFunction));
+ Scoped<QmlContext> qml(valueScope, qmlContext.value());
+ ScopedFunctionObject f(valueScope, engine->memoryManager->alloc<QmlBindingWrapper>(qml, vmFunction));
ScopedCallData callData(valueScope);
callData->thisObject = Primitive::undefinedValue();
return f->call(callData);
@@ -321,16 +323,15 @@ ReturnedValue Script::qmlBinding()
parse();
ExecutionEngine *v4 = scope->engine();
Scope valueScope(v4);
- Scoped<QmlContextWrapper> qmlObj(valueScope, qml.value());
- Scoped<QmlContext> qmlContext(valueScope, scope->newQmlContext(qmlObj));
- ScopedObject v(valueScope, v4->memoryManager->alloc<QmlBindingWrapper>(qmlContext, vmFunction));
+ Scoped<QmlContext> qml(valueScope, qmlContext.value());
+ ScopedObject v(valueScope, v4->memoryManager->alloc<QmlBindingWrapper>(qml, vmFunction));
return v.asReturnedValue();
}
-QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &script, Object *scopeObject)
+QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext)
{
QV4::Scope scope(engine);
- QV4::Script qmlScript(engine, scopeObject, script, QString());
+ QV4::Script qmlScript(engine, qmlContext, script, QString());
qmlScript.parse();
QV4::ScopedValue result(scope);