Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlmetatype.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qqmlmetatype_p.h"
5
6#include <private/qqmlextensionplugin_p.h>
7#include <private/qqmlmetatypedata_p.h>
8#include <private/qqmlpropertycachecreator_p.h>
9#include <private/qqmltype_p_p.h>
10#include <private/qqmltypeloader_p.h>
11#include <private/qqmltypemodule_p.h>
12#include <private/qqmlvaluetype_p.h>
13#include <private/qv4executablecompilationunit_p.h>
14
15#include <QtCore/qcoreapplication.h>
16#include <QtCore/qmutex.h>
17#include <QtCore/qloggingcategory.h>
18
19Q_DECLARE_LOGGING_CATEGORY(DBG_DISK_CACHE)
20Q_LOGGING_CATEGORY(lcTypeRegistration, "qt.qml.typeregistration")
21
23
28
29Q_GLOBAL_STATIC(LockedData, metaTypeData)
30Q_GLOBAL_STATIC(QRecursiveMutex, metaTypeDataLock)
31
32struct ModuleUri : public QString
33{
34 ModuleUri(const QString &string) : QString(string) {}
35 ModuleUri(const std::unique_ptr<QQmlTypeModule> &module) : QString(module->module()) {}
36};
37
39{
40 Q_DISABLE_COPY_MOVE(QQmlMetaTypeDataPtr)
41public:
42 QQmlMetaTypeDataPtr() : locker(metaTypeDataLock()), data(metaTypeData()) {}
44
47 operator QQmlMetaTypeData *() { return data; }
48
49 const QQmlMetaTypeData &operator*() const { return *data; }
50 const QQmlMetaTypeData *operator->() const { return data; }
51 operator const QQmlMetaTypeData *() const { return data; }
52
53 bool isValid() const { return data != nullptr; }
54
55private:
56 QMutexLocker<QRecursiveMutex> locker;
57 LockedData *data = nullptr;
58};
59
62{
64 d->extraData.interfaceTypeData = type.iid;
65 d->typeId = type.typeId;
66 d->listId = type.listId;
67 d->module = QString::fromUtf8(type.uri);
68 d->version = type.version;
69 data->registerType(d);
70 return d;
71}
72
74 QQmlMetaTypeData *data, const QString &elementName,
77{
79 data->registerType(d);
80
81 d->setName(QString::fromUtf8(type.uri), elementName);
82 d->version = type.version;
83
84 if (type.qObjectApi) {
85 d->baseMetaObject = type.instanceMetaObject;
86 d->typeId = type.typeId;
87 d->revision = type.revision;
88 }
89
90 d->extraData.singletonTypeData->singletonInstanceInfo = siinfo;
91 d->extraData.singletonTypeData->extFunc = type.extensionObjectCreate;
92 d->extraData.singletonTypeData->extMetaObject = type.extensionMetaObject;
93
94 return d;
95}
96
99{
101 data->registerType(d);
102 d->setName(QString::fromUtf8(type.uri), elementName);
103
104 d->version = type.version;
105 d->revision = type.revision;
106 d->typeId = type.typeId;
107 d->listId = type.listId;
108 d->extraData.cppTypeData->allocationSize = type.objectSize;
109 d->extraData.cppTypeData->userdata = type.userdata;
110 d->extraData.cppTypeData->newFunc = type.create;
111 d->extraData.cppTypeData->noCreationReason = type.noCreationReason;
112 d->extraData.cppTypeData->createValueTypeFunc = type.createValueType;
113 d->baseMetaObject = type.metaObject;
114 d->extraData.cppTypeData->attachedPropertiesFunc = type.attachedPropertiesFunction;
115 d->extraData.cppTypeData->attachedPropertiesType = type.attachedPropertiesMetaObject;
116 d->extraData.cppTypeData->parserStatusCast = type.parserStatusCast;
117 d->extraData.cppTypeData->propertyValueSourceCast = type.valueSourceCast;
118 d->extraData.cppTypeData->propertyValueInterceptorCast = type.valueInterceptorCast;
119 d->extraData.cppTypeData->finalizerCast = type.has(QQmlPrivate::RegisterType::FinalizerCast)
120 ? type.finalizerCast
121 : -1;
122 d->extraData.cppTypeData->extFunc = type.extensionObjectCreate;
123 d->extraData.cppTypeData->customParser = reinterpret_cast<QQmlCustomParser *>(type.customParser);
124 d->extraData.cppTypeData->registerEnumClassesUnscoped = true;
125 d->extraData.cppTypeData->registerEnumsFromRelatedTypes = true;
126 d->extraData.cppTypeData->constructValueType = type.has(QQmlPrivate::RegisterType::CreationMethod)
128 d->extraData.cppTypeData->populateValueType = type.has(QQmlPrivate::RegisterType::CreationMethod)
130
131 if (type.extensionMetaObject)
132 d->extraData.cppTypeData->extMetaObject = type.extensionMetaObject;
133
134 // Check if the user wants only scoped enum classes
135 if (d->baseMetaObject) {
136 auto indexOfUnscoped = d->baseMetaObject->indexOfClassInfo("RegisterEnumClassesUnscoped");
137 if (indexOfUnscoped != -1
138 && qstrcmp(d->baseMetaObject->classInfo(indexOfUnscoped).value(), "false") == 0) {
139 d->extraData.cppTypeData->registerEnumClassesUnscoped = false;
140 }
141
142 auto indexOfRelated = d->baseMetaObject->indexOfClassInfo("RegisterEnumsFromRelatedTypes");
143 if (indexOfRelated != -1
144 && qstrcmp(d->baseMetaObject->classInfo(indexOfRelated).value(), "false") == 0) {
145 d->extraData.cppTypeData->registerEnumsFromRelatedTypes = false;
146 }
147 }
148
149 return d;
150}
151
153{
154 Q_ASSERT(!className.isEmpty());
155 QByteArray ptr = className + '*';
156 QByteArray lst = "QQmlListProperty<" + className + '>';
157
158 QMetaType ptr_type(new QQmlMetaTypeInterface(ptr));
159 QMetaType lst_type(new QQmlListMetaTypeInterface(lst, ptr_type.iface()));
160
161 // Retrieve the IDs once, so that the types are added to QMetaType's custom type registry.
162 ptr_type.id();
163 lst_type.id();
164
165 priv->typeId = ptr_type;
166 priv->listId = lst_type;
167}
168
171{
172 // This is a procedurally registered composite type. It's evil. It doesn't get any metatypes
173 // because we never want to find it in the compositeTypes. Otherwise we might mix it up with an
174 // actually compiled version of the same type.
175
177 data->registerType(d);
178 d->setName(QString::fromUtf8(type.uri), elementName);
179 d->version = type.version;
180 d->extraData.compositeTypeData = QQmlTypeLoader::normalize(type.url);
181 return d;
182}
183
185 QQmlMetaTypeData *data, const QString &elementName,
188{
189 // This is a procedurally registered composite singleton. It's evil. It doesn't get any
190 // metatypes because we never want to find it in the compositeTypes. Otherwise we might mix it
191 // up with an actually compiled version of the same type.
192
194 data->registerType(d);
195 d->setName(QString::fromUtf8(type.uri), elementName);
196
197 d->version = type.version;
198
199 d->extraData.singletonTypeData->singletonInstanceInfo = siinfo;
200 return d;
201}
202
204 const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd,
206{
207 // Set classname
208 builder.setClassName(mo->className());
209
210 // Clone Q_CLASSINFO
211 for (int ii = mo->classInfoOffset(); ii < mo->classInfoCount(); ++ii) {
212 QMetaClassInfo info = mo->classInfo(ii);
213
214 int otherIndex = ignoreEnd->indexOfClassInfo(info.name());
215 if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) {
216 // Skip
217 } else {
218 builder.addClassInfo(info.name(), info.value());
219 }
220 }
221
223 // Clone Q_METHODS - do this first to avoid duplicating the notify signals.
224 for (int ii = mo->methodOffset(); ii < mo->methodCount(); ++ii) {
225 QMetaMethod method = mo->method(ii);
226
227 // More complex - need to search name
228 QByteArray name = method.name();
229
230 bool found = false;
231
232 for (int ii = ignoreStart->methodOffset() + ignoreStart->methodCount();
233 !found && ii < ignoreEnd->methodOffset() + ignoreEnd->methodCount(); ++ii) {
234
235 QMetaMethod other = ignoreEnd->method(ii);
236
237 found = name == other.name();
238 }
239
241 if (found) // SKIP
243 }
244
245 // Clone Q_PROPERTY
246 for (int ii = mo->propertyOffset(); ii < mo->propertyCount(); ++ii) {
247 QMetaProperty property = mo->property(ii);
248
249 int otherIndex = ignoreEnd->indexOfProperty(property.name());
250 if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) {
251 builder.addProperty(QByteArray("__qml_ignore__") + property.name(),
252 QByteArray("void"));
253 // Skip
254 } else {
255 builder.addProperty(property);
256 }
257 }
258 }
259
260 // Clone enums registered with the metatype system
261 for (int ii = mo->enumeratorOffset(); ii < mo->enumeratorCount(); ++ii) {
262 QMetaEnum enumerator = mo->enumerator(ii);
263
264 int otherIndex = ignoreEnd->indexOfEnumerator(enumerator.name());
265 if (otherIndex >= ignoreStart->enumeratorOffset() + ignoreStart->enumeratorCount()) {
266 // Skip
267 } else {
268 builder.addEnumerator(enumerator);
269 }
270 }
271}
272
273void QQmlMetaType::qmlInsertModuleRegistration(const QString &uri, void (*registerFunction)())
274{
276 if (data->moduleTypeRegistrationFunctions.contains(uri))
277 qFatal("Cannot add multiple registrations for %s", qPrintable(uri));
278 else
279 data->moduleTypeRegistrationFunctions.insert(uri, registerFunction);
280}
281
283{
285
286 if (!data.isValid())
287 return; // shutdown/deletion race. Not a problem.
288
289 if (!data->moduleTypeRegistrationFunctions.contains(uri))
290 qFatal("Cannot remove multiple registrations for %s", qPrintable(uri));
291 else
292 data->moduleTypeRegistrationFunctions.remove(uri);
293}
294
300
302{
303 //Only cleans global static, assumed no running engine
305
306 data->uriToModule.clear();
307 data->types.clear();
308 data->idToType.clear();
309 data->nameToType.clear();
310 data->urlToType.clear();
311 data->typePropertyCaches.clear();
312 data->urlToNonFileImportType.clear();
313 data->metaObjectToType.clear();
314 data->undeletableTypes.clear();
315 data->propertyCaches.clear();
316 data->inlineComponentTypes.clear();
317
318 // Avoid deletion recursion (via QQmlTypePrivate dtor) by moving them out of the way first.
319 QQmlMetaTypeData::CompositeTypes emptyComposites;
320 emptyComposites.swap(data->compositeTypes);
321}
322
324{
326 const QQmlType type = data->types.value(typeIndex);
327 const QQmlTypePrivate *priv = type.priv();
328 data->nameToType.insert(name, priv);
329}
330
332{
333 if (function.structVersion > 1)
334 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
335
337
338 data->parentFunctions.append(function.function);
339
340 return data->parentFunctions.size() - 1;
341}
342
348
350{
351 if (type.structVersion > 1)
352 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
353
356 Q_ASSERT(priv);
357
358
359 data->idToType.insert(priv->typeId.id(), priv);
360 data->idToType.insert(priv->listId.id(), priv);
361
362 data->interfaces.insert(type.typeId.id());
363
364 return QQmlType(priv);
365}
366
368{
370 if (typeType == QQmlType::CppType)
371 typeStr = QStringLiteral("element");
372 else if (typeType == QQmlType::SingletonType)
373 typeStr = QStringLiteral("singleton type");
374 else if (typeType == QQmlType::CompositeSingletonType)
375 typeStr = QStringLiteral("composite singleton type");
376 else if (typeType == QQmlType::SequentialContainerType)
377 typeStr = QStringLiteral("sequential container type");
378 else
379 typeStr = QStringLiteral("type");
380 return typeStr;
381}
382
383// NOTE: caller must hold a QMutexLocker on "data"
385 QQmlType::RegistrationType typeType, QQmlMetaTypeData *data, const char *uri,
386 const QString &typeName, QTypeRevision version, QMetaType::TypeFlags flags)
387{
388 if (!typeName.isEmpty()) {
389 if (typeName.at(0).isLower() && (flags & QMetaType::PointerToQObject)) {
390 QString failure(QCoreApplication::translate("qmlRegisterType", "Invalid QML %1 name \"%2\"; type names must begin with an uppercase letter"));
391 data->recordTypeRegFailure(failure.arg(registrationTypeString(typeType), typeName));
392 return false;
393 }
394
395 if (typeName.at(0).isUpper()
397 qCWarning(lcTypeRegistration).noquote()
399 "qmlRegisterType",
400 "Invalid QML %1 name \"%2\"; "
401 "value type names should begin with a lowercase letter")
402 .arg(registrationTypeString(typeType), typeName);
403 }
404
405 // There can also be types that aren't even gadgets, and there can be types for namespaces.
406 // We cannot check those, but namespaces should be uppercase.
407
408 int typeNameLen = typeName.size();
409 for (int ii = 0; ii < typeNameLen; ++ii) {
410 if (!(typeName.at(ii).isLetterOrNumber() || typeName.at(ii) == u'_')) {
411 QString failure(QCoreApplication::translate("qmlRegisterType", "Invalid QML %1 name \"%2\""));
412 data->recordTypeRegFailure(failure.arg(registrationTypeString(typeType), typeName));
413 return false;
414 }
415 }
416 }
417
418 if (uri && !typeName.isEmpty()) {
419 QString nameSpace = QString::fromUtf8(uri);
420 QQmlTypeModule *qqtm = data->findTypeModule(nameSpace, version);
421 if (qqtm && qqtm->lockLevel() != QQmlTypeModule::LockLevel::Open) {
423 "qmlRegisterType",
424 "Cannot install %1 '%2' into protected module '%3' version '%4'"));
425 data->recordTypeRegFailure(failure
426 .arg(registrationTypeString(typeType), typeName, nameSpace)
427 .arg(version.majorVersion()));
428 return false;
429 }
430 }
431
432 return true;
433}
434
435// NOTE: caller must hold a QMutexLocker on "data"
437 const QHashedString &uri, QTypeRevision version, QQmlMetaTypeData *data)
438{
439 if (QQmlTypeModule *module = data->findTypeModule(uri, version))
440 return module;
441 return data->addTypeModule(std::make_unique<QQmlTypeModule>(uri, version.majorVersion()));
442}
443
444// NOTE: caller must hold a QMutexLocker on "data"
446{
447 Q_ASSERT(type);
448
449 if (!type->elementName.isEmpty())
450 data->nameToType.insert(type->elementName, type);
451
452 if (type->baseMetaObject)
453 data->metaObjectToType.insert(type->baseMetaObject, type);
454
455 if (type->regType == QQmlType::SequentialContainerType) {
456 if (type->listId.isValid())
457 data->idToType.insert(type->listId.id(), type);
458 } else {
459 if (type->typeId.isValid())
460 data->idToType.insert(type->typeId.id(), type);
461
462 if (type->listId.flags().testFlag(QMetaType::IsQmlList))
463 data->idToType.insert(type->listId.id(), type);
464 }
465
466 if (!type->module.isEmpty()) {
467 const QHashedString &mod = type->module;
468
469 QQmlTypeModule *module = getTypeModule(mod, type->version, data);
470 Q_ASSERT(module);
471 module->add(type);
472 }
473}
474
476{
477 if (type.structVersion > int(QQmlPrivate::RegisterType::CurrentVersion))
478 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
479
481
482 QString elementName = QString::fromUtf8(type.elementName);
483 if (!checkRegistration(QQmlType::CppType, data, type.uri, elementName, type.version,
484 QMetaType(type.typeId).flags())) {
485 return QQmlType();
486 }
487
488 QQmlTypePrivate *priv = createQQmlType(data, elementName, type);
490
491 return QQmlType(priv);
492}
493
497{
498 if (type.structVersion > 1)
499 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
500
502
505 QMetaType(type.typeId).flags())) {
506 return QQmlType();
507 }
508
510
512
513 return QQmlType(priv);
514}
515
519{
520 if (type.structVersion > 1)
521 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
522
523 // Assumes URL is absolute and valid. Checking of user input should happen before the URL enters type.
525
527 bool fileImport = false;
528 if (*(type.uri) == '\0')
529 fileImport = true;
530 if (!checkRegistration(QQmlType::CompositeSingletonType, data, fileImport ? nullptr : type.uri,
531 typeName, type.version, {})) {
532 return QQmlType();
533 }
534
537
538 QQmlMetaTypeData::Files *files = fileImport ? &(data->urlToType) : &(data->urlToNonFileImportType);
539 files->insert(siinfo->url, priv);
540
541 return QQmlType(priv);
542}
543
545{
546 if (type.structVersion > 1)
547 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
548
549 // Assumes URL is absolute and valid. Checking of user input should happen before the URL enters type.
551
553 bool fileImport = false;
554 if (*(type.uri) == '\0')
555 fileImport = true;
556 if (!checkRegistration(QQmlType::CompositeType, data, fileImport?nullptr:type.uri, typeName,
557 type.version, {})) {
558 return QQmlType();
559 }
560
563
564 QQmlMetaTypeData::Files *files = fileImport ? &(data->urlToType) : &(data->urlToNonFileImportType);
566
567 return QQmlType(priv);
568}
569
571{
572 Q_DISABLE_COPY_MOVE(QQmlMetaTypeRegistrationFailureRecorder)
573public:
575 : data(data)
576 {
577 data->setTypeRegistrationFailures(failures);
578 }
579
581 {
582 data->setTypeRegistrationFailures(nullptr);
583 }
584
586};
587
588
590 QQmlMetaTypeData *data, const QUrl &url, const QHashedStringRef &qualifiedType,
591 QQmlMetaType::CompositeTypeLookupMode mode, QList<QQmlError> *errors, QTypeRevision version)
592{
593 const int dot = qualifiedType.indexOf(QLatin1Char('.'));
594 const QString typeName = dot < 0
595 ? qualifiedType.toString()
596 : QString(qualifiedType.constData() + dot + 1, qualifiedType.length() - dot - 1);
597
598 QStringList failures;
599 QQmlMetaTypeRegistrationFailureRecorder failureRecorder(data, &failures);
600
601 // Register the type. Note that the URI parameters here are empty; for
602 // file type imports, we do not place them in a URI as we don't
603 // necessarily have a good and unique one (picture a library import,
604 // which may be found in multiple plugin locations on disk), but there
605 // are other reasons for this too.
606 //
607 // By not putting them in a URI, we prevent the types from being
608 // registered on a QQmlTypeModule; this is important, as once types are
609 // placed on there, they cannot be easily removed, meaning if the
610 // developer subsequently loads a different import (meaning different
611 // types) with the same URI (using, say, a different plugin path), it is
612 // very undesirable that we continue to associate the types from the
613 // "old" URI with that new module.
614 //
615 // Not having URIs also means that the types cannot be found by name
616 // etc, the only way to look them up is through QQmlImports -- for
617 // better or worse.
621 if (checkRegistration(registrationType, data, nullptr, typeName, version, {})) {
622
623 // TODO: Ideally we should defer most of this work using some lazy/atomic mechanism
624 // that creates the details on first use. We must not observably modify
625 // QQmlTypePrivate after it has been created since it is supposed to be immutable
626 // and shared across threads.
627
628 auto *priv = new QQmlTypePrivate(registrationType);
630
631 priv->setName(QString(), typeName);
632 priv->version = version;
633
636 siinfo->url = url;
637 siinfo->typeName = typeName.toUtf8();
638 priv->extraData.singletonTypeData->singletonInstanceInfo =
641 } else {
642 priv->extraData.compositeTypeData = url;
643 }
644
645 data->registerType(priv);
647 return QQmlType(priv);
648 }
649
650 // This means that the type couldn't be found by URL, but could not be
651 // registered either, meaning we most likely were passed some kind of bad
652 // data.
653 if (errors) {
655 error.setDescription(failures.join(u'\n'));
656 errors->prepend(error);
657 } else {
658 qWarning("%s", failures.join(u'\n').toLatin1().constData());
659 }
660 return QQmlType();
661}
662
664 const QUrl &url, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
666{
669
670 bool urlExists = true;
671 auto found = data->urlToType.constFind(normalized);
672 if (found == data->urlToType.cend()) {
673 found = data->urlToNonFileImportType.constFind(normalized);
674 if (found == data->urlToNonFileImportType.cend())
675 urlExists = false;
676 }
677
678 if (const QtPrivate::QMetaTypeInterface *iface = urlExists
679 ? found.value()->typeId.iface()
680 : nullptr) {
681 if (compilationUnit.isNull())
682 return QQmlType(*found);
683
684 const auto composite = data->compositeTypes.constFind(iface);
685 if (composite == data->compositeTypes.constEnd() || composite.value() == compilationUnit)
686 return QQmlType(*found);
687 }
688
691
692 if (!urlExists && type.isValid())
693 data->urlToType.insert(normalized, type.priv());
694
695 return type;
696}
697
699{
701 priv->setName(QString(), url.fragment());
702
703 priv->extraData.inlineComponentTypeData = url;
704
707
709 const QQmlType result(priv);
710 priv->release();
711
712 data->inlineComponentTypes.insert(url, result);
713
714 return result;
715}
716
718 const QUrl &url, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
719{
721
722 // If there is an "unclaimed" inline component type, we can "claim" it now. Otherwise
723 // we have to create a new one.
724 const auto it = data->inlineComponentTypes.constFind(url);
725 if (it != data->inlineComponentTypes.constEnd()) {
726 const auto jt = data->compositeTypes.constFind(it->typeId().iface());
727 if (jt == data->compositeTypes.constEnd() || *jt == compilationUnit)
728 return *it;
729 }
730
732}
733
735{
736 // This may be called from delayed dtors on shutdown when the data is already gone.
738 if (data.isValid()) {
739 if (QQmlValueType *vt = data->metaTypeToValueType.take(metaType.id()))
740 delete vt;
741 if (QQmlValueType *vt = data->metaTypeToValueType.take(listMetaType.id()))
742 delete vt;
743
744 auto it = data->compositeTypes.constFind(metaType.iface());
745 if (it != data->compositeTypes.constEnd())
746 data->compositeTypes.erase(it);
747 }
748
750 QMetaType::unregisterMetaType(listMetaType);
751 delete static_cast<const QQmlMetaTypeInterface *>(metaType.iface());
752 delete static_cast<const QQmlListMetaTypeInterface *>(listMetaType.iface());
753}
754
756 const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration)
757{
758 if (hookRegistration.structVersion > 1)
759 qFatal("qmlRegisterType(): Cannot mix incompatible QML versions.");
760
762 data->lookupCachedQmlUnit << hookRegistration.lookupCachedQmlUnit;
763 return 0;
764}
765
768{
769 if (container.structVersion > 1)
770 qFatal("qmlRegisterSequenceContainer(): Cannot mix incompatible QML versions.");
771
773
775 container.version, {})) {
776 return QQmlType();
777 }
778
780
781 data->registerType(priv);
782 priv->setName(QString::fromUtf8(container.uri), QString());
783 priv->version = container.version;
784 priv->revision = container.revision;
785 priv->typeId = container.metaSequence.valueMetaType();
786 priv->listId = container.typeId;
787 priv->extraData.sequentialContainerTypeData = container.metaSequence;
788
790
791 return QQmlType(priv);
792}
793
798
800 bool weakProtectAllVersions)
801{
803 if (version.hasMajorVersion()) {
804 if (QQmlTypeModule *module = data->findTypeModule(uri, version)) {
805 if (!weakProtectAllVersions) {
806 module->setLockLevel(QQmlTypeModule::LockLevel::Strong);
807 return true;
808 }
809 } else {
810 return false;
811 }
812 }
813
814 const auto range = std::equal_range(
815 data->uriToModule.begin(), data->uriToModule.end(), uri,
816 std::less<ModuleUri>());
817
818 for (auto it = range.first; it != range.second; ++it)
819 (*it)->setLockLevel(QQmlTypeModule::LockLevel::Weak);
820
821 return range.first != range.second;
822}
823
825 const QQmlDirParser::Import &import)
826{
828
829 data->moduleImports.insert(QQmlMetaTypeData::VersionedUri(uri, moduleVersion), import);
830}
831
833 const QQmlDirParser::Import &import)
834{
836 data->moduleImports.remove(QQmlMetaTypeData::VersionedUri(uri, moduleVersion), import);
837}
838
839QList<QQmlDirParser::Import> QQmlMetaType::moduleImports(
840 const QString &uri, QTypeRevision version)
841{
843 QList<QQmlDirParser::Import> result;
844
845 const auto unrevisioned = data->moduleImports.equal_range(
847 for (auto it = unrevisioned.second; it != unrevisioned.first;)
848 result.append(*(--it));
849
850 if (version.hasMajorVersion()) {
851 const auto revisioned = data->moduleImports.equal_range(
852 QQmlMetaTypeData::VersionedUri(uri, version));
853 for (auto it = revisioned.second; it != revisioned.first;)
854 result.append(*(--it));
855 return result;
856 }
857
858 // Use latest module available with that URI.
859 const auto begin = data->moduleImports.begin();
860 auto it = unrevisioned.first;
861 if (it == begin)
862 return result;
863
864 const QQmlMetaTypeData::VersionedUri latestVersion = (--it).key();
865 if (latestVersion.uri != uri)
866 return result;
867
868 do {
869 result += *it;
870 } while (it != begin && (--it).key() == latestVersion);
871
872 return result;
873}
874
875void QQmlMetaType::registerModule(const char *uri, QTypeRevision version)
876{
878
879 QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), version, data);
880 Q_ASSERT(module);
881
882 if (version.hasMinorVersion())
883 module->addMinorVersion(version.minorVersion());
884}
885
886int QQmlMetaType::typeId(const char *uri, QTypeRevision version, const char *qmlName)
887{
889
890 QQmlTypeModule *module = getTypeModule(QString::fromUtf8(uri), version, data);
891 if (!module)
892 return -1;
893
894 QQmlType type = module->type(QHashedStringRef(QString::fromUtf8(qmlName)), version);
895 if (!type.isValid())
896 return -1;
897
898 return type.index();
899}
900
906
908 QTypeRevision version)
909{
910 // Has any type previously been installed to this namespace?
911 QHashedString nameSpace(uri);
912 for (const QQmlType &type : data->types) {
913 if (type.module() == nameSpace && type.version().majorVersion() == version.majorVersion())
914 return true;
915 }
916
917 return false;
918}
919
921 QObject *instance, const QString &basePath, const QString &uri,
922 const QString &typeNamespace, QTypeRevision version, QList<QQmlError> *errors)
923{
924 if (!typeNamespace.isEmpty() && typeNamespace != uri) {
925 // This is an 'identified' module
926 // The namespace for type registrations must match the URI for locating the module
927 if (errors) {
929 error.setDescription(
930 QStringLiteral("Module namespace '%1' does not match import URI '%2'")
931 .arg(typeNamespace, uri));
932 errors->prepend(error);
933 }
935 }
936
937 QStringList failures;
939 {
940 QQmlMetaTypeRegistrationFailureRecorder failureRecorder(data, &failures);
941 if (!typeNamespace.isEmpty()) {
942 // This is an 'identified' module
943 if (namespaceContainsRegistrations(data, typeNamespace, version)) {
944 // Other modules have already installed to this namespace
945 if (errors) {
947 error.setDescription(QStringLiteral("Namespace '%1' has already been used "
948 "for type registration")
949 .arg(typeNamespace));
950 errors->prepend(error);
951 }
953 }
954 } else {
955 // This is not an identified module - provide a warning
956 qWarning().nospace() << qPrintable(
957 QStringLiteral("Module '%1' does not contain a module identifier directive - "
958 "it cannot be protected from external registrations.").arg(uri));
959 }
960
961 if (instance && !qobject_cast<QQmlEngineExtensionInterface *>(instance)) {
962 QQmlTypesExtensionInterface *iface = qobject_cast<QQmlTypesExtensionInterface *>(instance);
963 if (!iface) {
964 if (errors) {
966 // Also does not implement QQmlTypesExtensionInterface, but we want to discourage that.
967 error.setDescription(QStringLiteral("Module loaded for URI '%1' does not implement "
968 "QQmlEngineExtensionInterface").arg(typeNamespace));
969 errors->prepend(error);
970 }
972 }
973
974#if QT_DEPRECATED_SINCE(6, 3)
975 if (auto *plugin = qobject_cast<QQmlExtensionPlugin *>(instance)) {
976 // basepath should point to the directory of the module, not the plugin file itself:
977 QQmlExtensionPluginPrivate::get(plugin)->baseUrl
979 }
980#else
981 Q_UNUSED(basePath)
982#endif
983
984 const QByteArray bytes = uri.toUtf8();
985 const char *moduleId = bytes.constData();
986 iface->registerTypes(moduleId);
987 }
988
989 if (failures.isEmpty() && !data->registerModuleTypes(uri))
991
992 if (!failures.isEmpty()) {
993 if (errors) {
994 for (const QString &failure : std::as_const(failures)) {
996 error.setDescription(failure);
997 errors->prepend(error);
998 }
999 }
1001 }
1002 }
1003
1005}
1006
1007/*
1008 \internal
1009
1010 Fetches the QQmlType instance registered for \a urlString, creating a
1011 registration for it if it is not already registered, using the associated
1012 \a typeName, \a isCompositeSingleton, \a majorVersion and \a minorVersion
1013 details.
1014
1015 Errors (if there are any) are placed into \a errors, if it is nonzero.
1016 Otherwise errors are printed as warnings.
1017*/
1019 const QHashedStringRef &qualifiedType,
1020 CompositeTypeLookupMode mode, QList<QQmlError> *errors,
1021 QTypeRevision version)
1022{
1023 // ### unfortunate (costly) conversion
1024 const QUrl url = QQmlTypeLoader::normalize(QUrl(urlString));
1025
1027 {
1028 QQmlType ret(data->urlToType.value(url));
1029 if (ret.isValid() && ret.sourceUrl() == url)
1030 return ret;
1031 }
1032 {
1033 QQmlType ret(data->urlToNonFileImportType.value(url));
1034 if (ret.isValid() && ret.sourceUrl() == url)
1035 return ret;
1036 }
1037
1039 data, url, qualifiedType, mode, errors, version);
1040 data->urlToType.insert(url, type.priv());
1041 return type;
1042}
1043
1044/*
1045 Returns the latest version of \a uri installed, or an in valid QTypeRevision().
1046*/
1048{
1050 auto upper = std::upper_bound(data->uriToModule.begin(), data->uriToModule.end(), uri,
1051 std::less<ModuleUri>());
1052 if (upper == data->uriToModule.begin())
1053 return QTypeRevision();
1054
1055 const auto module = (--upper)->get();
1056 return (module->module() == uri)
1057 ? QTypeRevision::fromVersion(module->majorVersion(), module->maximumMinorVersion())
1058 : QTypeRevision();
1059}
1060
1061/*
1062 Returns true if a module \a uri of this version is installed and locked;
1063*/
1065{
1067
1068 if (QQmlTypeModule* qqtm = data->findTypeModule(uri, version))
1069 return qqtm->lockLevel() == QQmlTypeModule::LockLevel::Strong;
1070 return false;
1071}
1072
1073/*
1074 Returns the best matching registered version for the given \a module. If \a version is
1075 the does not have a major version, returns the latest registered version. Otherwise
1076 chooses the same major version and checks if the minor version is within the range
1077 of registered minor versions. If so, retuens the original version, otherwise returns
1078 an invalid version. If \a version does not have a minor version, chooses the latest one.
1079*/
1081{
1082 if (!version.hasMajorVersion())
1083 return latestModuleVersion(module);
1084
1086
1087 // first, check Types
1088 if (QQmlTypeModule *tm = data->findTypeModule(module, version)) {
1089 if (!version.hasMinorVersion())
1090 return QTypeRevision::fromVersion(version.majorVersion(), tm->maximumMinorVersion());
1091
1092 if (tm->minimumMinorVersion() <= version.minorVersion()
1093 && tm->maximumMinorVersion() >= version.minorVersion()) {
1094 return version;
1095 }
1096 }
1097
1098 return QTypeRevision();
1099}
1100
1102{
1104
1105 if (version.hasMajorVersion())
1106 return data->findTypeModule(uri, version);
1107
1108 auto range = std::equal_range(data->uriToModule.begin(), data->uriToModule.end(),
1109 uri, std::less<ModuleUri>());
1110
1111 return range.first == range.second ? nullptr : (--range.second)->get();
1112}
1113
1114QList<QQmlPrivate::AutoParentFunction> QQmlMetaType::parentFunctions()
1115{
1117 return data->parentFunctions;
1118}
1119
1121{
1122 if (!v.metaType().flags().testFlag(QMetaType::PointerToQObject)) {
1123 if (ok) *ok = false;
1124 return nullptr;
1125 }
1126
1127 if (ok) *ok = true;
1128
1129 return *(QObject *const *)v.constData();
1130}
1131
1132/*
1133 Returns the item type for a list of type \a id.
1134 */
1136{
1137 if (isList(metaType)) {
1138 const auto iface = metaType.iface();
1139 if (iface && iface->metaObjectFn == &dynamicQmlListMarker)
1140 return QMetaType(static_cast<const QQmlListMetaTypeInterface *>(iface)->valueType);
1141 } else if (metaType.flags() & QMetaType::PointerToQObject) {
1142 return QMetaType();
1143 }
1144
1146 Q_ASSERT(data);
1147 QQmlTypePrivate *type = data->idToType.value(metaType.id());
1148
1149 if (type && type->listId == metaType)
1150 return type->typeId;
1151 else
1152 return QMetaType {};
1153}
1154
1156 const QMetaObject *mo)
1157{
1159
1160 QQmlType type(data->metaObjectToType.value(mo));
1161 return type.attachedPropertiesFunction(engine);
1162}
1163
1165{
1166 int idx = metaObject->indexOfClassInfo("DefaultProperty");
1167 if (-1 == idx)
1168 return QMetaProperty();
1169
1170 QMetaClassInfo info = metaObject->classInfo(idx);
1171 if (!info.value())
1172 return QMetaProperty();
1173
1174 idx = metaObject->indexOfProperty(info.value());
1175 if (-1 == idx)
1176 return QMetaProperty();
1177
1178 return metaObject->property(idx);
1179}
1180
1182{
1183 if (!obj)
1184 return QMetaProperty();
1185
1186 const QMetaObject *metaObject = obj->metaObject();
1188}
1189
1191{
1192 int idx = metaObject->indexOfClassInfo("DefaultMethod");
1193 if (-1 == idx)
1194 return QMetaMethod();
1195
1196 QMetaClassInfo info = metaObject->classInfo(idx);
1197 if (!info.value())
1198 return QMetaMethod();
1199
1200 idx = metaObject->indexOfMethod(info.value());
1201 if (-1 == idx)
1202 return QMetaMethod();
1203
1204 return metaObject->method(idx);
1205}
1206
1208{
1209 if (!obj)
1210 return QMetaMethod();
1211
1212 const QMetaObject *metaObject = obj->metaObject();
1213 return defaultMethod(metaObject);
1214}
1215
1224
1226{
1228 const QQmlType type(data->idToType.value(metaType.id()));
1229 return (type.isInterface() && type.typeId() == metaType) ? type.interfaceIId() : nullptr;
1230}
1231
1233{
1234 if (type.flags().testFlag(QMetaType::IsQmlList))
1235 return true;
1236 else
1237 return false;
1238}
1239
1245{
1246 int slash = qualifiedName.indexOf(QLatin1Char('/'));
1247 if (slash <= 0)
1248 return QQmlType();
1249
1250 QHashedStringRef module(qualifiedName.constData(), slash);
1251 QHashedStringRef name(qualifiedName.constData() + slash + 1, qualifiedName.size() - slash - 1);
1252
1253 return qmlType(name, module, version);
1254}
1255
1265 QTypeRevision version)
1266{
1268
1269 const QHashedString key(QString::fromRawData(name.constData(), name.length()), name.hash());
1271 while (it != data->nameToType.cend() && it.key() == name) {
1272 QQmlType t(*it);
1273 if (module.isEmpty() || t.availableInVersion(module, version))
1274 return t;
1275 ++it;
1276 }
1277
1278 return QQmlType();
1279}
1280
1286{
1288 return QQmlType(data->metaObjectToType.value(metaObject));
1289}
1290
1297 QTypeRevision version)
1298{
1300
1302 for (auto it = range.first; it != range.second; ++it) {
1303 QQmlType t(*it);
1304 if (module.isEmpty() || t.availableInVersion(module, version))
1305 return t;
1306 }
1307
1308 return QQmlType();
1309}
1310
1316{
1318 QQmlType type = data->types.value(qmlTypeId);
1319 if (type.isValid())
1320 return type;
1321 return QQmlType();
1322}
1323
1329{
1331 QQmlTypePrivate *type = data->idToType.value(metaType.id());
1332 return (type && type->typeId == metaType) ? QQmlType(type) : QQmlType();
1333}
1334
1336{
1338 QQmlTypePrivate *type = data->idToType.value(metaType.id());
1339 return (type && type->listId == metaType) ? QQmlType(type) : QQmlType();
1340}
1341
1348QQmlType QQmlMetaType::qmlType(const QUrl &unNormalizedUrl, bool includeNonFileImports /* = false */)
1349{
1350 const QUrl url = QQmlTypeLoader::normalize(unNormalizedUrl);
1352
1353 QQmlType type(data->urlToType.value(url));
1354 if (!type.isValid() && includeNonFileImports)
1355 type = QQmlType(data->urlToNonFileImportType.value(url));
1356
1357 if (type.sourceUrl() == url)
1358 return type;
1359 else
1360 return QQmlType();
1361}
1362
1364{
1366 const auto it = data->inlineComponentTypes.constFind(url);
1367 if (it != data->inlineComponentTypes.constEnd())
1368 return *it;
1369
1371}
1372
1385
1387 const QMetaObject *metaObject, QTypeRevision version)
1388{
1389 QQmlMetaTypeDataPtr data; // not const: the cache is created on demand
1390 return data->propertyCache(metaObject, version);
1391}
1392
1394 const QQmlType &type, QTypeRevision version)
1395{
1396 QQmlMetaTypeDataPtr data; // not const: the cache is created on demand
1397 return data->propertyCache(type, version);
1398}
1399
1406{
1408 if (auto composite = data->findPropertyCacheInCompositeTypes(metaType))
1409 return QQmlMetaObject(composite);
1410
1411 const QQmlTypePrivate *type = data->idToType.value(metaType.id());
1412 return (type && type->typeId == metaType) ? type->baseMetaObject : nullptr;
1413}
1414
1421{
1423 if (auto composite = data->findPropertyCacheInCompositeTypes(metaType))
1424 return QQmlMetaObject(composite);
1425
1426 const QQmlTypePrivate *type = data->idToType.value(metaType.id());
1427 return (type && type->typeId == metaType)
1429 : nullptr;
1430}
1431
1438{
1440 if (auto composite = data->findPropertyCacheInCompositeTypes(metaType))
1441 return composite;
1442
1443 const QQmlTypePrivate *type = data->idToType.value(metaType.id());
1444 if (type && type->typeId == metaType) {
1445 if (const QMetaObject *mo = QQmlType(type).metaObject())
1446 return data->propertyCache(mo, type->version);
1447 }
1448
1450}
1451
1460{
1462 if (auto composite = QQmlMetaType::findPropertyCacheInCompositeTypes(metaType))
1463 return composite;
1464
1465 const QQmlTypePrivate *type = data->idToType.value(metaType.id());
1466 if (!type || type->typeId != metaType)
1468
1469 const QMetaObject *metaObject = type->isValueType()
1470 ? type->metaObjectForValueType()
1471 : type->baseMetaObject;
1472
1473 return metaObject
1474 ? data->propertyCache(metaObject, QTypeRevision())
1476}
1477
1485 QMetaType metaType, QTypeRevision version)
1486{
1488 if (auto composite = data->findPropertyCacheInCompositeTypes(metaType))
1489 return composite;
1490
1491 const QQmlTypePrivate *typePriv = data->idToType.value(metaType.id());
1492 if (!typePriv || typePriv->typeId != metaType)
1494
1495 const QQmlType type(typePriv);
1496 if (type.containsRevisionedAttributes()) {
1497 // It can only have (revisioned) properties or methods if it has a metaobject
1498 Q_ASSERT(type.metaObject());
1499 return data->propertyCache(type, version);
1500 }
1501
1502 if (const QMetaObject *metaObject = type.metaObject())
1503 return data->propertyCache(metaObject, version);
1504
1506}
1507
1509{
1511 const QQmlType type = data->types.value(typeIndex);
1512 if (const QQmlTypePrivate *d = type.priv()) {
1513 if (d->regType == QQmlType::CompositeType || d->regType == QQmlType::CompositeSingletonType)
1514 removeFromInlineComponents(data->inlineComponentTypes, d);
1515 removeQQmlTypePrivate(data->idToType, d);
1516 removeQQmlTypePrivate(data->nameToType, d);
1517 removeQQmlTypePrivate(data->urlToType, d);
1518 removeQQmlTypePrivate(data->urlToNonFileImportType, d);
1519 removeQQmlTypePrivate(data->metaObjectToType, d);
1520 for (auto & module : data->uriToModule)
1521 module->remove(d);
1522 data->clearPropertyCachesForVersion(typeIndex);
1523 data->types[typeIndex] = QQmlType();
1524 data->undeletableTypes.remove(type);
1525 }
1526}
1527
1535
1537{
1538 for (auto it = data->inlineComponentTypes.begin(), end = data->inlineComponentTypes.end();
1539 it != end; ++it) {
1540 if (!QQmlMetaType::equalBaseUrls(it.key(), d->sourceUrl()))
1541 continue;
1542
1543 const QQmlTypePrivate *icPriv = it->priv();
1544 if (icPriv && icPriv->count() > 1)
1545 return true;
1546 }
1547 return false;
1548}
1549
1552 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
1553{
1554 int result = 0;
1555 auto doCheck = [&](const QtPrivate::QMetaTypeInterface *iface) {
1556 if (!iface)
1557 return;
1558
1559 const auto it = data->compositeTypes.constFind(iface);
1560 if (it != data->compositeTypes.constEnd() && *it == compilationUnit)
1561 ++result;
1562 };
1563
1564 doCheck(compilationUnit->metaType().iface());
1565 for (auto &&inlineData: compilationUnit->inlineComponentData)
1566 doCheck(inlineData.qmlType.typeId().iface());
1567
1568 return result;
1569}
1570
1572{
1574
1575 // in case this is being called during program exit, `data` might be destructed already
1576 if (!data.isValid())
1577 return;
1578
1579 bool droppedAtLeastOneComposite;
1580 do {
1581 droppedAtLeastOneComposite = false;
1582 auto it = data->compositeTypes.begin();
1583 while (it != data->compositeTypes.end()) {
1584 if ((*it)->count() <= doCountInternalCompositeTypeSelfReferences(data, *it)) {
1585 it = data->compositeTypes.erase(it);
1586 droppedAtLeastOneComposite = true;
1587 } else {
1588 ++it;
1589 }
1590 }
1591 } while (droppedAtLeastOneComposite);
1592
1593 bool deletedAtLeastOneType;
1594 do {
1595 deletedAtLeastOneType = false;
1597 while (it != data->types.end()) {
1598 const QQmlTypePrivate *d = (*it).priv();
1599 if (d && d->count() == 1 && !hasActiveInlineComponents(data, d)) {
1600 deletedAtLeastOneType = true;
1601
1602 if (d->regType == QQmlType::CompositeType
1603 || d->regType == QQmlType::CompositeSingletonType) {
1604 removeFromInlineComponents(data->inlineComponentTypes, d);
1605 }
1606 removeQQmlTypePrivate(data->idToType, d);
1607 removeQQmlTypePrivate(data->nameToType, d);
1608 removeQQmlTypePrivate(data->urlToType, d);
1609 removeQQmlTypePrivate(data->urlToNonFileImportType, d);
1610 removeQQmlTypePrivate(data->metaObjectToType, d);
1611
1612 for (auto &module : data->uriToModule)
1613 module->remove(d);
1614
1615 data->clearPropertyCachesForVersion(d->index);
1616 *it = QQmlType();
1617 } else {
1618 ++it;
1619 }
1620 }
1621 } while (deletedAtLeastOneType);
1622
1623 bool deletedAtLeastOneCache;
1624 do {
1625 deletedAtLeastOneCache = false;
1626 auto it = data->propertyCaches.begin();
1627 while (it != data->propertyCaches.end()) {
1628 if ((*it)->count() == 1) {
1629 it = data->propertyCaches.erase(it);
1630 deletedAtLeastOneCache = true;
1631 } else {
1632 ++it;
1633 }
1634 }
1635 } while (deletedAtLeastOneCache);
1636}
1637
1642{
1644
1645 QList<QString> names;
1646 names.reserve(data->nameToType.size());
1648 while (it != data->nameToType.cend()) {
1649 QQmlType t(*it);
1650 names += t.qmlTypeName();
1651 ++it;
1652 }
1653
1654 return names;
1655}
1656
1660QList<QQmlType> QQmlMetaType::qmlTypes()
1661{
1663
1664 QList<QQmlType> types;
1665 for (const QQmlTypePrivate *t : data->nameToType)
1666 types.append(QQmlType(t));
1667
1668 return types;
1669}
1670
1675{
1677 return data->types;
1678}
1679
1684{
1686
1687 QList<QQmlType> retn;
1688 for (const auto t : std::as_const(data->nameToType)) {
1689 QQmlType type(t);
1690 if (type.isSingleton())
1691 retn.append(type);
1692 }
1693 return retn;
1694}
1695
1697{
1698 quint32 numTypedFunctions = 0;
1699 for (const QQmlPrivate::AOTCompiledFunction *function = unit->aotCompiledFunctions;
1700 function; ++function) {
1701 if (function->functionPtr)
1702 ++numTypedFunctions;
1703 else
1704 return false;
1705 }
1706 return numTypedFunctions == unit->qmlData->functionTableSize;
1707}
1708
1711{
1714
1715 for (const auto lookup : std::as_const(data->lookupCachedQmlUnit)) {
1716 if (const QQmlPrivate::CachedQmlUnit *unit = lookup(uri)) {
1717 QString error;
1718 if (!unit->qmlData->verifyHeader(QDateTime(), &error)) {
1719 qCDebug(DBG_DISK_CACHE) << "Error loading pre-compiled file " << uri << ":" << error;
1720 if (status)
1722 return nullptr;
1723 }
1724
1725 if (mode == RequireFullyTyped && !isFullyTyped(unit)) {
1726 qCDebug(DBG_DISK_CACHE)
1727 << "Error loading pre-compiled file " << uri
1728 << ": compilation unit contains functions not compiled to native code.";
1729 if (status)
1731 return nullptr;
1732 }
1733
1734 if (status)
1736 return unit;
1737 }
1738 }
1739
1740 if (status)
1742
1743 return nullptr;
1744}
1745
1751
1757
1762{
1764
1765 if (!object)
1766 return typeName;
1767
1768 QQmlType type = QQmlMetaType::qmlType(object->metaObject());
1769 if (type.isValid()) {
1770 typeName = type.qmlTypeName();
1771 const int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
1772 if (lastSlash != -1)
1773 typeName = typeName.mid(lastSlash + 1);
1774 }
1775
1776 if (typeName.isEmpty()) {
1777 typeName = QString::fromUtf8(object->metaObject()->className());
1778 int marker = typeName.indexOf(QLatin1String("_QMLTYPE_"));
1779 if (marker != -1)
1780 typeName = typeName.left(marker);
1781
1782 marker = typeName.indexOf(QLatin1String("_QML_"));
1783 if (marker != -1) {
1786 if (type.isValid()) {
1787 QString qmlTypeName = type.qmlTypeName();
1788 const int lastSlash = qmlTypeName.lastIndexOf(QLatin1Char('/'));
1789 if (lastSlash != -1)
1790 qmlTypeName = qmlTypeName.mid(lastSlash + 1);
1791 if (!qmlTypeName.isEmpty())
1793 }
1794 }
1795 }
1796
1797 return typeName;
1798}
1799
1800QList<QQmlProxyMetaObject::ProxyData> QQmlMetaType::proxyData(const QMetaObject *mo,
1801 const QMetaObject *baseMetaObject,
1802 QMetaObject *lastMetaObject)
1803{
1804 QList<QQmlProxyMetaObject::ProxyData> metaObjects;
1805 mo = mo->d.superdata;
1806
1807 if (!mo)
1808 return metaObjects;
1809
1810 auto createProxyMetaObject = [&](QQmlTypePrivate *This,
1811 const QMetaObject *superdataBaseMetaObject,
1812 const QMetaObject *extMetaObject,
1813 QObject *(*extFunc)(QObject *)) {
1814 if (!extMetaObject)
1815 return;
1816
1817 QMetaObjectBuilder builder;
1818 clone(builder, extMetaObject, superdataBaseMetaObject, baseMetaObject,
1820 QMetaObject *mmo = builder.toMetaObject();
1821 mmo->d.superdata = baseMetaObject;
1822 if (!metaObjects.isEmpty())
1823 metaObjects.constLast().metaObject->d.superdata = mmo;
1824 else if (lastMetaObject)
1825 lastMetaObject->d.superdata = mmo;
1826 QQmlProxyMetaObject::ProxyData data = { mmo, extFunc, 0, 0 };
1827 metaObjects << data;
1828 registerMetaObjectForType(mmo, This);
1829 };
1830
1831 for (const QQmlMetaTypeDataPtr data; mo; mo = mo->d.superdata) {
1832 // TODO: There can in fact be multiple QQmlTypePrivate* for a single QMetaObject*.
1833 // This algorithm only accounts for the most recently inserted one. That's pretty
1834 // random. However, the availability of types depends on what documents you have
1835 // loaded before. Just adding all possible extensions would also be pretty random.
1836 // The right way to do this would be to take the relations between the QML modules
1837 // into account. For this we would need proper module dependency information.
1838 if (QQmlTypePrivate *t = data->metaObjectToType.value(mo)) {
1839 if (t->regType == QQmlType::CppType) {
1840 createProxyMetaObject(
1841 t, t->baseMetaObject, t->extraData.cppTypeData->extMetaObject,
1842 t->extraData.cppTypeData->extFunc);
1843 } else if (t->regType == QQmlType::SingletonType) {
1844 createProxyMetaObject(
1845 t, t->baseMetaObject, t->extraData.singletonTypeData->extMetaObject,
1846 t->extraData.singletonTypeData->extFunc);
1847 }
1848 }
1849 };
1850
1851 return metaObjects;
1852}
1853
1854static bool isInternalType(int idx)
1855{
1856 // Qt internal types
1857 switch (idx) {
1859 case QMetaType::QStringList:
1860 case QMetaType::QObjectStar:
1861 case QMetaType::VoidStar:
1862 case QMetaType::Nullptr:
1864 case QMetaType::QLocale:
1865 case QMetaType::QImage: // scarce type, keep as QVariant
1866 case QMetaType::QPixmap: // scarce type, keep as QVariant
1867 return true;
1868 default:
1869 return false;
1870 }
1871}
1872
1874{
1875 if (!type.isValid() || isInternalType(type.id()))
1876 return false;
1877
1878 return valueType(type) != nullptr;
1879}
1880
1882{
1883 switch (metaType.id()) {
1884 case QMetaType::QPoint:
1885 return &QQmlPointValueType::staticMetaObject;
1886 case QMetaType::QPointF:
1887 return &QQmlPointFValueType::staticMetaObject;
1888 case QMetaType::QSize:
1889 return &QQmlSizeValueType::staticMetaObject;
1890 case QMetaType::QSizeF:
1891 return &QQmlSizeFValueType::staticMetaObject;
1892 case QMetaType::QRect:
1893 return &QQmlRectValueType::staticMetaObject;
1894 case QMetaType::QRectF:
1895 return &QQmlRectFValueType::staticMetaObject;
1896#if QT_CONFIG(easingcurve)
1897 case QMetaType::QEasingCurve:
1898 return &QQmlEasingValueType::staticMetaObject;
1899#endif
1900 default:
1901 break;
1902 }
1903
1904 // It doesn't have to be a gadget for a QML type to exist, but we don't want to
1905 // call QObject pointers value types. Explicitly registered types also override
1906 // the implicit use of gadgets.
1907 if (!(metaType.flags() & QMetaType::PointerToQObject)) {
1909 const QQmlTypePrivate *type = data->idToType.value(metaType.id());
1910 if (type && type->regType == QQmlType::CppType && type->typeId == metaType) {
1911 if (const QMetaObject *mo = type->metaObjectForValueType())
1912 return mo;
1913 }
1914 }
1915
1916 // If it _is_ a gadget, we can just use it.
1917 if (metaType.flags() & QMetaType::IsGadget)
1918 return metaType.metaObject();
1919
1920 return nullptr;
1921}
1922
1924{
1926
1927 const auto it = data->metaTypeToValueType.constFind(type.id());
1928 if (it != data->metaTypeToValueType.constEnd())
1929 return *it;
1930
1932 return *data->metaTypeToValueType.insert(type.id(), new QQmlValueType(type, mo));
1933 return *data->metaTypeToValueType.insert(type.id(), nullptr);
1934}
1935
1941
1943 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
1944{
1946
1947 auto doInsert = [&data, &compilationUnit](const QtPrivate::QMetaTypeInterface *iface) {
1948 Q_ASSERT(iface);
1949 Q_ASSERT(compilationUnit);
1950
1951 // We can't assert on anything else here. We may get a completely new type as exposed
1952 // by the qmldiskcache test that changes a QML file in place during the execution
1953 // of the test.
1954 data->compositeTypes.insert(iface, compilationUnit);
1955 };
1956
1957 doInsert(compilationUnit->metaType().iface());
1958 for (auto &&inlineData: compilationUnit->inlineComponentData)
1959 doInsert(inlineData.qmlType.typeId().iface());
1960}
1961
1963 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
1964{
1966
1967 auto doRemove = [&](const QtPrivate::QMetaTypeInterface *iface) {
1968 if (!iface)
1969 return;
1970
1971 const auto it = data->compositeTypes.constFind(iface);
1972 if (it != data->compositeTypes.constEnd() && *it == compilationUnit)
1973 data->compositeTypes.erase(it);
1974 };
1975
1976 doRemove(compilationUnit->metaType().iface());
1977 for (auto &&inlineData: compilationUnit->inlineComponentData)
1978 doRemove(inlineData.qmlType.typeId().iface());
1979}
1980
1982 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit)
1983{
1985 return doCountInternalCompositeTypeSelfReferences(data, compilationUnit);
1986}
1987
1988QQmlRefPointer<QV4::CompiledData::CompilationUnit> QQmlMetaType::obtainCompilationUnit(
1990{
1992 return data->compositeTypes.value(type.iface());
1993}
1994
1995QQmlRefPointer<QV4::CompiledData::CompilationUnit> QQmlMetaType::obtainCompilationUnit(
1996 const QUrl &url)
1997{
2000
2001 auto found = data->urlToType.constFind(normalized);
2002 if (found == data->urlToType.constEnd()) {
2003 found = data->urlToNonFileImportType.constFind(normalized);
2004 if (found == data->urlToNonFileImportType.constEnd())
2005 return QQmlRefPointer<QV4::CompiledData::CompilationUnit>();
2006 }
2007
2008 const auto composite = data->compositeTypes.constFind(found.value()->typeId.iface());
2009 return composite == data->compositeTypes.constEnd()
2010 ? QQmlRefPointer<QV4::CompiledData::CompilationUnit>()
2011 : composite.value();
2012}
2013
\inmodule QtCore
Definition qbytearray.h:57
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\inmodule QtCore\reentrant
Definition qdatetime.h:283
const_iterator constFind(const Key &key) const noexcept
Definition qhash.h:1299
T value(const Key &key) const noexcept
Definition qhash.h:1054
void swap(QHash &other) noexcept
Definition qhash.h:900
int indexOf(const QChar &, int from=0) const
QString toString() const
const QChar * constData() const
bool isEmpty() const
bool removeOne(const AT &t)
Definition qlist.h:598
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
\inmodule QtCore
const char * name() const
Returns the name of the type (without the scope).
void setAccess(QMetaMethod::Access value)
Sets the access specification of this method (private, protected, or public) to value.
\inmodule QtCore
Definition qmetaobject.h:19
QMetaEnumBuilder addEnumerator(const QByteArray &name)
Adds a new enumerator to this class with the specified name.
QMetaObject * toMetaObject() const
Converts this meta object builder into a concrete QMetaObject.
int addClassInfo(const QByteArray &name, const QByteArray &value)
Adds name and value as an item of class information to this class.
QMetaMethodBuilder addMethod(const QByteArray &signature)
Adds a new public method to this class with the specified signature.
QMetaPropertyBuilder addProperty(const QByteArray &name, const QByteArray &type, int notifierId=-1)
Adds a new readable/writable property to this class with the specified name and type.
void setClassName(const QByteArray &name)
Sets the name of the class being constructed by this meta object builder.
\inmodule QtCore
QMetaType valueMetaType() const
Returns the meta type for values stored in the container.
\inmodule QtCore
Definition qmetatype.h:341
constexpr TypeFlags flags() const
Definition qmetatype.h:2658
const QtPrivate::QMetaTypeInterface * iface() const
Definition qmetatype.h:771
static QMetaType fromName(QByteArrayView name)
Returns a QMetaType matching typeName.
int id(int=0) const
Definition qmetatype.h:475
@ PointerToQObject
Definition qmetatype.h:406
@ PointerToGadget
Definition qmetatype.h:413
constexpr const QMetaObject * metaObject() const
Definition qmetatype.h:2663
static void unregisterMetaType(QMetaType type)
friend class QVariant
Definition qmetatype.h:796
std::pair< iterator, iterator > equal_range(const Key &key)
Definition qhash.h:2266
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition qhash.h:2034
iterator insert(const Key &key, const T &value)
Definition qmap.h:1452
size_type remove(const Key &key)
Definition qmap.h:971
std::pair< iterator, iterator > equal_range(const Key &akey)
Definition qmap.h:1522
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
The QQmlCustomParser class allows you to add new arbitrary types to QML.
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
static QUrl urlFromLocalFileOrQrcOrUrl(const QString &)
QQmlMetaTypeData & operator*()
~QQmlMetaTypeDataPtr()=default
QQmlMetaTypeData * operator->()
const QQmlMetaTypeData * operator->() const
const QQmlMetaTypeData & operator*() const
QQmlMetaTypeRegistrationFailureRecorder(QQmlMetaTypeData *data, QStringList *failures)
static QQmlType qmlTypeById(int qmlTypeId)
Returns the type (if any) that corresponds to qmlTypeId.
static QQmlType registerSequentialContainer(const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration)
static QString prettyTypeName(const QObject *object)
Returns the pretty QML type name (e.g.
static void unregisterType(int type)
static void qmlRemoveModuleRegistration(const QString &uri)
static QMetaType listValueType(QMetaType type)
static void registerUndeletableType(const QQmlType &dtype)
static QQmlType findCompositeType(const QUrl &url, const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit, CompositeTypeLookupMode mode=NonSingleton)
static QQmlPropertyCache::ConstPtr rawPropertyCacheForType(QMetaType metaType)
static bool equalBaseUrls(const QUrl &aUrl, const QUrl &bUrl)
static void unregisterAutoParentFunction(const QQmlPrivate::AutoParentFunction &function)
static bool protectModule(const QString &uri, QTypeRevision version, bool weakProtectAllVersions=false)
static bool isStronglyLockedModule(const QString &uri, QTypeRevision version)
static QQmlType qmlListType(QMetaType metaType)
static QQmlType registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &type, const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo)
static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler)
static void prependCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler)
static void registerModule(const char *uri, QTypeRevision version)
static QQmlType findInlineComponentType(const QUrl &url, const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit)
static bool isList(QMetaType type)
static QQmlType registerInterface(const QQmlPrivate::RegisterInterface &type)
static int typeId(const char *uri, QTypeRevision version, const char *qmlName)
static const char * interfaceIId(QMetaType type)
static QQmlType registerType(const QQmlPrivate::RegisterType &type)
static QList< QQmlProxyMetaObject::ProxyData > proxyData(const QMetaObject *mo, const QMetaObject *baseMetaObject, QMetaObject *lastMetaObject)
static const QMetaObject * metaObjectForValueType(QMetaType type)
static QQmlMetaObject metaObjectForType(QMetaType metaType)
static QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t)
static QList< QQmlPrivate::AutoParentFunction > parentFunctions()
static QQmlType fetchOrCreateInlineComponentTypeForUrl(const QUrl &url)
static QTypeRevision matchingModuleVersion(const QString &module, QTypeRevision version)
static void registerModuleImport(const QString &uri, QTypeRevision version, const QQmlDirParser::Import &import)
static QList< QQmlDirParser::Import > moduleImports(const QString &uri, QTypeRevision version)
static QQmlAttachedPropertiesFunc attachedPropertiesFunc(QQmlEnginePrivate *, const QMetaObject *)
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd, ClonePolicy policy)
static QObject * toQObject(const QVariant &, bool *ok=nullptr)
static void registerTypeAlias(int typeId, const QString &name)
static QQmlType registerCompositeType(const QQmlPrivate::RegisterCompositeType &type)
static void qmlInsertModuleRegistration(const QString &uri, void(*registerFunction)())
static int registerAutoParentFunction(const QQmlPrivate::RegisterAutoParent &autoparent)
static QList< QQmlType > qmlSingletonTypes()
Returns the list of registered QML singleton types.
static QTypeRevision latestModuleVersion(const QString &uri)
static QQmlTypeModule * typeModule(const QString &uri, QTypeRevision version)
static void clearTypeRegistrations()
static bool qmlRegisterModuleTypes(const QString &uri)
static bool isInterface(QMetaType type)
See qmlRegisterInterface() for information about when this will return true.
static int countInternalCompositeTypeSelfReferences(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit)
static QQmlMetaObject rawMetaObjectForType(QMetaType metaType)
static QQmlValueType * valueType(QMetaType metaType)
static QMetaProperty defaultProperty(const QMetaObject *)
static void removeFromInlineComponents(InlineComponentContainer &container, const QQmlTypePrivate *reference)
static QQmlType typeForUrl(const QString &urlString, const QHashedStringRef &typeName, CompositeTypeLookupMode mode, QList< QQmlError > *errors, QTypeRevision version=QTypeRevision())
static const QQmlPrivate::CachedQmlUnit * findCachedCompilationUnit(const QUrl &uri, CacheMode mode, CachedUnitLookupError *status)
static QQmlPropertyCache::ConstPtr propertyCache(QObject *object, QTypeRevision version=QTypeRevision())
Returns a QQmlPropertyCache for obj if one is available.
static QQmlType registerSingletonType(const QQmlPrivate::RegisterSingletonType &type, const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo)
static QQmlType qmlType(const QString &qualifiedName, QTypeRevision version)
Returns the type (if any) of URI-qualified named qualifiedName and version specified by version_major...
static QList< QQmlType > qmlTypes()
Returns the list of registered QML types.
static QList< QString > qmlTypeNames()
Returns the list of registered QML type names.
static void registerMetaObjectForType(const QMetaObject *metaobject, QQmlTypePrivate *type)
static void freeUnusedTypesAndCaches()
static void unregisterSequentialContainer(int id)
static bool isValueType(QMetaType type)
static void removeQQmlTypePrivate(QQmlTypeContainer &container, const QQmlTypePrivate *reference)
static int registerUnitCacheHook(const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration)
static QList< QQmlType > qmlAllTypes()
Returns the list of all registered types.
static RegistrationResult registerPluginTypes(QObject *instance, const QString &basePath, const QString &uri, const QString &typeNamespace, QTypeRevision version, QList< QQmlError > *errors)
static QQmlRefPointer< QV4::CompiledData::CompilationUnit > obtainCompilationUnit(QMetaType type)
static void unregisterInternalCompositeType(QMetaType metaType, QMetaType listMetaType)
static QMetaMethod defaultMethod(const QMetaObject *)
static void unregisterModuleImport(const QString &uri, QTypeRevision version, const QQmlDirParser::Import &import)
static QQmlPropertyCache::ConstPtr propertyCacheForType(QMetaType metaType)
static void registerInternalCompositeType(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit)
static QUrl normalize(const QUrl &unNormalizedUrl)
const QMetaObject * baseMetaObject
@ InlineComponentType
Definition qqmltype_p.h:165
@ SingletonType
Definition qqmltype_p.h:161
@ SequentialContainerType
Definition qqmltype_p.h:166
@ CompositeType
Definition qqmltype_p.h:163
@ CompositeSingletonType
Definition qqmltype_p.h:164
@ InterfaceType
Definition qqmltype_p.h:162
int index() const
Definition qqmltype.cpp:758
const QMetaObject * metaObject() const
Definition qqmltype.cpp:683
\inmodule QtCore
Definition qmutex.h:309
iterator begin()
Definition qset.h:136
iterator end()
Definition qset.h:140
const_iterator cend() const noexcept
Definition qset.h:142
const_iterator constEnd() const noexcept
Definition qset.h:143
iterator erase(const_iterator i)
Definition qset.h:145
const_iterator constFind(const T &value) const
Definition qset.h:161
bool contains(const T &value) const
Definition qset.h:71
const_iterator cbegin() const noexcept
Definition qset.h:138
iterator insert(const T &value)
Definition qset.h:155
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4517
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition qstring.h:1246
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8870
static QString fromRawData(const QChar *, qsizetype size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Definition qstring.cpp:9482
QByteArray toUtf8() const &
Definition qstring.h:634
\inmodule QtCore
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
constexpr bool hasMinorVersion() const
Returns true if the minor version is known, otherwise false.
constexpr bool hasMajorVersion() const
Returns true if the major version is known, otherwise false.
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
\inmodule QtCore
Definition qurl.h:94
QString fragment(ComponentFormattingOptions options=PrettyDecoded) const
Returns the fragment of the URL.
Definition qurl.cpp:2682
\inmodule QtCore
Definition qvariant.h:65
QSet< QString >::iterator it
auto mo
[7]
const CachedQmlUnit *(* QmlUnitCacheLookupFunction)(const QUrl &url)
AutoParentResult(* AutoParentFunction)(QObject *object, QObject *parent)
Combined button and popup list for selecting options.
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
DBusConnection const char DBusError * error
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static QDBusError::ErrorType get(const char *name)
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
return ret
static ControlElement< T > * ptr(QWidget *widget)
static const QMetaObjectPrivate * priv(const uint *data)
const char * typeName
GLsizei const GLfloat * v
[13]
GLenum mode
const GLfloat * m
GLuint64 key
GLuint GLuint end
GLsizei GLenum GLenum * types
GLuint object
[3]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei range
GLenum type
GLbitfield flags
const GLchar * marker
GLuint name
GLhandleARB obj
[2]
GLuint GLuint * names
GLdouble GLdouble t
Definition qopenglext.h:243
GLint GLenum GLboolean normalized
Definition qopenglext.h:752
GLuint64EXT * result
[6]
GLsizei const GLchar *const * string
[0]
Definition qopenglext.h:694
static qreal dot(const QPointF &a, const QPointF &b)
int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
Definition qqml.cpp:357
static void addTypeToData(QQmlTypePrivate *type, QQmlMetaTypeData *data)
static bool namespaceContainsRegistrations(const QQmlMetaTypeData *data, const QString &uri, QTypeRevision version)
static bool isFullyTyped(const QQmlPrivate::CachedQmlUnit *unit)
static void addQQmlMetaTypeInterfaces(QQmlTypePrivate *priv, const QByteArray &className)
static bool hasActiveInlineComponents(const QQmlMetaTypeData *data, const QQmlTypePrivate *d)
static bool isInternalType(int idx)
static QQmlTypePrivate * createQQmlType(QQmlMetaTypeData *data, const QQmlPrivate::RegisterInterface &type)
static QQmlType createTypeForUrl(QQmlMetaTypeData *data, const QUrl &url, const QHashedStringRef &qualifiedType, QQmlMetaType::CompositeTypeLookupMode mode, QList< QQmlError > *errors, QTypeRevision version)
static bool checkRegistration(QQmlType::RegistrationType typeType, QQmlMetaTypeData *data, const char *uri, const QString &typeName, QTypeRevision version, QMetaType::TypeFlags flags)
static QQmlTypeModule * getTypeModule(const QHashedString &uri, QTypeRevision version, QQmlMetaTypeData *data)
static QQmlType doRegisterInlineComponentType(QQmlMetaTypeData *data, const QUrl &url)
static int doCountInternalCompositeTypeSelfReferences(QQmlMetaTypeData *data, const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &compilationUnit)
static QString registrationTypeString(QQmlType::RegistrationType typeType)
const QMetaObject * dynamicQmlListMarker(const QtPrivate::QMetaTypeInterface *)
QQmlPrivate::QQmlAttachedPropertiesFunc< QObject > QQmlAttachedPropertiesFunc
Definition qqmlprivate.h:63
static const char * qmlTypeName(const QObject *object)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
static QLatin1StringView typeStr(QShaderDescription::VariableType t)
SSL_CTX int void * arg
#define qPrintable(string)
Definition qstring.h:1531
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:50
const char property[13]
Definition qwizard.cpp:101
const char className[16]
[1]
Definition qwizard.cpp:100
QUrl url("example.com")
[constructor-url-reference]
obj metaObject() -> className()
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]
QStringList files
[8]
QSizePolicy policy
QHostInfo info
[0]
QJSEngine engine
[0]
ModuleUri(const std::unique_ptr< QQmlTypeModule > &module)
ModuleUri(const QString &string)
\inmodule QtCore \reentrant
Definition qchar.h:18
\inmodule QtCore
struct QMetaObject::Data d
bool registerModuleTypes(const QString &uri)
MetaObjects metaObjectToType
QQmlTypeModule * findTypeModule(const QString &module, QTypeRevision version)
QQmlPropertyCache::ConstPtr propertyCache(const QMetaObject *metaObject, QTypeRevision version)
QVector< QQmlPrivate::QmlUnitCacheLookupFunction > lookupCachedQmlUnit
QList< QQmlPrivate::AutoParentFunction > parentFunctions
CompositeTypes compositeTypes
ModuleImports moduleImports
QList< QQmlType > types
QSet< QQmlType > undeletableTypes
QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t) const
const AOTCompiledFunction * aotCompiledFunctions
const QV4::CompiledData::Unit * qmlData
static QByteArray createClassNameTypeByUrl(const QUrl &url)
static QByteArray createClassNameForInlineComponent(const QUrl &baseUrl, const QString &name)
QQmlRefPointer< const SingletonInstanceInfo > ConstPtr
Definition qqmltype_p.h:127
QQmlRefPointer< SingletonInstanceInfo > Ptr
Definition qqmltype_p.h:126