diff options
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 26 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 4 |
3 files changed, 35 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 716678d2f8..54896382fb 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -69,8 +69,24 @@ 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) +{ + const FunctionObject *f = static_cast<const FunctionObject *>(m); + return f->vtable()->call(f, data); +} +ReturnedValue jsConstructWrapper(const QV4::Managed *m, CallData *data) +{ + const FunctionObject *f = static_cast<const FunctionObject *>(m); + return f->vtable()->construct(f, data); +} + + + void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto) { + jsCall = jsCallWrapper; + jsConstruct = jsConstructWrapper; + Object::init(); function = nullptr; this->scope.set(scope->engine(), scope->d()); @@ -81,6 +97,9 @@ 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; + Object::init(); this->function = function; function->compilationUnit->addref(); @@ -100,6 +119,9 @@ 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; + Object::init(); function = nullptr; this->scope.set(internalClass->engine, internalClass->engine->rootContext()->d()); @@ -441,10 +463,6 @@ ReturnedValue BuiltinFunction::construct(const Managed *f, CallData *) ReturnedValue BuiltinFunction::call(const Managed *that, CallData *callData) { const BuiltinFunction *f = static_cast<const BuiltinFunction *>(that); - ExecutionEngine *v4 = f->engine(); - if (v4->hasException) - return Encode::undefined(); - return f->d()->code(f, callData); } diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index d76655179d..36f873e1a2 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -64,11 +64,17 @@ namespace QV4 { struct BuiltinFunction; struct IndexedBuiltinFunction; +typedef ReturnedValue (*jsCallFunction)(const Managed *, CallData *data); +typedef ReturnedValue (*jsConstructFunction)(const Managed *, CallData *data); + namespace Heap { + #define FunctionObjectMembers(class, Member) \ Member(class, Pointer, ExecutionContext *, scope) \ - Member(class, NoMark, Function *, function) + Member(class, NoMark, Function *, function) \ + Member(class, NoMark, jsCallFunction, jsCall) \ + Member(class, NoMark, jsConstructFunction, jsConstruct) DECLARE_HEAP_OBJECT(FunctionObject, Object) { DECLARE_MARK_TABLE(FunctionObject); @@ -149,8 +155,12 @@ struct Q_QML_EXPORT FunctionObject: Object { void init(String *name, bool createProto); - using Object::construct; - using Object::call; + ReturnedValue construct(CallData *callData) { + return d()->jsConstruct(this, callData); + } + ReturnedValue call(CallData *callData) { + return d()->jsCall(this, callData); + } static ReturnedValue construct(const Managed *that, CallData *); static ReturnedValue call(const Managed *that, CallData *d); diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 2bb230412d..473b872747 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -427,10 +427,6 @@ public: ReturnedValue instanceOf(const Value &var) const { return vtable()->instanceOf(this, var); } - inline ReturnedValue construct(CallData *d) const - { return vtable()->construct(this, d); } - inline ReturnedValue call(CallData *d) const - { return vtable()->call(this, d); } protected: static ReturnedValue construct(const Managed *m, CallData *); static ReturnedValue call(const Managed *m, CallData *); |