39 friend class QQmlDesignerMetaObject;
43 enum class RegistrationResult {
46 NoRegistrationFunction
49 static QUrl inlineComponentUrl(
const QUrl &baseUrl,
const QString &name)
52 icUrl.setFragment(name);
56 static bool equalBaseUrls(
const QUrl &aUrl,
const QUrl &bUrl)
59 return aUrl.port() == bUrl.port()
60 && aUrl.scheme() == bUrl.scheme()
61 && aUrl.userName() == bUrl.userName()
62 && aUrl.password() == bUrl.password()
63 && aUrl.host() == bUrl.host()
64 && aUrl.path() == bUrl.path()
65 && aUrl.query() == bUrl.query();
68 static QUrl normalizedUrl(
const QUrl &unNormalizedUrl)
70 QUrl normalized(unNormalizedUrl);
71 if (normalized.scheme() == QLatin1String(
"qrc"))
72 normalized.setHost(QString());
76 enum CompositeTypeLookupMode {
82 static QQmlType findCompositeType(
84 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
85 CompositeTypeLookupMode mode = NonSingleton);
86 static QQmlType findInlineComponentType(
88 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
89 static QQmlType findInlineComponentType(
90 const QUrl &baseUrl,
const QString &name,
91 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
93 return findInlineComponentType(inlineComponentUrl(baseUrl, name), compilationUnit);
96 static QQmlType registerType(
const QQmlPrivate::RegisterType &type);
97 static QQmlType registerInterface(
const QQmlPrivate::RegisterInterface &type);
98 static QQmlType registerSingletonType(
99 const QQmlPrivate::RegisterSingletonType &type,
100 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
101 static QQmlType registerCompositeSingletonType(
102 const QQmlPrivate::RegisterCompositeSingletonType &type,
103 const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo);
104 static QQmlType registerCompositeType(
const QQmlPrivate::RegisterCompositeType &type);
105 static RegistrationResult registerPluginTypes(QObject *instance,
const QString &basePath,
106 const QString &uri,
const QString &typeNamespace,
107 QTypeRevision version, QList<QQmlError> *errors);
109 static QQmlType typeForUrl(
110 const QUrl &url,
const QHashedStringRef &typeName, CompositeTypeLookupMode mode,
111 QList<QQmlError> *errors, QTypeRevision version = QTypeRevision());
113 static QQmlType fetchOrCreateInlineComponentTypeForUrl(
const QUrl &url);
114 static QQmlType inlineComponentType(
const QQmlType &outerType,
const QString &name)
116 return outerType.isComposite()
117 ? fetchOrCreateInlineComponentTypeForUrl(
118 inlineComponentUrl(outerType.sourceUrl(), name))
122 static void unregisterType(
int type);
124 static void registerMetaObjectForType(
const QMetaObject *metaobject,
const QQmlTypePrivate *type);
126 static void registerModule(
const char *uri, QTypeRevision version);
127 static bool protectModule(
const QString &uri, QTypeRevision version,
128 bool weakProtectAllVersions =
false);
130 static void registerModuleImport(
const QString &uri, QTypeRevision version,
131 const QQmlDirParser::Import &import);
132 static void unregisterModuleImport(
const QString &uri, QTypeRevision version,
133 const QQmlDirParser::Import &import);
134 static QList<QQmlDirParser::Import> moduleImports(
const QString &uri, QTypeRevision version);
136 static int typeId(
const char *uri, QTypeRevision version,
const char *qmlName);
138 static void registerUndeletableType(
const QQmlType &dtype);
140 static QList<QString> qmlTypeNames();
141 static QList<QQmlType> qmlTypes();
142 static QList<QQmlType> qmlSingletonTypes();
143 static QList<QQmlType> qmlAllTypes();
145 static QQmlType qmlType(
const QString &qualifiedName, QTypeRevision version);
146 static QQmlType qmlType(
const QHashedStringRef &name,
const QHashedStringRef &module, QTypeRevision version);
147 static QQmlType qmlType(
const QMetaObject *);
148 static QQmlType qmlType(
const QMetaObject *metaObject,
const QHashedStringRef &module, QTypeRevision version);
149 static QQmlType qmlTypeById(
int qmlTypeId);
150 static QQmlType firstQmlTypeForAttachmentMetaObject(
const QMetaObject *attachmentMetaObject);
152 static QQmlType qmlType(QMetaType metaType);
153 static QQmlType qmlListType(QMetaType metaType);
155 static QQmlType qmlType(
const QUrl &unNormalizedUrl);
157 static QQmlPropertyCache::ConstPtr propertyCache(
158 QObject *object, QTypeRevision version = QTypeRevision());
159 static QQmlPropertyCache::ConstPtr propertyCache(
160 const QMetaObject *metaObject, QTypeRevision version = QTypeRevision());
161 static QQmlPropertyCache::ConstPtr propertyCache(
162 const QQmlType &type, QTypeRevision version);
165 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
166 static QQmlMetaObject metaObjectForType(QMetaType metaType);
167 static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType);
168 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType);
169 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(
170 QMetaType metaType, QTypeRevision version);
171 static bool canConvert(QObject *o, QMetaType metaType);
173 static void freeUnusedTypesAndCaches();
175 static QMetaProperty defaultProperty(
const QMetaObject *);
176 static QMetaProperty defaultProperty(QObject *);
177 static QMetaMethod defaultMethod(
const QMetaObject *);
178 static QMetaMethod defaultMethod(QObject *);
180 static QObject *toQObject(
const QVariant &,
bool *ok =
nullptr);
182 static QMetaType listValueType(QMetaType type);
183 static QQmlAttachedPropertiesFunc attachedPropertiesFunc(
184 QQmlTypeLoader *typeLoader,
const QMetaObject *);
185 static bool isInterface(QMetaType type);
186 static const char *interfaceIId(QMetaType type);
187 static bool isList(QMetaType type);
189 static QTypeRevision latestModuleVersion(
const QString &uri);
190 static bool isStronglyLockedModule(
const QString &uri, QTypeRevision version);
191 static QTypeRevision matchingModuleVersion(
const QString &module, QTypeRevision version);
192 static QQmlTypeModule *typeModule(
const QString &uri, QTypeRevision version);
194 static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
196 enum class CachedUnitLookupError {
203 enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
204 static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
205 const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
208 static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
209 static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
211 static QString prettyTypeName(
const QObject *object);
213 template <
typename QQmlTypeContainer>
214 static void removeQQmlTypePrivate(QQmlTypeContainer &container,
215 const QQmlTypePrivate *reference)
217 for (
typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) {
218 if (*it == reference)
219 it = container.erase(it);
225 template <
typename InlineComponentContainer>
226 static void removeFromInlineComponents(
227 InlineComponentContainer &container,
const QQmlTypePrivate *reference)
229 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
230 for (
auto it = container.begin(), end = container.end(); it != end;) {
231 if (equalBaseUrls(it.key(), referenceUrl))
232 it = container.erase(it);
238 static void registerTypeAlias(
int typeId,
const QString &name);
240 static int registerAutoParentFunction(
const QQmlPrivate::RegisterAutoParent &autoparent);
241 static void unregisterAutoParentFunction(
const QQmlPrivate::AutoParentFunction &function);
243 static QQmlType registerSequentialContainer(
244 const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration);
245 static void unregisterSequentialContainer(
int id);
247 static int registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration);
248 static void clearTypeRegistrations();
250 static QList<QQmlProxyMetaObject::ProxyData> proxyData(
const QMetaObject *mo,
251 const QMetaObject *baseMetaObject,
252 QMetaObject *lastMetaObject);
258 static void clone(QMetaObjectBuilder &builder,
const QMetaObject *mo,
259 const QMetaObject *ignoreStart,
const QMetaObject *ignoreEnd,
262 static void qmlInsertModuleRegistration(
const QString &uri,
void (*registerFunction)());
263 static void qmlRemoveModuleRegistration(
const QString &uri);
265 static bool qmlRegisterModuleTypes(
const QString &uri);
267 static bool isValueType(QMetaType type);
268 static QQmlValueType *valueType(QMetaType metaType);
269 static const QMetaObject *metaObjectForValueType(QMetaType type);
271 static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t);
272 static void registerInternalCompositeType(
273 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
274 static void unregisterInternalCompositeType(
275 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
276 static int countInternalCompositeTypeSelfReferences(
277 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
278 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(
280 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(