aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-12-02 10:18:34 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-12-02 13:06:27 +0100
commitd6fb8791ab8734455398ac556fd035dc08a1a0a6 (patch)
tree05fc627383415f4fed090f078201b3678c2453ec
parent8a555cc22afb93dbe0e0da83f211c6e4f032bd09 (diff)
Let AOT-compiled functions modify their arguments
It allows for more natural looking generated code and there is no downside. The arguments are specially prepared for the call anyway. Change-Id: I8437e93adb1c67db1b53fbdb29cbea10f6ef278f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp2
-rw-r--r--src/qml/qml/qqmlprivate.h2
-rw-r--r--src/qmlcompiler/qqmljscompiler.cpp8
3 files changed, 6 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 98a6d94ecc..4815f5ad91 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -491,7 +491,7 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
Scoped<QmlContext> qmlContext(scope, engine->qmlContext());
function->aotFunction->functionPtr(
qmlContext->qmlContext()->asQQmlContext(), qmlContext->qmlScope(),
- returnValue, const_cast<const void **>(argumentPtrs)); // We're adding const here
+ returnValue, argumentPtrs);
if (returnValue) {
result = engine->metaTypeToJS(returnType.id(), returnValue);
diff --git a/src/qml/qml/qqmlprivate.h b/src/qml/qml/qqmlprivate.h
index 654ae35c57..6d0c176bdd 100644
--- a/src/qml/qml/qqmlprivate.h
+++ b/src/qml/qml/qqmlprivate.h
@@ -594,7 +594,7 @@ namespace QQmlPrivate
QMetaType returnType;
QList<QMetaType> argumentTypes;
void (*functionPtr)(QQmlContext *context, QObject *scopeObject, void *resultPtr,
- const void **arguments);
+ void **arguments);
};
struct CachedQmlUnit {
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp
index 0990e0c896..bf4dc55b6d 100644
--- a/src/qmlcompiler/qqmljscompiler.cpp
+++ b/src/qmlcompiler/qqmljscompiler.cpp
@@ -464,8 +464,8 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile
writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = { { 0, QMetaType::fromType<void>(), {}, nullptr } };");
} else {
writeStr(R"(template <typename Binding>
- void wrapCall(QQmlContext *context, QObject *scopeObject, void *dataPtr, const void **argumentsPtr, Binding &&binding) {
- using return_type = std::invoke_result_t<Binding, QQmlContext*, QObject*, const void **>;
+ void wrapCall(QQmlContext *context, QObject *scopeObject, void *dataPtr, void **argumentsPtr, Binding &&binding) {
+ using return_type = std::invoke_result_t<Binding, QQmlContext*, QObject*, void **>;
if constexpr (std::is_same_v<return_type, void>) {
Q_UNUSED(dataPtr);
binding(context, scopeObject, argumentsPtr);
@@ -476,8 +476,8 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile
writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = {");
- QString header = QStringLiteral("[](QQmlContext *context, QObject *scopeObject, void *dataPtr, const void **argumentsPtr) {\n");
- header += QStringLiteral("wrapCall(context, scopeObject, dataPtr, argumentsPtr, [](QQmlContext *context, QObject *scopeObject, const void **argumentsPtr) {");
+ QString header = QStringLiteral("[](QQmlContext *context, QObject *scopeObject, void *dataPtr, void **argumentsPtr) {\n");
+ header += QStringLiteral("wrapCall(context, scopeObject, dataPtr, argumentsPtr, [](QQmlContext *context, QObject *scopeObject, void **argumentsPtr) {");
header += QStringLiteral("Q_UNUSED(context); Q_UNUSED(scopeObject); Q_UNUSED(argumentsPtr);\n");
QString footer = QStringLiteral("});}\n");