diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2022-05-12 14:39:38 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-10 12:06:49 +0000 |
commit | 7373e6149f7e28fff1dfc5b5642d63aa4bb5a886 (patch) | |
tree | 90359e9ef7b2e130ac8df3ffab1289da7d4bc0df /src | |
parent | 7360c1af181dc6ef3ae82a885ada0dc6919c85f7 (diff) |
qmltc: Move from QmlIR::Binding to QQmlJSMetaPropertyBinding
This symbolizes the last piece of QmlIR dependency that qmltc has.
We do still have some implicit dependencies on QmlIR, though, but
that should go way once the remaining prototype code's logic is
migrated to QmltcVisitor, QQmlJSScope and friends. This, however,
is not attempted here as the patch itself is rather large
In the process of switching to QQmlJSMetaPropertyBinding, observe
and fix issues in QmltcVisitor and surroundings
Change-Id: I752b68a7f57baf354de16dc0bb466a3f693a4e49
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
(cherry picked from commit bf7aaeda87d409253f8d114273cc71f4244973af)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 20 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsutils_p.h | 15 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 4bc1c6ebc2..e2ffa3c084 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -928,21 +928,6 @@ void QQmlJSImportVisitor::processPropertyBindings() } } -static std::optional<QQmlJSMetaProperty> -propertyForChangeHandler(const QQmlJSScope::ConstPtr &scope, QString name) -{ - if (!name.endsWith(QLatin1String("Changed"))) - return {}; - constexpr int length = int(sizeof("Changed") / sizeof(char)) - 1; - name.chop(length); - auto p = scope->property(name); - const bool isBindable = !p.bindable().isEmpty(); - const bool canNotify = !p.notify().isEmpty(); - if (p.isValid() && (isBindable || canNotify)) - return p; - return {}; -} - void QQmlJSImportVisitor::checkSignals() { for (auto it = m_signals.constBegin(); it != m_signals.constEnd(); ++it) { @@ -963,7 +948,8 @@ void QQmlJSImportVisitor::checkSignals() if (signal.has_value()) { if (signalScope->hasMethod(*signal)) { setSignalMethod(signalScope, *signal); - } else if (auto p = propertyForChangeHandler(signalScope, *signal); p.has_value()) { + } else if (auto p = QQmlJSUtils::changeHandlerProperty(signalScope, *signal); + p.has_value()) { // we have a change handler of the form "onXChanged" where 'X' // is a property name @@ -1930,7 +1916,7 @@ bool QQmlJSImportVisitor::visit(UiScriptBinding *scriptBinding) const auto methods = scope->methods(signalName, QQmlJSMetaMethod::Signal); if (!methods.isEmpty()) kind = QQmlJSMetaPropertyBinding::Script_SignalHandler; - else if (propertyForChangeHandler(scope, signalName).has_value()) + else if (QQmlJSUtils::changeHandlerProperty(scope, signalName).has_value()) kind = QQmlJSMetaPropertyBinding::Script_ChangeHandler; // ### TODO: needs an error if kind is still Invalid diff --git a/src/qmlcompiler/qqmljsutils_p.h b/src/qmlcompiler/qqmljsutils_p.h index 0921080020..632be0b4a3 100644 --- a/src/qmlcompiler/qqmljsutils_p.h +++ b/src/qmlcompiler/qqmljsutils_p.h @@ -141,6 +141,21 @@ struct Q_QMLCOMPILER_PRIVATE_EXPORT QQmlJSUtils return {}; } + static std::optional<QQmlJSMetaProperty> + changeHandlerProperty(const QQmlJSScope::ConstPtr &scope, QStringView signalName) + { + if (!signalName.endsWith(QLatin1String("Changed"))) + return {}; + constexpr int length = int(sizeof("Changed") / sizeof(char)) - 1; + signalName.chop(length); + auto p = scope->property(signalName.toString()); + const bool isBindable = !p.bindable().isEmpty(); + const bool canNotify = !p.notify().isEmpty(); + if (p.isValid() && (isBindable || canNotify)) + return p; + return {}; + } + static bool hasCompositeBase(const QQmlJSScope::ConstPtr &scope) { if (!scope) |