diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-04-28 16:55:22 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-05-18 18:57:56 +0200 |
commit | 79b742fb84abe699ff726eec548793880cfa7527 (patch) | |
tree | 2947c614ac2453e44cbc3a6f45dca438d6486e8b /tools/shared | |
parent | 1e30ec77aaedcc29ba7ac1c3ec3937ee0b8287e9 (diff) |
Preserve access semantics in qmltypes
gadget types are accessed with value semantics, object types are
accessed with reference semantics, and namespaces are not accessed.
Change-Id: I5eb8f132d729416f28bf94e651f877fc4a9a5c77
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/shared')
-rw-r--r-- | tools/shared/scopetree.h | 34 | ||||
-rw-r--r-- | tools/shared/typedescriptionreader.cpp | 12 |
2 files changed, 37 insertions, 9 deletions
diff --git a/tools/shared/scopetree.h b/tools/shared/scopetree.h index 92e60d6d0a..08d529acc9 100644 --- a/tools/shared/scopetree.h +++ b/tools/shared/scopetree.h @@ -71,6 +71,20 @@ public: using ConstPtr = QSharedPointer<const ScopeTree>; using WeakConstPtr = QWeakPointer<const ScopeTree>; + enum class AccessSemantics { + Reference, + Value, + None + }; + + enum Flag { + Creatable = 0x1, + Composite = 0x2, + Singleton = 0x4 + }; + Q_DECLARE_FLAGS(Flags, Flag) + Q_FLAGS(Flags); + class Export { public: Export() = default; @@ -149,12 +163,15 @@ public: QString attachedTypeName() const { return m_attachedTypeName; } void setAttachedTypeName(const QString &name) { m_attachedTypeName = name; } - bool isSingleton() const { return m_isSingleton; } - bool isCreatable() const { return m_isCreatable; } - bool isComposite() const { return m_isComposite; } - void setIsSingleton(bool value) { m_isSingleton = value; } - void setIsCreatable(bool value) { m_isCreatable = value; } - void setIsComposite(bool value) { m_isSingleton = value; } + bool isSingleton() const { return m_flags & Singleton; } + bool isCreatable() const { return m_flags & Creatable; } + bool isComposite() const { return m_flags & Composite; } + void setIsSingleton(bool v) { m_flags = v ? (m_flags | Singleton) : (m_flags & ~Singleton); } + void setIsCreatable(bool v) { m_flags = v ? (m_flags | Creatable) : (m_flags & ~Creatable); } + void setIsComposite(bool v) { m_flags = v ? (m_flags | Composite) : (m_flags & ~Composite); } + + void setAccessSemantics(AccessSemantics semantics) { m_semantics = semantics; } + AccessSemantics accessSemantics() const { return m_semantics; } struct FieldMember { @@ -214,9 +231,8 @@ private: QString m_defaultPropertyName; QString m_attachedTypeName; - bool m_isSingleton = false; - bool m_isCreatable = true; - bool m_isComposite = false; + Flags m_flags; + AccessSemantics m_semantics = AccessSemantics::Reference; }; #endif // SCOPETREE_H diff --git a/tools/shared/typedescriptionreader.cpp b/tools/shared/typedescriptionreader.cpp index 7831c1ad10..b1738b94e8 100644 --- a/tools/shared/typedescriptionreader.cpp +++ b/tools/shared/typedescriptionreader.cpp @@ -228,6 +228,18 @@ void TypeDescriptionReader::readComponent(UiObjectDefinition *ast) scope->setIsCreatable(readBoolBinding(script)); } else if (name == QLatin1String("isComposite")) { scope->setIsComposite(readBoolBinding(script)); + } else if (name == QLatin1String("accessSemantics")) { + const QString semantics = readStringBinding(script); + if (semantics == QLatin1String("reference")) { + scope->setAccessSemantics(ScopeTree::AccessSemantics::Reference); + } else if (semantics == QLatin1String("value")) { + scope->setAccessSemantics(ScopeTree::AccessSemantics::Value); + } else if (semantics == QLatin1String("none")) { + scope->setAccessSemantics(ScopeTree::AccessSemantics::None); + } else { + addWarning(script->firstSourceLocation(), + tr("Unknown access semantics \"%1\".").arg(semantics)); + } } else { addWarning(script->firstSourceLocation(), tr("Expected only name, prototype, defaultProperty, attachedType, " |