Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmltypedata_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
4#ifndef QQMLTYPEDATA_P_H
5#define QQMLTYPEDATA_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qqmltypeloader_p.h>
19#include <private/qv4executablecompilationunit_p.h>
20
22
24{
26public:
28 {
29 TypeReference() : version(QTypeRevision::zero()), needsCreation(true) {}
30
35 bool selfReference = false;
36 QString prefix; // used by CompositeSingleton types
37 QString qualifiedName() const;
39 };
40
42 {
46 };
47
48private:
49 friend class QQmlTypeLoader;
50
52 template<typename Container>
53 void setCompileUnit(const Container &container);
54
55public:
56 ~QQmlTypeData() override;
57
58 const QList<ScriptReference> &resolvedScripts() const;
59
60 QV4::ExecutableCompilationUnit *compilationUnit() const;
61
62 // Used by QQmlComponent to get notifications
64 virtual ~TypeDataCallback();
66 virtual void typeDataReady(QQmlTypeData *) {}
67 };
68 void registerCallback(TypeDataCallback *);
69 void unregisterCallback(TypeDataCallback *);
70
71 QQmlType qmlType(const QString &inlineComponentName = QString()) const;
72 QByteArray typeClassName() const { return m_typeClassName; }
73 SourceCodeData backupSourceCode() const { return m_backupSourceCode; }
74
75protected:
76 void done() override;
77 void completed() override;
78 void dataReceived(const SourceCodeData &) override;
80 void allDependenciesDone() override;
81 void downloadProgressChanged(qreal) override;
82
83 QString stringAt(int index) const override;
84
85private:
86 bool tryLoadFromDiskCache();
87 bool loadFromSource();
88 void restoreIR(QV4::CompiledData::CompilationUnit &&unit);
89 void continueLoadFromIR();
90 void resolveTypes();
91 QQmlError buildTypeResolutionCaches(
93 QV4::ResolvedTypeReferenceMap *resolvedTypeCache
94 ) const;
95 void compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache,
96 QV4::ResolvedTypeReferenceMap *resolvedTypeCache,
97 const QV4::CompiledData::DependentTypesHasher &dependencyHasher);
98 QQmlError createTypeAndPropertyCaches(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache,
99 const QV4::ResolvedTypeReferenceMap &resolvedTypeCache);
100 bool resolveType(const QString &typeName, QTypeRevision &version,
101 TypeReference &ref, int lineNumber = -1, int columnNumber = -1,
102 bool reportErrors = true,
104 bool *typeRecursionDetected = nullptr);
105
106 void scriptImported(
108 const QString &nameSpace, const QString &qualifier) override;
109
110 SourceCodeData m_backupSourceCode; // used when cache verification fails.
113
114 QList<ScriptReference> m_scripts;
115
116 QSet<QString> m_namespaces;
117 QList<TypeReference> m_compositeSingletons;
118
119 // map from name index to resolved type
120 // While this could be a hash, a map is chosen here to provide a stable
121 // order, which is used to calculating a check-sum on dependent meta-objects.
122 QMap<int, TypeReference> m_resolvedTypes;
123 bool m_typesResolved:1;
124
125 // Used for self-referencing types, otherwise invalid.
126 QQmlType m_qmlType;
127 QByteArray m_typeClassName; // used for meta-object later
128
129 using ExecutableCompilationUnitPtr = QQmlRefPointer<QV4::ExecutableCompilationUnit>;
130
131 QHash<QString, InlineComponentData> m_inlineComponentData;
132
133 ExecutableCompilationUnitPtr m_compiledData;
134
135 QList<TypeDataCallback *> m_callbacks;
136
137 bool m_implicitImportLoaded;
138 bool loadImplicitImport();
139};
140
142
143#endif // QQMLTYPEDATA_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qhash.h:818
Definition qlist.h:74
Definition qmap.h:186
virtual void dataReceived(const SourceCodeData &)=0
Invoked when data for the blob is received.
virtual void initializeFromCachedUnit(const QQmlPrivate::CachedQmlUnit *)=0
virtual void allDependenciesDone()
Called when all blobs waited for have completed.
virtual void completed()
Invoked on the main thread sometime after done() was called on the load thread.
virtual void done()
Invoked once data has either been received or a network error occurred, and all dependencies are comp...
virtual void downloadProgressChanged(qreal)
Called when the download progress of this blob changes.
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
QByteArray typeClassName() const
SourceCodeData backupSourceCode() const
virtual void scriptImported(const QQmlRefPointer< QQmlScriptBlob > &, const QV4::CompiledData::Location &, const QString &, const QString &)
virtual QString stringAt(int) const
The QQmlTypeLoader class abstracts loading files and their dependencies over the network.
@ AnyRegistrationType
Definition qqmltype_p.h:158
\inmodule QtCore
Definition qset.h:18
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
std::function< QByteArray()> DependentTypesHasher
#define Q_DECLARE_TR_FUNCTIONS(context)
const char * typeName
GLint location
GLuint index
[2]
GLint ref
#define zero
#define Q_AUTOTEST_EXPORT
double qreal
Definition qtypes.h:92
QQmlRefPointer< QQmlScriptBlob > script
QV4::CompiledData::Location location
virtual void typeDataProgress(QQmlTypeData *, qreal)
virtual void typeDataReady(QQmlTypeData *)
QQmlRefPointer< QQmlTypeData > typeData
QV4::CompiledData::Location location