diff options
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/qqmlboundsignal.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmldelayedcallqueue.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlexpression.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmlexpression_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 19 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 17 |
10 files changed, 41 insertions, 32 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 62288a5845..911df78595 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -202,12 +202,11 @@ protected: bool isUndefined = false; - QV4::ScopedCallData callData(scope); - QQmlJavaScriptExpression::evaluate(callData, &isUndefined, scope); + QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(&isUndefined)); bool error = false; if (!watcher.wasDeleted() && isAddedToObject() && !hasError()) - error = !write(scope.result, isUndefined, flags); + error = !write(result, isUndefined, flags); if (!watcher.wasDeleted()) { @@ -412,12 +411,11 @@ QVariant QQmlBinding::evaluate() bool isUndefined = false; QV4::Scope scope(ep->v4engine()); - QV4::ScopedCallData callData(scope); - QQmlJavaScriptExpression::evaluate(callData, &isUndefined, scope); + QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(&isUndefined)); ep->dereferenceScarceResources(); - return scope.engine->toVariant(scope.result, qMetaTypeId<QList<QObject*> >()); + return scope.engine->toVariant(result, qMetaTypeId<QList<QObject*> >()); } QString QQmlBinding::expressionIdentifier() const diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 19ece44beb..2c0f0091ea 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -220,7 +220,7 @@ void QQmlBoundSignalExpression::evaluate(void **a) } } - QQmlJavaScriptExpression::evaluate(callData, 0, scope); + QQmlJavaScriptExpression::evaluate(callData, 0); ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. } @@ -242,7 +242,7 @@ void QQmlBoundSignalExpression::evaluate(const QList<QVariant> &args) callData->args[ii] = scope.engine->fromVariant(args[ii]); } - QQmlJavaScriptExpression::evaluate(callData, 0, scope); + QQmlJavaScriptExpression::evaluate(callData, 0); ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. } diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e7a45482e6..b22fa31d13 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1545,7 +1545,7 @@ void QV4::QmlIncubatorObject::statusChanged(QQmlIncubator::Status s) QV4::ScopedCallData callData(scope, 1); callData->thisObject = this; callData->args[0] = QV4::Primitive::fromUInt32(s); - f->call(scope, callData); + f->call(callData); if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error); diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index 0c82eadc97..5f274b8da5 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -73,7 +73,7 @@ void QQmlDelayedCallQueue::DelayedFunctionCall::execute(QV4::ExecutionEngine *en const QV4::FunctionObject *callback = m_function.as<QV4::FunctionObject>(); Q_ASSERT(callback); - callback->call(scope, callData); + callback->call(callData); if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); diff --git a/src/qml/qml/qqmlexpression.cpp b/src/qml/qml/qqmlexpression.cpp index b70db5ed86..c4b705230a 100644 --- a/src/qml/qml/qqmlexpression.cpp +++ b/src/qml/qml/qqmlexpression.cpp @@ -248,15 +248,14 @@ void QQmlExpression::setExpression(const QString &expression) } // Must be called with a valid handle scope -void QQmlExpressionPrivate::v4value(bool *isUndefined, QV4::Scope &scope) +QV4::ReturnedValue QQmlExpressionPrivate::v4value(bool *isUndefined) { if (!expressionFunctionValid) { createQmlBinding(context(), scopeObject(), expression, url, line); expressionFunctionValid = true; } - QV4::ScopedCallData callData(scope); - evaluate(callData, isUndefined, scope); + return evaluate(isUndefined); } QVariant QQmlExpressionPrivate::value(bool *isUndefined) @@ -275,9 +274,9 @@ QVariant QQmlExpressionPrivate::value(bool *isUndefined) { QV4::Scope scope(QV8Engine::getV4(ep->v8engine())); - v4value(isUndefined, scope); + QV4::ScopedValue result(scope, v4value(isUndefined)); if (!hasError()) - rv = scope.engine->toVariant(scope.result, -1); + rv = scope.engine->toVariant(result, -1); } ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h index 44342a957b..a94ca0fc2d 100644 --- a/src/qml/qml/qqmlexpression_p.h +++ b/src/qml/qml/qqmlexpression_p.h @@ -75,7 +75,7 @@ public: QVariant value(bool *isUndefined = 0); - void v4value(bool *isUndefined, QV4::Scope &scope); + QV4::ReturnedValue v4value(bool *isUndefined = 0); static inline QQmlExpressionPrivate *get(QQmlExpression *expr); static inline QQmlExpression *get(QQmlExpressionPrivate *expr); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 17cccc0bbd..6c5c00e8ae 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -179,9 +179,16 @@ void QQmlJavaScriptExpression::refresh() { } +QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(bool *isUndefined) +{ + QV4::ExecutionEngine *v4 = QV8Engine::getV4(m_context->engine); + QV4::Scope scope(v4); + QV4::ScopedCallData callData(scope); + return evaluate(callData, isUndefined); +} -void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefined, QV4::Scope &scope) +QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefined) { Q_ASSERT(m_context && m_context->engine); @@ -189,7 +196,7 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin if (!v4Function) { if (isUndefined) *isUndefined = true; - return; + return QV4::Encode::undefined(); } QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_context->engine); @@ -209,7 +216,8 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin capture.guards.copyAndClearPrepend(activeGuards); QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); - scope.result = QV4::Primitive::undefinedValue(); + QV4::Scope scope(v4); + QV4::ScopedValue result(scope, QV4::Primitive::undefinedValue()); callData->thisObject = v4->globalObject; if (scopeObject()) { QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(v4, scopeObject())); @@ -223,6 +231,7 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin } else { outer->call(scope, callData, v4Function); } + result = scope.result; if (scope.hasException()) { if (watcher.wasDeleted()) @@ -233,7 +242,7 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin *isUndefined = true; } else { if (isUndefined) - *isUndefined = scope.result.isUndefined(); + *isUndefined = result->isUndefined(); if (!watcher.wasDeleted() && hasDelayedError()) delayedError()->clearError(); @@ -250,6 +259,8 @@ void QQmlJavaScriptExpression::evaluate(QV4::CallData *callData, bool *isUndefin g->Delete(); ep->propertyCapture = lastPropertyCapture; + + return result->asReturnedValue(); } void QQmlPropertyCapture::captureProperty(QQmlNotifier *n, Duration duration) diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 646cc5ab3d..6941aebe64 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -103,7 +103,8 @@ public: virtual QString expressionIdentifier() const = 0; virtual void expressionChanged() = 0; - void evaluate(QV4::CallData *callData, bool *isUndefined, QV4::Scope &scope); + QV4::ReturnedValue evaluate(bool *isUndefined); + QV4::ReturnedValue evaluate(QV4::CallData *callData, bool *isUndefined); inline bool notifyOnValueChanged() const; diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index a2ab9bdfed..7e6fa2ee67 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -955,14 +955,15 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void * for (uint ii = 0; ii < parameterCount; ++ii) callData->args[ii] = scope.engine->fromVariant(*(QVariant *)a[ii + 1]); - function->call(scope, callData); + QV4::ScopedValue result(scope); + result = function->call(callData); if (scope.hasException()) { QQmlError error = scope.engine->catchExceptionAsQmlError(); if (error.isValid()) ep->warning(error); if (a[0]) *(QVariant *)a[0] = QVariant(); } else { - if (a[0]) *(QVariant *)a[0] = scope.engine->toVariant(scope.result, 0); + if (a[0]) *(QVariant *)a[0] = scope.engine->toVariant(result, 0); } ep->dereferenceScarceResources(); // "release" scarce resources if top-level expression evaluation is complete. diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 9e8735cbc6..59db5bd9ac 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1559,7 +1559,7 @@ void QQmlXMLHttpRequest::dispatchCallback(Object *thisObj, QQmlContextData *cont QV4::ScopedCallData callData(scope); callData->thisObject = Encode::undefined(); - callback->call(scope, callData); + callback->call(callData); if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); @@ -1617,23 +1617,22 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject { V4_OBJECT2(QQmlXMLHttpRequestCtor, FunctionObject) - static void construct(const Managed *that, Scope &scope, QV4::CallData *) + static ReturnedValue construct(const Managed *that, QV4::CallData *) { + Scope scope(that->engine()); Scoped<QQmlXMLHttpRequestCtor> ctor(scope, that->as<QQmlXMLHttpRequestCtor>()); - if (!ctor) { - scope.result = scope.engine->throwTypeError(); - return; - } + if (!ctor) + return scope.engine->throwTypeError(); QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(scope.engine->v8Engine->networkAccessManager()); Scoped<QQmlXMLHttpRequestWrapper> w(scope, scope.engine->memoryManager->allocObject<QQmlXMLHttpRequestWrapper>(r)); ScopedObject proto(scope, ctor->d()->proto); w->setPrototype(proto); - scope.result = w.asReturnedValue(); + return w.asReturnedValue(); } - static void call(const Managed *, Scope &scope, QV4::CallData *) { - scope.result = Primitive::undefinedValue(); + static ReturnedValue call(const Managed *, QV4::CallData *) { + return Encode::undefined(); } void setupProto(); |