From: Lars Knoll Date: Sat, 22 Jun 2013 07:29:23 +0000 (+0200) Subject: Remove the context argument from Managed::construct X-Git-Tag: upstream/5.2.1~669^2~157 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c7581f1d03668df7b77e0076d128fd6a122d96b;p=platform%2Fupstream%2Fqtdeclarative.git Remove the context argument from Managed::construct Change-Id: I39f5c23de787da70cd4259b3cdcd56391ee0dc7b Reviewed-by: Simon Hausmann --- diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index aec4949..e1de67c 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1556,15 +1556,15 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject if (c->proto) c->proto->mark(); } - static Value construct(Managed *that, ExecutionContext *context, Value *, int) + static Value construct(Managed *that, Value *, int) { QQmlXMLHttpRequestCtor *ctor = that->as(); if (!ctor) - context->throwTypeError(); + that->engine()->current->throwTypeError(); - QV8Engine *engine = context->engine->v8Engine; + QV8Engine *engine = that->engine()->v8Engine; QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(engine, engine->networkAccessManager()); - QQmlXMLHttpRequestWrapper *w = new (context->engine->memoryManager) QQmlXMLHttpRequestWrapper(context->engine, r); + QQmlXMLHttpRequestWrapper *w = new (that->engine()->memoryManager) QQmlXMLHttpRequestWrapper(that->engine(), r); w->prototype = ctor->proto; return Value::fromObject(w); } diff --git a/src/qml/qml/v4/qv4arrayobject.cpp b/src/qml/qml/v4/qv4arrayobject.cpp index 4734fbc..6f3f36a 100644 --- a/src/qml/qml/v4/qv4arrayobject.cpp +++ b/src/qml/qml/v4/qv4arrayobject.cpp @@ -52,16 +52,17 @@ ArrayCtor::ArrayCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value ArrayCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc) +Value ArrayCtor::construct(Managed *m, Value *argv, int argc) { - ArrayObject *a = ctx->engine->newArrayObject(); + ExecutionEngine *v4 = m->engine(); + ArrayObject *a = v4->newArrayObject(); uint len; if (argc == 1 && argv[0].isNumber()) { bool ok; len = argv[0].asArrayLength(&ok); if (!ok) - ctx->throwRangeError(argv[0]); + v4->current->throwRangeError(argv[0]); if (len < 0x1000) a->arrayReserve(len); @@ -77,9 +78,9 @@ Value ArrayCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int ar return Value::fromObject(a); } -Value ArrayCtor::call(Managed *that, ExecutionContext *ctx, const Value &thisObject, Value *argv, int argc) +Value ArrayCtor::call(Managed *that, ExecutionContext *, const Value &, Value *argv, int argc) { - return construct(that, ctx, argv, argc); + return construct(that, argv, argc); } ArrayPrototype::ArrayPrototype(ExecutionContext *context) diff --git a/src/qml/qml/v4/qv4arrayobject_p.h b/src/qml/qml/v4/qv4arrayobject_p.h index 4201997..a1c9eb4 100644 --- a/src/qml/qml/v4/qv4arrayobject_p.h +++ b/src/qml/qml/v4/qv4arrayobject_p.h @@ -53,7 +53,7 @@ struct ArrayCtor: FunctionObject { ArrayCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4booleanobject.cpp b/src/qml/qml/v4/qv4booleanobject.cpp index 3395e79..049f577 100644 --- a/src/qml/qml/v4/qv4booleanobject.cpp +++ b/src/qml/qml/v4/qv4booleanobject.cpp @@ -51,10 +51,10 @@ BooleanCtor::BooleanCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value BooleanCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value BooleanCtor::construct(Managed *m, Value *args, int argc) { bool n = argc ? args[0].toBoolean() : false; - return Value::fromObject(ctx->engine->newBooleanObject(Value::fromBoolean(n))); + return Value::fromObject(m->engine()->newBooleanObject(Value::fromBoolean(n))); } Value BooleanCtor::call(Managed *, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc) diff --git a/src/qml/qml/v4/qv4booleanobject_p.h b/src/qml/qml/v4/qv4booleanobject_p.h index 79f5d4a..cffdf8a 100644 --- a/src/qml/qml/v4/qv4booleanobject_p.h +++ b/src/qml/qml/v4/qv4booleanobject_p.h @@ -53,7 +53,7 @@ struct BooleanCtor: FunctionObject { BooleanCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4dateobject.cpp b/src/qml/qml/v4/qv4dateobject.cpp index 83fdc2f..ab1c91a 100644 --- a/src/qml/qml/v4/qv4dateobject.cpp +++ b/src/qml/qml/v4/qv4dateobject.cpp @@ -659,7 +659,7 @@ DateCtor::DateCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value DateCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value DateCtor::construct(Managed *m, Value *args, int argc) { double t = 0; @@ -693,7 +693,7 @@ Value DateCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int arg t = TimeClip(UTC(t)); } - Object *d = ctx->engine->newDateObject(Value::fromDouble(t)); + Object *d = m->engine()->newDateObject(Value::fromDouble(t)); return Value::fromObject(d); } diff --git a/src/qml/qml/v4/qv4dateobject_p.h b/src/qml/qml/v4/qv4dateobject_p.h index dc94291..d58d5bd 100644 --- a/src/qml/qml/v4/qv4dateobject_p.h +++ b/src/qml/qml/v4/qv4dateobject_p.h @@ -63,7 +63,7 @@ struct DateCtor: FunctionObject { DateCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4errorobject.cpp b/src/qml/qml/v4/qv4errorobject.cpp index ffd3058..bee8f5c 100644 --- a/src/qml/qml/v4/qv4errorobject.cpp +++ b/src/qml/qml/v4/qv4errorobject.cpp @@ -235,14 +235,14 @@ ErrorCtor::ErrorCtor(ExecutionContext *scope, String *name) vtbl = &static_vtbl; } -Value ErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value ErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(ctx->engine->newErrorObject(argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(m->engine()->newErrorObject(argc ? args[0] : Value::undefinedValue())); } Value ErrorCtor::call(Managed *that, ExecutionContext *ctx, const Value &, Value *args, int argc) { - return that->construct(ctx, args, argc); + return that->construct(args, argc); } EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope) @@ -251,9 +251,9 @@ EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value EvalErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value EvalErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(new (ctx->engine->memoryManager) EvalErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) EvalErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue())); } RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope) @@ -262,9 +262,9 @@ RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value RangeErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value RangeErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(new (ctx->engine->memoryManager) RangeErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) RangeErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue())); } ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope) @@ -273,9 +273,9 @@ ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value ReferenceErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value ReferenceErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(new (ctx->engine->memoryManager) ReferenceErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) ReferenceErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue())); } SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope) @@ -284,9 +284,9 @@ SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value SyntaxErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value SyntaxErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(new (ctx->engine->memoryManager) SyntaxErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) SyntaxErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue())); } TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope) @@ -295,9 +295,9 @@ TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value TypeErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value TypeErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(new (ctx->engine->memoryManager) TypeErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) TypeErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue())); } URIErrorCtor::URIErrorCtor(ExecutionContext *scope) @@ -306,9 +306,9 @@ URIErrorCtor::URIErrorCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value URIErrorCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value URIErrorCtor::construct(Managed *m, Value *args, int argc) { - return Value::fromObject(new (ctx->engine->memoryManager) URIErrorObject(ctx->engine, argc ? args[0] : Value::undefinedValue())); + return Value::fromObject(new (m->engine()->memoryManager) URIErrorObject(m->engine(), argc ? args[0] : Value::undefinedValue())); } void ErrorPrototype::init(ExecutionEngine *engine, const Value &ctor, Object *obj) diff --git a/src/qml/qml/v4/qv4errorobject_p.h b/src/qml/qml/v4/qv4errorobject_p.h index a5a6bba..774e9e8 100644 --- a/src/qml/qml/v4/qv4errorobject_p.h +++ b/src/qml/qml/v4/qv4errorobject_p.h @@ -119,7 +119,7 @@ struct ErrorCtor: FunctionObject ErrorCtor(ExecutionContext *scope); ErrorCtor(ExecutionContext *scope, String *name); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: @@ -130,7 +130,7 @@ struct EvalErrorCtor: ErrorCtor { EvalErrorCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); protected: static const ManagedVTable static_vtbl; @@ -140,7 +140,7 @@ struct RangeErrorCtor: ErrorCtor { RangeErrorCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); protected: static const ManagedVTable static_vtbl; @@ -150,7 +150,7 @@ struct ReferenceErrorCtor: ErrorCtor { ReferenceErrorCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); protected: static const ManagedVTable static_vtbl; @@ -160,7 +160,7 @@ struct SyntaxErrorCtor: ErrorCtor { SyntaxErrorCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); protected: static const ManagedVTable static_vtbl; @@ -170,7 +170,7 @@ struct TypeErrorCtor: ErrorCtor { TypeErrorCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); protected: static const ManagedVTable static_vtbl; @@ -180,7 +180,7 @@ struct URIErrorCtor: ErrorCtor { URIErrorCtor(ExecutionContext *scope); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); protected: static const ManagedVTable static_vtbl; diff --git a/src/qml/qml/v4/qv4functionobject.cpp b/src/qml/qml/v4/qv4functionobject.cpp index a27ac16..96ea4ee 100644 --- a/src/qml/qml/v4/qv4functionobject.cpp +++ b/src/qml/qml/v4/qv4functionobject.cpp @@ -94,7 +94,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, String *name) Value FunctionObject::newInstance() { - return construct(internalClass->engine->current, 0, 0); + return construct(0, 0); } bool FunctionObject::hasInstance(Managed *that, const Value &value) @@ -122,12 +122,13 @@ bool FunctionObject::hasInstance(Managed *that, const Value &value) return false; } -Value FunctionObject::construct(Managed *that, ExecutionContext *context, Value *, int) +Value FunctionObject::construct(Managed *that, Value *, int) { FunctionObject *f = static_cast(that); + ExecutionEngine *v4 = f->engine(); - Object *obj = context->engine->newObject(); - Value proto = f->get(context->engine->id_prototype); + Object *obj = v4->newObject(); + Value proto = f->get(v4->id_prototype); if (proto.isObject()) obj->prototype = proto.objectValue(); return Value::fromObject(obj); @@ -165,11 +166,12 @@ FunctionCtor::FunctionCtor(ExecutionContext *scope) } // 15.3.2 -Value FunctionCtor::construct(Managed *that, ExecutionContext *ctx, Value *args, int argc) +Value FunctionCtor::construct(Managed *that, Value *args, int argc) { FunctionCtor *f = static_cast(that); - MemoryManager::GCBlocker gcBlocker(ctx->engine->memoryManager); + MemoryManager::GCBlocker gcBlocker(f->engine()->memoryManager); + ExecutionContext *ctx = f->engine()->current; QString arguments; QString body; if (argc > 0) { @@ -191,28 +193,29 @@ Value FunctionCtor::construct(Managed *that, ExecutionContext *ctx, Value *args, const bool parsed = parser.parseExpression(); if (!parsed) - ctx->throwSyntaxError(0); + f->engine()->current->throwSyntaxError(0); using namespace QQmlJS::AST; FunctionExpression *fe = QQmlJS::AST::cast(parser.rootNode()); + ExecutionEngine *v4 = f->engine(); if (!fe) - ctx->throwSyntaxError(0); + v4->current->throwSyntaxError(0); QQmlJS::V4IR::Module module; - QQmlJS::Codegen cg(ctx, f->strictMode); + QQmlJS::Codegen cg(v4->current, f->strictMode); QQmlJS::V4IR::Function *irf = cg(QString(), function, fe, &module); - QScopedPointer isel(ctx->engine->iselFactory->create(ctx->engine, &module)); + QScopedPointer isel(v4->iselFactory->create(v4, &module)); QV4::Function *vmf = isel->vmFunction(irf); - return Value::fromObject(ctx->engine->newScriptFunction(ctx->engine->rootContext, vmf)); + return Value::fromObject(v4->newScriptFunction(v4->rootContext, vmf)); } // 15.3.1: This is equivalent to new Function(...) Value FunctionCtor::call(Managed *that, ExecutionContext *context, const Value &thisObject, Value *args, int argc) { - return construct(that, context, args, argc); + return construct(that, args, argc); } FunctionPrototype::FunctionPrototype(ExecutionContext *ctx) @@ -346,17 +349,19 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) } } -Value ScriptFunction::construct(Managed *that, ExecutionContext *context, Value *args, int argc) +Value ScriptFunction::construct(Managed *that, Value *args, int argc) { ScriptFunction *f = static_cast(that); assert(f->function->code); - Object *obj = context->engine->newObject(); - Value proto = f->get(context->engine->id_prototype); + ExecutionEngine *v4 = f->engine(); + Object *obj = v4->newObject(); + Value proto = f->get(v4->id_prototype); if (proto.isObject()) obj->prototype = proto.objectValue(); + ExecutionContext *context = v4->current; quintptr stackSpace[stackContextSize/sizeof(quintptr)]; - ExecutionContext *ctx = context->engine->newCallContext(stackSpace, f, Value::fromObject(obj), args, argc); + ExecutionContext *ctx = v4->newCallContext(stackSpace, f, Value::fromObject(obj), args, argc); Value result; try { @@ -410,9 +415,9 @@ BuiltinFunctionOld::BuiltinFunctionOld(ExecutionContext *scope, String *name, Va isBuiltinFunction = true; } -Value BuiltinFunctionOld::construct(Managed *, ExecutionContext *ctx, Value *, int) +Value BuiltinFunctionOld::construct(Managed *f, Value *, int) { - ctx->throwTypeError(); + f->engine()->current->throwTypeError(); return Value::undefinedValue(); } @@ -517,14 +522,14 @@ Value BoundFunction::call(Managed *that, ExecutionContext *context, const Value return f->target->call(context, f->boundThis, newArgs, f->boundArgs.size() + argc); } -Value BoundFunction::construct(Managed *that, ExecutionContext *context, Value *args, int argc) +Value BoundFunction::construct(Managed *that, Value *args, int argc) { BoundFunction *f = static_cast(that); Value *newArgs = static_cast(alloca(sizeof(Value)*(f->boundArgs.size() + argc))); memcpy(newArgs, f->boundArgs.constData(), f->boundArgs.size()*sizeof(Value)); memcpy(newArgs + f->boundArgs.size(), args, argc*sizeof(Value)); - return f->target->construct(context, newArgs, f->boundArgs.size() + argc); + return f->target->construct(newArgs, f->boundArgs.size() + argc); } bool BoundFunction::hasInstance(Managed *that, const Value &value) diff --git a/src/qml/qml/v4/qv4functionobject_p.h b/src/qml/qml/v4/qv4functionobject_p.h index 09b31c0..9616052 100644 --- a/src/qml/qml/v4/qv4functionobject_p.h +++ b/src/qml/qml/v4/qv4functionobject_p.h @@ -114,13 +114,10 @@ struct Q_QML_EXPORT FunctionObject: Object { Value newInstance(); - static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *that, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); - inline Value construct(ExecutionContext *context, Value *args, int argc) { - return vtbl->construct(this, context, args, argc); - } inline Value construct(Value *args, int argc) { - return vtbl->construct(this, engine()->current, args, argc); + return vtbl->construct(this, args, argc); } inline Value call(ExecutionContext *context, const Value &thisObject, Value *args, int argc) { return vtbl->call(this, context, thisObject, args, argc); @@ -139,7 +136,7 @@ struct FunctionCtor: FunctionObject { FunctionCtor(ExecutionContext *scope); - static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *that, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: @@ -162,7 +159,7 @@ struct BuiltinFunctionOld: FunctionObject { BuiltinFunctionOld(ExecutionContext *scope, String *name, Value (*code)(SimpleCallContext *)); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: @@ -185,9 +182,9 @@ struct IndexedBuiltinFunction: FunctionObject isBuiltinFunction = true; } - static Value construct(Managed *, ExecutionContext *ctx, Value *, int) + static Value construct(Managed *m, Value *, int) { - ctx->throwTypeError(); + m->engine()->current->throwTypeError(); return Value::undefinedValue(); } @@ -198,7 +195,7 @@ struct IndexedBuiltinFunction: FunctionObject struct ScriptFunction: FunctionObject { ScriptFunction(ExecutionContext *scope, Function *function); - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: @@ -214,7 +211,7 @@ struct BoundFunction: FunctionObject { ~BoundFunction() {} - static Value construct(Managed *, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); static const ManagedVTable static_vtbl; diff --git a/src/qml/qml/v4/qv4managed.cpp b/src/qml/qml/v4/qv4managed.cpp index 6372719..545f88b 100644 --- a/src/qml/qml/v4/qv4managed.cpp +++ b/src/qml/qml/v4/qv4managed.cpp @@ -176,9 +176,9 @@ bool Managed::hasInstance(Managed *m, const Value &) m->engine()->current->throwTypeError(); } -Value Managed::construct(Managed *, ExecutionContext *context, Value *, int) +Value Managed::construct(Managed *m, Value *, int) { - context->throwTypeError(); + m->engine()->current->throwTypeError(); } Value Managed::call(Managed *, ExecutionContext *context, const Value &, Value *, int) diff --git a/src/qml/qml/v4/qv4managed_p.h b/src/qml/qml/v4/qv4managed_p.h index 2f88478..39b7f0c 100644 --- a/src/qml/qml/v4/qv4managed_p.h +++ b/src/qml/qml/v4/qv4managed_p.h @@ -100,7 +100,7 @@ struct GCDeletable struct ManagedVTable { Value (*call)(Managed *, ExecutionContext *context, const Value &thisObject, Value *args, int argc); - Value (*construct)(Managed *, ExecutionContext *context, Value *args, int argc); + Value (*construct)(Managed *, Value *args, int argc); void (*markObjects)(Managed *); void (*destroy)(Managed *); void (*collectDeletables)(Managed *, GCDeletable **deletable); @@ -260,7 +260,7 @@ public: inline bool hasInstance(const Value &v) { return vtbl->hasInstance(this, v); } - Value construct(ExecutionContext *context, Value *args, int argc); + Value construct(Value *args, int argc); Value call(ExecutionContext *context, const Value &thisObject, Value *args, int argc); Value get(String *name, bool *hasProperty = 0); Value getIndexed(uint index, bool *hasProperty = 0); @@ -289,7 +289,7 @@ public: static void destroy(Managed *that) { that->_data = 0; } static bool hasInstance(Managed *that, const Value &value); - static Value construct(Managed *, ExecutionContext *context, Value *, int); + static Value construct(Managed *m, Value *, int); static Value call(Managed *, ExecutionContext *, const Value &, Value *, int); static void getLookup(Managed *m, Lookup *, Value *); static void setLookup(Managed *m, Lookup *l, const Value &v); diff --git a/src/qml/qml/v4/qv4numberobject.cpp b/src/qml/qml/v4/qv4numberobject.cpp index 6bd03ab..2e5ed49 100644 --- a/src/qml/qml/v4/qv4numberobject.cpp +++ b/src/qml/qml/v4/qv4numberobject.cpp @@ -56,10 +56,10 @@ NumberCtor::NumberCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value NumberCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc) +Value NumberCtor::construct(Managed *m, Value *args, int argc) { double d = argc ? args[0].toNumber() : 0.; - return Value::fromObject(ctx->engine->newNumberObject(Value::fromDouble(d))); + return Value::fromObject(m->engine()->newNumberObject(Value::fromDouble(d))); } Value NumberCtor::call(Managed *m, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc) diff --git a/src/qml/qml/v4/qv4numberobject_p.h b/src/qml/qml/v4/qv4numberobject_p.h index f7f5ed7..2cc3c0b 100644 --- a/src/qml/qml/v4/qv4numberobject_p.h +++ b/src/qml/qml/v4/qv4numberobject_p.h @@ -53,7 +53,7 @@ struct NumberCtor: FunctionObject { NumberCtor(ExecutionContext *scope); - static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *that, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4objectproto.cpp b/src/qml/qml/v4/qv4objectproto.cpp index 1d6eda4..b1d1a9e 100644 --- a/src/qml/qml/v4/qv4objectproto.cpp +++ b/src/qml/qml/v4/qv4objectproto.cpp @@ -79,17 +79,18 @@ ObjectCtor::ObjectCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value ObjectCtor::construct(Managed *that, ExecutionContext *ctx, Value *args, int argc) +Value ObjectCtor::construct(Managed *that, Value *args, int argc) { ObjectCtor *ctor = static_cast(that); + ExecutionEngine *v4 = that->engine(); if (!argc || args[0].isUndefined() || args[0].isNull()) { - Object *obj = ctx->engine->newObject(); - Value proto = ctor->get(ctx->engine->id_prototype); + Object *obj = v4->newObject(); + Value proto = ctor->get(v4->id_prototype); if (proto.isObject()) obj->prototype = proto.objectValue(); return Value::fromObject(obj); } - return __qmljs_to_object(ctx, args[0]); + return __qmljs_to_object(v4->current, args[0]); } Value ObjectCtor::call(Managed *, ExecutionContext *ctx, const Value &/*thisObject*/, Value *args, int argc) diff --git a/src/qml/qml/v4/qv4objectproto_p.h b/src/qml/qml/v4/qv4objectproto_p.h index 84bc715..e16f554 100644 --- a/src/qml/qml/v4/qv4objectproto_p.h +++ b/src/qml/qml/v4/qv4objectproto_p.h @@ -53,7 +53,7 @@ struct ObjectCtor: FunctionObject { ObjectCtor(ExecutionContext *scope); - static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *that, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4regexpobject.cpp b/src/qml/qml/v4/qv4regexpobject.cpp index fc6ffd2..a346f9e 100644 --- a/src/qml/qml/v4/qv4regexpobject.cpp +++ b/src/qml/qml/v4/qv4regexpobject.cpp @@ -218,10 +218,11 @@ RegExpCtor::RegExpCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value RegExpCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc) +Value RegExpCtor::construct(Managed *m, Value *argv, int argc) { Value r = argc > 0 ? argv[0] : Value::undefinedValue(); Value f = argc > 1 ? argv[1] : Value::undefinedValue(); + ExecutionContext *ctx = m->engine()->current; if (RegExpObject *re = r.as()) { if (!f.isUndefined()) ctx->throwTypeError(); @@ -268,7 +269,7 @@ Value RegExpCtor::call(Managed *that, ExecutionContext *ctx, const Value &thisOb return argv[0]; } - return construct(that, ctx, argv, argc); + return construct(that, argv, argc); } void RegExpPrototype::init(ExecutionContext *ctx, const Value &ctor) @@ -346,7 +347,7 @@ Value RegExpPrototype::method_compile(SimpleCallContext *ctx) if (!r) ctx->throwTypeError(); - RegExpObject *re = ctx->engine->regExpCtor.asFunctionObject()->construct(ctx, ctx->arguments, ctx->argumentCount).as(); + RegExpObject *re = ctx->engine->regExpCtor.asFunctionObject()->construct(ctx->arguments, ctx->argumentCount).as(); r->value = re->value; r->global = re->global; diff --git a/src/qml/qml/v4/qv4regexpobject_p.h b/src/qml/qml/v4/qv4regexpobject_p.h index 8589d1e..7fb520c 100644 --- a/src/qml/qml/v4/qv4regexpobject_p.h +++ b/src/qml/qml/v4/qv4regexpobject_p.h @@ -98,7 +98,7 @@ struct RegExpCtor: FunctionObject { RegExpCtor(ExecutionContext *scope); - static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4runtime.cpp b/src/qml/qml/v4/qv4runtime.cpp index 774abb6..22e43ca 100644 --- a/src/qml/qml/v4/qv4runtime.cpp +++ b/src/qml/qml/v4/qv4runtime.cpp @@ -889,7 +889,7 @@ void __qmljs_construct_global_lookup(ExecutionContext *context, Value *result, u l->globalGetter(l, context, &func); if (Object *f = func.asObject()) { - Value res = f->construct(context, args, argc); + Value res = f->construct(args, argc); if (result) *result = res; return; @@ -908,7 +908,7 @@ void __qmljs_construct_activation_property(ExecutionContext *context, Value *res void __qmljs_construct_value(ExecutionContext *context, Value *result, const Value &func, Value *args, int argc) { if (Object *f = func.asObject()) { - Value res = f->construct(context, args, argc); + Value res = f->construct(args, argc); if (result) *result = res; return; @@ -923,7 +923,7 @@ void __qmljs_construct_property(ExecutionContext *context, Value *result, const Value func = thisObject->get(name); if (Object *f = func.asObject()) { - Value res = f->construct(context, args, argc); + Value res = f->construct(args, argc); if (result) *result = res; return; diff --git a/src/qml/qml/v4/qv4stringobject.cpp b/src/qml/qml/v4/qv4stringobject.cpp index 350a2c4..8845e63 100644 --- a/src/qml/qml/v4/qv4stringobject.cpp +++ b/src/qml/qml/v4/qv4stringobject.cpp @@ -149,14 +149,14 @@ StringCtor::StringCtor(ExecutionContext *scope) vtbl = &static_vtbl; } -Value StringCtor::construct(Managed *, ExecutionContext *ctx, Value *argv, int argc) +Value StringCtor::construct(Managed *m, Value *argv, int argc) { Value value; if (argc) - value = Value::fromString(argv[0].toString(ctx)); + value = Value::fromString(argv[0].toString(m->engine()->current)); else - value = Value::fromString(ctx, QString()); - return Value::fromObject(ctx->engine->newStringObject(value)); + value = Value::fromString(m->engine()->current, QString()); + return Value::fromObject(m->engine()->newStringObject(value)); } Value StringCtor::call(Managed *, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc) @@ -342,7 +342,7 @@ Value StringPrototype::method_match(SimpleCallContext *context) Value regexp = context->argumentCount ? context->arguments[0] : Value::undefinedValue(); RegExpObject *rx = regexp.as(); if (!rx) - rx = context->engine->regExpCtor.asFunctionObject()->construct(context, ®exp, 1).as(); + rx = context->engine->regExpCtor.asFunctionObject()->construct(®exp, 1).as(); if (!rx) // ### CHECK @@ -530,7 +530,7 @@ Value StringPrototype::method_search(SimpleCallContext *ctx) Value regExpValue = ctx->argument(0); RegExpObject *regExp = regExpValue.as(); if (!regExp) { - regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(ctx, ®ExpValue, 1); + regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(®ExpValue, 1); regExp = regExpValue.as(); } uint* matchOffsets = (uint*)alloca(regExp->value->captureCount() * 2 * sizeof(uint)); diff --git a/src/qml/qml/v4/qv4stringobject_p.h b/src/qml/qml/v4/qv4stringobject_p.h index 442cfa0..1a7a466 100644 --- a/src/qml/qml/v4/qv4stringobject_p.h +++ b/src/qml/qml/v4/qv4stringobject_p.h @@ -69,7 +69,7 @@ struct StringCtor: FunctionObject { StringCtor(ExecutionContext *scope); - static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc); + static Value construct(Managed *m, Value *args, int argc); static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int); protected: diff --git a/src/qml/qml/v4/qv4value_p.h b/src/qml/qml/v4/qv4value_p.h index c9c4bba..2441a9a 100644 --- a/src/qml/qml/v4/qv4value_p.h +++ b/src/qml/qml/v4/qv4value_p.h @@ -553,8 +553,8 @@ inline ErrorObject *Value::asErrorObject() const } // ### -inline Value Managed::construct(ExecutionContext *context, Value *args, int argc) { - return vtbl->construct(this, context, args, argc); +inline Value Managed::construct(Value *args, int argc) { + return vtbl->construct(this, args, argc); } inline Value Managed::call(ExecutionContext *context, const Value &thisObject, Value *args, int argc) { return vtbl->call(this, context, thisObject, args, argc); diff --git a/src/qml/qml/v8/qjsvalue.cpp b/src/qml/qml/v8/qjsvalue.cpp index 036cdc8..a21a1cc 100644 --- a/src/qml/qml/v8/qjsvalue.cpp +++ b/src/qml/qml/v8/qjsvalue.cpp @@ -619,7 +619,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) Value result; QV4::ExecutionContext *ctx = engine->current; try { - result = f->construct(ctx, arguments.data(), arguments.size()); + result = f->construct(arguments.data(), arguments.size()); } catch (Exception &e) { e.accept(ctx); result = e.value(); diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 8926615..bbac92a 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -75,9 +75,9 @@ struct DelegateModelGroupFunction: QV4::FunctionObject isBuiltinFunction = true; } - static QV4::Value construct(QV4::Managed *, QV4::ExecutionContext *ctx, QV4::Value *, int) + static QV4::Value construct(QV4::Managed *m, QV4::Value *, int) { - ctx->throwTypeError(); + m->engine()->current->throwTypeError(); return QV4::Value::undefinedValue(); }