44 friend class QQmlDesignerMetaObject;
48 enum class RegistrationResult {
51 NoRegistrationFunction
54 static QUrl inlineComponentUrl(
const QUrl &baseUrl,
const QString &name)
57 icUrl.setFragment(name);
61 static bool equalBaseUrls(
const QUrl &aUrl,
const QUrl &bUrl)
64 return aUrl.port() == bUrl.port()
65 && aUrl.scheme() == bUrl.scheme()
66 && aUrl.userName() == bUrl.userName()
67 && aUrl.password() == bUrl.password()
68 && aUrl.host() == bUrl.host()
69 && aUrl.path() == bUrl.path()
70 && aUrl.query() == bUrl.query();
73 static QUrl normalizedUrl(
const QUrl &unNormalizedUrl)
75 QUrl normalized(unNormalizedUrl);
76 if (normalized.scheme() == QLatin1String(
"qrc"))
77 normalized.setHost(QString());
81 enum CompositeTypeLookupMode {
87 static QQmlType findCompositeType(
89 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
90 CompositeTypeLookupMode mode = NonSingleton);
91 static QQmlType findOrCreateFactualInlineComponentType(
93 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
94 static QQmlType findOrCreateFactualInlineComponentType(
95 const QUrl &baseUrl,
const QString &name,
96 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
98 return findOrCreateFactualInlineComponentType(inlineComponentUrl(baseUrl, name), compilationUnit);
101 static QQmlType registerType(
const QQmlPrivate::RegisterType &type);
102 static QQmlType registerInterface(
const QQmlPrivate::RegisterInterface &type);
103 static QQmlType registerSingletonType(
104 const QQmlPrivate::RegisterSingletonType &type,
105 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
106 static QQmlType registerCompositeSingletonType(
107 const QQmlPrivate::RegisterCompositeSingletonType &type,
108 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
109 static QQmlType registerCompositeType(
const QQmlPrivate::RegisterCompositeType &type);
110 static RegistrationResult registerPluginTypes(QObject *instance,
const QString &basePath,
111 const QString &uri,
const QString &typeNamespace,
112 QTypeRevision version, QList<QQmlError> *errors);
114 static QQmlType typeForUrl(
115 const QUrl &url,
const QHashedStringRef &typeName, CompositeTypeLookupMode mode,
116 QList<QQmlError> *errors, QTypeRevision version = QTypeRevision());
118 static QQmlType findOrCreateSpeculativeInlineComponentType(
const QUrl &url);
119 static QQmlType findOrCreateSpeculativeInlineComponentType(
const QQmlType &outerType,
const QString &name)
121 return (outerType.isComposite() && !outerType.isInlineComponent())
122 ? findOrCreateSpeculativeInlineComponentType(
123 inlineComponentUrl(outerType.sourceUrl(), name))
127 static void unregisterType(
int type);
129 static void registerMetaObjectForType(
const QMetaObject *metaobject,
const QQmlTypePrivate *type);
131 static void registerModule(
const char *uri, QTypeRevision version);
132 static bool protectModule(
const QString &uri, QTypeRevision version,
133 bool weakProtectAllVersions =
false);
135 static void registerModuleImport(
const QString &uri, QTypeRevision version,
136 const QQmlDirParser::Import &import);
137 static void unregisterModuleImport(
const QString &uri, QTypeRevision version,
138 const QQmlDirParser::Import &import);
139 static QList<QQmlDirParser::Import> moduleImports(
const QString &uri, QTypeRevision version);
141 static int typeId(
const char *uri, QTypeRevision version,
const char *qmlName);
143 static void registerUndeletableType(
const QQmlType &dtype);
145 static QList<QString> qmlTypeNames();
146 static QList<QQmlType> qmlTypes();
147 static QList<QQmlType> qmlSingletonTypes();
148 static QList<QQmlType> qmlAllTypes();
150 static QQmlType qmlType(
const QString &qualifiedName, QTypeRevision version);
151 static QQmlType qmlType(
const QHashedStringRef &name,
const QHashedStringRef &module, QTypeRevision version);
152 static QQmlType qmlType(
const QMetaObject *);
153 static QQmlType qmlType(
const QMetaObject *metaObject,
const QHashedStringRef &module, QTypeRevision version);
154 static QQmlType qmlTypeById(
int qmlTypeId);
155 static QQmlType firstQmlTypeForAttachmentMetaObject(
const QMetaObject *attachmentMetaObject);
157 static QQmlType qmlType(QMetaType metaType);
158 static QQmlType qmlListType(QMetaType metaType);
160 static QQmlType qmlType(
const QUrl &unNormalizedUrl);
162 static QQmlPropertyCache::ConstPtr propertyCache(
163 QObject *object, QTypeRevision version = QTypeRevision());
164 static QQmlPropertyCache::ConstPtr propertyCache(
165 const QMetaObject *metaObject, QTypeRevision version = QTypeRevision());
166 static QQmlPropertyCache::ConstPtr propertyCache(
167 const QQmlType &type, QTypeRevision version);
170 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
171 static QQmlMetaObject metaObjectForType(QMetaType metaType);
172 static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType);
173 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType);
174 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(
175 QMetaType metaType, QTypeRevision version);
178 static QVarLengthArray<QQmlPropertyCache::ConstPtr, 4> rawCompositePropertyCachesForType(
181 static bool canConvert(QObject *o, QMetaType metaType);
182 static bool canConvert(
const QQmlPropertyCache::ConstPtr &from, QMetaType metaType);
183 static bool canLosslesslyHoldUndefined(QMetaType metaType);
185 static void freeUnusedTypesAndCaches();
187 static QMetaProperty defaultProperty(
const QMetaObject *);
188 static QMetaProperty defaultProperty(QObject *);
189 static QMetaMethod defaultMethod(
const QMetaObject *);
190 static QMetaMethod defaultMethod(QObject *);
192 static QObject *toQObject(
const QVariant &,
bool *ok =
nullptr);
194 static QMetaType listValueType(QMetaType type);
195 static QQmlAttachedPropertiesFunc attachedPropertiesFunc(
196 QQmlTypeLoader *typeLoader,
const QMetaObject *);
197 static bool isInterface(QMetaType type);
198 static const char *interfaceIId(QMetaType type);
199 static bool isList(QMetaType type);
201 static QTypeRevision latestModuleVersion(
const QString &uri);
202 static bool isStronglyLockedModule(
const QString &uri, QTypeRevision version);
203 static QTypeRevision matchingModuleVersion(
const QString &module, QTypeRevision version);
204 static QQmlTypeModule *typeModule(
const QString &uri, QTypeRevision version);
206 static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
208 enum class CachedUnitLookupError {
215 enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
216 static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
217 const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
220 static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
221 static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
223 static QString prettyTypeName(
const QObject *object);
225 template <
typename QQmlTypeContainer>
226 static void removeQQmlTypePrivate(QQmlTypeContainer &container,
227 const QQmlTypePrivate *reference)
229 for (
typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) {
230 if (*it == reference)
231 it = container.erase(it);
237 template <
typename InlineComponentContainer>
238 static void removeFromInlineComponents(
239 InlineComponentContainer &container,
const QQmlTypePrivate *reference)
241 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
242 for (
auto it = container.begin(), end = container.end(); it != end;) {
243 if (equalBaseUrls(it.key(), referenceUrl))
244 it = container.erase(it);
250 static void removeFromInlineComponents(
251 QSet<QUrl> &container,
const QQmlTypePrivate *reference)
253 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
254 for (
auto it = container.begin(), end = container.end(); it != end;) {
255 if (equalBaseUrls(*it, referenceUrl))
256 it = container.erase(it);
262 static void registerTypeAlias(
int typeId,
const QString &name);
264 static int registerAutoParentFunction(
const QQmlPrivate::RegisterAutoParent &autoparent);
265 static void unregisterAutoParentFunction(
const QQmlPrivate::AutoParentFunction &function);
267 static QQmlType registerSequentialContainer(
268 const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration);
269 static void unregisterSequentialContainer(
int id);
271 static int registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration);
272 static void clearTypeRegistrations();
274 static QList<QQmlProxyMetaObject::ProxyData> proxyData(
const QMetaObject *mo,
275 const QMetaObject *baseMetaObject,
276 QMetaObject *lastMetaObject);
282 static void clone(QMetaObjectBuilder &builder,
const QMetaObject *mo,
283 const QMetaObject *ignoreStart,
const QMetaObject *ignoreEnd,
286 static void qmlInsertModuleRegistration(
const QString &uri,
void (*registerFunction)());
287 static void qmlRemoveModuleRegistration(
const QString &uri);
289 static bool qmlRegisterModuleTypes(
const QString &uri);
291 static bool isValueType(QMetaType type);
292 static QQmlValueType *valueType(QMetaType metaType);
293 static const QMetaObject *metaObjectForValueType(QMetaType type);
295 static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t);
296 static void registerInternalCompositeType(
297 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
298 static void unregisterInternalCompositeType(
299 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
300 static void deepClearCompositeType(
301 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &oldUnit);
302 static int countInternalCompositeTypeSelfReferences(
303 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
304 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(
306 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(