From f6fc35b45b449fe7aaca3237f29393a12fc3f90c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 1 Feb 2021 15:03:19 +0100 Subject: QmlCompiler: Allow for multiple extensions per object Previously, the assumption was that each object could only have a single extension object. As proven by the new qqmllanguage test this is not the case. Each registered object in the type hierarchy can have its own extension. Therefore, adjust the algorithms that generate qmltypes and iterate the extension objects when analyzing them. This leads us to the realization that anonymous types can in fact meaningfully carry extensions and implement interfaces. Adapt qmltyperegistrar accordingly. For the test to compile, however, we need to realize that the class declaring interfaces needs to befriend all potential subclass's QmlInterface structs. Fix that, too. The rabbit hole went deep. Change-Id: Ia451897e927e03b95c3062e829edf1dfcd216613 Reviewed-by: Fabian Kosmale --- .../qml/qmllint/data/StaticTest/multi.qmltypes | 41 ++++++++++++++++++++++ tests/auto/qml/qmllint/data/StaticTest/qmldir | 2 ++ tests/auto/qml/qmllint/data/multiExtension.qml | 6 ++++ 3 files changed, 49 insertions(+) create mode 100644 tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes create mode 100644 tests/auto/qml/qmllint/data/StaticTest/qmldir create mode 100644 tests/auto/qml/qmllint/data/multiExtension.qml (limited to 'tests/auto/qml/qmllint/data') diff --git a/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes b/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes new file mode 100644 index 0000000000..9a2ed24482 --- /dev/null +++ b/tests/auto/qml/qmllint/data/StaticTest/multi.qmltypes @@ -0,0 +1,41 @@ +import QtQuick.tooling 1.2 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by qmltyperegistrar. + +Module { + Component { + file: "testtypes.h" + name: "ExtensionA" + accessSemantics: "reference" + prototype: "QObject" + Property { name: "a"; type: "int"; isReadonly: true; read: "a" } + } + Component { + file: "testtypes.h" + name: "ExtensionB" + accessSemantics: "reference" + prototype: "QObject" + Property { name: "b"; type: "int"; isReadonly: true; read: "b" } + } + Component { + file: "testtypes.h" + name: "MultiExtension" + accessSemantics: "reference" + prototype: "MultiExtensionParent" + exports: ["StaticTest/MultiExtension 1.0"] + exportMetaObjectRevisions: [256] + extension: "ExtensionB" + Property { name: "e"; type: "int"; isReadonly: true; read: "e" } + } + Component { + file: "testtypes.h" + name: "MultiExtensionParent" + accessSemantics: "reference" + prototype: "QObject" + extension: "ExtensionA" + Property { name: "p"; type: "int"; isReadonly: true; read: "p" } + } +} diff --git a/tests/auto/qml/qmllint/data/StaticTest/qmldir b/tests/auto/qml/qmllint/data/StaticTest/qmldir new file mode 100644 index 0000000000..4702175b79 --- /dev/null +++ b/tests/auto/qml/qmllint/data/StaticTest/qmldir @@ -0,0 +1,2 @@ +module StaticTest +typeinfo multi.qmltypes diff --git a/tests/auto/qml/qmllint/data/multiExtension.qml b/tests/auto/qml/qmllint/data/multiExtension.qml new file mode 100644 index 0000000000..12b36dbb4f --- /dev/null +++ b/tests/auto/qml/qmllint/data/multiExtension.qml @@ -0,0 +1,6 @@ +import StaticTest + +MultiExtension { + property int t: a + b + e + p +} + -- cgit v1.2.3