diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-06 15:13:27 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-11-11 11:37:49 +0100 |
commit | f0908255c9921371d886eff0b8ce245929b50d88 (patch) | |
tree | b246bca2fcdae9ee906acc6e2b54a874b36734ea /src/qmltyperegistrar/metatypesjsonprocessor.cpp | |
parent | 40c0cbda771e9888999d8b78179e9600de4e7795 (diff) |
QtQml: Integrate sequences with registration macros
You get to write QML_SEQUENTIAL_CONTAINER(value_type) now, and
qmltyperegistrar will generate a sensible registration call from that.
A registration might look like this:
struct MyStringListForeign
{
Q_GADGET
QML_ANONYMOUS
QML_SEQUENTIAL_CONTAINER(QString)
QML_FOREIGN(MyStringList)
QML_ADDED_IN_VERSION(3, 1)
};
It's unfortunate that we need to use a metaobject to transfer all of
this information, but there is no other sensible way.
Transform the containers defined in qv4sequenceobject.cpp to use the new
style, and move them out of the builtins, into QtQml. Recognize that
only one of them was ever tested, and add tests for the rest.
Task-number: QTBUG-82443
Change-Id: I3a30f9e27266bb575eea26c5daf5dad1ec461cc5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmltyperegistrar/metatypesjsonprocessor.cpp')
-rw-r--r-- | src/qmltyperegistrar/metatypesjsonprocessor.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qmltyperegistrar/metatypesjsonprocessor.cpp b/src/qmltyperegistrar/metatypesjsonprocessor.cpp index f71a94c67d..e4b9c32b8b 100644 --- a/src/qmltyperegistrar/metatypesjsonprocessor.cpp +++ b/src/qmltyperegistrar/metatypesjsonprocessor.cpp @@ -153,6 +153,7 @@ QVector<QJsonObject> MetaTypesJsonProcessor::foreignRelatedTypes() const const QLatin1String qmlNamePrefix("QML."); const QLatin1String qmlForeignName("QML.Foreign"); const QLatin1String qmlAttachedName("QML.Attached"); + const QLatin1String qmlSequenceName("QML.Sequence"); const QLatin1String valueKey("value"); const QLatin1String superClassesKey("superClasses"); const QLatin1String accessKey("access"); @@ -214,9 +215,10 @@ QVector<QJsonObject> MetaTypesJsonProcessor::foreignRelatedTypes() const const auto classInfos = classDef.value(classInfosKey).toArray(); for (const QJsonValue classInfo : classInfos) { const QJsonObject obj = classInfo.toObject(); - if (obj.value(nameKey).toString() == qmlAttachedName) { + const QString objNameValue = obj.value(nameKey).toString(); + if (objNameValue == qmlAttachedName || objNameValue == qmlSequenceName) { addType(obj.value(valueKey).toString()); - } else if (obj.value(nameKey).toString() == qmlForeignName) { + } else if (objNameValue == qmlForeignName) { const QString foreignClassName = obj.value(valueKey).toString(); if (const QJsonObject *other = QmlTypesClassDescription::findType( m_foreignTypes, foreignClassName)) { @@ -230,7 +232,8 @@ QVector<QJsonObject> MetaTypesJsonProcessor::foreignRelatedTypes() const const auto otherClassInfos = other->value(classInfosKey).toArray(); for (const QJsonValue otherClassInfo : otherClassInfos) { const QJsonObject obj = otherClassInfo.toObject(); - if (obj.value(nameKey).toString() == qmlAttachedName) { + const QString objNameValue = obj.value(nameKey).toString(); + if (objNameValue == qmlAttachedName || objNameValue == qmlSequenceName) { addType(obj.value(valueKey).toString()); break; } |