aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@qt.io>2022-03-25 13:38:10 +0100
committerFawzi Mohamed <fawzi.mohamed@qt.io>2022-04-22 01:47:58 +0200
commit23dbad97a21de35da57dfa46f045e8c6346b236d (patch)
tree577481f4748042c3e5780bea7095dc27a98d6ddf
parent838c7724e6393b21c5adeb0b7d85aa5d8457c59e (diff)
qmldom/standalone: Fix build against Qt 6.2.4
Change-Id: Ia6c1dfccf959c06ddb4e8c5bd0685828f9298f6f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp18
-rw-r--r--src/qmldom/qqmldomastcreator.cpp30
-rw-r--r--src/qmldom/qqmldomastdumper.cpp13
-rw-r--r--src/qmldom/qqmldomtypesreader.cpp11
4 files changed, 58 insertions, 14 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index 58b3cac995..2c82795372 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -1322,7 +1322,12 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember)
QQmlJSMetaProperty prop;
prop.setPropertyName(publicMember->name.toString());
prop.setIsList(publicMember->typeModifier == QLatin1String("list"));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ // #if required for standalone DOM compilation against Qt 6.2
prop.setIsWritable(!publicMember->isReadonly());
+#else
+ prop.setIsWritable(!publicMember->readonlyToken.isValid());
+#endif
prop.setAliasExpression(aliasExpr);
const auto type = isAlias
? QQmlJSScope::ConstPtr()
@@ -1337,11 +1342,21 @@ bool QQmlJSImportVisitor::visit(UiPublicMember *publicMember)
prop.setTypeName(typeName);
}
prop.setAnnotations(parseAnnotations(publicMember->annotations));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ // #if required for standalone DOM compilation against Qt 6.2
if (publicMember->isDefaultMember())
+#else
+ if (publicMember->defaultToken.isValid())
+#endif
m_currentScope->setOwnDefaultPropertyName(prop.propertyName());
prop.setIndex(m_currentScope->ownProperties().size());
m_currentScope->insertPropertyIdentifier(prop);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ // #if required for standalone DOM compilation against Qt 6.2
if (publicMember->isRequired())
+#else
+ if (publicMember->requiredToken.isValid())
+#endif
m_currentScope->setPropertyLocallyRequired(prop.propertyName(), true);
// if property is an alias, initialization expression is not a binding
@@ -1489,7 +1504,10 @@ void handleTranslationBinding(QQmlJSMetaPropertyBinding &binding, QStringView ba
binding.setStringLiteral(mainString);
}
};
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
+ // #if required for standalone DOM compilation against Qt 6.2
QmlIR::tryGeneratingTranslationBindingBase(base, args, registerMainString, discardCommentString, finalizeBinding);
+#endif
}
QQmlJSImportVisitor::LiteralOrScriptParseResult QQmlJSImportVisitor::parseLiteralOrScriptBinding(const QString name,
diff --git a/src/qmldom/qqmldomastcreator.cpp b/src/qmldom/qqmldomastcreator.cpp
index 8fe4873cec..d6aa5d4c62 100644
--- a/src/qmldom/qqmldomastcreator.cpp
+++ b/src/qmldom/qqmldomastcreator.cpp
@@ -364,14 +364,22 @@ public:
MethodInfo m;
m.name = el->name.toString();
m.typeName = toString(el->memberType);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
m.isReadonly = el->isReadonly();
+#else
+ m.isReadonly = el->readonlyToken.isValid();
+#endif
m.access = MethodInfo::Public;
m.methodType = MethodInfo::Signal;
m.isList = el->typeModifier == QLatin1String("list");
MethodInfo *mPtr;
Path p = current<QmlObject>().addMethod(m, AddOption::KeepExisting, &mPtr);
pushEl(p, *mPtr, el);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
FileLocations::addRegion(nodeStack.last().fileLocations, u"signal", el->propertyToken());
+#else
+ FileLocations::addRegion(nodeStack.last().fileLocations, u"signal", el->propertyToken);
+#endif
MethodInfo &mInfo = std::get<MethodInfo>(currentNode().value);
AST::UiParameterList *args = el->parameters;
while (args) {
@@ -392,30 +400,50 @@ public:
PropertyDefinition p;
p.name = el->name.toString();
p.typeName = toString(el->memberType);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
p.isReadonly = el->isReadonly();
p.isDefaultMember = el->isDefaultMember();
- p.isList = el->typeModifier == QLatin1String("list");
p.isRequired = el->isRequired();
+#else
+ p.isReadonly = el->readonlyToken.isValid();
+ p.isDefaultMember = el->defaultToken.isValid();
+ p.isRequired = el->requiredToken.isValid();
+#endif
+ p.isList = el->typeModifier == QLatin1String("list");
if (!el->typeModifier.isEmpty())
p.typeName = el->typeModifier.toString() + QChar(u'<') + p.typeName + QChar(u'>');
PropertyDefinition *pPtr;
Path pPathFromOwner =
current<QmlObject>().addPropertyDef(p, AddOption::KeepExisting, &pPtr);
pushEl(pPathFromOwner, *pPtr, el);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
FileLocations::addRegion(nodeStack.last().fileLocations, u"property",
el->propertyToken());
+#else
+ FileLocations::addRegion(nodeStack.last().fileLocations, u"property",
+ el->propertyToken);
+#endif
if (p.name == u"id")
qmlFile.addError(
myParseErrors()
.warning(tr("id is a special attribute, that should not be "
"used as property name"))
.withPath(currentNodeEl().path));
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
if (p.isDefaultMember)
FileLocations::addRegion(nodeStack.last().fileLocations, u"default",
el->defaultToken());
if (p.isRequired)
FileLocations::addRegion(nodeStack.last().fileLocations, u"required",
el->requiredToken());
+#else
+ if (p.isDefaultMember)
+ FileLocations::addRegion(nodeStack.last().fileLocations, u"default",
+ el->defaultToken);
+ if (p.isRequired)
+ FileLocations::addRegion(nodeStack.last().fileLocations, u"required",
+ el->requiredToken);
+#endif
if (el->statement) {
BindingType bType = BindingType::Normal;
SourceLocation loc = combineLocations(el->statement);
diff --git a/src/qmldom/qqmldomastdumper.cpp b/src/qmldom/qqmldomastdumper.cpp
index 6cb0285ec5..94f8d17a7c 100644
--- a/src/qmldom/qqmldomastdumper.cpp
+++ b/src/qmldom/qqmldomastdumper.cpp
@@ -196,10 +196,19 @@ public:
"typeModifierToken=%11 typeToken=%12 "
"identifierToken=%13 colonToken=%14%15")
.arg(quotedString(typeStr), quotedString(el->typeModifier),
+#if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
quotedString(el->name), boolStr(el->isDefaultMember()),
boolStr(el->isReadonly()), boolStr(el->isRequired()),
- loc(el->defaultToken()), loc(el->readonlyToken()), loc(el->propertyToken()),
- loc(el->requiredToken()), loc(el->typeModifierToken), loc(el->typeToken),
+ loc(el->defaultToken()), loc(el->readonlyToken()),
+ loc(el->propertyToken()), loc(el->requiredToken()),
+ loc(el->typeModifierToken), loc(el->typeToken),
+#else
+ quotedString(el->name), boolStr(el->defaultToken.isValid()),
+ boolStr(el->readonlyToken.isValid()),
+ boolStr(el->requiredToken.isValid()), loc(el->defaultToken),
+ loc(el->readonlyToken), loc(el->propertyToken), loc(el->requiredToken),
+ loc(el->typeModifierToken), loc(el->typeToken),
+#endif
loc(el->identifierToken), loc(el->colonToken),
semicolonToken(el->semicolonToken)));
if (!noAnnotations()) // put annotations inside the node they refer to
diff --git a/src/qmldom/qqmldomtypesreader.cpp b/src/qmldom/qqmldomtypesreader.cpp
index 27d77c4581..2caede28a1 100644
--- a/src/qmldom/qqmldomtypesreader.cpp
+++ b/src/qmldom/qqmldomtypesreader.cpp
@@ -189,11 +189,7 @@ void QmltypesReader::insertComponent(const QQmlJSScope::Ptr &jsScope,
.index(qmltypesFilePtr()->components().values(comp.name()).length());
incrementedPath = true;
prototype = jsScope->baseTypeName();
-#if QT_VERSION <= 0x060200
- defaultPropertyName = jsScope->defaultPropertyName();
-#else
defaultPropertyName = jsScope->ownDefaultPropertyName();
-#endif // QT_VERSION <= 0x060200
comp.setInterfaceNames(jsScope->interfaceNames());
QString typeName = jsScope->ownAttachedTypeName();
comp.setAttachedTypeName(typeName);
@@ -276,17 +272,10 @@ bool QmltypesReader::parse()
QQmlJSTypeDescriptionReader reader(qmltypesFilePtr()->canonicalFilePath(),
qmltypesFilePtr()->code());
QStringList dependencies;
-#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0)
- QHash<QString, QQmlJSScope::Ptr> objects;
- m_isValid = reader(&objects, &dependencies);
- for (const auto &obj : qAsConst(objects))
- insertComponent(obj, obj->exports());
-#else
QHash<QString, QQmlJSExportedScope> objects;
m_isValid = reader(&objects, &dependencies);
for (const auto &obj : qAsConst(objects))
insertComponent(obj.scope, obj.exports);
-#endif
qmltypesFilePtr()->setIsValid(m_isValid);
return m_isValid;
}