From 7287690a41ab762c0c4efe02632efeaf3e0187b4 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 20 Oct 2017 14:50:19 +0200 Subject: Change signature of call/construct Change-Id: I139a7a31651d9a2ea46ced88978ac4633294bc60 Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4functionobject.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/qml/jsruntime/qv4functionobject.cpp') 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(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(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(vtable())->call; - jsConstruct = reinterpret_cast(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(vtable())->call; - jsConstruct = reinterpret_cast(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(callData->function).call(callData); + return static_cast(callData->function).call(&callData->thisObject, callData->args, callData->argc()); } ReturnedValue FunctionPrototype::method_bind(const BuiltinFunction *b, CallData *callData) -- cgit v1.2.3