diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-10-20 14:50:19 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-07 09:00:23 +0000 |
commit | 7287690a41ab762c0c4efe02632efeaf3e0187b4 (patch) | |
tree | b5f1a04748b005119ee4d2f0693f50d80c8ec5c2 /src/qml/jsruntime/qv4functionobject.cpp | |
parent | fb84c9b4f860ee71d0584207f4c0f1d70d96755c (diff) |
Change signature of call/construct
Change-Id: I139a7a31651d9a2ea46ced88978ac4633294bc60
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 54896382fb..2ae2cc57e9 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -69,15 +69,17 @@ DEFINE_OBJECT_VTABLE(FunctionObject); Q_STATIC_ASSERT((Heap::FunctionObject::markTable & Heap::Object::markTable) == Heap::Object::markTable); -static ReturnedValue jsCallWrapper(const QV4::Managed *m, CallData *data) +static ReturnedValue jsCallWrapper(const QV4::FunctionObject *f, const Value *thisObject, const Value *argv, int argc) { - const FunctionObject *f = static_cast<const FunctionObject *>(m); - return f->vtable()->call(f, data); + Scope scope(f->engine()); + JSCall callData(scope, f->asReturnedValue(), argv, argc, thisObject); + return f->vtable()->call(f, callData); } -ReturnedValue jsConstructWrapper(const QV4::Managed *m, CallData *data) +ReturnedValue jsConstructWrapper(const QV4::FunctionObject *f, const Value *argv, int argc) { - const FunctionObject *f = static_cast<const FunctionObject *>(m); - return f->vtable()->construct(f, data); + Scope scope(f->engine()); + JSCall callData(scope, f->asReturnedValue(), argv, argc); + return f->vtable()->construct(f, callData); } @@ -97,8 +99,8 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto) { - jsCall = reinterpret_cast<const ObjectVTable *>(vtable())->call; - jsConstruct = reinterpret_cast<const ObjectVTable *>(vtable())->construct; + jsCall = jsCallWrapper; + jsConstruct = jsConstructWrapper; Object::init(); this->function = function; @@ -119,8 +121,8 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &nam void Heap::FunctionObject::init() { - jsCall = reinterpret_cast<const ObjectVTable *>(vtable())->call; - jsConstruct = reinterpret_cast<const ObjectVTable *>(vtable())->construct; + jsCall = jsCallWrapper; + jsConstruct = jsConstructWrapper; Object::init(); function = nullptr; @@ -349,7 +351,7 @@ ReturnedValue FunctionPrototype::method_call(const BuiltinFunction *b, CallData callData->args[i] = callData->args[i + 1]; --engine->jsStackTop; } - return static_cast<FunctionObject &>(callData->function).call(callData); + return static_cast<FunctionObject &>(callData->function).call(&callData->thisObject, callData->args, callData->argc()); } ReturnedValue FunctionPrototype::method_bind(const BuiltinFunction *b, CallData *callData) |