1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2019 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtQml module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QQMLTYPE_P_H |
41 | #define QQMLTYPE_P_H |
42 | |
43 | // |
44 | // W A R N I N G |
45 | // ------------- |
46 | // |
47 | // This file is not part of the Qt API. It exists purely as an |
48 | // implementation detail. This header file may change from version to |
49 | // version without notice, or even be removed. |
50 | // |
51 | // We mean it. |
52 | // |
53 | |
54 | #include <functional> |
55 | |
56 | #include <private/qtqmlglobal_p.h> |
57 | #include <private/qqmlrefcount_p.h> |
58 | |
59 | #include <QtQml/qqmlprivate.h> |
60 | #include <QtQml/qjsvalue.h> |
61 | |
62 | #include <QtCore/qobject.h> |
63 | |
64 | QT_BEGIN_NAMESPACE |
65 | |
66 | class QHashedCStringRef; |
67 | class QQmlTypePrivate; |
68 | class QHashedString; |
69 | class QHashedStringRef; |
70 | class QQmlCustomParser; |
71 | class QQmlEnginePrivate; |
72 | class QQmlPropertyCache; |
73 | |
74 | namespace QV4 { |
75 | struct String; |
76 | } |
77 | |
78 | class Q_QML_PRIVATE_EXPORT QQmlType |
79 | { |
80 | public: |
81 | QQmlType(); |
82 | QQmlType(const QQmlType &other); |
83 | QQmlType(QQmlType &&other); |
84 | QQmlType &operator =(const QQmlType &other); |
85 | QQmlType &operator =(QQmlType &&other); |
86 | explicit QQmlType(const QQmlTypePrivate *priv); |
87 | ~QQmlType(); |
88 | |
89 | bool operator ==(const QQmlType &other) const { |
90 | return d.data() == other.d.data(); |
91 | } |
92 | |
93 | bool isValid() const { return !d.isNull(); } |
94 | |
95 | QByteArray typeName() const; |
96 | QString qmlTypeName() const; |
97 | QString elementName() const; |
98 | |
99 | QHashedString module() const; |
100 | int majorVersion() const; |
101 | int minorVersion() const; |
102 | |
103 | bool availableInVersion(int vmajor, int vminor) const; |
104 | bool availableInVersion(const QHashedStringRef &module, int vmajor, int vminor) const; |
105 | |
106 | QObject *create() const; |
107 | void create(QObject **, void **, size_t) const; |
108 | |
109 | typedef void (*CreateFunc)(void *); |
110 | CreateFunc createFunction() const; |
111 | QQmlCustomParser *customParser() const; |
112 | |
113 | bool isCreatable() const; |
114 | typedef QObject *(*ExtensionFunc)(QObject *); |
115 | ExtensionFunc extensionFunction() const; |
116 | bool isExtendedType() const; |
117 | QString noCreationReason() const; |
118 | |
119 | bool isSingleton() const; |
120 | bool isInterface() const; |
121 | bool isComposite() const; |
122 | bool isCompositeSingleton() const; |
123 | bool isQObjectSingleton() const; |
124 | bool isQJSValueSingleton() const; |
125 | |
126 | int typeId() const; |
127 | int qListTypeId() const; |
128 | |
129 | const QMetaObject *metaObject() const; |
130 | const QMetaObject *baseMetaObject() const; |
131 | int metaObjectRevision() const; |
132 | bool containsRevisionedAttributes() const; |
133 | |
134 | QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const; |
135 | const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const; |
136 | #if QT_DEPRECATED_SINCE(5, 14) |
137 | QT_DEPRECATED int attachedPropertiesId(QQmlEnginePrivate *engine) const; |
138 | #endif |
139 | |
140 | int parserStatusCast() const; |
141 | const char *interfaceIId() const; |
142 | int propertyValueSourceCast() const; |
143 | int propertyValueInterceptorCast() const; |
144 | |
145 | int index() const; |
146 | |
147 | struct Q_QML_PRIVATE_EXPORT SingletonInstanceInfo |
148 | { |
149 | QJSValue (*scriptCallback)(QQmlEngine *, QJSEngine *) = nullptr; |
150 | std::function<QObject *(QQmlEngine *, QJSEngine *)> qobjectCallback = {}; |
151 | const QMetaObject *instanceMetaObject = nullptr; |
152 | QString typeName; |
153 | QUrl url; // used by composite singletons |
154 | }; |
155 | SingletonInstanceInfo *singletonInstanceInfo() const; |
156 | |
157 | QUrl sourceUrl() const; |
158 | |
159 | int enumValue(QQmlEnginePrivate *engine, const QHashedStringRef &, bool *ok) const; |
160 | int enumValue(QQmlEnginePrivate *engine, const QHashedCStringRef &, bool *ok) const; |
161 | int enumValue(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; |
162 | |
163 | int scopedEnumIndex(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; |
164 | int scopedEnumIndex(QQmlEnginePrivate *engine, const QString &, bool *ok) const; |
165 | int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const; |
166 | int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const; |
167 | int scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &, const QByteArray &, bool *ok) const; |
168 | int scopedEnumValue(QQmlEnginePrivate *engine, const QStringRef &, const QStringRef &, bool *ok) const; |
169 | |
170 | const QQmlTypePrivate *priv() const { return d.data(); } |
171 | static void refHandle(const QQmlTypePrivate *priv); |
172 | static void derefHandle(const QQmlTypePrivate *priv); |
173 | static int refCount(const QQmlTypePrivate *priv); |
174 | |
175 | enum RegistrationType { |
176 | CppType = 0, |
177 | SingletonType = 1, |
178 | InterfaceType = 2, |
179 | CompositeType = 3, |
180 | CompositeSingletonType = 4, |
181 | AnyRegistrationType = 255 |
182 | }; |
183 | |
184 | private: |
185 | QQmlType superType() const; |
186 | QQmlType resolveCompositeBaseType(QQmlEnginePrivate *engine) const; |
187 | int resolveCompositeEnumValue(QQmlEnginePrivate *engine, const QString &name, bool *ok) const; |
188 | QQmlPropertyCache *compositePropertyCache(QQmlEnginePrivate *engine) const; |
189 | friend uint qHash(const QQmlType &t, uint seed); |
190 | |
191 | QQmlRefPointer<const QQmlTypePrivate> d; |
192 | }; |
193 | |
194 | inline uint qHash(const QQmlType &t, uint seed = 0) |
195 | { |
196 | return qHash(reinterpret_cast<quintptr>(t.d.data()), seed); |
197 | } |
198 | |
199 | QT_END_NAMESPACE |
200 | |
201 | #endif // QQMLTYPE_P_H |
202 | |