aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmltc/qmltccompilerpieces.h
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-07-27 13:36:04 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-07-28 16:22:37 +0000
commit1ecc61b2746782b576147470d0f6f0f30e0b40d1 (patch)
tree5f62e1c844f14b60e5d1be00a4ffaa7d60c9e119 /tools/qmltc/qmltccompilerpieces.h
parente7dd123c57397ab721ecd7fe0aa12725f33234ac (diff)
Address TODOs in qmltc tool
Deal with low hanging fruits. Remove outdated TODOs. Fix the rest. Many things are still open Change-Id: Ia2cd0724552b1116c34d12a30a4c911ee42e15d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit ca2a903b55dfd6cc3191f6398f118e04427e7478) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/qmltc/qmltccompilerpieces.h')
-rw-r--r--tools/qmltc/qmltccompilerpieces.h39
1 files changed, 16 insertions, 23 deletions
diff --git a/tools/qmltc/qmltccompilerpieces.h b/tools/qmltc/qmltccompilerpieces.h
index 9afc001b55..100fe8bdad 100644
--- a/tools/qmltc/qmltccompilerpieces.h
+++ b/tools/qmltc/qmltccompilerpieces.h
@@ -34,8 +34,7 @@ struct QmltcCodeGenerator
const QQmlJSScope::ConstPtr &type) const;
inline void generate_initCodeForTopLevelComponent(QmltcType &current,
const QQmlJSScope::ConstPtr &type);
- [[nodiscard]] inline decltype(auto)
- generate_endInitCode(QmltcType &current, const QQmlJSScope::ConstPtr &type) const;
+ inline void generate_endInitCode(QmltcType &current, const QQmlJSScope::ConstPtr &type) const;
inline void generate_interfaceCallCode(QmltcMethod *function, const QQmlJSScope::ConstPtr &type,
const QString &interfaceName,
@@ -69,7 +68,6 @@ struct QmltcCodeGenerator
const QString &returnType,
const QList<QmltcVariable> &parameters = {});
- // TODO: 3 separate versions: bindable QML, bindable C++, non-bindable C++
static void generate_createBindingOnProperty(QStringList *block, const QString &unitVarName,
const QString &scope, qsizetype functionIndex,
const QString &target, int propertyIndex,
@@ -140,7 +138,7 @@ inline decltype(auto) QmltcCodeGenerator::generate_initCode(QmltcType &current,
// another document. we need to fix it by using parentContext->parent()
const auto realQmlScope = [](const QQmlJSScope::ConstPtr &scope) {
- if (scope->isArrayScope()) // TODO: it is special for some reason
+ if (scope->isArrayScope())
return scope->parentScope();
return scope;
};
@@ -317,9 +315,8 @@ QmltcCodeGenerator::generate_initCodeForTopLevelComponent(QmltcType &current,
initialization. Additionally, the QML document root's endInit calls endInit
methods of all the necessary QML types within the document.
*/
-inline decltype(auto)
-QmltcCodeGenerator::generate_endInitCode(QmltcType &current,
- const QQmlJSScope::ConstPtr &type) const
+inline void QmltcCodeGenerator::generate_endInitCode(QmltcType &current,
+ const QQmlJSScope::ConstPtr &type) const
{
using namespace Qt::StringLiterals;
@@ -361,22 +358,18 @@ QmltcCodeGenerator::generate_endInitCode(QmltcType &current,
current.endInit.body << u"}"_s;
}
- // TODO: QScopeGuard here is redundant. we should call endInit of children
- // directly
- const auto generateFinalLines = [&current, isDocumentRoot, this]() {
- if (!isDocumentRoot) // document root does all the work here
- return;
-
- const auto types = visitor->pureQmlTypes();
- current.endInit.body << u"// finalize children"_s;
- for (qsizetype i = 1; i < types.size(); ++i) {
- const auto &type = types[i];
- Q_ASSERT(!type->isComponentRootElement());
- current.endInit.body << u"creator->get<%1>(%2)->%3(creator, engine);"_s.arg(
- type->internalName(), QString::number(i), current.endInit.name);
- }
- };
- return QScopeGuard(generateFinalLines);
+ if (!isDocumentRoot) // document root does all the work here
+ return;
+
+ const auto types = visitor->pureQmlTypes();
+ current.endInit.body << u"// finalize children"_s;
+ for (qsizetype i = 1; i < types.size(); ++i) {
+ const auto &type = types[i];
+ Q_ASSERT(!type->isComponentRootElement());
+ current.endInit.body << u"creator->get<%1>(%2)->%3(creator, engine);"_s.arg(
+ type->internalName(), QString::number(i), current.endInit.name);
+ }
+ current.endInit.body << u"// finalize self"_s;
}
/*!