42 friend class QQmlDesignerMetaObject;
46 enum class RegistrationResult {
49 NoRegistrationFunction
52 static QUrl inlineComponentUrl(
const QUrl &baseUrl,
const QString &name)
55 icUrl.setFragment(name);
59 static bool equalBaseUrls(
const QUrl &aUrl,
const QUrl &bUrl)
62 return aUrl.port() == bUrl.port()
63 && aUrl.scheme() == bUrl.scheme()
64 && aUrl.userName() == bUrl.userName()
65 && aUrl.password() == bUrl.password()
66 && aUrl.host() == bUrl.host()
67 && aUrl.path() == bUrl.path()
68 && aUrl.query() == bUrl.query();
71 static QUrl normalizedUrl(
const QUrl &unNormalizedUrl)
73 QUrl normalized(unNormalizedUrl);
74 if (normalized.scheme() == QLatin1String(
"qrc"))
75 normalized.setHost(QString());
79 enum CompositeTypeLookupMode {
85 static QQmlType findCompositeType(
87 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
88 CompositeTypeLookupMode mode = NonSingleton);
89 static QQmlType findOrCreateFactualInlineComponentType(
91 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
92 static QQmlType findOrCreateFactualInlineComponentType(
93 const QUrl &baseUrl,
const QString &name,
94 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
96 return findOrCreateFactualInlineComponentType(inlineComponentUrl(baseUrl, name), compilationUnit);
99 static QQmlType registerType(
const QQmlPrivate::RegisterType &type);
100 static QQmlType registerInterface(
const QQmlPrivate::RegisterInterface &type);
101 static QQmlType registerSingletonType(
102 const QQmlPrivate::RegisterSingletonType &type,
103 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
104 static QQmlType registerCompositeSingletonType(
105 const QQmlPrivate::RegisterCompositeSingletonType &type,
106 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
107 static QQmlType registerCompositeType(
const QQmlPrivate::RegisterCompositeType &type);
108 static RegistrationResult registerPluginTypes(QObject *instance,
const QString &basePath,
109 const QString &uri,
const QString &typeNamespace,
110 QTypeRevision version, QList<QQmlError> *errors);
112 static QQmlType typeForUrl(
113 const QUrl &url,
const QHashedStringRef &typeName, CompositeTypeLookupMode mode,
114 QList<QQmlError> *errors, QTypeRevision version = QTypeRevision());
116 static QQmlType findOrCreateSpeculativeInlineComponentType(
const QUrl &url);
117 static QQmlType findOrCreateSpeculativeInlineComponentType(
const QQmlType &outerType,
const QString &name)
119 return outerType.isComposite()
120 ? findOrCreateSpeculativeInlineComponentType(
121 inlineComponentUrl(outerType.sourceUrl(), name))
125 static void unregisterType(
int type);
127 static void registerMetaObjectForType(
const QMetaObject *metaobject,
const QQmlTypePrivate *type);
129 static void registerModule(
const char *uri, QTypeRevision version);
130 static bool protectModule(
const QString &uri, QTypeRevision version,
131 bool weakProtectAllVersions =
false);
133 static void registerModuleImport(
const QString &uri, QTypeRevision version,
134 const QQmlDirParser::Import &import);
135 static void unregisterModuleImport(
const QString &uri, QTypeRevision version,
136 const QQmlDirParser::Import &import);
137 static QList<QQmlDirParser::Import> moduleImports(
const QString &uri, QTypeRevision version);
139 static int typeId(
const char *uri, QTypeRevision version,
const char *qmlName);
141 static void registerUndeletableType(
const QQmlType &dtype);
143 static QList<QString> qmlTypeNames();
144 static QList<QQmlType> qmlTypes();
145 static QList<QQmlType> qmlSingletonTypes();
146 static QList<QQmlType> qmlAllTypes();
148 static QQmlType qmlType(
const QString &qualifiedName, QTypeRevision version);
149 static QQmlType qmlType(
const QHashedStringRef &name,
const QHashedStringRef &module, QTypeRevision version);
150 static QQmlType qmlType(
const QMetaObject *);
151 static QQmlType qmlType(
const QMetaObject *metaObject,
const QHashedStringRef &module, QTypeRevision version);
152 static QQmlType qmlTypeById(
int qmlTypeId);
153 static QQmlType firstQmlTypeForAttachmentMetaObject(
const QMetaObject *attachmentMetaObject);
155 static QQmlType qmlType(QMetaType metaType);
156 static QQmlType qmlListType(QMetaType metaType);
158 static QQmlType qmlType(
const QUrl &unNormalizedUrl);
160 static QQmlPropertyCache::ConstPtr propertyCache(
161 QObject *object, QTypeRevision version = QTypeRevision());
162 static QQmlPropertyCache::ConstPtr propertyCache(
163 const QMetaObject *metaObject, QTypeRevision version = QTypeRevision());
164 static QQmlPropertyCache::ConstPtr propertyCache(
165 const QQmlType &type, QTypeRevision version);
168 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
169 static QQmlMetaObject metaObjectForType(QMetaType metaType);
170 static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType);
171 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType);
172 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(
173 QMetaType metaType, QTypeRevision version);
175 static bool canConvert(QObject *o, QMetaType metaType);
176 static bool canConvert(
const QQmlPropertyCache::ConstPtr &from, QMetaType metaType);
178 static void freeUnusedTypesAndCaches();
180 static QMetaProperty defaultProperty(
const QMetaObject *);
181 static QMetaProperty defaultProperty(QObject *);
182 static QMetaMethod defaultMethod(
const QMetaObject *);
183 static QMetaMethod defaultMethod(QObject *);
185 static QObject *toQObject(
const QVariant &,
bool *ok =
nullptr);
187 static QMetaType listValueType(QMetaType type);
188 static QQmlAttachedPropertiesFunc attachedPropertiesFunc(
189 QQmlTypeLoader *typeLoader,
const QMetaObject *);
190 static bool isInterface(QMetaType type);
191 static const char *interfaceIId(QMetaType type);
192 static bool isList(QMetaType type);
194 static QTypeRevision latestModuleVersion(
const QString &uri);
195 static bool isStronglyLockedModule(
const QString &uri, QTypeRevision version);
196 static QTypeRevision matchingModuleVersion(
const QString &module, QTypeRevision version);
197 static QQmlTypeModule *typeModule(
const QString &uri, QTypeRevision version);
199 static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
201 enum class CachedUnitLookupError {
208 enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
209 static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
210 const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
213 static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
214 static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
216 static QString prettyTypeName(
const QObject *object);
218 template <
typename QQmlTypeContainer>
219 static void removeQQmlTypePrivate(QQmlTypeContainer &container,
220 const QQmlTypePrivate *reference)
222 for (
typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) {
223 if (*it == reference)
224 it = container.erase(it);
230 template <
typename InlineComponentContainer>
231 static void removeFromInlineComponents(
232 InlineComponentContainer &container,
const QQmlTypePrivate *reference)
234 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
235 for (
auto it = container.begin(), end = container.end(); it != end;) {
236 if (equalBaseUrls(it.key(), referenceUrl))
237 it = container.erase(it);
243 static void removeFromInlineComponents(
244 QSet<QUrl> &container,
const QQmlTypePrivate *reference)
246 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
247 for (
auto it = container.begin(), end = container.end(); it != end;) {
248 if (equalBaseUrls(*it, referenceUrl))
249 it = container.erase(it);
255 static void registerTypeAlias(
int typeId,
const QString &name);
257 static int registerAutoParentFunction(
const QQmlPrivate::RegisterAutoParent &autoparent);
258 static void unregisterAutoParentFunction(
const QQmlPrivate::AutoParentFunction &function);
260 static QQmlType registerSequentialContainer(
261 const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration);
262 static void unregisterSequentialContainer(
int id);
264 static int registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration);
265 static void clearTypeRegistrations();
267 static QList<QQmlProxyMetaObject::ProxyData> proxyData(
const QMetaObject *mo,
268 const QMetaObject *baseMetaObject,
269 QMetaObject *lastMetaObject);
275 static void clone(QMetaObjectBuilder &builder,
const QMetaObject *mo,
276 const QMetaObject *ignoreStart,
const QMetaObject *ignoreEnd,
279 static void qmlInsertModuleRegistration(
const QString &uri,
void (*registerFunction)());
280 static void qmlRemoveModuleRegistration(
const QString &uri);
282 static bool qmlRegisterModuleTypes(
const QString &uri);
284 static bool isValueType(QMetaType type);
285 static QQmlValueType *valueType(QMetaType metaType);
286 static const QMetaObject *metaObjectForValueType(QMetaType type);
288 static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t);
289 static void registerInternalCompositeType(
290 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
291 static void unregisterInternalCompositeType(
292 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
293 static int countInternalCompositeTypeSelfReferences(
294 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
295 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(
297 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(