diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-16 09:11:40 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-19 15:59:58 +0200 |
commit | c010364342e3cd749c5ec8e44f1b73e7d8cba99c (patch) | |
tree | 55e3828d67da44460f5c9dec497d3197642744e7 /src | |
parent | cc57bac899b6e13078197da7c40ad27fade7ee0d (diff) |
QmlCompiler: Drop the metaobject revision from exports
Instead, output a warning if the revision doesn't match the version. We
want to get rid of generic version/revision matching. To this end, add a
way to retrieve the version from an export.
Change-Id: Ie887103eba910f14e49faa684ac559cc72cab199
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qmlcompiler/qqmljsscope.cpp | 16 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljsscope_p.h | 12 | ||||
-rw-r--r-- | src/qmlcompiler/qqmljstypedescriptionreader.cpp | 12 |
3 files changed, 18 insertions, 22 deletions
diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp index ed434c17e7..ba74280ae2 100644 --- a/src/qmlcompiler/qqmljsscope.cpp +++ b/src/qmlcompiler/qqmljsscope.cpp @@ -157,22 +157,16 @@ QQmlJSScope::ConstPtr QQmlJSScope::findCurrentQMLScope(const QQmlJSScope::ConstP return qmlScope; } -void QQmlJSScope::addExport(const QString &name, const QString &package, const QTypeRevision &version) +void QQmlJSScope::addExport(const QString &name, const QString &package, + const QTypeRevision &version) { - m_exports.append(Export(package, name, version, 0)); + m_exports.append(Export(package, name, version)); } -void QQmlJSScope::setExportMetaObjectRevision(int exportIndex, int metaObjectRevision) -{ - m_exports[exportIndex].setMetaObjectRevision(metaObjectRevision); -} - -QQmlJSScope::Export::Export(QString package, QString type, const QTypeRevision &version, - int metaObjectRevision) : +QQmlJSScope::Export::Export(QString package, QString type, const QTypeRevision &version) : m_package(std::move(package)), m_type(std::move(type)), - m_version(version), - m_metaObjectRevision(metaObjectRevision) + m_version(version) { } diff --git a/src/qmlcompiler/qqmljsscope_p.h b/src/qmlcompiler/qqmljsscope_p.h index 40bb5ff544..d656b2f5b4 100644 --- a/src/qmlcompiler/qqmljsscope_p.h +++ b/src/qmlcompiler/qqmljsscope_p.h @@ -114,25 +114,18 @@ public: class Export { public: Export() = default; - Export(QString package, QString type, const QTypeRevision &version, - int metaObjectRevision); + Export(QString package, QString type, const QTypeRevision &version); bool isValid() const; - int metaObjectRevision() const { return m_metaObjectRevision; } - void setMetaObjectRevision(int metaObjectRevision) - { - m_metaObjectRevision = metaObjectRevision; - } - QString package() const { return m_package; } QString type() const { return m_type; } + QTypeRevision version() const { return m_version; } private: QString m_package; QString m_type; QTypeRevision m_version; - int m_metaObjectRevision = 0; }; struct JavaScriptIdentifier @@ -181,7 +174,6 @@ public: void setInternalName(const QString &internalName) { m_internalName = internalName; } void addExport(const QString &name, const QString &package, const QTypeRevision &version); - void setExportMetaObjectRevision(int exportIndex, int metaObjectRevision); QList<Export> exports() const { return m_exports; } // If isComposite(), this is the QML/JS name of the prototype. Otherwise it's the diff --git a/src/qmlcompiler/qqmljstypedescriptionreader.cpp b/src/qmlcompiler/qqmljstypedescriptionreader.cpp index f0b011cc7e..4b7dcead31 100644 --- a/src/qmlcompiler/qqmljstypedescriptionreader.cpp +++ b/src/qmlcompiler/qqmljstypedescriptionreader.cpp @@ -642,7 +642,17 @@ void QQmlJSTypeDescriptionReader::readMetaObjectRevisions(UiScriptBinding *ast, return; } - scope->setExportMetaObjectRevision(exportIndex, metaObjectRevision); + const QTypeRevision metaObjectVersion + = QTypeRevision::fromEncodedVersion(metaObjectRevision); + const QTypeRevision exportVersion = scope->exports()[exportIndex].version(); + if (metaObjectVersion != exportVersion) { + addWarning(numberLit->firstSourceLocation(), + tr("Meta object revision and export version differ, ignoring the revision.\n" + "Revision %1 corresponds to version %2.%3; it should be %4.%5.") + .arg(metaObjectRevision) + .arg(metaObjectVersion.majorVersion()).arg(metaObjectVersion.minorVersion()) + .arg(exportVersion.majorVersion()).arg(exportVersion.minorVersion())); + } } } |