From a1ce0596e517e84913b14ab23422137c95b8c785 Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Thu, 10 Aug 2023 09:45:37 +0200 Subject: Replace signal name manipulations with QQmlSignalNames Remove custom implementations found in qqmljs* and use the static helper methods from qqmlsignalnames_p.h instead. This sometimes requires to move some code around to avoid bugs with property that do not have letters in their name. Add a warning in the JS implementation of the SignalSpy.qml that the used heuristic might fail on certain signal names. Add tests in in tst_qqmllanguage to see if the property change handlers work correctly for weird names. Change-Id: I4dc73c34df7f77f529511fa04ab5fcc5385b59fc Reviewed-by: Qt CI Bot Reviewed-by: Fabian Kosmale --- src/qml/compiler/qqmlirbuilder.cpp | 32 -------------------------------- src/qml/compiler/qqmlirbuilder_p.h | 3 --- 2 files changed, 35 deletions(-) (limited to 'src/qml/compiler') diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 072894adde..2d1a617b09 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -442,38 +442,6 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen return errors.isEmpty(); } -bool IRBuilder::isSignalPropertyName(const QString &name) -{ - if (name.size() < 3) return false; - if (!name.startsWith(QLatin1String("on"))) return false; - int ns = name.size(); - for (int i = 2; i < ns; ++i) { - const QChar curr = name.at(i); - if (curr.unicode() == '_') continue; - if (curr.isUpper()) return true; - return false; - } - return false; // consists solely of underscores - invalid. -} - -QString IRBuilder::signalNameFromSignalPropertyName(const QString &signalPropertyName) -{ - Q_ASSERT(signalPropertyName.startsWith(QLatin1String("on"))); - QString signalNameCandidate = signalPropertyName; - signalNameCandidate.remove(0, 2); - - // Note that the property name could start with any alpha or '_' or '$' character, - // so we need to do the lower-casing of the first alpha character. - for (int firstAlphaIndex = 0; firstAlphaIndex < signalNameCandidate.size(); ++firstAlphaIndex) { - if (signalNameCandidate.at(firstAlphaIndex).isUpper()) { - signalNameCandidate[firstAlphaIndex] = signalNameCandidate.at(firstAlphaIndex).toLower(); - return signalNameCandidate; - } - } - - Q_UNREACHABLE_RETURN(QString()); -} - bool IRBuilder::visit(QQmlJS::AST::UiArrayMemberList *ast) { return QQmlJS::AST::Visitor::visit(ast); diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h index 5b9c0fce60..2935a3273b 100644 --- a/src/qml/compiler/qqmlirbuilder_p.h +++ b/src/qml/compiler/qqmlirbuilder_p.h @@ -506,9 +506,6 @@ public: IRBuilder(const QSet &illegalNames); bool generateFromQml(const QString &code, const QString &url, Document *output); - static bool isSignalPropertyName(const QString &name); - static QString signalNameFromSignalPropertyName(const QString &signalPropertyName); - using QQmlJS::AST::Visitor::visit; using QQmlJS::AST::Visitor::endVisit; -- cgit v1.2.3