1 | // Copyright (C) 2019 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 QQMLTYPE_P_H |
5 | #define QQMLTYPE_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <functional> |
19 | |
20 | #include <private/qtqmlglobal_p.h> |
21 | #include <private/qqmlrefcount_p.h> |
22 | |
23 | #include <QtQml/qqmlprivate.h> |
24 | #include <QtQml/qjsvalue.h> |
25 | |
26 | #include <QtCore/qobject.h> |
27 | #include <QtCore/qversionnumber.h> |
28 | |
29 | QT_BEGIN_NAMESPACE |
30 | |
31 | class QHashedCStringRef; |
32 | class QQmlTypePrivate; |
33 | class QHashedString; |
34 | class QHashedStringRef; |
35 | class QQmlCustomParser; |
36 | class QQmlEnginePrivate; |
37 | class QQmlPropertyCache; |
38 | |
39 | namespace QV4 { |
40 | struct String; |
41 | } |
42 | struct CompositeMetaTypeIds; |
43 | |
44 | class Q_QML_PRIVATE_EXPORT QQmlType |
45 | { |
46 | public: |
47 | QQmlType(); |
48 | QQmlType(const QQmlType &other); |
49 | QQmlType(QQmlType &&other); |
50 | QQmlType &operator =(const QQmlType &other); |
51 | QQmlType &operator =(QQmlType &&other); |
52 | explicit QQmlType(const QQmlTypePrivate *priv); |
53 | ~QQmlType(); |
54 | |
55 | bool operator ==(const QQmlType &other) const { |
56 | return d.data() == other.d.data(); |
57 | } |
58 | |
59 | bool isValid() const { return !d.isNull(); } |
60 | |
61 | QByteArray typeName() const; |
62 | QString qmlTypeName() const; |
63 | QString elementName() const; |
64 | |
65 | QHashedString module() const; |
66 | QTypeRevision version() const; |
67 | |
68 | bool availableInVersion(QTypeRevision version) const; |
69 | bool availableInVersion(const QHashedStringRef &module, QTypeRevision version) const; |
70 | |
71 | typedef QVariant (*CreateValueTypeFunc)(const QJSValue &); |
72 | CreateValueTypeFunc createValueTypeFunction() const; |
73 | |
74 | bool canConstructValueType() const; |
75 | bool canPopulateValueType() const; |
76 | |
77 | QObject *create() const; |
78 | QObject *create(void **, size_t) const; |
79 | QObject *createWithQQmlData() const; |
80 | |
81 | typedef void (*CreateFunc)(void *, void *); |
82 | CreateFunc createFunction() const; |
83 | |
84 | QQmlCustomParser *customParser() const; |
85 | |
86 | bool isCreatable() const; |
87 | typedef QObject *(*ExtensionFunc)(QObject *); |
88 | ExtensionFunc extensionFunction() const; |
89 | const QMetaObject *extensionMetaObject() const; |
90 | bool isExtendedType() const; |
91 | QString noCreationReason() const; |
92 | |
93 | bool isSingleton() const; |
94 | bool isInterface() const; |
95 | bool isComposite() const; |
96 | bool isCompositeSingleton() const; |
97 | bool isQObjectSingleton() const; |
98 | bool isQJSValueSingleton() const; |
99 | bool isSequentialContainer() const; |
100 | |
101 | QMetaType typeId() const; |
102 | QMetaType qListTypeId() const; |
103 | QMetaSequence listMetaSequence() const; |
104 | |
105 | const QMetaObject *metaObject() const; |
106 | const QMetaObject *baseMetaObject() const; |
107 | QTypeRevision metaObjectRevision() const; |
108 | bool containsRevisionedAttributes() const; |
109 | |
110 | QQmlAttachedPropertiesFunc attachedPropertiesFunction(QQmlEnginePrivate *engine) const; |
111 | const QMetaObject *attachedPropertiesType(QQmlEnginePrivate *engine) const; |
112 | |
113 | int parserStatusCast() const; |
114 | const char *interfaceIId() const; |
115 | int propertyValueSourceCast() const; |
116 | int propertyValueInterceptorCast() const; |
117 | int finalizerCast() const; |
118 | |
119 | int index() const; |
120 | |
121 | bool isInlineComponentType() const; |
122 | |
123 | struct Q_QML_PRIVATE_EXPORT SingletonInstanceInfo |
124 | { |
125 | std::function<QJSValue(QQmlEngine *, QJSEngine *)> scriptCallback = {}; |
126 | std::function<QObject *(QQmlEngine *, QJSEngine *)> qobjectCallback = {}; |
127 | const QMetaObject *instanceMetaObject = nullptr; |
128 | QString typeName; |
129 | QUrl url; // used by composite singletons |
130 | }; |
131 | SingletonInstanceInfo *singletonInstanceInfo() const; |
132 | |
133 | QUrl sourceUrl() const; |
134 | |
135 | int enumValue(QQmlEnginePrivate *engine, const QHashedStringRef &, bool *ok) const; |
136 | int enumValue(QQmlEnginePrivate *engine, const QHashedCStringRef &, bool *ok) const; |
137 | int enumValue(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; |
138 | |
139 | int scopedEnumIndex(QQmlEnginePrivate *engine, const QV4::String *, bool *ok) const; |
140 | int scopedEnumIndex(QQmlEnginePrivate *engine, const QString &, bool *ok) const; |
141 | int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QV4::String *, bool *ok) const; |
142 | int scopedEnumValue(QQmlEnginePrivate *engine, int index, const QString &, bool *ok) const; |
143 | int scopedEnumValue(QQmlEnginePrivate *engine, const QByteArray &, const QByteArray &, bool *ok) const; |
144 | int scopedEnumValue(QQmlEnginePrivate *engine, QStringView, QStringView, bool *ok) const; |
145 | |
146 | const QQmlTypePrivate *priv() const { return d.data(); } |
147 | static void refHandle(const QQmlTypePrivate *priv); |
148 | static void derefHandle(const QQmlTypePrivate *priv); |
149 | static int refCount(const QQmlTypePrivate *priv); |
150 | |
151 | enum RegistrationType { |
152 | CppType = 0, |
153 | SingletonType = 1, |
154 | InterfaceType = 2, |
155 | CompositeType = 3, |
156 | CompositeSingletonType = 4, |
157 | InlineComponentType = 5, |
158 | SequentialContainerType = 6, |
159 | AnyRegistrationType = 255 |
160 | }; |
161 | |
162 | QQmlType containingType() const; |
163 | |
164 | void createProxy(QObject *instance) const; |
165 | |
166 | private: |
167 | friend class QQmlTypePrivate; |
168 | friend size_t qHash(const QQmlType &t, size_t seed); |
169 | QQmlRefPointer<const QQmlTypePrivate> d; |
170 | }; |
171 | |
172 | inline size_t qHash(const QQmlType &t, size_t seed = 0) |
173 | { |
174 | return qHash(key: reinterpret_cast<quintptr>(t.d.data()), seed); |
175 | } |
176 | |
177 | QT_END_NAMESPACE |
178 | |
179 | #endif // QQMLTYPE_P_H |
180 | |