Use ReturnedValue for Managed::construct()
authorLars Knoll <lars.knoll@digia.com>
Wed, 11 Sep 2013 13:09:25 +0000 (15:09 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 18 Sep 2013 11:13:30 +0000 (13:13 +0200)
Change-Id: I9e702d60c4e1b7ba19a699ff7a8d53876d6cd5f7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
25 files changed:
src/qml/jsapi/qjsvalue.cpp
src/qml/jsruntime/qv4arrayobject.cpp
src/qml/jsruntime/qv4arrayobject_p.h
src/qml/jsruntime/qv4booleanobject.cpp
src/qml/jsruntime/qv4booleanobject_p.h
src/qml/jsruntime/qv4dateobject.cpp
src/qml/jsruntime/qv4dateobject_p.h
src/qml/jsruntime/qv4errorobject.cpp
src/qml/jsruntime/qv4errorobject_p.h
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4functionobject_p.h
src/qml/jsruntime/qv4managed.cpp
src/qml/jsruntime/qv4managed_p.h
src/qml/jsruntime/qv4numberobject.cpp
src/qml/jsruntime/qv4numberobject_p.h
src/qml/jsruntime/qv4objectproto.cpp
src/qml/jsruntime/qv4objectproto_p.h
src/qml/jsruntime/qv4regexpobject.cpp
src/qml/jsruntime/qv4regexpobject_p.h
src/qml/jsruntime/qv4runtime.cpp
src/qml/jsruntime/qv4stringobject.cpp
src/qml/jsruntime/qv4stringobject_p.h
src/qml/jsruntime/qv4value_p.h
src/qml/qml/qqmlxmlhttprequest.cpp
src/qml/types/qqmldelegatemodel.cpp

index 7325cf8..eb2390f 100644 (file)
@@ -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);
index d0eae3d..280062e 100644 (file)
@@ -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)
index e8a8ddd..33c32f3 100644 (file)
@@ -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:
index aa5ebbd..fc76830 100644 (file)
@@ -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)
index 7cdd2d7..6a04cb4 100644 (file)
@@ -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:
index 01325ae..c2a15b8 100644 (file)
@@ -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 *)
index eff47e6..84748f2 100644 (file)
@@ -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:
index a029663..90b4189 100644 (file)
@@ -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)
index 7ccb9cb..a9eab58 100644 (file)
@@ -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;
index cb5d4c2..475874c 100644 (file)
@@ -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);
index bad62af..bc5bc5c 100644 (file)
@@ -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;
index 1a86889..711c7cf 100644 (file)
@@ -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();
 }
index a71ee71..44d809c 100644 (file)
@@ -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);
index 2c5961f..0f62a68 100644 (file)
@@ -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)
index a6e622e..a024b7f 100644 (file)
@@ -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:
index b851cc3..37becf8 100644 (file)
@@ -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)
index 06f88db..a8294d2 100644 (file)
@@ -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:
index 90ab558..4ad8c4a 100644 (file)
@@ -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;
index cbf185e..e95f362 100644 (file)
@@ -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:
index 283246d..a625795 100644 (file)
@@ -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)
index 9faa1eb..8df40ea 100644 (file)
@@ -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);
index 702900b..42c2a20 100644 (file)
@@ -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:
index ecd0c31..663e0aa 100644 (file)
@@ -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) {
index 52e959f..849e226 100644 (file)
@@ -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 *) {
index 9c9a219..0744b18 100644 (file)
@@ -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)