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
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
34 QQmlRefPointer<QQmlTypeData> typeData;
35 bool selfReference = false;
36 QString prefix; // used by CompositeSingleton types
37 QString qualifiedName() const;
39 };
40
42 {
45 QQmlRefPointer<QQmlScriptBlob> script;
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 QV4::CompiledData::CompilationUnit *compilationUnit() const;
59
60 // Used by QQmlComponent to get notifications
62 virtual ~TypeDataCallback();
64 virtual void typeDataReady(QQmlTypeData *) {}
65 };
66 void registerCallback(TypeDataCallback *);
67 void unregisterCallback(TypeDataCallback *);
68
69 QQmlType qmlType(const QString &inlineComponentName = QString()) const;
70 QByteArray typeClassName() const { return m_typeClassName; }
71 SourceCodeData backupSourceCode() const { return m_backupSourceCode; }
72
73protected:
74 void done() override;
75 void completed() override;
76 void dataReceived(const SourceCodeData &) override;
78 void allDependenciesDone() override;
79 void downloadProgressChanged(qreal) override;
80
81 QString stringAt(int index) const override;
82
83private:
84 using InlineComponentData = QV4::CompiledData::InlineComponentData;
85
86 bool tryLoadFromDiskCache();
87 bool loadFromSource();
88 void restoreIR(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit);
89 void continueLoadFromIR();
90 void resolveTypes();
91 QQmlError buildTypeResolutionCaches(
92 QQmlRefPointer<QQmlTypeNameCache> *typeNameCache,
94 ) const;
95 void compile(const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache,
97 const QV4::CompiledData::DependentTypesHasher &dependencyHasher);
98 QQmlError createTypeAndPropertyCaches(
99 const QQmlRefPointer<QQmlTypeNameCache> &typeNameCache,
100 const QV4::CompiledData::ResolvedTypeReferenceMap &resolvedTypeCache);
101 bool resolveType(const QString &typeName, QTypeRevision &version,
102 TypeReference &ref, int lineNumber = -1, int columnNumber = -1,
103 bool reportErrors = true,
105 bool *typeRecursionDetected = nullptr);
106
107 void scriptImported(
108 const QQmlRefPointer<QQmlScriptBlob> &blob, const QV4::CompiledData::Location &location,
109 const QString &nameSpace, const QString &qualifier) override;
110
111 SourceCodeData m_backupSourceCode; // used when cache verification fails.
112 QScopedPointer<QmlIR::Document> m_document;
114
115 QList<ScriptReference> m_scripts;
116
117 QSet<QString> m_namespaces;
118 QList<TypeReference> m_compositeSingletons;
119
120 // map from name index to resolved type
121 // While this could be a hash, a map is chosen here to provide a stable
122 // order, which is used to calculating a check-sum on dependent meta-objects.
123 QMap<int, TypeReference> m_resolvedTypes;
124 bool m_typesResolved:1;
125
126 // Used for self-referencing types, otherwise invalid.
127 QQmlType m_qmlType;
128 QByteArray m_typeClassName; // used for meta-object later
129
130 using CompilationUnitPtr = QQmlRefPointer<QV4::CompiledData::CompilationUnit>;
131
132 QHash<QString, InlineComponentData> m_inlineComponentData;
133
134 CompilationUnitPtr m_compiledData;
135
136 QList<TypeDataCallback *> m_callbacks;
137
138 bool m_implicitImportLoaded;
139 bool loadImplicitImport();
140};
141
143
144#endif // QQMLTYPEDATA_P_H
\inmodule QtCore
Definition qbytearray.h:57
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:167
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\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:187
QQmlRefPointer< QQmlScriptBlob > script
QV4::CompiledData::Location location
virtual void typeDataProgress(QQmlTypeData *, qreal)
virtual void typeDataReady(QQmlTypeData *)
QQmlRefPointer< QQmlTypeData > typeData
QV4::CompiledData::Location location