From 9744e8bd423d528165f5e78704c6e017852b8e9a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 6 May 2014 09:23:59 +0200 Subject: Convert ExecutionContext to new storage scheme Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlxmlhttprequest.cpp | 152 ++++++++++++++++++------------------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'src/qml/qml/qqmlxmlhttprequest.cpp') diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 2818a178d2..019869fec1 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -72,7 +72,7 @@ using namespace QV4; #ifndef QT_NO_XMLSTREAMREADER #define V4THROW_REFERENCE(string) { \ - Scoped error(scope, ctx->engine->newReferenceErrorObject(QStringLiteral(string))); \ + Scoped error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \ return ctx->throwError(error); \ } @@ -437,7 +437,7 @@ void NodeImpl::release() ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -456,13 +456,13 @@ ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) name = r->d()->d->name; break; } - return Encode(ctx->engine->newString(name)); + return Encode(ctx->d()->engine->newString(name)); } ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -475,13 +475,13 @@ ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) r->d()->d->type == NodeImpl::Notation) return Encode::null(); - return Encode(ctx->engine->newString(r->d()->d->data)); + return Encode(ctx->d()->engine->newString(r->d()->d->data)); } ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -491,11 +491,11 @@ ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->parent) return Node::create(engine, r->d()->d->parent); @@ -506,11 +506,11 @@ ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return NodeList::create(engine, r->d()->d); } @@ -518,11 +518,11 @@ ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->children.isEmpty()) return Encode::null(); @@ -533,11 +533,11 @@ ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->children.isEmpty()) return Encode::null(); @@ -548,11 +548,11 @@ ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (!r->d()->d->parent) return Encode::null(); @@ -572,11 +572,11 @@ ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (!r->d()->d->parent) return Encode::null(); @@ -596,11 +596,11 @@ ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->type != NodeImpl::Element) return Encode::null(); @@ -690,10 +690,10 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine) ReturnedValue Attr::method_name(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(r->d()->d->name); } @@ -701,10 +701,10 @@ ReturnedValue Attr::method_name(CallContext *ctx) ReturnedValue Attr::method_value(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(r->d()->d->data); } @@ -712,10 +712,10 @@ ReturnedValue Attr::method_value(CallContext *ctx) ReturnedValue Attr::method_ownerElement(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return Node::create(engine, r->d()->d->parent); } @@ -723,10 +723,10 @@ ReturnedValue Attr::method_ownerElement(CallContext *ctx) ReturnedValue CharacterData::method_length(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; Q_UNUSED(engine) return Encode(r->d()->d->data.length()); } @@ -750,7 +750,7 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4) ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); return Encode(r->d()->d->data.trimmed().isEmpty()); @@ -759,10 +759,10 @@ ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx) ReturnedValue Text::method_wholeText(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(r->d()->d->data); } @@ -1024,10 +1024,10 @@ ReturnedValue NodeList::create(QV8Engine *engine, NodeImpl *data) ReturnedValue Document::method_documentElement(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return Node::create(engine, static_cast(r->d()->d)->root); } @@ -1035,10 +1035,10 @@ ReturnedValue Document::method_documentElement(CallContext *ctx) ReturnedValue Document::method_xmlStandalone(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; Q_UNUSED(engine) return Encode(static_cast(r->d()->d)->isStandalone); } @@ -1046,10 +1046,10 @@ ReturnedValue Document::method_xmlStandalone(CallContext *ctx) ReturnedValue Document::method_xmlVersion(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(static_cast(r->d()->d)->version); } @@ -1057,10 +1057,10 @@ ReturnedValue Document::method_xmlVersion(CallContext *ctx) ReturnedValue Document::method_xmlEncoding(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(static_cast(r->d()->d)->encoding); } @@ -1760,18 +1760,18 @@ void QQmlXMLHttpRequestCtor::setupProto() ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->callData->argc < 2 || ctx->callData->argc > 5) + if (ctx->d()->callData->argc < 2 || ctx->d()->callData->argc > 5) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; // Argument 0 - Method - QString method = ctx->callData->args[0].toQStringNoThrow().toUpper(); + QString method = ctx->d()->callData->args[0].toQStringNoThrow().toUpper(); if (method != QLatin1String("GET") && method != QLatin1String("PUT") && method != QLatin1String("HEAD") && @@ -1780,21 +1780,21 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type"); // Argument 1 - URL - QUrl url = QUrl(ctx->callData->args[1].toQStringNoThrow()); + QUrl url = QUrl(ctx->d()->callData->args[1].toQStringNoThrow()); if (url.isRelative()) url = engine->callingContext()->resolvedUrl(url); // Argument 2 - async (optional) - if (ctx->callData->argc > 2 && !ctx->callData->args[2].booleanValue()) + if (ctx->d()->callData->argc > 2 && !ctx->d()->callData->args[2].booleanValue()) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported"); // Argument 3/4 - user/pass (optional) QString username, password; - if (ctx->callData->argc > 3) - username = ctx->callData->args[3].toQStringNoThrow(); - if (ctx->callData->argc > 4) - password = ctx->callData->args[4].toQStringNoThrow(); + if (ctx->d()->callData->argc > 3) + username = ctx->d()->callData->args[3].toQStringNoThrow(); + if (ctx->d()->callData->argc > 4) + password = ctx->d()->callData->args[4].toQStringNoThrow(); // Clear the fragment (if any) url.setFragment(QString()); @@ -1803,26 +1803,26 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) if (!username.isNull()) url.setUserName(username); if (!password.isNull()) url.setPassword(password); - ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine)); + ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, engine)); return r->open(meObject, method, url); } ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag()) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - QString name = ctx->callData->args[0].toQStringNoThrow(); - QString value = ctx->callData->args[1].toQStringNoThrow(); + QString name = ctx->d()->callData->args[0].toQStringNoThrow(); + QString value = ctx->d()->callData->args[1].toQStringNoThrow(); // ### Check that name and value are well formed @@ -1857,48 +1857,48 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_send(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag()) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); QByteArray data; - if (ctx->callData->argc > 0) - data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); + if (ctx->d()->callData->argc > 0) + data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); - ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine)); + ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, engine)); return r->send(meObject, data); } ReturnedValue QQmlXMLHttpRequestCtor::method_abort(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, ctx->engine->v8Engine)); + ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, ctx->d()->engine->v8Engine)); return r->abort(meObject); } ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1906,20 +1906,20 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx) r->readyState() != QQmlXMLHttpRequest::HeadersReceived) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - return engine->toString(r->header(ctx->callData->args[0].toQStringNoThrow())); + return engine->toString(r->header(ctx->d()->callData->args[0].toQStringNoThrow())); } ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; - if (ctx->callData->argc != 0) + if (ctx->d()->callData->argc != 0) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1934,7 +1934,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext * ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1945,7 +1945,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1963,12 +1963,12 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->readyState() == QQmlXMLHttpRequest::Unsent || r->readyState() == QQmlXMLHttpRequest::Opened) @@ -1983,12 +1983,12 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->readyState() != QQmlXMLHttpRequest::Loading && r->readyState() != QQmlXMLHttpRequest::Done) @@ -2000,7 +2000,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -2010,7 +2010,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) r->readyState() != QQmlXMLHttpRequest::Done)) { return Encode::null(); } else { - return Document::load(ctx->engine->v8Engine, r->rawResponseBody()); + return Document::load(ctx->d()->engine->v8Engine, r->rawResponseBody()); } } -- cgit v1.2.3