From: Lars Knoll Date: Thu, 26 Sep 2013 10:34:53 +0000 (+0200) Subject: Less QV4::Value usage X-Git-Tag: upstream/5.2.1~365 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=112531bc23494ba3c5cf2e0a51b2d654be28dbfd;p=platform%2Fupstream%2Fqtdeclarative.git Less QV4::Value usage Fix some usages in qv4engine, and fix return types in methods in qqmlxmlhttprequest. Change-Id: I3d6225ca01bf7ea77fcc424914c8392bb6c3a454 Reviewed-by: Simon Hausmann --- diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 0e0b130..4b02f89 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -220,21 +220,21 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) SequencePrototype *sequencePrototype = new (memoryManager) SequencePrototype(arrayClass->changePrototype(arrayPrototype)); sequenceClass = emptyClass->changePrototype(sequencePrototype); - objectCtor = Value::fromObject(new (memoryManager) ObjectCtor(rootContext)); - stringCtor = Value::fromObject(new (memoryManager) StringCtor(rootContext)); - numberCtor = Value::fromObject(new (memoryManager) NumberCtor(rootContext)); - booleanCtor = Value::fromObject(new (memoryManager) BooleanCtor(rootContext)); - arrayCtor = Value::fromObject(new (memoryManager) ArrayCtor(rootContext)); - functionCtor = Value::fromObject(new (memoryManager) FunctionCtor(rootContext)); - dateCtor = Value::fromObject(new (memoryManager) DateCtor(rootContext)); - regExpCtor = Value::fromObject(new (memoryManager) RegExpCtor(rootContext)); - errorCtor = Value::fromObject(new (memoryManager) ErrorCtor(rootContext)); - evalErrorCtor = Value::fromObject(new (memoryManager) EvalErrorCtor(rootContext)); - rangeErrorCtor = Value::fromObject(new (memoryManager) RangeErrorCtor(rootContext)); - referenceErrorCtor = Value::fromObject(new (memoryManager) ReferenceErrorCtor(rootContext)); - syntaxErrorCtor = Value::fromObject(new (memoryManager) SyntaxErrorCtor(rootContext)); - typeErrorCtor = Value::fromObject(new (memoryManager) TypeErrorCtor(rootContext)); - uRIErrorCtor = Value::fromObject(new (memoryManager) URIErrorCtor(rootContext)); + objectCtor = new (memoryManager) ObjectCtor(rootContext); + stringCtor = new (memoryManager) StringCtor(rootContext); + numberCtor = new (memoryManager) NumberCtor(rootContext); + booleanCtor = new (memoryManager) BooleanCtor(rootContext); + arrayCtor = new (memoryManager) ArrayCtor(rootContext); + functionCtor = new (memoryManager) FunctionCtor(rootContext); + dateCtor = new (memoryManager) DateCtor(rootContext); + regExpCtor = new (memoryManager) RegExpCtor(rootContext); + errorCtor = new (memoryManager) ErrorCtor(rootContext); + evalErrorCtor = new (memoryManager) EvalErrorCtor(rootContext); + rangeErrorCtor = new (memoryManager) RangeErrorCtor(rootContext); + referenceErrorCtor = new (memoryManager) ReferenceErrorCtor(rootContext); + syntaxErrorCtor = new (memoryManager) SyntaxErrorCtor(rootContext); + typeErrorCtor = new (memoryManager) TypeErrorCtor(rootContext); + uRIErrorCtor = new (memoryManager) URIErrorCtor(rootContext); objectPrototype->init(this, objectCtor); stringPrototype->init(this, stringCtor); @@ -260,7 +260,7 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory) // globalObject = newObject()->getPointer(); rootContext->global = globalObject; - rootContext->callData->thisObject = Value::fromObject(globalObject); + rootContext->callData->thisObject = globalObject; globalObject->defineDefaultProperty(QStringLiteral("Object"), objectCtor); globalObject->defineDefaultProperty(QStringLiteral("String"), stringCtor); diff --git a/src/qml/jsruntime/qv4value_def_p.h b/src/qml/jsruntime/qv4value_def_p.h index bc73a85..3e6c192 100644 --- a/src/qml/jsruntime/qv4value_def_p.h +++ b/src/qml/jsruntime/qv4value_def_p.h @@ -338,6 +338,12 @@ struct SafeValue : public Value return *this; } template + SafeValue &operator=(T *t) { + val = Value::fromManaged(t).val; + return *this; + } + + template SafeValue &operator=(const Scoped &t); SafeValue &operator=(const ValueRef v); SafeValue &operator=(const Value &v) { @@ -369,10 +375,15 @@ struct Q_QML_EXPORT Primitive : public Value template struct Safe : public SafeValue { + template + Safe &operator =(X *x) { + val = Value::fromManaged(x).val; + } Safe &operator =(T *t); Safe &operator =(const Scoped &v); Safe &operator =(const Referenced &v); Safe &operator =(Returned *t); + Safe &operator =(const Safe &t); // ### GC: remove me diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 6c7bdb7..0b5e8cf 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1247,7 +1247,7 @@ void QQmlComponent::createObject(QQmlV4Function *args) QV4::ScopedValue f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlglobal)); Q_ASSERT(f->asFunctionObject()); QV4::ScopedCallData callData(scope, 2); - callData->thisObject = QV4::Value::fromObject(v4->globalObject); + callData->thisObject = v4->globalObject; callData->args[0] = object; callData->args[1] = valuemap; f->asFunctionObject()->call(callData); @@ -1401,7 +1401,7 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu QV4::Scoped f(scope, QV4::Script::evaluate(QV8Engine::getV4(v8engine), QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobalObj)); QV4::ScopedCallData callData(scope, 2); - callData->thisObject = QV4::Value::fromObject(v4engine->globalObject); + callData->thisObject = v4engine->globalObject; callData->args[0] = object; callData->args[1] = valuemap; f->call(callData); @@ -1502,7 +1502,7 @@ void QmlIncubatorObject::setInitialState(QObject *o) QV4::Scoped f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal)); QV4::ScopedCallData callData(scope, 2); - callData->thisObject = QV4::Value::fromObject(v4->globalObject); + callData->thisObject = v4->globalObject; callData->args[0] = QV4::Value::fromReturnedValue(QV4::QObjectWrapper::wrap(v4, o)); callData->args[1] = valuemap; f->call(callData); @@ -1540,7 +1540,7 @@ void QmlIncubatorObject::statusChanged(Status s) QV4::Scope scope(ctx); try { QV4::ScopedCallData callData(scope, 1); - callData->thisObject = QV4::Value::fromObject(this); + callData->thisObject = this; callData->args[0] = QV4::Primitive::fromUInt32(s); f->call(callData); } catch (QV4::Exception &e) { diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp index 65edcad..3ea40bd 100644 --- a/src/qml/qml/qqmlobjectcreator.cpp +++ b/src/qml/qml/qqmlobjectcreator.cpp @@ -1374,8 +1374,7 @@ bool QmlObjectCreator::populateInstance(int index, QObject *instance, QQmlRefPoi QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::Scope valueScope(v4); QV4::ScopedValue scopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _qobjectForBindings)); - QV4::QmlBindingWrapper *qmlBindingWrapper = new (v4->memoryManager) QV4::QmlBindingWrapper(v4->rootContext, scopeObject->asObject()); - QV4::ScopedValue qmlScopeFunction(valueScope, QV4::Value::fromObject(qmlBindingWrapper)); + QV4::Scoped qmlBindingWrapper(valueScope, new (v4->memoryManager) QV4::QmlBindingWrapper(v4->rootContext, scopeObject->asObject())); QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context(); qSwap(_qmlContext, qmlContext); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 01a373b..9104c4b 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -203,7 +203,7 @@ public: } // C++ API - static Value create(QV8Engine *, NodeImpl *, const QList &); + static ReturnedValue create(QV8Engine *, NodeImpl *, const QList &); // JS API static void destroy(Managed *that) { @@ -244,7 +244,7 @@ public: static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); // C++ API - static Value create(QV8Engine *, NodeImpl *); + static ReturnedValue create(QV8Engine *, NodeImpl *); NodeImpl *d; }; @@ -287,14 +287,14 @@ public: static ReturnedValue method_get_nextSibling(SimpleCallContext *ctx); static ReturnedValue method_get_attributes(SimpleCallContext *ctx); - //static Value ownerDocument(SimpleCallContext *ctx); - //static Value namespaceURI(SimpleCallContext *ctx); - //static Value prefix(SimpleCallContext *ctx); - //static Value localName(SimpleCallContext *ctx); - //static Value baseURI(SimpleCallContext *ctx); - //static Value textContent(SimpleCallContext *ctx); + //static ReturnedValue ownerDocument(SimpleCallContext *ctx); + //static ReturnedValue namespaceURI(SimpleCallContext *ctx); + //static ReturnedValue prefix(SimpleCallContext *ctx); + //static ReturnedValue localName(SimpleCallContext *ctx); + //static ReturnedValue baseURI(SimpleCallContext *ctx); + //static ReturnedValue textContent(SimpleCallContext *ctx); - static Value getProto(ExecutionEngine *v4); + static ReturnedValue getProto(ExecutionEngine *v4); }; @@ -324,7 +324,7 @@ class Node : public Object } // C++ API - static Value create(QV8Engine *, NodeImpl *); + static ReturnedValue create(QV8Engine *, NodeImpl *); Node(const Node &o); bool isNull() const; @@ -341,7 +341,7 @@ class Element : public Node { public: // C++ API - static Value prototype(ExecutionEngine *); + static ReturnedValue prototype(ExecutionEngine *); }; class Attr : public Node @@ -349,14 +349,14 @@ class Attr : public Node public: // JS API static ReturnedValue method_name(SimpleCallContext *ctx); -// static Value specified(SimpleCallContext *); +// static ReturnedValue specified(SimpleCallContext *); static ReturnedValue method_value(SimpleCallContext *ctx); static ReturnedValue method_ownerElement(SimpleCallContext *ctx); -// static Value schemaTypeInfo(SimpleCallContext *); -// static Value isId(SimpleCallContext *c); +// static ReturnedValue schemaTypeInfo(SimpleCallContext *); +// static ReturnedValue isId(SimpleCallContext *c); // C++ API - static Value prototype(ExecutionEngine *); + static ReturnedValue prototype(ExecutionEngine *); }; class CharacterData : public Node @@ -366,7 +366,7 @@ public: static ReturnedValue method_length(SimpleCallContext *ctx); // C++ API - static Value prototype(ExecutionEngine *v4); + static ReturnedValue prototype(ExecutionEngine *v4); }; class Text : public CharacterData @@ -377,14 +377,14 @@ public: static ReturnedValue method_wholeText(SimpleCallContext *ctx); // C++ API - static Value prototype(ExecutionEngine *); + static ReturnedValue prototype(ExecutionEngine *); }; class CDATA : public Text { public: // C++ API - static Value prototype(ExecutionEngine *v4); + static ReturnedValue prototype(ExecutionEngine *v4); }; class Document : public Node @@ -397,7 +397,7 @@ public: static ReturnedValue method_documentElement(SimpleCallContext *ctx); // C++ API - static Value prototype(ExecutionEngine *); + static ReturnedValue prototype(ExecutionEngine *); static ReturnedValue load(QV8Engine *engine, const QByteArray &data); }; @@ -477,7 +477,7 @@ ReturnedValue NodePrototype::method_get_parentNode(SimpleCallContext *ctx) QV8Engine *engine = ctx->engine->v8Engine; if (r->d->parent) - return Node::create(engine, r->d->parent).asReturnedValue(); + return Node::create(engine, r->d->parent); else return Encode::null(); } @@ -491,7 +491,7 @@ ReturnedValue NodePrototype::method_get_childNodes(SimpleCallContext *ctx) QV8Engine *engine = ctx->engine->v8Engine; - return NodeList::create(engine, r->d).asReturnedValue(); + return NodeList::create(engine, r->d); } ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx) @@ -506,7 +506,7 @@ ReturnedValue NodePrototype::method_get_firstChild(SimpleCallContext *ctx) if (r->d->children.isEmpty()) return Encode::null(); else - return Node::create(engine, r->d->children.first()).asReturnedValue(); + return Node::create(engine, r->d->children.first()); } ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx) @@ -521,7 +521,7 @@ ReturnedValue NodePrototype::method_get_lastChild(SimpleCallContext *ctx) if (r->d->children.isEmpty()) return Encode::null(); else - return Node::create(engine, r->d->children.last()).asReturnedValue(); + return Node::create(engine, r->d->children.last()); } ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx) @@ -541,7 +541,7 @@ ReturnedValue NodePrototype::method_get_previousSibling(SimpleCallContext *ctx) if (ii == 0) return Encode::null(); else - return Node::create(engine, r->d->parent->children.at(ii - 1)).asReturnedValue(); + return Node::create(engine, r->d->parent->children.at(ii - 1)); } } @@ -565,7 +565,7 @@ ReturnedValue NodePrototype::method_get_nextSibling(SimpleCallContext *ctx) if ((ii + 1) == r->d->parent->children.count()) return Encode::null(); else - return Node::create(engine, r->d->parent->children.at(ii + 1)).asReturnedValue(); + return Node::create(engine, r->d->parent->children.at(ii + 1)); } } @@ -584,10 +584,10 @@ ReturnedValue NodePrototype::method_get_attributes(SimpleCallContext *ctx) if (r->d->type != NodeImpl::Element) return Encode::null(); else - return NamedNodeMap::create(engine, r->d, r->d->attributes).asReturnedValue(); + return NamedNodeMap::create(engine, r->d, r->d->attributes); } -Value NodePrototype::getProto(ExecutionEngine *v4) +ReturnedValue NodePrototype::getProto(ExecutionEngine *v4) { Scope scope(v4); QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine); @@ -596,19 +596,21 @@ Value NodePrototype::getProto(ExecutionEngine *v4) d->nodePrototype = p; v4->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->nodePrototype.value()); + return d->nodePrototype.value(); } -Value Node::create(QV8Engine *engine, NodeImpl *data) +ReturnedValue Node::create(QV8Engine *engine, NodeImpl *data) { ExecutionEngine *v4 = QV8Engine::getV4(engine); + Scope scope(v4); QQmlXMLHttpRequestData *d = xhrdata(engine); - Node *instance = new (v4->memoryManager) Node(v4, data); + Scoped instance(scope, new (v4->memoryManager) Node(v4, data)); + ScopedObject p(scope); switch (data->type) { case NodeImpl::Attr: - instance->setPrototype(Attr::prototype(v4).asObject()); + instance->setPrototype((p = Attr::prototype(v4)).getPointer()); break; case NodeImpl::Comment: case NodeImpl::Document: @@ -618,49 +620,51 @@ Value Node::create(QV8Engine *engine, NodeImpl *data) case NodeImpl::EntityReference: case NodeImpl::Notation: case NodeImpl::ProcessingInstruction: - return Primitive::undefinedValue(); + return Encode::undefined(); case NodeImpl::CDATA: - instance->setPrototype(CDATA::prototype(v4).asObject()); + instance->setPrototype((p = CDATA::prototype(v4)).getPointer()); break; case NodeImpl::Text: - instance->setPrototype(Text::prototype(v4).asObject()); + instance->setPrototype((p = Text::prototype(v4)).getPointer()); break; case NodeImpl::Element: - instance->setPrototype(Element::prototype(v4).asObject()); + instance->setPrototype((p = Element::prototype(v4)).getPointer()); break; } - return Value::fromObject(instance); + return instance.asReturnedValue(); } -Value Element::prototype(ExecutionEngine *engine) +ReturnedValue Element::prototype(ExecutionEngine *engine) { QQmlXMLHttpRequestData *d = xhrdata(engine->v8Engine); if (d->elementPrototype.isUndefined()) { Scope scope(engine); - Scoped p(scope, engine->newObject()); - p->setPrototype(NodePrototype::getProto(engine).asObject()); + ScopedObject p(scope, engine->newObject()); + ScopedObject pp(scope); + p->setPrototype((pp = NodePrototype::getProto(engine)).getPointer()); p->defineAccessorProperty(QStringLiteral("tagName"), NodePrototype::method_get_nodeName, 0); d->elementPrototype = p; engine->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->elementPrototype.value()); + return d->elementPrototype.value(); } -Value Attr::prototype(ExecutionEngine *engine) +ReturnedValue Attr::prototype(ExecutionEngine *engine) { QQmlXMLHttpRequestData *d = xhrdata(engine->v8Engine); if (d->attrPrototype.isUndefined()) { Scope scope(engine); Scoped p(scope, engine->newObject()); - p->setPrototype(NodePrototype::getProto(engine).asObject()); + ScopedObject pp(scope); + p->setPrototype((pp = NodePrototype::getProto(engine)).getPointer()); p->defineAccessorProperty(QStringLiteral("name"), method_name, 0); p->defineAccessorProperty(QStringLiteral("value"), method_value, 0); p->defineAccessorProperty(QStringLiteral("ownerElement"), method_ownerElement, 0); d->attrPrototype = p; engine->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->attrPrototype.value()); + return d->attrPrototype.value(); } ReturnedValue Attr::method_name(SimpleCallContext *ctx) @@ -693,7 +697,7 @@ ReturnedValue Attr::method_ownerElement(SimpleCallContext *ctx) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; - return Node::create(engine, r->d->parent).asReturnedValue(); + return Node::create(engine, r->d->parent); } ReturnedValue CharacterData::method_length(SimpleCallContext *ctx) @@ -707,19 +711,20 @@ ReturnedValue CharacterData::method_length(SimpleCallContext *ctx) return Encode(r->d->data.length()); } -Value CharacterData::prototype(ExecutionEngine *v4) +ReturnedValue CharacterData::prototype(ExecutionEngine *v4) { QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine); if (d->characterDataPrototype.isUndefined()) { Scope scope(v4); Scoped p(scope, v4->newObject()); - p->setPrototype(NodePrototype::getProto(v4).asObject()); + ScopedObject pp(scope); + p->setPrototype((pp = NodePrototype::getProto(v4)).getPointer()); p->defineAccessorProperty(QStringLiteral("data"), NodePrototype::method_get_nodeValue, 0); p->defineAccessorProperty(QStringLiteral("length"), method_length, 0); d->characterDataPrototype = p; v4->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->characterDataPrototype.value()); + return d->characterDataPrototype.value(); } ReturnedValue Text::method_isElementContentWhitespace(SimpleCallContext *ctx) @@ -742,42 +747,45 @@ ReturnedValue Text::method_wholeText(SimpleCallContext *ctx) return engine->toString(r->d->data); } -Value Text::prototype(ExecutionEngine *v4) +ReturnedValue Text::prototype(ExecutionEngine *v4) { QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine); if (d->textPrototype.isUndefined()) { Scope scope(v4); Scoped p(scope, v4->newObject()); - p->setPrototype(CharacterData::prototype(v4).asObject()); + ScopedObject pp(scope); + p->setPrototype((pp = CharacterData::prototype(v4)).getPointer()); p->defineAccessorProperty(QStringLiteral("isElementContentWhitespace"), method_isElementContentWhitespace, 0); p->defineAccessorProperty(QStringLiteral("wholeText"), method_wholeText, 0); d->textPrototype = p; v4->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->textPrototype.value()); + return d->textPrototype.value(); } -Value CDATA::prototype(ExecutionEngine *v4) +ReturnedValue CDATA::prototype(ExecutionEngine *v4) { // ### why not just use TextProto??? QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine); if (d->cdataPrototype.isUndefined()) { Scope scope(v4); Scoped p(scope, v4->newObject()); - p->setPrototype(Text::prototype(v4).asObject()); + ScopedObject pp(scope); + p->setPrototype((pp = Text::prototype(v4)).getPointer()); d->cdataPrototype = p; v4->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->cdataPrototype.value()); + return d->cdataPrototype.value(); } -Value Document::prototype(ExecutionEngine *v4) +ReturnedValue Document::prototype(ExecutionEngine *v4) { QQmlXMLHttpRequestData *d = xhrdata(v4->v8Engine); if (d->documentPrototype.isUndefined()) { Scope scope(v4); Scoped p(scope, v4->newObject()); - p->setPrototype(NodePrototype::getProto(v4).asObject()); + ScopedObject pp(scope); + p->setPrototype((pp = NodePrototype::getProto(v4)).getPointer()); p->defineAccessorProperty(QStringLiteral("xmlVersion"), method_xmlVersion, 0); p->defineAccessorProperty(QStringLiteral("xmlEncoding"), method_xmlEncoding, 0); p->defineAccessorProperty(QStringLiteral("xmlStandalone"), method_xmlStandalone, 0); @@ -785,7 +793,7 @@ Value Document::prototype(ExecutionEngine *v4) d->documentPrototype = p; v4->v8Engine->freezeObject(p); } - return Value::fromReturnedValue(d->documentPrototype.value()); + return d->documentPrototype.value(); } ReturnedValue Document::load(QV8Engine *engine, const QByteArray &data) @@ -873,7 +881,8 @@ ReturnedValue Document::load(QV8Engine *engine, const QByteArray &data) } ScopedObject instance(scope, new (v4->memoryManager) Node(v4, document)); - instance->setPrototype(Document::prototype(v4).asObject()); + ScopedObject p(scope); + instance->setPrototype((p = Document::prototype(v4)).getPointer()); return instance.asReturnedValue(); } @@ -901,7 +910,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty if ((int)index < r->list.count()) { if (hasProperty) *hasProperty = true; - return Node::create(engine, r->list.at(index)).asReturnedValue(); + return Node::create(engine, r->list.at(index)); } if (hasProperty) *hasProperty = false; @@ -926,7 +935,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, const StringRef name, bool *hasPrope if (r->list.at(ii)->name == str) { if (hasProperty) *hasProperty = true; - return Node::create(engine, r->list.at(ii)).asReturnedValue(); + return Node::create(engine, r->list.at(ii)); } } @@ -935,12 +944,13 @@ ReturnedValue NamedNodeMap::get(Managed *m, const StringRef name, bool *hasPrope return Encode::undefined(); } -Value NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QList &list) +ReturnedValue NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QList &list) { ExecutionEngine *v4 = QV8Engine::getV4(engine); + Scope scope(v4); - NamedNodeMap *instance = new (v4->memoryManager) NamedNodeMap(v4, data, list); - return Value::fromObject(instance); + Scoped instance(scope, new (v4->memoryManager) NamedNodeMap(v4, data, list)); + return instance.asReturnedValue(); } ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) @@ -955,7 +965,7 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) if ((int)index < r->d->children.count()) { if (hasProperty) *hasProperty = true; - return Node::create(engine, r->d->children.at(index)).asReturnedValue(); + return Node::create(engine, r->d->children.at(index)); } if (hasProperty) *hasProperty = false; @@ -976,12 +986,13 @@ ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty) return Object::get(m, name, hasProperty); } -Value NodeList::create(QV8Engine *engine, NodeImpl *data) +ReturnedValue NodeList::create(QV8Engine *engine, NodeImpl *data) { QQmlXMLHttpRequestData *d = xhrdata(engine); ExecutionEngine *v4 = QV8Engine::getV4(engine); - NodeList *instance = new (v4->memoryManager) NodeList(v4, data); - return Value::fromObject(instance); + Scope scope(v4); + Scoped instance(scope, new (v4->memoryManager) NodeList(v4, data)); + return instance.asReturnedValue(); } ReturnedValue Document::method_documentElement(SimpleCallContext *ctx) @@ -992,7 +1003,7 @@ ReturnedValue Document::method_documentElement(SimpleCallContext *ctx) return Encode::undefined(); QV8Engine *engine = ctx->engine->v8Engine; - return Node::create(engine, static_cast(r->d)->root).asReturnedValue(); + return Node::create(engine, static_cast(r->d)->root); } ReturnedValue Document::method_xmlStandalone(SimpleCallContext *ctx)