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, 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);
151 static QQmlType qmlType(QMetaType metaType);
152 static QQmlType qmlListType(QMetaType metaType);
154 static QQmlType qmlType(
const QUrl &unNormalizedUrl);
156 static QQmlPropertyCache::ConstPtr propertyCache(
157 QObject *object, QTypeRevision version = QTypeRevision());
158 static QQmlPropertyCache::ConstPtr propertyCache(
159 const QMetaObject *metaObject, QTypeRevision version = QTypeRevision());
160 static QQmlPropertyCache::ConstPtr propertyCache(
161 const QQmlType &type, QTypeRevision version);
164 static QQmlMetaObject rawMetaObjectForType(QMetaType metaType);
165 static QQmlMetaObject metaObjectForType(QMetaType metaType);
166 static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType);
167 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType);
168 static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(
169 QMetaType metaType, QTypeRevision version);
171 static void freeUnusedTypesAndCaches();
173 static QMetaProperty defaultProperty(
const QMetaObject *);
174 static QMetaProperty defaultProperty(QObject *);
175 static QMetaMethod defaultMethod(
const QMetaObject *);
176 static QMetaMethod defaultMethod(QObject *);
178 static QObject *toQObject(
const QVariant &,
bool *ok =
nullptr);
180 static QMetaType listValueType(QMetaType type);
181 static QQmlAttachedPropertiesFunc attachedPropertiesFunc(
182 QQmlTypeLoader *typeLoader,
const QMetaObject *);
183 static bool isInterface(QMetaType type);
184 static const char *interfaceIId(QMetaType type);
185 static bool isList(QMetaType type);
187 static QTypeRevision latestModuleVersion(
const QString &uri);
188 static bool isStronglyLockedModule(
const QString &uri, QTypeRevision version);
189 static QTypeRevision matchingModuleVersion(
const QString &module, QTypeRevision version);
190 static QQmlTypeModule *typeModule(
const QString &uri, QTypeRevision version);
192 static QList<QQmlPrivate::AutoParentFunction> parentFunctions();
194 enum class CachedUnitLookupError {
201 enum CacheMode { RejectAll, AcceptUntyped, RequireFullyTyped };
202 static const QQmlPrivate::CachedQmlUnit *findCachedCompilationUnit(
203 const QUrl &uri, CacheMode mode, CachedUnitLookupError *status);
206 static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
207 static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler);
209 static QString prettyTypeName(
const QObject *object);
211 template <
typename QQmlTypeContainer>
212 static void removeQQmlTypePrivate(QQmlTypeContainer &container,
213 const QQmlTypePrivate *reference)
215 for (
typename QQmlTypeContainer::iterator it = container.begin(); it != container.end();) {
216 if (*it == reference)
217 it = container.erase(it);
223 template <
typename InlineComponentContainer>
224 static void removeFromInlineComponents(
225 InlineComponentContainer &container,
const QQmlTypePrivate *reference)
227 const QUrl referenceUrl = QQmlType(reference).sourceUrl();
228 for (
auto it = container.begin(), end = container.end(); it != end;) {
229 if (equalBaseUrls(it.key(), referenceUrl))
230 it = container.erase(it);
236 static void registerTypeAlias(
int typeId,
const QString &name);
238 static int registerAutoParentFunction(
const QQmlPrivate::RegisterAutoParent &autoparent);
239 static void unregisterAutoParentFunction(
const QQmlPrivate::AutoParentFunction &function);
241 static QQmlType registerSequentialContainer(
242 const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration);
243 static void unregisterSequentialContainer(
int id);
245 static int registerUnitCacheHook(
const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration);
246 static void clearTypeRegistrations();
248 static QList<QQmlProxyMetaObject::ProxyData> proxyData(
const QMetaObject *mo,
249 const QMetaObject *baseMetaObject,
250 QMetaObject *lastMetaObject);
256 static void clone(QMetaObjectBuilder &builder,
const QMetaObject *mo,
257 const QMetaObject *ignoreStart,
const QMetaObject *ignoreEnd,
260 static void qmlInsertModuleRegistration(
const QString &uri,
void (*registerFunction)());
261 static void qmlRemoveModuleRegistration(
const QString &uri);
263 static bool qmlRegisterModuleTypes(
const QString &uri);
265 static bool isValueType(QMetaType type);
266 static QQmlValueType *valueType(QMetaType metaType);
267 static const QMetaObject *metaObjectForValueType(QMetaType type);
269 static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t);
270 static void registerInternalCompositeType(
271 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
272 static void unregisterInternalCompositeType(
273 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
274 static int countInternalCompositeTypeSelfReferences(
275 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit);
276 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(
278 static QQmlRefPointer<QV4::CompiledData::CompilationUnit> obtainCompilationUnit(