aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2021-02-19 11:10:51 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2021-02-19 18:12:29 +0100
commit3b91f3a69a2679e69d056a53e9c7edc7e6d552a6 (patch)
tree1f78b3f3bdac88ae74ad1a2e0cada101d7991cd2 /src/qml
parent1a61ff978661cb2eb536dec4858158386320c2b4 (diff)
QV4::populateJSCallArguments: Use v4->metaTypeToJS
It appears that nowadays v4->metaTypeToJS handles QVariant and QObject derived classes just fine, and in exactly the same way as the custom code in populateJSCallArguments did. Task-number: QTBUG-82931 Change-Id: Ic5f97dfc3296a409fdd6a1fcb78d3b9bdba5f3a1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4engine.cpp3
-rw-r--r--src/qml/jsruntime/qv4jscall.cpp23
-rw-r--r--src/qml/jsruntime/qv4jscall_p.h2
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp2
4 files changed, 5 insertions, 25 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index fe35fe6193..38a21f87b5 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -2071,8 +2071,7 @@ ReturnedValue ExecutionEngine::callInContext(Function *function, QObject *self,
// use JSCallData to pass arguments into the function call
QV4::JSCallData jsCall(scope, types[0]);
- QQmlEnginePrivate *ep = QQmlEnginePrivate::get(m_qmlEngine);
- QV4::populateJSCallArguments(ep, this, jsCall, args, types);
+ QV4::populateJSCallArguments(this, jsCall, args, types);
QV4::CallData *callData = jsCall->callData();
return function->call(selfValue, callData->argValues<QV4::Value>(), callData->argc(),
diff --git a/src/qml/jsruntime/qv4jscall.cpp b/src/qml/jsruntime/qv4jscall.cpp
index ce91248f80..5ffdc40879 100644
--- a/src/qml/jsruntime/qv4jscall.cpp
+++ b/src/qml/jsruntime/qv4jscall.cpp
@@ -49,32 +49,13 @@ QT_BEGIN_NAMESPACE
Sets the arguments of JSCallData from type erased \a args based on type
information provided by \a types
*/
-void QV4::populateJSCallArguments(QQmlEnginePrivate *ep, ExecutionEngine *v4, JSCallData &jsCall,
+void QV4::populateJSCallArguments(ExecutionEngine *v4, JSCallData &jsCall,
void **args, int *types)
{
const int argCount = types ? types[0] : 0;
for (int ii = 0; ii < argCount; ++ii) {
int type = types[ii + 1];
- //### ideally we would use metaTypeToJS, however it currently gives different results
- // for several cases (such as QVariant type and QObject-derived types)
- // args[ii] = v4->metaTypeToJS(type, args[ii + 1]);
- if (type == qMetaTypeId<QJSValue>()) {
- jsCall.args[ii] = QJSValuePrivate::convertToReturnedValue(
- v4, *reinterpret_cast<QJSValue *>(args[ii + 1]));
- } else if (type == QMetaType::QVariant) {
- jsCall.args[ii] = v4->fromVariant(*((QVariant *)args[ii + 1]));
- } else if (type == QMetaType::Int) {
- //### optimization. Can go away if we switch to metaTypeToJS, or be expanded otherwise
- jsCall.args[ii] = QV4::Value::fromInt32(*reinterpret_cast<const int *>(args[ii + 1]));
- } else if (ep->isQObject(type)) {
- if (!*reinterpret_cast<void *const *>(args[ii + 1]))
- jsCall.args[ii] = QV4::Value::nullValue();
- else
- jsCall.args[ii] = QV4::QObjectWrapper::wrap(
- v4, *reinterpret_cast<QObject *const *>(args[ii + 1]));
- } else {
- jsCall.args[ii] = v4->fromVariant(QVariant(QMetaType(type), args[ii + 1]));
- }
+ jsCall.args[ii] = v4->metaTypeToJS(type, args[ii + 1]);
}
}
diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h
index ffc666d1e5..e0b47c76e3 100644
--- a/src/qml/jsruntime/qv4jscall_p.h
+++ b/src/qml/jsruntime/qv4jscall_p.h
@@ -112,7 +112,7 @@ ReturnedValue FunctionObject::call(const JSCallData &data) const
return call(data.thisObject, data.args, data.argc);
}
-void populateJSCallArguments(QQmlEnginePrivate *ep, ExecutionEngine *v4, JSCallData &jsCall,
+void populateJSCallArguments(ExecutionEngine *v4, JSCallData &jsCall,
void **args, int *types);
struct ScopedStackFrame {
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 1bc0efc5d9..4347c96240 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -196,7 +196,7 @@ void QQmlBoundSignalExpression::evaluate(void **a)
int argCount = argsTypes ? *argsTypes : 0;
QV4::JSCallData jsCall(scope, argCount);
- populateJSCallArguments(ep, v4, jsCall, a, argsTypes);
+ populateJSCallArguments(v4, jsCall, a, argsTypes);
QQmlJavaScriptExpression::evaluate(jsCall.callData(), nullptr);