Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlmetatypedata_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 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// Qt-Security score:significant
4
5#ifndef QQMLMETATYPEDATA_P_H
6#define QQMLMETATYPEDATA_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qhashedstring_p.h>
20#include <private/qqmlmetatype_p.h>
21#include <private/qqmlscriptdata_p.h>
22#include <private/qqmltype_p.h>
23#include <private/qqmlvaluetype_p.h>
24
25#include <QtCore/qset.h>
26#include <QtCore/qvector.h>
27
28QT_BEGIN_NAMESPACE
29
30class QQmlTypePrivate;
32{
35 void registerType(QQmlTypePrivate *priv);
36
42
45
46 typedef QHash<int, QQmlTypePrivate *> Ids;
48
51
52 typedef QHash<QUrl, const QQmlTypePrivate *> Files; //For file imported composite types only
54
55 // Inline component types created speculatively before their base type's CU was registered.
56 // These need to be pruned when the CU registers if the IC doesn't actually exist.
58
62
63 // This has to be a multihash because a user can create a compilation unit using arbitrary
64 // static data, via e.g. QQmlComponent::setData() or Qt.createQmlObject(). Since you can also
65 // freely choose the URL and therefore the metatype for those, we can end up we can end up
66 // with multiple compilation units per URL. Some compilation units need special handling on
67 // removal. Therefore we need to hold on to all of them.
71
72 struct VersionedUri {
73 VersionedUri() = default;
74 VersionedUri(const QString &uri, QTypeRevision version)
76 VersionedUri(const std::unique_ptr<QQmlTypeModule> &module);
77
78 friend bool operator==(const VersionedUri &a, const VersionedUri &b)
79 {
80 return a.majorVersion == b.majorVersion && a.uri == b.uri;
81 }
82
83 friend size_t qHash(const VersionedUri &v, size_t seed = 0)
84 {
85 return qHashMulti(seed, v.uri, v.majorVersion);
86 }
87
88 friend bool operator<(const QQmlMetaTypeData::VersionedUri &a,
90 {
91 const int diff = a.uri.compare(b.uri);
92 return diff < 0 || (diff == 0 && a.majorVersion < b.majorVersion);
93 }
94
97 };
98
101 QQmlTypeModule *findTypeModule(const QString &module, QTypeRevision version);
102 QQmlTypeModule *addTypeModule(std::unique_ptr<QQmlTypeModule> module);
103
106
108 bool registerModuleTypes(const QString &uri);
109
112
114
121
122 QQmlPropertyCache::ConstPtr propertyCacheForVersion(int index, QTypeRevision version) const;
124 int index, QTypeRevision version, const QQmlPropertyCache::ConstPtr &cache);
125
126 QQmlPropertyCache::ConstPtr propertyCache(const QMetaObject *metaObject, QTypeRevision version);
127 QQmlPropertyCache::ConstPtr propertyCache(const QQmlType &type, QTypeRevision version);
129
131 QMetaType t, const QQmlMetaTypeData::CompositeTypes::const_iterator &iter);
132
133 void setTypeRegistrationFailures(QStringList *failures)
134 {
135 m_typeRegistrationFailures = failures;
136 }
137
138 void recordTypeRegFailure(const QString &message)
139 {
140 if (m_typeRegistrationFailures)
141 m_typeRegistrationFailures->append(message);
142 else
143 qWarning("%s", message.toUtf8().constData());
144 }
145
146 static void clearCompositeType(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &cu)
147 {
148 if (cu->isESModule())
149 cu->dependentScripts.clear();
150 }
151
152 void clearCompositeTypes();
154private:
155 QStringList *m_typeRegistrationFailures = nullptr;
156};
157
158QT_END_NAMESPACE
159
160#endif // QQMLMETATYPEDATA_P_H
Combined button and popup list for selecting options.
QQmlListMetaTypeInterface * listType
QHash< QTypeRevision, QQmlPropertyCache::ConstPtr > propertyCaches
VersionedUri(const std::unique_ptr< QQmlTypeModule > &module)
friend size_t qHash(const VersionedUri &v, size_t seed=0)
friend bool operator<(const QQmlMetaTypeData::VersionedUri &a, const QQmlMetaTypeData::VersionedUri &b)
friend bool operator==(const VersionedUri &a, const VersionedUri &b)
VersionedUri(const QString &uri, QTypeRevision version)
static QQmlPropertyCache::ConstPtr propertyCacheForPotentialInlineComponentType(QMetaType t, const QQmlMetaTypeData::CompositeTypes::const_iterator &iter)
QQmlTypeModule * addTypeModule(std::unique_ptr< QQmlTypeModule > module)
bool registerModuleTypes(const QString &uri)
QHash< int, QQmlTypePrivate * > Ids
MetaObjects metaObjectToType
QQmlTypeModule * findTypeModule(const QString &module, QTypeRevision version)
QHash< int, QQmlValueType * > metaTypeToValueType
QQmlPropertyCache::ConstPtr propertyCache(const QMetaObject *metaObject, QTypeRevision version)
QHash< const QMetaObject *, QQmlPropertyCache::ConstPtr > propertyCaches
QQmlPropertyCache::ConstPtr propertyCache(const QQmlType &type, QTypeRevision version)
QList< QQmlPrivate::QmlUnitCacheLookupFunction > lookupCachedQmlUnit
void registerType(QQmlTypePrivate *priv)
QHash< QString, void(*)()> moduleTypeRegistrationFunctions
QList< QQmlPrivate::AutoParentFunction > parentFunctions
QHash< QUrl, CompositeMetaTypes > compositeMetaTypes
CompositeTypes compositeTypes
QSet< QUrl > speculativeInlineComponentTypes
QMultiHash< const QMetaObject *, const QQmlTypePrivate * > MetaObjects
ModuleImports moduleImports
void setTypeRegistrationFailures(QStringList *failures)
QHash< QUrl, const QQmlTypePrivate * > Files
QSet< QQmlType > undeletableTypes
static void clearCompositeType(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &cu)
QQmlPropertyCache::ConstPtr findPropertyCacheInCompositeTypes(QMetaType t) const
QQmlPropertyCache::ConstPtr propertyCacheForVersion(int index, QTypeRevision version) const
void setPropertyCacheForVersion(int index, QTypeRevision version, const QQmlPropertyCache::ConstPtr &cache)
void recordTypeRegFailure(const QString &message)