aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljscompiler.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-04-19 11:19:01 +0200
committerUlf Hermann <ulf.hermann@qt.io>2024-04-24 16:49:06 +0200
commitb7f4779ccbf39f063ff38f72aecaeaa8b58bc759 (patch)
tree550d7c1d10edec33a31876bc414690f926fbca02 /src/qmlcompiler/qqmljscompiler.cpp
parent5fdd8793c2adc7c2c93f5d02ef33044dc784afa4 (diff)
QmlCompiler: Perform return value assignment inside generated code
This is in preparation for using exact types and actually enforcing them. We shouldn't wrap the return value into a QVariant in order to then painstakingly unwrap it again. The generated code can already do the right thing. Task-number: QTBUG-119885 Change-Id: I13e517967ee982be717024a9abb74d5e02a185d6 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljscompiler.cpp')
-rw-r--r--src/qmlcompiler/qqmljscompiler.cpp28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp
index 2cc32fc63d..cca05380c9 100644
--- a/src/qmlcompiler/qqmljscompiler.cpp
+++ b/src/qmlcompiler/qqmljscompiler.cpp
@@ -460,29 +460,10 @@ bool qCompileJSFile(const QString &inputFileName, const QString &inputFileUrl, Q
QV4::CompiledData::SaveableUnitPointer(unit->unitData()), empty, &error->message);
}
-static const char *wrapCallCode = R"(
-template <typename Binding>
-void wrapCall(const QQmlPrivate::AOTCompiledContext *aotContext, void *dataPtr, void **argumentsPtr, Binding &&binding)
-{
- using return_type = std::invoke_result_t<Binding, const QQmlPrivate::AOTCompiledContext *, void **>;
- if constexpr (std::is_same_v<return_type, void>) {
- Q_UNUSED(dataPtr)
- binding(aotContext, argumentsPtr);
- } else {
- if (dataPtr) {
- *static_cast<return_type *>(dataPtr) = binding(aotContext, argumentsPtr);
- } else {
- binding(aotContext, argumentsPtr);
- }
- }
-}
-)";
-
static const char *funcHeaderCode = R"(
- [](const QQmlPrivate::AOTCompiledContext *context, void *data, void **argv) {
- wrapCall(context, data, argv, [](const QQmlPrivate::AOTCompiledContext *aotContext, void **argumentsPtr) {
+ [](const QQmlPrivate::AOTCompiledContext *aotContext, void **argv) {
Q_UNUSED(aotContext)
-Q_UNUSED(argumentsPtr)
+Q_UNUSED(argv)
)";
bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFileName, const QV4::CompiledData::SaveableUnitPointer &unit, const QQmlJSAotFunctionMap &aotFunctions, QString *errorString)
@@ -579,13 +560,12 @@ bool qSaveQmlJSUnitAsCpp(const QString &inputFileName, const QString &outputFile
if (aotFunctions.size() <= 1) {
// FileScopeCodeIndex is always there, but it may be the only one.
writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];\n"
- "extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = { { 0, QMetaType::fromType<void>(), {}, nullptr } };");
+ "extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = { { 0, QMetaType::fromType<void>(), {}, nullptr } };\n");
} else {
- writeStr(wrapCallCode);
writeStr("extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[];\n"
"extern const QQmlPrivate::AOTCompiledFunction aotBuiltFunctions[] = {\n");
- QString footer = QStringLiteral("});}\n");
+ QString footer = QStringLiteral("}\n");
for (QQmlJSAotFunctionMap::ConstIterator func = aotFunctions.constBegin(),
end = aotFunctions.constEnd();