diff options
| author | Andrei Golubev <andrei.golubev@qt.io> | 2021-05-03 11:04:39 +0200 |
|---|---|---|
| committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-05-11 08:48:11 +0200 |
| commit | 2f9b62ea5961550e8d65897932a792da8b232a9c (patch) | |
| tree | 0fb4642f532e99423953deaed65d9cd3d337116f /src/qml/jsruntime/qv4engine.cpp | |
| parent | 0d5c2768808a5c0b77df9e0e4763cf7348b47b5f (diff) | |
QQmlEngine::executeRuntimeFunction: pass return value as input argument
Use the newer version of QV4::Function::call() that does not require
manual JSCallData setup and is more optimal for AOT function calls
Change-Id: I5a5e2d0477c0603b05b7213f1b2adcc34d156bf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4engine.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 033da47f7d..567ef03428 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -2098,28 +2098,27 @@ bool ExecutionEngine::diskCacheEnabled() const return (!disableDiskCache() && !debugger()) || forceDiskCache(); } -ReturnedValue ExecutionEngine::callInContext(Function *function, QObject *self, - QQmlRefPointer<QQmlContextData> ctxtdata, int argc, void **args, - QMetaType *types) +void ExecutionEngine::callInContext(Function *function, QObject *self, + QQmlRefPointer<QQmlContextData> ctxtdata, int argc, void **args, + QMetaType *types) { QV4::Scope scope(this); ExecutionContext *ctx = currentStackFrame ? currentContext() : scriptContext(); QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(ctx, ctxtdata, self)); QV4::ScopedValue selfValue(scope, QV4::QObjectWrapper::wrap(this, self)); - - if (!args) - return function->call(selfValue, nullptr, 0, qmlContext); + if (!args) { + Q_ASSERT(argc == 0); + void *dummyArgs[] = { nullptr }; + QMetaType dummyTypes[] = { QMetaType::fromType<void>() }; + function->call(selfValue, dummyArgs, dummyTypes, argc, qmlContext); + return; + } if (!types) // both args and types must be present - return Encode::undefined(); - - // use JSCallData to pass arguments into the function call - QV4::JSCallArguments jsCall(scope, argc); - QV4::populateJSCallArguments(this, jsCall, argc, args, types); + return; - QV4::CallData *callData = jsCall.callData(scope); - return function->call(selfValue, callData->argValues<QV4::Value>(), callData->argc(), - qmlContext); + // implicitly sets the return value, which is args[0] + function->call(selfValue, args, types, argc, qmlContext); } void ExecutionEngine::initQmlGlobalObject() |
