aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-10-12 15:56:00 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-11-11 17:33:12 +0100
commitfa1a28852369786a580cc7e0e37bc36dc905b81d (patch)
tree09e89800f308fd11c0d5e29a226375387c962d33 /tools
parentedc01fbfa430d6f0ce66f1871ab28e0f691ee252 (diff)
qmltyperegistrar: add IsConstant for method parameters
Mark method parameters with IsConstant instead of including "const " in the typename, which makes type resolution in the qml compilers impossible. This also avoids a crash in qmltc happening when qmltc sees a signal defined in C++ that has a const parameter. When qmltyperegistrar writes out the types in the qmltypes, check if it starts with a const, remove it and add instead IsConstant: true. The name returned by MOC is normalized so no need to check for "volatile const" or "const volatile" (its always the latter) and no need to filter out for extra whitespace. Once the const is read by the qmltypes reader, propagate the const-information around using a newly introduced enum called QQmlJSMetaMethod::PConstness that can currently be Const or NonConst. Also add the isConstant property to the Parameter.qml in the tooling module. Add a test to see if the IsConstant information is written into the qmltypes. This is also required for QTBUG-107625. Fixes: QTBUG-108147 Task-number: QTBUG-107625 Change-Id: I13bda0a27fe83867f259b751468788128fec82ed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmltc/qmltccompiler.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp
index 10d67e12ba..7ed2fecccb 100644
--- a/tools/qmltc/qmltccompiler.cpp
+++ b/tools/qmltc/qmltccompiler.cpp
@@ -399,12 +399,12 @@ void QmltcCompiler::compileEnum(QmltcType &current, const QQmlJSMetaEnum &e)
u"Q_ENUM(%1)"_s.arg(e.name()));
}
-static QList<QmltcVariable>
-compileMethodParameters(const QStringList &names,
- const QList<QSharedPointer<const QQmlJSScope>> &types,
- bool allowUnnamed = false)
+static QList<QmltcVariable> compileMethodParameters(
+ const QStringList &names, const QList<QSharedPointer<const QQmlJSScope>> &types,
+ const QList<QQmlJSMetaMethod::Constness> &parameterQualifiers, bool allowUnnamed = false)
{
Q_ASSERT(names.size() == types.size());
+ Q_ASSERT(parameterQualifiers.size() == types.size());
QList<QmltcVariable> parameters;
const auto size = names.size();
@@ -440,8 +440,12 @@ void QmltcCompiler::compileMethod(QmltcType &current, const QQmlJSMetaMethod &m,
const auto returnType = figureReturnType(m);
const auto paramNames = m.parameterNames();
const auto paramTypes = m.parameterTypes();
+ const auto paramFlags = m.parameterTypeQualifiers();
+
Q_ASSERT(paramNames.size() == paramTypes.size()); // assume verified
- const QList<QmltcVariable> compiledParams = compileMethodParameters(paramNames, paramTypes);
+ Q_ASSERT(paramFlags.size() == paramTypes.size());
+ const QList<QmltcVariable> compiledParams =
+ compileMethodParameters(paramNames, paramTypes, paramFlags);
const auto methodType = QQmlJSMetaMethod::Type(m.methodType());
QStringList code;
@@ -902,6 +906,7 @@ void QmltcCompiler::compileAlias(QmltcType &current, const QQmlJSMetaProperty &a
} else {
setter.parameterList = compileMethodParameters(methods.at(0).parameterNames(),
methods.at(0).parameterTypes(),
+ methods.at(0).parameterTypeQualifiers(),
/* allow unnamed = */ true);
}
@@ -1635,7 +1640,8 @@ void QmltcCompiler::compileScriptBinding(QmltcType &current,
const QString signalReturnType = figureReturnType(signal);
const QList<QmltcVariable> slotParameters = compileMethodParameters(
- signal.parameterNames(), signal.parameterTypes(), /* allow unnamed = */ true);
+ signal.parameterNames(), signal.parameterTypes(), signal.parameterTypeQualifiers(),
+ /* allow unnamed = */ true);
// SignalHander specific:
QmltcMethod slotMethod {};