1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMLINTEGRATION_H
5#define QMLINTEGRATION_H
6
7#include <QtCore/qglobal.h>
8
9// forward declarations of structs and functions defined in QtQml
10QT_BEGIN_NAMESPACE
11namespace QQmlPrivate {
12 template<typename, typename> struct QmlSingleton;
13 template<class, class, bool> struct QmlAttached;
14 template<class> struct QmlAttachedAccessor;
15 template<class, class> struct QmlExtended;
16 template<typename, typename> struct QmlInterface;
17 template<class, class>
18 struct QmlExtendedNamespace;
19 template<class, class>
20 struct QmlUncreatable;
21 template<class, class>
22 struct QmlAnonymous;
23}
24
25template <typename T> class QList;
26
27template<typename... Args>
28void qmlRegisterTypesAndRevisions(const char *uri, int versionMajor,
29 QList<int> *qmlTypeIds = nullptr);
30
31QT_END_NAMESPACE
32
33
34#define QML_PRIVATE_NAMESPACE \
35 QT_PREPEND_NAMESPACE(QQmlPrivate)
36
37#define QML_REGISTER_TYPES_AND_REVISIONS \
38 QT_PREPEND_NAMESPACE(qmlRegisterTypesAndRevisions)
39
40
41#define QML_ELEMENT \
42 Q_CLASSINFO("QML.Element", "auto")
43
44#define QML_ANONYMOUS \
45 Q_CLASSINFO("QML.Element", "anonymous") \
46 enum class QmlIsAnonymous{yes = true}; \
47 template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlAnonymous; \
48 template<typename... Args> \
49 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
50 inline constexpr void qt_qmlMarker_anonymous() {}
51
52#define QML_NAMED_ELEMENT(NAME) \
53 Q_CLASSINFO("QML.Element", #NAME)
54
55#define QML_UNCREATABLE(REASON) \
56 Q_CLASSINFO("QML.Creatable", "false") \
57 Q_CLASSINFO("QML.UncreatableReason", REASON) \
58 enum class QmlIsUncreatable {yes = true}; \
59 template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlUncreatable; \
60 template<typename... Args> \
61 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
62 inline constexpr void qt_qmlMarker_uncreatable() {}
63
64#define QML_VALUE_TYPE(NAME) \
65 Q_CLASSINFO("QML.Element", #NAME)
66
67#define QML_CONSTRUCTIBLE_VALUE \
68 Q_CLASSINFO("QML.Creatable", "true") \
69 Q_CLASSINFO("QML.CreationMethod", "construct")
70
71#define QML_STRUCTURED_VALUE \
72 Q_CLASSINFO("QML.Creatable", "true") \
73 Q_CLASSINFO("QML.CreationMethod", "structured")
74
75#define QML_SINGLETON \
76 Q_CLASSINFO("QML.Singleton", "true") \
77 enum class QmlIsSingleton {yes = true}; \
78 template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlSingleton; \
79 template<typename... Args> \
80 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
81 inline constexpr void qt_qmlMarker_singleton() {}
82
83#define QML_ADDED_IN_MINOR_VERSION(VERSION) \
84 Q_CLASSINFO("QML.AddedInVersion", Q_REVISION(VERSION))
85
86#define QML_ADDED_IN_VERSION(MAJOR, MINOR) \
87 Q_CLASSINFO("QML.AddedInVersion", Q_REVISION(MAJOR, MINOR))
88
89#define QML_EXTRA_VERSION(MAJOR, MINOR) \
90 Q_CLASSINFO("QML.ExtraVersion", Q_REVISION(MAJOR, MINOR))
91
92#define QML_REMOVED_IN_MINOR_VERSION(VERSION) \
93 Q_CLASSINFO("QML.RemovedInVersion", Q_REVISION(VERSION))
94
95#define QML_REMOVED_IN_VERSION(MAJOR, MINOR) \
96 Q_CLASSINFO("QML.RemovedInVersion", Q_REVISION(MAJOR, MINOR))
97
98#define QML_ATTACHED(ATTACHED_TYPE) \
99 Q_CLASSINFO("QML.Attached", #ATTACHED_TYPE) \
100 using QmlAttachedType = ATTACHED_TYPE; \
101 template<class, class, bool> friend struct QML_PRIVATE_NAMESPACE::QmlAttached; \
102 template<class> friend struct QML_PRIVATE_NAMESPACE::QmlAttachedAccessor; \
103 inline constexpr void qt_qmlMarker_attached() {}
104
105#define QML_EXTENDED(EXTENDED_TYPE) \
106 Q_CLASSINFO("QML.Extended", #EXTENDED_TYPE) \
107 using QmlExtendedType = EXTENDED_TYPE; \
108 template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlExtended; \
109 template<typename... Args> \
110 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
111 inline constexpr void qt_qmlMarker_extended() {}
112
113#define QML_EXTENDED_NAMESPACE(EXTENDED_NAMESPACE) \
114 Q_CLASSINFO("QML.Extended", #EXTENDED_NAMESPACE) \
115 Q_CLASSINFO("QML.ExtensionIsNamespace", "true") \
116 static constexpr const QMetaObject *qmlExtendedNamespace() { return &EXTENDED_NAMESPACE::staticMetaObject; } \
117 template<class, class> friend struct QML_PRIVATE_NAMESPACE::QmlExtendedNamespace; \
118 template<typename... Args> \
119 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
120 inline constexpr void qt_qmlMarker_extendedNamespace() {}
121
122#define QML_NAMESPACE_EXTENDED(EXTENDED_NAMESPACE) \
123 Q_CLASSINFO("QML.Extended", #EXTENDED_NAMESPACE)
124
125#define QML_INTERFACE \
126 Q_CLASSINFO("QML.Element", "anonymous") \
127 enum class QmlIsInterface {yes = true}; \
128 template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlInterface; \
129 template<typename... Args> \
130 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
131 inline constexpr void qt_qmlMarker_interface() {}
132
133#define QML_IMPLEMENTS_INTERFACES(INTERFACES) \
134 Q_INTERFACES(INTERFACES) \
135 enum class QmlIsInterface {yes = false}; \
136 template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlInterface;
137
138#define QML_SEQUENTIAL_CONTAINER(VALUE_TYPE) \
139 Q_CLASSINFO("QML.Sequence", #VALUE_TYPE) \
140 using QmlSequenceValueType = VALUE_TYPE; \
141 enum class QmlIsSequence {yes = true}; \
142 template<typename, typename> friend struct QML_PRIVATE_NAMESPACE::QmlSequence; \
143 template<typename... Args> \
144 friend void QML_REGISTER_TYPES_AND_REVISIONS(const char *uri, int versionMajor, QList<int> *); \
145 inline constexpr void qt_qmlMarker_sequence() {}
146
147#define QML_UNAVAILABLE \
148 QML_FOREIGN(QQmlTypeNotAvailable)
149
150#endif
151

source code of qtdeclarative/src/qmlintegration/qqmlintegration.h