From f0908255c9921371d886eff0b8ce245929b50d88 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 6 Nov 2020 15:13:27 +0100 Subject: 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 --- src/qmlcompiler/qqmljstypedescriptionreader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/qmlcompiler/qqmljstypedescriptionreader.cpp') diff --git a/src/qmlcompiler/qqmljstypedescriptionreader.cpp b/src/qmlcompiler/qqmljstypedescriptionreader.cpp index 215a82b4bc..fd875dd715 100644 --- a/src/qmlcompiler/qqmljstypedescriptionreader.cpp +++ b/src/qmlcompiler/qqmljstypedescriptionreader.cpp @@ -224,6 +224,8 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) readMetaObjectRevisions(script, scope); } else if (name == QLatin1String("attachedType")) { scope->setAttachedTypeName(readStringBinding(script)); + } else if (name == QLatin1String("valueType")) { + scope->setValueTypeName(readStringBinding(script)); } else if (name == QLatin1String("isSingleton")) { scope->setIsSingleton(readBoolBinding(script)); } else if (name == QLatin1String("isCreatable")) { @@ -238,6 +240,8 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) scope->setAccessSemantics(QQmlJSScope::AccessSemantics::Value); } else if (semantics == QLatin1String("none")) { scope->setAccessSemantics(QQmlJSScope::AccessSemantics::None); + } else if (semantics == QLatin1String("sequence")) { + scope->setAccessSemantics(QQmlJSScope::AccessSemantics::Sequence); } else { addWarning(script->firstSourceLocation(), tr("Unknown access semantics \"%1\".").arg(semantics)); @@ -245,7 +249,7 @@ void QQmlJSTypeDescriptionReader::readComponent(UiObjectDefinition *ast) } else { addWarning(script->firstSourceLocation(), tr("Expected only name, prototype, defaultProperty, attachedType, " - "exports, isSingleton, isCreatable, isComposite and " + "valueType, exports, isSingleton, isCreatable, isComposite and " "exportMetaObjectRevisions script bindings, not \"%1\".").arg(name)); } } else { -- cgit v1.2.3