43 friend class QQmlDesignerMetaObject;
47 enum class RegistrationResult {
50 NoRegistrationFunction
53 static QUrl inlineComponentUrl(
const QUrl &baseUrl,
const QString &name)
56 icUrl.setFragment(name);
60 static bool equalBaseUrls(
const QUrl &aUrl,
const QUrl &bUrl)
63 return aUrl.port() == bUrl.port()
64 && aUrl.scheme() == bUrl.scheme()
65 && aUrl.userName() == bUrl.userName()
66 && aUrl.password() == bUrl.password()
67 && aUrl.host() == bUrl.host()
68 && aUrl.path() == bUrl.path()
69 && aUrl.query() == bUrl.query();
72 static QUrl normalizedUrl(
const QUrl &unNormalizedUrl)
74 QUrl normalized(unNormalizedUrl);
75 if (normalized.scheme() == QLatin1String(
"qrc"))
76 normalized.setHost(QString());
80 enum CompositeTypeLookupMode {
86 static QQmlType findCompositeType(
88 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
89 CompositeTypeLookupMode mode = NonSingleton);
90 static QQmlType findOrCreateFactualInlineComponentType(
92 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
93 static QQmlType findOrCreateFactualInlineComponentType(
94 const QUrl &baseUrl,
const QString &name,
95 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
97 return findOrCreateFactualInlineComponentType(inlineComponentUrl(baseUrl, name), compilationUnit);
100 static QQmlType registerType(
const QQmlPrivate::RegisterType &type);
101 static QQmlType registerInterface(
const QQmlPrivate::RegisterInterface &type);
102 static QQmlType registerSingletonType(
103 const QQmlPrivate::RegisterSingletonType &type,
104 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
105 static QQmlType registerCompositeSingletonType(
106 const QQmlPrivate::RegisterCompositeSingletonType &type,
107 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
108 static QQmlType registerCompositeType(
const QQmlPrivate::RegisterCompositeType &type);
109 static RegistrationResult registerPluginTypes(QObject *instance,
const QString &basePath,
110 const QString &uri,
const QString &typeNamespace,
111 QTypeRevision version, QList<QQmlError> *errors);
113 static QQmlType typeForUrl(
114 const QUrl &url,
const QHashedStringRef &typeName, CompositeTypeLookupMode mode,
115 QList<QQmlError> *errors, QTypeRevision version = QTypeRevision());
117 static QQmlType findOrCreateSpeculativeInlineComponentType(
const QUrl &url);
118 static QQmlType findOrCreateSpeculativeInlineComponentType(
const QQmlType &outerType,
const QString &name)
120 return outerType.isComposite()
121 ? findOrCreateSpeculativeInlineComponentType(
122 inlineComponentUrl(outerType.sourceUrl(), name))
126 static void unregisterType(
int type);
128 static void registerMetaObjectForType(
const QMetaObject *metaobject,
const QQmlTypePrivate *type);
130 static void registerModule(
const char *uri, QTypeRevision version);
131 static bool protectModule(
const QString &uri, QTypeRevision version,
132 bool weakProtectAllVersions =
false);
134 static void registerModuleImport(
const QString &uri, QTypeRevision version,
135 const QQmlDirParser::Import &import);
136 static void unregisterModuleImport(
const QString &uri, QTypeRevision version,
137 const QQmlDirParser::Import &import);
138 static QList<QQmlDirParser::Import> moduleImports(
const QString &uri, QTypeRevision version);
140 static int typeId(
const char *uri, QTypeRevision version,
const char *qmlName);
142 static void registerUndeletableType(
const QQmlType &dtype);
144 static QList<QString> qmlTypeNames();
145 static QList<QQmlType> qmlTypes();
146 static QList<QQmlType> qmlSingletonTypes();
147 static QList<QQmlType> qmlAllTypes();
149 static QQmlType qmlType(
const QString &qualifiedName, QTypeRevision version);
150 static QQmlType qmlType(
const QHashedStringRef &name,
const QHashedStringRef &module, QTypeRevision version);
151 static QQmlType qmlType(
const QMetaObject *);
152 static QQmlType qmlType(
const QMetaObject *metaObject,
const QHashedStringRef &module, QTypeRevision version);
153 static QQmlType qmlTypeById(
int qmlTypeId);
154 static QQmlType firstQmlTypeForAttachmentMetaObject(
const QMetaObject *attachmentMetaObject);
156 static QQmlType qmlType(QMetaType metaType);
157 static QQmlType qmlListType(QMetaType metaType);
159 static QQmlType qmlType(
const QUrl &unNormalizedUrl);
161 static QQmlPropertyCache::ConstPtr propertyCache(
162 QObject *object, QTypeRevision version = QTypeRevision());
163 static QQmlPropertyCache::ConstPtr propertyCache(
164 const QMetaObject *metaObject, QTypeRevision version = QTypeRevision());
165 static QQmlPropertyCache::ConstPtr propertyCache(
166 const QQmlType &type, QTypeRevision version);
169 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
170 static QQmlMetaObject metaObjectForType(QMetaType metaType);
171 static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType);
172 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType);
173 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(
174 QMetaType metaType, QTypeRevision version);
176 static bool canConvert(QObject *o, QMetaType metaType);
177 static bool canConvert(
const QQmlPropertyCache::ConstPtr &from, QMetaType metaType);
179 static void freeUnusedTypesAndCaches();
181 static QMetaProperty defaultProperty(
const QMetaObject *);
182 static QMetaProperty defaultProperty(QObject *);
183 static QMetaMethod defaultMethod(
const QMetaObject *);
184 static QMetaMethod defaultMethod(QObject *);
186 static QObject *toQObject(
const QVariant &,
bool *ok =
nullptr);
188 static QMetaType listValueType(QMetaType type);
189 static QQmlAttachedPropertiesFunc attachedPropertiesFunc(
190 QQmlTypeLoader *typeLoader,
const QMetaObject *);
191 static bool isInterface(QMetaType type);
192 static const char *interfaceIId(QMetaType type);
193 static bool isList(QMetaType type);
195 static QTypeRevision latestModuleVersion(
const QString &uri);
196 static bool isStronglyLockedModule(
const QString &uri, QTypeRevision version);
197 static QTypeRevision matchingModuleVersion(
const QString &module, QTypeRevision version);
198 static QQmlTypeModule *typeModule(
const QString &uri, QTypeRevision version);
200 static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
202 enum class CachedUnitLookupError {
209 enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
210 static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
211 const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
214 static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
215 static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
217 static QString prettyTypeName(
const QObject *object);
219 template <
typename QQmlTypeContainer>
220 static void removeQQmlTypePrivate(QQmlTypeContainer &container,
221 const QQmlTypePrivate *reference)
223 for (
typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) {
224 if (*it == reference)
225 it = container.erase(it);
231 template <
typename InlineComponentContainer>
232 static void removeFromInlineComponents(
233 InlineComponentContainer &container,
const QQmlTypePrivate *reference)
235 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
236 for (
auto it = container.begin(), end = container.end(); it != end;) {
237 if (equalBaseUrls(it.key(), referenceUrl))
238 it = container.erase(it);
244 static void removeFromInlineComponents(
245 QSet<QUrl> &container,
const QQmlTypePrivate *reference)
247 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
248 for (
auto it = container.begin(), end = container.end(); it != end;) {
249 if (equalBaseUrls(*it, referenceUrl))
250 it = container.erase(it);
256 static void registerTypeAlias(
int typeId,
const QString &name);
258 static int registerAutoParentFunction(
const QQmlPrivate::RegisterAutoParent &autoparent);
259 static void unregisterAutoParentFunction(
const QQmlPrivate::AutoParentFunction &function);
261 static QQmlType registerSequentialContainer(
262 const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration);
263 static void unregisterSequentialContainer(
int id);
265 static int registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration);
266 static void clearTypeRegistrations();
268 static QList<QQmlProxyMetaObject::ProxyData> proxyData(
const QMetaObject *mo,
269 const QMetaObject *baseMetaObject,
270 QMetaObject *lastMetaObject);
276 static void clone(QMetaObjectBuilder &builder,
const QMetaObject *mo,
277 const QMetaObject *ignoreStart,
const QMetaObject *ignoreEnd,
280 static void qmlInsertModuleRegistration(
const QString &uri,
void (*registerFunction)());
281 static void qmlRemoveModuleRegistration(
const QString &uri);
283 static bool qmlRegisterModuleTypes(
const QString &uri);
285 static bool isValueType(QMetaType type);
286 static QQmlValueType *valueType(QMetaType metaType);
287 static const QMetaObject *metaObjectForValueType(QMetaType type);
289 static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t);
290 static void registerInternalCompositeType(
291 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
292 static void unregisterInternalCompositeType(
293 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
294 static int countInternalCompositeTypeSelfReferences(
295 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
296 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(
298 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(