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/qvarlengtharray.h>
27#include <QtCore/qvector.h>
28
29QT_BEGIN_NAMESPACE
30
31class QQmlTypePrivate;
33{
36 void registerType(QQmlTypePrivate *priv);
37
43
46
47 typedef QHash<int, QQmlTypePrivate *> Ids;
49
52
53 typedef QHash<QUrl, const QQmlTypePrivate *> Files; //For file imported composite types only
55
56 // Inline component types created speculatively before their base type's CU was registered.
57 // These need to be pruned when the CU registers if the IC doesn't actually exist.
59
63
64 // This has to be a multihash because a user can create a compilation unit using arbitrary
65 // static data, via e.g. QQmlComponent::setData() or Qt.createQmlObject(). Since you can also
66 // freely choose the URL and therefore the metatype for those, we can end up we can end up
67 // with multiple compilation units per URL. Some compilation units need special handling on
68 // removal. Therefore we need to hold on to all of them.
72
73 struct VersionedUri {
74 VersionedUri() = default;
75 VersionedUri(const QString &uri, QTypeRevision version)
77 VersionedUri(const std::unique_ptr<QQmlTypeModule> &module);
78
79 friend bool operator==(const VersionedUri &a, const VersionedUri &b)
80 {
81 return a.majorVersion == b.majorVersion && a.uri == b.uri;
82 }
83
84 friend size_t qHash(const VersionedUri &v, size_t seed = 0)
85 {
86 return qHashMulti(seed, v.uri, v.majorVersion);
87 }
88
89 friend bool operator<(const QQmlMetaTypeData::VersionedUri &a,
91 {
92 const int diff = a.uri.compare(b.uri);
93 return diff < 0 || (diff == 0 && a.majorVersion < b.majorVersion);
94 }
95
98 };
99
102 QQmlTypeModule *findTypeModule(const QString &module, QTypeRevision version);
103 QQmlTypeModule *addTypeModule(std::unique_ptr<QQmlTypeModule> module);
104
107
109 bool registerModuleTypes(const QString &uri);
110
113
115
122
123 QQmlPropertyCache::ConstPtr propertyCacheForVersion(int index, QTypeRevision version) const;
125 int index, QTypeRevision version, const QQmlPropertyCache::ConstPtr &cache);
126
127 QQmlPropertyCache::ConstPtr propertyCache(const QMetaObject *metaObject, QTypeRevision version);
128 QQmlPropertyCache::ConstPtr propertyCache(const QQmlType &type, QTypeRevision version);
130
131 // Same, but returns all matches rather than only the last inserted one.
133 QMetaType t) const;
134
136 QMetaType t, const QQmlMetaTypeData::CompositeTypes::const_iterator &iter);
137
138 void setTypeRegistrationFailures(QStringList *failures)
139 {
140 m_typeRegistrationFailures = failures;
141 }
142
143 void recordTypeRegFailure(const QString &message)
144 {
145 if (m_typeRegistrationFailures)
146 m_typeRegistrationFailures->append(message);
147 else
148 qWarning("%s", message.toUtf8().constData());
149 }
150
151 static void clearCompositeType(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &cu)
152 {
153 if (cu->isESModule())
154 cu->dependentScripts.clear();
155 }
156
157 void clearCompositeTypes();
159private:
160 QStringList *m_typeRegistrationFailures = nullptr;
161};
162
163QT_END_NAMESPACE
164
165#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)
QVarLengthArray< QQmlPropertyCache::ConstPtr, 4 > findPropertyCachesInCompositeTypes(QMetaType t) const
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)