diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-10-20 11:06:15 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-11-07 09:00:19 +0000 |
commit | fb84c9b4f860ee71d0584207f4c0f1d70d96755c (patch) | |
tree | e813c93c54c2cfb93ab0894de25740a093ca87ea /src/qml/jsruntime/qv4functionobject.cpp | |
parent | 07980a034609383e79132c9819b682c88d343a95 (diff) |
Add functions pointers for call/construct to FunctionObject
This will allow us to avoid one level of indirection when
calling js functions in the future.
Change-Id: I814b72d18adb5a5580c11053e53b582549b629fc
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 26 |
1 files changed, 22 insertions, 4 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); } |