diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-11 15:09:25 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:13:30 +0200 |
commit | 8d26084ae56ba5aedd73ab733553dbf9cb3eb672 (patch) | |
tree | c0c14b3fdb87bdb23d5612de77605b98aa03dd52 /src | |
parent | 4691396f96cf8468a9ee4fbb339cc94e339928a7 (diff) |
Use ReturnedValue for Managed::construct()
Change-Id: I9e702d60c4e1b7ba19a699ff7a8d53876d6cd5f7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
25 files changed, 92 insertions, 91 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 7325cf8035..eb2390fa01 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -623,7 +623,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) callData->args[i] = args.at(i).d->getValue(engine); } - Value result; + ScopedValue result(scope); QV4::ExecutionContext *ctx = engine->current; try { result = f->construct(callData); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index d0eae3d241..280062eb0d 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -54,7 +54,7 @@ ArrayCtor::ArrayCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value ArrayCtor::construct(Managed *m, CallData *callData) +ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData) { ExecutionEngine *v4 = m->engine(); ArrayObject *a = v4->newArrayObject(); @@ -77,12 +77,12 @@ Value ArrayCtor::construct(Managed *m, CallData *callData) } a->setArrayLengthUnchecked(len); - return Value::fromObject(a); + return Value::fromObject(a).asReturnedValue(); } ReturnedValue ArrayCtor::call(Managed *that, CallData *callData) { - return construct(that, callData).asReturnedValue(); + return construct(that, callData); } ArrayPrototype::ArrayPrototype(InternalClass *ic) diff --git a/src/qml/jsruntime/qv4arrayobject_p.h b/src/qml/jsruntime/qv4arrayobject_p.h index e8a8ddda22..33c32f3cd6 100644 --- a/src/qml/jsruntime/qv4arrayobject_p.h +++ b/src/qml/jsruntime/qv4arrayobject_p.h @@ -53,7 +53,7 @@ struct ArrayCtor: FunctionObject { ArrayCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp index aa5ebbd38c..fc76830a2f 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -51,10 +51,10 @@ BooleanCtor::BooleanCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value BooleanCtor::construct(Managed *m, CallData *callData) +ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData) { bool n = callData->argc ? callData->args[0].toBoolean() : false; - return Value::fromObject(m->engine()->newBooleanObject(Value::fromBoolean(n))); + return Value::fromObject(m->engine()->newBooleanObject(Value::fromBoolean(n))).asReturnedValue(); } ReturnedValue BooleanCtor::call(Managed *, CallData *callData) diff --git a/src/qml/jsruntime/qv4booleanobject_p.h b/src/qml/jsruntime/qv4booleanobject_p.h index 7cdd2d741b..6a04cb4b7e 100644 --- a/src/qml/jsruntime/qv4booleanobject_p.h +++ b/src/qml/jsruntime/qv4booleanobject_p.h @@ -53,7 +53,7 @@ struct BooleanCtor: FunctionObject { BooleanCtor(ExecutionContext *scope); - static Value construct(Managed *, CallData *callData); + static ReturnedValue construct(Managed *, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 01325aef76..c2a15b8725 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -654,7 +654,7 @@ DateCtor::DateCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value DateCtor::construct(Managed *m, CallData *callData) +ReturnedValue DateCtor::construct(Managed *m, CallData *callData) { double t = 0; @@ -690,7 +690,7 @@ Value DateCtor::construct(Managed *m, CallData *callData) } Object *o = m->engine()->newDateObject(Value::fromDouble(t)); - return Value::fromObject(o); + return Value::fromObject(o).asReturnedValue(); } ReturnedValue DateCtor::call(Managed *m, CallData *) diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index eff47e60f2..84748f2107 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -66,7 +66,7 @@ struct DateCtor: FunctionObject { DateCtor(ExecutionContext *scope); - static Value construct(Managed *, CallData *callData); + static ReturnedValue construct(Managed *, CallData *callData); static ReturnedValue call(Managed *that, CallData *); protected: diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index a02966369f..90b4189e6f 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -240,14 +240,14 @@ ErrorCtor::ErrorCtor(ExecutionContext *scope, String *name) vtbl = &static_vtbl; } -Value ErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue ErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); } ReturnedValue ErrorCtor::call(Managed *that, CallData *callData) { - return that->construct(callData).asReturnedValue(); + return that->construct(callData); } EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope) @@ -256,9 +256,10 @@ EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value EvalErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())) + .asReturnedValue(); } RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope) @@ -267,9 +268,9 @@ RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value RangeErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); } ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope) @@ -278,9 +279,9 @@ ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value ReferenceErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); } SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope) @@ -289,9 +290,9 @@ SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value SyntaxErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); } TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope) @@ -300,9 +301,9 @@ TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value TypeErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); } URIErrorCtor::URIErrorCtor(ExecutionContext *scope) @@ -311,9 +312,9 @@ URIErrorCtor::URIErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value URIErrorCtor::construct(Managed *m, CallData *callData) +ReturnedValue URIErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); } void ErrorPrototype::init(ExecutionEngine *engine, const Value &ctor, Object *obj) diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index 7ccb9cb4cf..a9eab58414 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -114,7 +114,7 @@ struct ErrorCtor: FunctionObject ErrorCtor(ExecutionContext *scope); ErrorCtor(ExecutionContext *scope, String *name); - static Value construct(Managed *, CallData *callData); + static ReturnedValue construct(Managed *, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: @@ -125,7 +125,7 @@ struct EvalErrorCtor: ErrorCtor { EvalErrorCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); protected: static const ManagedVTable static_vtbl; @@ -135,7 +135,7 @@ struct RangeErrorCtor: ErrorCtor { RangeErrorCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); protected: static const ManagedVTable static_vtbl; @@ -145,7 +145,7 @@ struct ReferenceErrorCtor: ErrorCtor { ReferenceErrorCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); protected: static const ManagedVTable static_vtbl; @@ -155,7 +155,7 @@ struct SyntaxErrorCtor: ErrorCtor { SyntaxErrorCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); protected: static const ManagedVTable static_vtbl; @@ -165,7 +165,7 @@ struct TypeErrorCtor: ErrorCtor { TypeErrorCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); protected: static const ManagedVTable static_vtbl; @@ -175,7 +175,7 @@ struct URIErrorCtor: ErrorCtor { URIErrorCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); protected: static const ManagedVTable static_vtbl; diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index cb5d4c22e5..475874ce01 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -122,7 +122,7 @@ FunctionObject::~FunctionObject() function->compilationUnit->deref(); } -Value FunctionObject::newInstance() +ReturnedValue FunctionObject::newInstance() { Scope scope(engine()); ScopedCallData callData(scope, 0); @@ -154,7 +154,7 @@ bool FunctionObject::hasInstance(Managed *that, const Value &value) return false; } -Value FunctionObject::construct(Managed *that, CallData *) +ReturnedValue FunctionObject::construct(Managed *that, CallData *) { FunctionObject *f = static_cast<FunctionObject *>(that); ExecutionEngine *v4 = f->engine(); @@ -164,7 +164,7 @@ Value FunctionObject::construct(Managed *that, CallData *) if (proto.isObject()) ic = v4->emptyClass->changePrototype(proto.objectValue()); Object *obj = v4->newObject(ic); - return Value::fromObject(obj); + return Value::fromObject(obj).asReturnedValue(); } ReturnedValue FunctionObject::call(Managed *, CallData *) @@ -206,7 +206,7 @@ FunctionCtor::FunctionCtor(ExecutionContext *scope) } // 15.3.2 -Value FunctionCtor::construct(Managed *that, CallData *callData) +ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) { FunctionCtor *f = static_cast<FunctionCtor *>(that); MemoryManager::GCBlocker gcBlocker(f->engine()->memoryManager); @@ -250,13 +250,13 @@ Value FunctionCtor::construct(Managed *that, CallData *callData) QV4::CompiledData::CompilationUnit *compilationUnit = isel->compile(); QV4::Function *vmf = compilationUnit->linkToEngine(v4); - return Value::fromObject(FunctionObject::creatScriptFunction(v4->rootContext, vmf)); + return Value::fromObject(FunctionObject::creatScriptFunction(v4->rootContext, vmf)).asReturnedValue(); } // 15.3.1: This is equivalent to new Function(...) ReturnedValue FunctionCtor::call(Managed *that, CallData *callData) { - return construct(that, callData).asReturnedValue(); + return construct(that, callData); } FunctionPrototype::FunctionPrototype(InternalClass *ic) @@ -405,7 +405,7 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) } } -Value ScriptFunction::construct(Managed *that, CallData *callData) +ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) { ScriptFunction *f = static_cast<ScriptFunction *>(that); ExecutionEngine *v4 = f->engine(); @@ -433,8 +433,8 @@ Value ScriptFunction::construct(Managed *that, CallData *callData) ctx->engine->popContext(); if (result->isObject()) - return result; - return Value::fromObject(obj); + return result.asReturnedValue(); + return Value::fromObject(obj).asReturnedValue(); } ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) @@ -501,7 +501,7 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu } } -Value SimpleScriptFunction::construct(Managed *that, CallData *callData) +ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) { SimpleScriptFunction *f = static_cast<SimpleScriptFunction *>(that); ExecutionEngine *v4 = f->engine(); @@ -530,8 +530,8 @@ Value SimpleScriptFunction::construct(Managed *that, CallData *callData) ctx->engine->popContext(); if (result->isObject()) - return result; - return Value::fromObject(obj); + return result.asReturnedValue(); + return Value::fromObject(obj).asReturnedValue(); } ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) @@ -576,10 +576,10 @@ BuiltinFunctionOld::BuiltinFunctionOld(ExecutionContext *scope, String *name, Va isBuiltinFunction = true; } -Value BuiltinFunctionOld::construct(Managed *f, CallData *) +ReturnedValue BuiltinFunctionOld::construct(Managed *f, CallData *) { f->engine()->current->throwTypeError(); - return Value::undefinedValue(); + return Value::undefinedValue().asReturnedValue(); } ReturnedValue BuiltinFunctionOld::call(Managed *that, CallData *callData) @@ -676,7 +676,7 @@ ReturnedValue BoundFunction::call(Managed *that, CallData *dd) return f->target->call(callData); } -Value BoundFunction::construct(Managed *that, CallData *dd) +ReturnedValue BoundFunction::construct(Managed *that, CallData *dd) { BoundFunction *f = static_cast<BoundFunction *>(that); Scope scope(f->scope->engine); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index bad62af6f3..bc5bc5c8df 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -115,11 +115,11 @@ struct Q_QML_EXPORT FunctionObject: Object { FunctionObject(ExecutionContext *scope, String *name = 0, bool createProto = false); ~FunctionObject(); - Value newInstance(); + ReturnedValue newInstance(); - static Value construct(Managed *that, CallData *); + static ReturnedValue construct(Managed *that, CallData *); static ReturnedValue call(Managed *that, CallData *d); - inline Value construct(CallData *callData) { + inline ReturnedValue construct(CallData *callData) { return vtbl->construct(this, callData); } inline ReturnedValue call(CallData *callData) { @@ -142,7 +142,7 @@ struct FunctionCtor: FunctionObject { FunctionCtor(ExecutionContext *scope); - static Value construct(Managed *that, CallData *callData); + static ReturnedValue construct(Managed *that, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: @@ -165,7 +165,7 @@ struct BuiltinFunctionOld: FunctionObject { BuiltinFunctionOld(ExecutionContext *scope, String *name, Value (*code)(SimpleCallContext *)); - static Value construct(Managed *, CallData *); + static ReturnedValue construct(Managed *, CallData *); static ReturnedValue call(Managed *that, CallData *callData); protected: @@ -188,10 +188,10 @@ struct IndexedBuiltinFunction: FunctionObject isBuiltinFunction = true; } - static Value construct(Managed *m, CallData *) + static ReturnedValue construct(Managed *m, CallData *) { m->engine()->current->throwTypeError(); - return Value::undefinedValue(); + return Value::undefinedValue().asReturnedValue(); } static ReturnedValue call(Managed *that, CallData *callData); @@ -201,7 +201,7 @@ struct IndexedBuiltinFunction: FunctionObject struct ScriptFunction: FunctionObject { ScriptFunction(ExecutionContext *scope, Function *function); - static Value construct(Managed *, CallData *callData); + static ReturnedValue construct(Managed *, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: @@ -211,7 +211,7 @@ protected: struct SimpleScriptFunction: FunctionObject { SimpleScriptFunction(ExecutionContext *scope, Function *function); - static Value construct(Managed *, CallData *callData); + static ReturnedValue construct(Managed *, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: @@ -227,7 +227,7 @@ struct BoundFunction: FunctionObject { ~BoundFunction() {} - static Value construct(Managed *, CallData *d); + static ReturnedValue construct(Managed *, CallData *d); static ReturnedValue call(Managed *that, CallData *dd); static const ManagedVTable static_vtbl; diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index 1a86889373..711c7cf259 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -176,7 +176,7 @@ bool Managed::hasInstance(Managed *m, const Value &) m->engine()->current->throwTypeError(); } -Value Managed::construct(Managed *m, CallData *) +ReturnedValue Managed::construct(Managed *m, CallData *) { m->engine()->current->throwTypeError(); } diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index a71ee717db..44d809c605 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -92,7 +92,7 @@ struct CallData struct ManagedVTable { ReturnedValue (*call)(Managed *, CallData *data); - Value (*construct)(Managed *, CallData *data); + ReturnedValue (*construct)(Managed *, CallData *data); void (*markObjects)(Managed *); void (*destroy)(Managed *); void (*collectDeletables)(Managed *, GCDeletable **deletable); @@ -252,7 +252,7 @@ public: inline bool hasInstance(const Value &v) { return vtbl->hasInstance(this, v); } - Value construct(CallData *d); + ReturnedValue construct(CallData *d); ReturnedValue call(CallData *d); Value get(String *name, bool *hasProperty = 0); Value getIndexed(uint index, bool *hasProperty = 0); @@ -281,7 +281,7 @@ public: static void destroy(Managed *that) { that->_data = 0; } static bool hasInstance(Managed *that, const Value &value); - static Value construct(Managed *m, CallData *d); + static ReturnedValue construct(Managed *m, CallData *d); static ReturnedValue call(Managed *m, CallData *); static void getLookup(Managed *m, Lookup *, Value *); static void setLookup(Managed *m, Lookup *l, const Value &v); diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 2c5961f832..0f62a68903 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -56,10 +56,10 @@ NumberCtor::NumberCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value NumberCtor::construct(Managed *m, CallData *callData) +ReturnedValue NumberCtor::construct(Managed *m, CallData *callData) { double dbl = callData->argc ? callData->args[0].toNumber() : 0.; - return Value::fromObject(m->engine()->newNumberObject(Value::fromDouble(dbl))); + return Value::fromObject(m->engine()->newNumberObject(Value::fromDouble(dbl))).asReturnedValue(); } ReturnedValue NumberCtor::call(Managed *, CallData *callData) diff --git a/src/qml/jsruntime/qv4numberobject_p.h b/src/qml/jsruntime/qv4numberobject_p.h index a6e622e398..a024b7f334 100644 --- a/src/qml/jsruntime/qv4numberobject_p.h +++ b/src/qml/jsruntime/qv4numberobject_p.h @@ -53,7 +53,7 @@ struct NumberCtor: FunctionObject { NumberCtor(ExecutionContext *scope); - static Value construct(Managed *that, CallData *callData); + static ReturnedValue construct(Managed *that, CallData *callData); static ReturnedValue call(Managed *, CallData *callData); protected: diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index b851cc3903..37becf8deb 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -79,7 +79,7 @@ ObjectCtor::ObjectCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value ObjectCtor::construct(Managed *that, CallData *callData) +ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData) { ObjectCtor *ctor = static_cast<ObjectCtor *>(that); ExecutionEngine *v4 = that->engine(); @@ -88,9 +88,9 @@ Value ObjectCtor::construct(Managed *that, CallData *callData) Value proto = ctor->get(v4->id_prototype); if (proto.isObject()) obj->setPrototype(proto.objectValue()); - return Value::fromObject(obj); + return Value::fromObject(obj).asReturnedValue(); } - return Value::fromReturnedValue(__qmljs_to_object(v4->current, ValueRef(&callData->args[0]))); + return Value::fromReturnedValue(__qmljs_to_object(v4->current, ValueRef(&callData->args[0]))).asReturnedValue(); } ReturnedValue ObjectCtor::call(Managed *m, CallData *callData) diff --git a/src/qml/jsruntime/qv4objectproto_p.h b/src/qml/jsruntime/qv4objectproto_p.h index 06f88db656..a8294d2f47 100644 --- a/src/qml/jsruntime/qv4objectproto_p.h +++ b/src/qml/jsruntime/qv4objectproto_p.h @@ -53,7 +53,7 @@ struct ObjectCtor: FunctionObject { ObjectCtor(ExecutionContext *scope); - static Value construct(Managed *that, CallData *callData); + static ReturnedValue construct(Managed *that, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 90ab558d7a..4ad8c4a0a1 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -229,7 +229,7 @@ RegExpCtor::RegExpCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value RegExpCtor::construct(Managed *m, CallData *callData) +ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) { ExecutionContext *ctx = m->engine()->current; Scope scope(ctx); @@ -241,7 +241,7 @@ Value RegExpCtor::construct(Managed *m, CallData *callData) ctx->throwTypeError(); RegExpObject *o = ctx->engine->newRegExpObject(re->value, re->global); - return Value::fromObject(o); + return Value::fromObject(o).asReturnedValue(); } QString pattern; @@ -272,7 +272,7 @@ Value RegExpCtor::construct(Managed *m, CallData *callData) ctx->throwSyntaxError(0); RegExpObject *o = ctx->engine->newRegExpObject(re, global); - return Value::fromObject(o); + return Value::fromObject(o).asReturnedValue(); } ReturnedValue RegExpCtor::call(Managed *that, CallData *callData) @@ -282,7 +282,7 @@ ReturnedValue RegExpCtor::call(Managed *that, CallData *callData) return callData->args[0].asReturnedValue(); } - return construct(that, callData).asReturnedValue(); + return construct(that, callData); } void RegExpPrototype::init(ExecutionContext *ctx, const Value &ctor) @@ -366,7 +366,7 @@ Value RegExpPrototype::method_compile(SimpleCallContext *ctx) ScopedCallData callData(scope, ctx->argumentCount); memcpy(callData->args, ctx->arguments, ctx->argumentCount*sizeof(Value)); - RegExpObject *re = ctx->engine->regExpCtor.asFunctionObject()->construct(callData).as<RegExpObject>(); + RegExpObject *re = Value::fromReturnedValue(ctx->engine->regExpCtor.asFunctionObject()->construct(callData)).as<RegExpObject>(); r->value = re->value; r->global = re->global; diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index cbf185ebf0..e95f3620fd 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -105,7 +105,7 @@ struct RegExpCtor: FunctionObject { RegExpCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 283246d25c..a6257958b4 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -1043,7 +1043,7 @@ ReturnedValue __qmljs_construct_global_lookup(ExecutionContext *context, uint in if (!f) context->throwTypeError(); - return f->construct(callData).asReturnedValue(); + return f->construct(callData); } @@ -1055,7 +1055,7 @@ ReturnedValue __qmljs_construct_activation_property(ExecutionContext *context, S if (!f) context->throwTypeError(); - return f->construct(callData).asReturnedValue(); + return f->construct(callData); } ReturnedValue __qmljs_construct_value(ExecutionContext *context, const ValueRef func, CallDataRef callData) @@ -1064,7 +1064,7 @@ ReturnedValue __qmljs_construct_value(ExecutionContext *context, const ValueRef if (!f) context->throwTypeError(); - return f->construct(callData).asReturnedValue(); + return f->construct(callData); } ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueRef base, String *name, CallDataRef callData) @@ -1076,7 +1076,7 @@ ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueR if (!f) context->throwTypeError(); - return f->construct(callData).asReturnedValue(); + return f->construct(callData); } void __qmljs_throw(ExecutionContext *context, const ValueRef value) diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 9faa1ebeae..8df40ea488 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -160,14 +160,14 @@ StringCtor::StringCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value StringCtor::construct(Managed *m, CallData *callData) +ReturnedValue StringCtor::construct(Managed *m, CallData *callData) { Value value; if (callData->argc) value = Value::fromString(callData->args[0].toString(m->engine()->current)); else value = Value::fromString(m->engine()->current, QString()); - return Value::fromObject(m->engine()->newStringObject(value)); + return Value::fromObject(m->engine()->newStringObject(value)).asReturnedValue(); } ReturnedValue StringCtor::call(Managed *m, CallData *callData) @@ -359,7 +359,7 @@ Value StringPrototype::method_match(SimpleCallContext *context) if (!rx) { ScopedCallData callData(scope, 1); callData->args[0] = regexp; - rx = context->engine->regExpCtor.asFunctionObject()->construct(callData).as<RegExpObject>(); + rx = Value::fromReturnedValue(context->engine->regExpCtor.asFunctionObject()->construct(callData)).as<RegExpObject>(); } if (!rx) @@ -573,13 +573,13 @@ Value StringPrototype::method_search(SimpleCallContext *ctx) else string = ctx->thisObject.toString(ctx)->toQString(); - Value regExpValue = ctx->argument(0); - RegExpObject *regExp = regExpValue.as<RegExpObject>(); + ScopedValue regExpValue(scope, ctx->argument(0)); + RegExpObject *regExp = regExpValue->as<RegExpObject>(); if (!regExp) { ScopedCallData callData(scope, 1); callData->args[0] = regExpValue; regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(callData); - regExp = regExpValue.as<RegExpObject>(); + regExp = regExpValue->as<RegExpObject>(); } uint* matchOffsets = (uint*)alloca(regExp->value->captureCount() * 2 * sizeof(uint)); uint result = regExp->value->match(string, /*offset*/0, matchOffsets); diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index 702900bb36..42c2a208d9 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -70,7 +70,7 @@ struct StringCtor: FunctionObject { StringCtor(ExecutionContext *scope); - static Value construct(Managed *m, CallData *callData); + static ReturnedValue construct(Managed *m, CallData *callData); static ReturnedValue call(Managed *that, CallData *callData); protected: diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index ecd0c319b9..663e0aafb2 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -276,7 +276,7 @@ inline ErrorObject *Value::asErrorObject() const } // ### -inline Value Managed::construct(CallData *d) { +inline ReturnedValue Managed::construct(CallData *d) { return vtbl->construct(this, d); } inline ReturnedValue Managed::call(CallData *d) { diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 52e959f896..849e226a37 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1565,7 +1565,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject if (c->proto) c->proto->mark(); } - static Value construct(Managed *that, QV4::CallData *) + static ReturnedValue construct(Managed *that, QV4::CallData *) { QQmlXMLHttpRequestCtor *ctor = that->as<QQmlXMLHttpRequestCtor>(); if (!ctor) @@ -1575,7 +1575,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager()); QQmlXMLHttpRequestWrapper *w = new (that->engine()->memoryManager) QQmlXMLHttpRequestWrapper(that->engine(), r); w->setPrototype(ctor->proto); - return Value::fromObject(w); + return Value::fromObject(w).asReturnedValue(); } static ReturnedValue call(Managed *, QV4::CallData *) { diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 9c9a2196c7..0744b18197 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -75,10 +75,10 @@ struct DelegateModelGroupFunction: QV4::FunctionObject isBuiltinFunction = true; } - static QV4::Value construct(QV4::Managed *m, QV4::CallData *) + static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *) { m->engine()->current->throwTypeError(); - return QV4::Value::undefinedValue(); + return QV4::Value::undefinedValue().asReturnedValue(); } static QV4::ReturnedValue call(QV4::Managed *that, QV4::CallData *callData) |