From 486948817b26da2c62802bb93a0f671715c609d4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 28 Jul 2014 10:07:57 +0200 Subject: Move the throw methods from ExecutionContext to ExecutionEngine The methods don't require a context, and thus shouldn't be implemented there. Change-Id: If058e0c5067093a4161f2275ac4288aa2bc500f3 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcomponent.cpp | 10 +++++----- src/qml/qml/qqmlcontextwrapper.cpp | 4 ++-- src/qml/qml/qqmllocale_p.h | 2 +- src/qml/qml/qqmltypewrapper.cpp | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 6 +++--- src/qml/qml/qqmlxmlhttprequest.cpp | 32 ++++++++++++++++---------------- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 22 +++++++++++----------- src/qml/qml/v8/qv4domerrors_p.h | 2 +- src/qml/qml/v8/qv8engine_p.h | 4 ++-- 9 files changed, 42 insertions(+), 42 deletions(-) (limited to 'src/qml/qml') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 63a43966b1..bcb49b30ab 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1416,7 +1416,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx) QV4::Scope scope(ctx); QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); return QV4::QObjectWrapper::wrap(ctx->d()->engine, o->d()->incubator->object()); } @@ -1426,7 +1426,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext * QV4::Scope scope(ctx); QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); o->d()->incubator->forceCompletion(); @@ -1438,7 +1438,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) QV4::Scope scope(ctx); QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); return QV4::Encode(o->d()->incubator->status()); } @@ -1448,7 +1448,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext QV4::Scope scope(ctx); QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); return o->d()->statusChanged.asReturnedValue(); } @@ -1458,7 +1458,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::CallContext QV4::Scope scope(ctx); QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o || ctx->d()->callData->argc < 1) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); o->d()->statusChanged = ctx->d()->callData->args[0]; diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 0816bc05df..f18f6fa5ea 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -291,7 +291,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value) QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); Scoped e(scope, v4->currentContext()->d()->engine->newString(error)); - v4->currentContext()->throwError(e); + v4->throwError(e); return; } @@ -335,7 +335,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value) if (wrapper->d()->readOnly) { QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); - v4->currentContext()->throwError(error); + v4->throwError(error); return; } diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index a29b86fbea..a3fc8e4ed4 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -137,7 +137,7 @@ struct QQmlLocaleData : public QV4::Object QV4::Object *o = ctx->d()->callData->thisObject.asObject(); QQmlLocaleData *thisObject = o ? o->as() : 0; if (!thisObject) { - ctx->throwTypeError(); + ctx->engine()->throwTypeError(); return 0; } return &thisObject->d()->locale; diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index d8f282c030..ddd934c840 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -262,7 +262,7 @@ void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value) QV4::ScopedObject apiprivate(scope, QJSValuePrivate::get(siinfo->scriptApi(e))->value); if (!apiprivate) { QString error = QLatin1String("Cannot assign to read-only property \"") + name->toQString() + QLatin1Char('\"'); - v4->currentContext()->throwError(error); + v4->throwError(error); return; } else { apiprivate->put(name, value); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 8123a297fe..7de15eac7d 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -242,10 +242,10 @@ ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx) { Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QmlValueTypeWrapper *w = o->as(); if (!w) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); if (w->d()->objectType == QmlValueTypeWrapper::Reference) { QmlValueTypeReference *reference = static_cast(w); @@ -355,7 +355,7 @@ void QmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value) // assigning a JS function to a non-var-property is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to value-type property"); Scoped e(scope, r->d()->v8->toString(error)); - v4->currentContext()->throwError(e); + v4->throwError(e); return; } diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 9e0a1872be..e5c9ee7549 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -66,7 +66,7 @@ using namespace QV4; #define V4THROW_REFERENCE(string) { \ Scoped error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \ - return ctx->throwError(error); \ + return ctx->engine()->throwError(error); \ } QT_BEGIN_NAMESPACE @@ -421,7 +421,7 @@ ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QString name; switch (r->d()->d->type) { @@ -446,7 +446,7 @@ ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); if (r->d()->d->type == NodeImpl::Document || r->d()->d->type == NodeImpl::DocumentFragment || @@ -465,7 +465,7 @@ ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); return Encode(r->d()->d->type); } @@ -475,7 +475,7 @@ ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -490,7 +490,7 @@ ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -502,7 +502,7 @@ ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -517,7 +517,7 @@ ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -532,7 +532,7 @@ ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -556,7 +556,7 @@ ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -580,7 +580,7 @@ ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx) Scope scope(ctx); Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QV8Engine *engine = ctx->d()->engine->v8Engine; @@ -900,7 +900,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty if (!r) { if (hasProperty) *hasProperty = false; - return v4->currentContext()->throwTypeError(); + return v4->throwTypeError(); } QV8Engine *engine = v4->v8Engine; @@ -1534,14 +1534,14 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me) QV4::Scope scope(v4); Scoped o(scope, me); if (!o) { - ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject")); + ctx->engine()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject")); return; } ScopedString s(scope, v4->newString(QStringLiteral("ThisObject"))); Scoped thisObj(scope, o->get(s.getPointer())); if (!thisObj) { - ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject")); + ctx->engine()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject")); return; } @@ -1555,7 +1555,7 @@ void QQmlXMLHttpRequest::dispatchCallbackImpl(const ValueRef me) s = v4->newString(QStringLiteral("ActivationObject")); Scoped activationObject(scope, o->get(s.getPointer())); if (!activationObject) { - v4->currentContext()->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject")); + v4->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject")); return; } @@ -1650,7 +1650,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject Scope scope(that->engine()); Scoped ctor(scope, that->as()); if (!ctor) - return that->engine()->currentContext()->throwTypeError(); + return that->engine()->throwTypeError(); QV8Engine *engine = that->engine()->v8Engine; QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager()); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index f222d59494..b2cf29b67d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1004,7 +1004,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) if (component.isError()) { ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors())); - return ctx->throwError(v); + return ctx->engine()->throwError(v); } if (!component.isReady()) @@ -1028,7 +1028,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) if (component.isError()) { ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors())); - return ctx->throwError(v); + return ctx->engine()->throwError(v); } Q_ASSERT(obj); @@ -1070,7 +1070,7 @@ use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}. ReturnedValue QtObject::method_createComponent(CallContext *ctx) { if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3) - return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); + return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); Scope scope(ctx); @@ -1098,13 +1098,13 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) if (ctx->d()->callData->args[1].isInteger()) { int mode = ctx->d()->callData->args[1].integerValue(); if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous)) - return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); + return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); compileMode = QQmlComponent::CompilationMode(mode); consumedCount += 1; } else { // The second argument could be the parent only if there are exactly two args if ((ctx->d()->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull())) - return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); + return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); } if (consumedCount < ctx->d()->callData->argc) { @@ -1113,11 +1113,11 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) if (qobjectWrapper) parentArg = qobjectWrapper->object(); if (!parentArg) - return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object")); + return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object")); } else if (lastArg->isNull()) { parentArg = 0; } else { - return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object")); + return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid parent object")); } } } @@ -1257,10 +1257,10 @@ ReturnedValue QtObject::method_get_platform(CallContext *ctx) // ### inefficient. Should be just a value based getter Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QtObject *qt = o->as(); if (!qt) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); if (!qt->d()->platform) // Only allocate a platform object once @@ -1274,10 +1274,10 @@ ReturnedValue QtObject::method_get_application(CallContext *ctx) // ### inefficient. Should be just a value based getter Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); QtObject *qt = o->as(); if (!qt) - return ctx->throwTypeError(); + return ctx->engine()->throwTypeError(); if (!qt->d()->application) // Only allocate an application object once diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h index 59ed744f5e..facf7972ad 100644 --- a/src/qml/qml/v8/qv4domerrors_p.h +++ b/src/qml/qml/v8/qv4domerrors_p.h @@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \ QV4::Scoped ex(scope, scope.engine->newErrorObject(v)); \ ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))).getPointer(), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \ - return ctx->throwError(ex); \ + return ctx->engine()->throwError(ex); \ } namespace QV4 { diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index 51e857c8a2..2379689fb3 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -78,10 +78,10 @@ namespace QV4 { // #define QML_GLOBAL_HANDLE_DEBUGGING #define V4THROW_ERROR(string) \ - return ctx->throwError(QString::fromUtf8(string)); + return ctx->engine()->throwError(QString::fromUtf8(string)); #define V4THROW_TYPE(string) \ - return ctx->throwTypeError(QStringLiteral(string)); + return ctx->engine()->throwTypeError(QStringLiteral(string)); #define V8_DEFINE_EXTENSION(dataclass, datafunction) \ static inline dataclass *datafunction(QV8Engine *engine) \ -- cgit v1.2.3