11#include <QtCore/qcborarray.h>
12#include <QtCore/qcbormap.h>
21template<
typename Container>
25 if (
obj.revision.isValid() && !extraVersions.contains(
obj.revision))
26 extraVersions.append(
obj.revision);
44 if (single.inputFile().isEmpty()) {
55 if (
category.inputFile().isEmpty()) {
58 << relation <<
"type of" <<
category.qualifiedClassName()
59 <<
"is not a JavaScript type";
66 << relation <<
"of" <<
category.qualifiedClassName()
67 <<
"is not a native type";
73 const QVector<MetaType> &
types,
const QVector<MetaType> &foreign,
78 for (
const QVector<MetaType> &
t : {
types, foreign}) {
79 const auto [
first, last] = std::equal_range(
80 t.begin(),
t.end(), qualifiedName,
Compare());
82 Q_ASSERT(
it->qualifiedClassName() == qualifiedName);
85 if (
result.javaScript.isEmpty()) {
92 <<
"Multiple JavaScript types called" << qualifiedName <<
"found!";
94 }
else if (
result.native.isEmpty()) {
101 <<
"Multiple C++ types called" << qualifiedName <<
"found!"
102 <<
"This violates the One Definition Rule!";
111 return tryFindType(
name.mid(2));
114 for (
int i = 0,
end = namespaces.length();
i !=
end; ++
i) {
115 for (
int j = 0;
j <
end -
i; ++
j) {
120 if (
const FoundType found = tryFindType(qualified))
126 return tryFindType(
name);
129void QmlTypesClassDescription::collectSuperClasses(
131 const QVector<MetaType> &foreign, CollectMode
mode,
QTypeRevision defaultRevision)
134 for (
const BaseType &superObject :
std::as_const(classDef.superClasses())) {
151void QmlTypesClassDescription::collectInterfaces(
const MetaType &classDef)
153 for (
const Interface &iface : classDef.ifaces())
159 const QVector<MetaType> &foreign,
QTypeRevision defaultRevision)
161 file = classDef.inputFile();
164 className = classDef.qualifiedClassName();
166 switch (classDef.kind()) {
167 case MetaType::Kind::Object:
170 case MetaType::Kind::Gadget:
173 case MetaType::Kind::Namespace:
174 case MetaType::Kind::Unknown:
188 collectInterfaces(classDef);
189 collectSuperClasses(classDef,
types, foreign,
TopLevel, defaultRevision);
197 file = classDef.inputFile();
203 bool foreignIsNamespace =
false;
204 bool isConstructible =
false;
230 defaultRevision.majorVersion());
243 defaultRevision.majorVersion());
260 value,
types, foreign, defaultRevision, namespaces)) {
261 attachedType = attached.select(classDef,
"Attached").qualifiedClassName();
265 value,
types, foreign, defaultRevision, namespaces)) {
277 value,
types, foreign, defaultRevision, namespaces)) {
278 sequenceValueType = element.select(classDef,
"Sequence value").qualifiedClassName();
287 foreignTypeName =
value;
309 const bool isNamespace = foreignIsNamespace || classDef.kind() == MetaType::Kind::Namespace;
312 if (!foreignTypeName.isEmpty()) {
315 resolved = found.select(classDef,
"Foreign");
335 foreignValue,
types, foreign, defaultRevision, namespaces)) {
336 attachedType = attached.select(resolved,
"Attached").qualifiedClassName();
340 foreignValue,
types, foreign, defaultRevision, namespaces)) {
345 if (foreignValue ==
S_TRUE)
348 if (foreignValue ==
S_TRUE)
352 foreignValue,
types, foreign, defaultRevision, namespaces)) {
354 = element.select(resolved,
"Sequence value").qualifiedClassName();
371 collectSuperClasses(resolved,
types, foreign,
mode, defaultRevision);
378 collectInterfaces(resolved);
399 }
else if (isNamespace) {
402 }
else if (resolved.
kind() == MetaType::Kind::Object) {
415 if (elementName->isEmpty() || elementName->front().isLower()) {
427 <<
"Refusing to generate non-lowercase name"
428 << *elementName <<
"for unknown foreign type";
438 }
else if (resolved.
kind() == MetaType::Kind::Gadget) {
448 QTypeRevision defaultRevision,
const QList<QAnyStringView> &namespaces)
451 if (!
other.native.isEmpty())
453 if (!
other.javaScript.isEmpty())
467 if (
type ==
"void") {
485 if (elementType.
back() ==
'*'_L1)
493 if (!handleList(
"QQmlListProperty<"_L1) && !handleList(
"QList<"_L1)) {
494 if (
type.back() ==
'*'_L1) {
500 type =
type.sliced(strlen(
"const "));
constexpr QChar back() const
Returns the last character in the string view.
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
constexpr QAnyStringView chopped(qsizetype n) const
qsizetype size() const noexcept
bool isEmpty() const noexcept
iterator erase(const_iterator begin, const_iterator end)
void append(parameter_type t)
const_iterator constEnd() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
void truncate(qsizetype pos)
Truncates the string at the given position index.
QString & append(QChar c)
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
const QLoggingCategory & category()
[1]
QSet< QString >::iterator it
static constexpr QLatin1StringView S_REFERENCE
static constexpr QLatin1StringView S_VALUE
static constexpr QLatin1StringView S_NONE
static constexpr QLatin1StringView S_SEQUENCE
QAnyStringView trimmed(QAnyStringView string)
bool startsWith(QAnyStringView whole, QLatin1StringView part)
Combined button and popup list for selecting options.
constexpr QBindableInterface iface
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei GLenum GLenum * types
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
QT_BEGIN_NAMESPACE QTypeRevision handleInMinorVersion(QTypeRevision revision, int majorVersion)
QAnyStringView interfaceName(const Interface &iface)
QDebug warning(QAnyStringView fileName, int lineNumber)
static void collectExtraVersions(const Container &items, QList< QTypeRevision > &extraVersions)
static void split(QT_FT_Vector *b)
QLatin1StringView QLatin1String
static int toInt(const QChar &qc, int R)
bool operator()(const QAnyStringView &typeName, const MetaType &type) const
bool operator()(const MetaType &type, const QAnyStringView &typeName) const
MetaType select(const MetaType &category, QAnyStringView relation) const
QAnyStringView javaScriptExtensionType
QAnyStringView parentProp
QList< QAnyStringView > implementsInterfaces
QList< QAnyStringView > primitiveAliases
QTypeRevision addedInRevision
void collect(const MetaType &classDef, const QVector< MetaType > &types, const QVector< MetaType > &foreign, CollectMode mode, QTypeRevision defaultRevision)
QList< QAnyStringView > immediateNames
QAnyStringView sequenceValueType
QTypeRevision removedInRevision
QAnyStringView defaultProp
FoundType collectRelated(QAnyStringView related, const QVector< MetaType > &types, const QVector< MetaType > &foreign, QTypeRevision defaultRevision, const QList< QAnyStringView > &namespaces)
bool registerEnumClassesScoped
QList< QTypeRevision > revisions
static FoundType findType(const QVector< MetaType > &types, const QVector< MetaType > &foreign, const QAnyStringView &name, const QList< QAnyStringView > &namespaces)
bool extensionIsNamespace
QList< QAnyStringView > elementNames
QAnyStringView attachedType
bool extensionIsJavaScript
QList< QAnyStringView > deferredNames
void collectLocalAnonymous(const MetaType &classDef, const QVector< MetaType > &types, const QVector< MetaType > &foreign, QTypeRevision defaultRevision)
QAnyStringView accessSemantics
QAnyStringView superClass
QAnyStringView nativeExtensionType
ResolvedTypeAlias(QAnyStringView alias)