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
qqmltcoutputir_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant
4
5#ifndef QQMLTCOUTPUTIR_P_H
6#define QQMLTCOUTPUTIR_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 <QtCore/qstring.h>
20#include <QtCore/qlist.h>
21#include <QtCore/qstringlist.h>
22#include <QtCore/qset.h>
23
24#include <private/qqmljsmetatypes_p.h>
25
26#include <optional>
27
28QT_BEGIN_NAMESPACE
29
30namespace QQmltc {
31
32// Below are the classes that represent compiled QML types in a string data
33// form. These classes are used to generate C++ code.
34
35// Represents C++ variable
37{
38 QString cppType; // C++ type of a variable
39 QString name; // variable name
40 QString defaultValue; // optional initialization value
41
42 Variable() = default;
43 // special ctor for QList's emplace back
44 Variable(const QString &t, const QString &n, const QString &v = QString())
46 {
47 }
48};
49
51{
54
55 Property() = default;
56 Property(const QString t, const QString &n, const QString &c, const QString &s)
58 {
59 }
60};
61
62// Represents QML -> C++ compiled enumeration type
63struct Enum
64{
65 QString cppType; // C++ type of an enum
66 QStringList keys; // enumerator keys
67 QStringList values; // enumerator values
68 QString ownMocLine; // special MOC line that follows enum declaration
69
70 Enum() = default;
71 Enum(const QString &t, const QStringList &ks, const QStringList &vs, const QString &l)
73 {
74 }
75};
76
78{
79 QStringList comments; // C++ comments
80 QString name; // C++ function name
81 QList<Variable> parameterList; // C++ function parameter list
82 QStringList body; // C++ function code
85 QStringList modifiers; // cv-qualifiers, ref-qualifier, noexcept, attributes
86};
87
88// Represents QML -> C++ compiled function
90{
91 QString returnType; // C++ return type
93
94 // TODO: should be a better way to handle this
95 bool userVisible = false; // tells if a function is prioritized during the output generation
96};
97
98// Represents C++ ctor of a type
100{
101 QStringList initializerList; // C++ ctor's initializer list
102};
103
104// Represents C++ dtor of a type
106{
107};
108
109// Represents a generated class that knows how to set the public,
110// writable properties of a compiled QML -> C++ type.
111// This is generally intended to be available for the root of the
112// document to allow the user to set the initial values for
113// properties, when creating a component, with support for strong
114// typing.
116{
118
120
121 // A member containing a reference to the object for which the
122 // properties should be set.
124
125 // A member containing a cache of properties that were actually
126 // set that can be referenced later..
128
129 // Setter methods for each property.
131};
132
133// Represents a generated class that contains a bundle of values to
134// initialize the required properties of a type.
135//
136// This is generally intended to be available for the root component
137// of the document, where it will be used as a constructor argument to
138// force the user to provide initial values for the required
139// properties of the constructed type.
146
147// Represents QML -> C++ compiled type
148struct Type
149{
150 QString cppType; // C++ type of the QML type
151 QStringList baseClasses; // C++ type names of base classes
152 QStringList mocCode; // Qt MOC code
153 QStringList otherCode; // Random code that doesn't fit any category, e.g. friend declarations
154
155 // member types: enumerations and child types
157 QList<Type> children; // these are pretty much always empty
158
159 // special member functions:
160 Ctor baselineCtor {}; // does basic contruction
161 Ctor externalCtor {}; // calls basicCtor, calls init
162 Method init {}; // starts object initialization (context setup), calls finalize
163 Method beginClass {}; // calls QQmlParserStatus::classBegin()
164 Method endInit {}; // ends object initialization (with "simple" bindings setup)
165 Method setComplexBindings {}; // sets up "complex" (e.g. script) bindings
166 Method completeComponent {}; // calls QQmlParserStatus::componentComplete()
167 Method finalizeComponent {}; // calls QQmlFinalizerHook::componentFinalized()
168 Method handleOnCompleted {}; // calls Component.onCompleted
169
170 std::optional<Dtor> dtor {};
171
172 // member functions: methods, signals and slots
174 // member variables
177
178 // QML document root specific:
179 std::optional<Method> typeCount; // the number of QML types defined in a document
180
181 // TODO: only needed for binding callables - should not be needed, generally
182 bool ignoreInit = false; // specifies whether init and externalCtor should be ignored
183
184 // needed for singletons
185 std::optional<Method> staticCreate{};
186
187 // A proxy class that provides a restricted interface that only
188 // allows setting the properties of the type.
190
192};
193
194// Represents whole QML program, compiled to C++
196{
197 QString url; // QML file url
198 QString cppPath; // C++ output .cpp path
199 QString hPath; // C++ output .h path
201 QString exportMacro; // if not empty, the macro that should be used to export the generated
202 // classes
203 QSet<QString> includes; // non-default C++ include files
204 Method urlMethod; // returns QUrl of the QML document
205
206 QList<Type> compiledTypes; // all QML types that are compiled to C++
207};
208
209} // namespace QQmltc
210
211QT_END_NAMESPACE
212
213#endif // QQMLTCOUTPUTIR_P_H
QStringList initializerList
Enum()=default
QStringList values
Enum(const QString &t, const QStringList &ks, const QStringList &vs, const QString &l)
QStringList keys
QList< Variable > parameterList
QStringList declarationPrefixes
QQmlJSMetaMethod::Access access
QQmlJSMetaMethodType type
QList< Type > compiledTypes
QSet< QString > includes
Property(const QString t, const QString &n, const QString &c, const QString &s)
Property()=default
std::optional< Dtor > dtor
Method setComplexBindings
QStringList mocCode
QStringList baseClasses
QList< Variable > variables
std::optional< Method > typeCount
QList< Enum > enums
std::optional< Method > staticCreate
std::optional< RequiredPropertiesBundle > requiredPropertiesBundle
QList< Type > children
QList< Property > properties
PropertyInitializer propertyInitializer
QStringList otherCode
QList< Method > functions
Variable()=default
Variable(const QString &t, const QString &n, const QString &v=QString())