diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-01-16 15:00:36 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-13 12:48:07 +0100 |
commit | 164e559c8a7a34aa46ef7563a19100f81a1cade4 (patch) | |
tree | 5fcef6001bbc66c4589c852603a27d93f2aa0b09 /src/qmltyperegistrar | |
parent | 4b8699c88bcd129a3fe34155654921ff3d5ffd5d (diff) |
Process major versions as part of Q_REVISION
Retrieve the major version from the meta object revisions and use them
to register types and generate qmltypes files.
Change-Id: I35da8963457660d1a49ba9063574e1a68057a7ba
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmltyperegistrar')
-rw-r--r-- | src/qmltyperegistrar/qmltyperegistrar.cpp | 4 | ||||
-rw-r--r-- | src/qmltyperegistrar/qmltypesclassdescription.cpp | 20 | ||||
-rw-r--r-- | src/qmltyperegistrar/qmltypesclassdescription.h | 2 | ||||
-rw-r--r-- | src/qmltyperegistrar/qmltypescreator.cpp | 18 |
4 files changed, 24 insertions, 20 deletions
diff --git a/src/qmltyperegistrar/qmltyperegistrar.cpp b/src/qmltyperegistrar/qmltyperegistrar.cpp index c22f349ea0..697f96959f 100644 --- a/src/qmltyperegistrar/qmltyperegistrar.cpp +++ b/src/qmltyperegistrar/qmltyperegistrar.cpp @@ -368,8 +368,8 @@ int main(int argc, char **argv) qPrintable(module), qPrintable(majorVersion), qPrintable(parser.value(minorVersionOption))); fprintf(output, "\n}\n"); - fprintf(output, "\nstatic const QQmlModuleRegistration registration(\"%s\", %s, %s);\n", - qPrintable(module), qPrintable(majorVersion), qPrintable(functionName)); + fprintf(output, "\nstatic const QQmlModuleRegistration registration(\"%s\", %s);\n", + qPrintable(module), qPrintable(functionName)); if (!parser.isSet(pluginTypesOption)) return EXIT_SUCCESS; diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp index aceab7c2b1..f1ec700c50 100644 --- a/src/qmltyperegistrar/qmltypesclassdescription.cpp +++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp @@ -61,7 +61,7 @@ const QJsonObject *QmlTypesClassDescription::findType(const QVector<QJsonObject> void QmlTypesClassDescription::collect(const QJsonObject *classDef, const QVector<QJsonObject> &types, const QVector<QJsonObject> &foreign, - bool topLevel) + bool topLevel, QTypeRevision defaultRevision) { const auto classInfos = classDef->value(QLatin1String("classInfos")).toArray(); for (const QJsonValue &classInfo : classInfos) { @@ -72,7 +72,7 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, if (name == QLatin1String("DefaultProperty")) { if (defaultProp.isEmpty()) defaultProp = value; - } else if (name == QLatin1String("QML.AddedInMinorVersion")) { + } else if (name == QLatin1String("QML.AddedInVersion")) { const QTypeRevision revision = QTypeRevision::fromEncodedVersion(value.toInt()); if (topLevel) { addedInRevision = revision; @@ -91,16 +91,16 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, elementName = classDef->value(QLatin1String("className")).toString(); else if (value != QLatin1String("anonymous")) elementName = value; - } else if (name == QLatin1String("QML.RemovedInMinorVersion")) { + } else if (name == QLatin1String("QML.RemovedInVersion")) { removedInRevision = QTypeRevision::fromEncodedVersion(value.toInt()); } else if (name == QLatin1String("QML.Creatable")) { isCreatable = (value != QLatin1String("false")); } else if (name == QLatin1String("QML.Attached")) { attachedType = value; if (const QJsonObject *other = findType(types, attachedType)) - collect(other, types, foreign, false); + collect(other, types, foreign, false, defaultRevision); else if (const QJsonObject *other = findType(foreign, attachedType)) - collect(other, types, foreign, false); + collect(other, types, foreign, false, defaultRevision); } else if (name == QLatin1String("QML.Singleton")) { if (value == QLatin1String("true")) isSingleton = true; @@ -143,15 +143,17 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef, superClass = superName; if (const QJsonObject *other = findType(types, superName)) - collect(other, types, foreign, false); + collect(other, types, foreign, false, defaultRevision); else if (const QJsonObject *other = findType(foreign, superName)) - collect(other, types, foreign, false); + collect(other, types, foreign, false, defaultRevision); } } if (!addedInRevision.isValid()) { - revisions.append(QTypeRevision::zero()); - addedInRevision = QTypeRevision::zero(); + revisions.append(defaultRevision); + addedInRevision = defaultRevision; + } else if (addedInRevision < defaultRevision) { + revisions.append(defaultRevision); } std::sort(revisions.begin(), revisions.end()); diff --git a/src/qmltyperegistrar/qmltypesclassdescription.h b/src/qmltyperegistrar/qmltypesclassdescription.h index 8222016faf..6f391ba45c 100644 --- a/src/qmltyperegistrar/qmltypesclassdescription.h +++ b/src/qmltyperegistrar/qmltypesclassdescription.h @@ -51,7 +51,7 @@ struct QmlTypesClassDescription bool isBuiltin = false; void collect(const QJsonObject *classDef, const QVector<QJsonObject> &types, - const QVector<QJsonObject> &foreign, bool topLevel); + const QVector<QJsonObject> &foreign, bool topLevel, QTypeRevision defaultRevision); static const QJsonObject *findType(const QVector<QJsonObject> &types, const QString &name); }; diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp index 8991ee42b6..d34740eaa0 100644 --- a/src/qmltyperegistrar/qmltypescreator.cpp +++ b/src/qmltyperegistrar/qmltypescreator.cpp @@ -63,6 +63,11 @@ void QmlTypesCreator::writeClassProperties(const QmlTypesClassDescription &colle QStringList exports; QStringList metaObjects; + if (collector.isBuiltin) { + exports.append(enquote(QString::fromLatin1("QML/%1 1.0").arg(collector.elementName))); + metaObjects.append(QString::number(QTypeRevision::fromVersion(1, 0).toEncodedVersion<quint16>())); + } + for (auto it = collector.revisions.begin(), end = collector.revisions.end(); it != end; ++it) { const QTypeRevision revision = *it; if (revision < collector.addedInRevision) @@ -70,14 +75,11 @@ void QmlTypesCreator::writeClassProperties(const QmlTypesClassDescription &colle if (collector.removedInRevision.isValid() && !(revision < collector.removedInRevision)) break; - if (collector.isBuiltin) { - exports.append(enquote(QString::fromLatin1("QML/%1 1.0").arg(collector.elementName))); - metaObjects.append(QLatin1String("0")); - } - exports.append(enquote(QString::fromLatin1("%1/%2 %3.%4") - .arg(m_module).arg(collector.elementName) - .arg(m_version.majorVersion()).arg(revision.minorVersion()))); + .arg(m_module).arg(collector.elementName) + .arg(revision.hasMajorVersion() ? revision.majorVersion() + : m_version.majorVersion()) + .arg(revision.minorVersion()))); metaObjects.append(QString::number(revision.toEncodedVersion<quint16>())); } @@ -244,7 +246,7 @@ void QmlTypesCreator::writeComponents() m_qml.writeStartObject(componentElement); QmlTypesClassDescription collector; - collector.collect(&component, m_ownTypes, m_foreignTypes, true); + collector.collect(&component, m_ownTypes, m_foreignTypes, true, m_version); writeClassProperties(collector); |