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);
184 static void freeUnusedTypesAndCaches();
186 static QMetaProperty defaultProperty(
const QMetaObject *);
187 static QMetaProperty defaultProperty(QObject *);
188 static QMetaMethod defaultMethod(
const QMetaObject *);
189 static QMetaMethod defaultMethod(QObject *);
191 static QObject *toQObject(
const QVariant &,
bool *ok =
nullptr);
193 static QMetaType listValueType(QMetaType type);
194 static QQmlAttachedPropertiesFunc attachedPropertiesFunc(
195 QQmlTypeLoader *typeLoader,
const QMetaObject *);
196 static bool isInterface(QMetaType type);
197 static const char *interfaceIId(QMetaType type);
198 static bool isList(QMetaType type);
200 static QTypeRevision latestModuleVersion(
const QString &uri);
201 static bool isStronglyLockedModule(
const QString &uri, QTypeRevision version);
202 static QTypeRevision matchingModuleVersion(
const QString &module, QTypeRevision version);
203 static QQmlTypeModule *typeModule(
const QString &uri, QTypeRevision version);
205 static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
207 enum class CachedUnitLookupError {
214 enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
215 static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
216 const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
219 static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
220 static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
222 static QString prettyTypeName(
const QObject *object);
224 template <
typename QQmlTypeContainer>
225 static void removeQQmlTypePrivate(QQmlTypeContainer &container,
226 const QQmlTypePrivate *reference)
228 for (
typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) {
229 if (*it == reference)
230 it = container.erase(it);
236 template <
typename InlineComponentContainer>
237 static void removeFromInlineComponents(
238 InlineComponentContainer &container,
const QQmlTypePrivate *reference)
240 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
241 for (
auto it = container.begin(), end = container.end(); it != end;) {
242 if (equalBaseUrls(it.key(), referenceUrl))
243 it = container.erase(it);
249 static void removeFromInlineComponents(
250 QSet<QUrl> &container,
const QQmlTypePrivate *reference)
252 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
253 for (
auto it = container.begin(), end = container.end(); it != end;) {
254 if (equalBaseUrls(*it, referenceUrl))
255 it = container.erase(it);
261 static void registerTypeAlias(
int typeId,
const QString &name);
263 static int registerAutoParentFunction(
const QQmlPrivate::RegisterAutoParent &autoparent);
264 static void unregisterAutoParentFunction(
const QQmlPrivate::AutoParentFunction &function);
266 static QQmlType registerSequentialContainer(
267 const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration);
268 static void unregisterSequentialContainer(
int id);
270 static int registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration);
271 static void clearTypeRegistrations();
273 static QList<QQmlProxyMetaObject::ProxyData> proxyData(
const QMetaObject *mo,
274 const QMetaObject *baseMetaObject,
275 QMetaObject *lastMetaObject);
281 static void clone(QMetaObjectBuilder &builder,
const QMetaObject *mo,
282 const QMetaObject *ignoreStart,
const QMetaObject *ignoreEnd,
285 static void qmlInsertModuleRegistration(
const QString &uri,
void (*registerFunction)());
286 static void qmlRemoveModuleRegistration(
const QString &uri);
288 static bool qmlRegisterModuleTypes(
const QString &uri);
290 static bool isValueType(QMetaType type);
291 static QQmlValueType *valueType(QMetaType metaType);
292 static const QMetaObject *metaObjectForValueType(QMetaType type);
294 static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t);
295 static void registerInternalCompositeType(
296 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
297 static void unregisterInternalCompositeType(
298 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
299 static void deepClearCompositeType(
300 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &oldUnit);
301 static int countInternalCompositeTypeSelfReferences(
302 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
303 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(
305 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(