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
qqmljsregistercontent.cpp
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
6
8
9using namespace Qt::StringLiterals;
10
12{
13 if (m_storedType.isNull())
14 return u"(invalid type)"_s;
15
16 const auto scope = [this]() -> QString {
17 if (m_scope.isNull())
18 return u"(invalid type)::"_s;
19 return (m_scope->internalName().isEmpty()
20 ? (m_scope->filePath().isEmpty()
21 ? u"??"_s
22 : (u"(component in "_s + m_scope->filePath() + u")"_s))
23 : m_scope->internalName())
24 + u"::"_s;
25 };
26
28 switch (m_content.index()) {
29 case Type: {
30 auto contained = std::get<std::pair<QQmlJSScope::ConstPtr, int>>(m_content).first;
31 result += contained->internalName();
32 if (m_storedType->internalName() != contained->internalName())
33 result += u" stored as "_s + m_storedType->internalName();
34 return result;
35 }
36 case Property: {
37 const QQmlJSMetaProperty prop = std::get<PropertyLookup>(m_content).property;
38 result += scope() + prop.propertyName() + u" with type "_s + prop.typeName();
39 if (m_storedType->internalName() != prop.typeName())
40 result += u" (stored as "_s + m_storedType->internalName() + u")";
41 return result;
42 }
43 case Method: {
44 const auto methods = std::get<QList<QQmlJSMetaMethod>>(m_content);
45 if (methods.isEmpty())
46 result = scope() + u"(unknown method)"_s;
47 else
48 result = scope() + methods[0].methodName() + u"(...)"_s;
49 return result + u" (stored as "_s + m_storedType->internalName() + u")";
50 }
51 case Enum: {
52 const auto e = std::get<std::pair<QQmlJSMetaEnum, QString>>(m_content);
53 if (e.second.isEmpty())
54 result = scope() + e.first.name();
55 else
56 result = scope() + e.first.name() + u"::"_s + e.second;
57 return result + u" (stored as "_s + m_storedType->internalName() + u")";
58 }
59 case ImportNamespace: {
60 return u"import namespace %1"_s.arg(std::get<uint>(m_content));
61 }
62 case Conversion: {
63 return u"conversion to %1"_s.arg(std::get<ConvertedTypes>(m_content).result->internalName());
64 }
65 }
66
67 Q_UNREACHABLE_RETURN(result + u"wat?"_s);
68}
69
71{
72 switch (m_content.index()) {
73 case Type:
74 return std::get<std::pair<QQmlJSScope::ConstPtr, int>>(m_content).first->accessSemantics()
75 == QQmlJSScope::AccessSemantics::Sequence;
76 case Property:
77 return std::get<PropertyLookup>(m_content).property.type()->accessSemantics()
78 == QQmlJSScope::AccessSemantics::Sequence;
79 case Conversion:
80 return std::get<ConvertedTypes>(m_content).result->accessSemantics()
81 == QQmlJSScope::AccessSemantics::Sequence;
82 default:
83 return false;
84 }
85}
86
88{
89 switch (m_content.index()) {
90 case Property:
91 return std::get<PropertyLookup>(m_content).property.isWritable();
92
93 // TODO: What can we actually write?
94 default:
95 break;
96 }
97
98 return true;
99}
100
103 int resultLookupIndex,
105 const QQmlJSScope::ConstPtr &scope)
106{
108 result.m_content = std::make_pair(type, resultLookupIndex);
109 return result;
110}
111
114 int baseLookupIndex, int resultLookupIndex,
116 const QQmlJSScope::ConstPtr &scope)
117{
119 result.m_content = PropertyLookup { property, baseLookupIndex, resultLookupIndex};
120 return result;
121}
122
124 const QQmlJSMetaEnum &enumeration,
125 const QString &enumMember,
127 const QQmlJSScope::ConstPtr &scope)
128{
130 result.m_content = std::make_pair(enumeration, enumMember);
131 return result;
132}
133
135 const QList<QQmlJSMetaMethod> &methods,
137 const QQmlJSScope::ConstPtr &scope)
138{
140 result.m_content = methods;
141 return result;
142}
143
145 uint importNamespaceStringId,
147 const QQmlJSScope::ConstPtr &scope)
148{
150 result.m_content = importNamespaceStringId;
151 return result;
152}
153
155 const QList<QQmlJSScope::ConstPtr> &origins,
156 const QQmlJSScope::ConstPtr &conversion,
157 const QQmlJSScope::ConstPtr &conversionScope,
159 const QQmlJSScope::ConstPtr &scope)
160{
162 result.m_content = ConvertedTypes { origins, conversion, conversionScope };
163 return result;
164}
165
static JNINativeMethod methods[]
constexpr QAnyStringView first(qsizetype n) const
QString typeName() const
QString propertyName() const
QQmlJSMetaProperty property() const
ContentVariant variant() const
QQmlJSScope::ConstPtr storedType() const
static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, const QQmlJSScope::ConstPtr &type, int resultLookupIndex, ContentVariant variant, const QQmlJSScope::ConstPtr &scope={})
QQmlJSMetaEnum enumeration() const
QString filePath() const
QString internalName() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
Combined button and popup list for selecting options.
static const QCssKnownValue origins[NumKnownOrigins - 1]
GLenum type
GLint first
GLuint64EXT * result
[6]
unsigned int uint
Definition qtypes.h:34
const char property[13]
Definition qwizard.cpp:101
QVariant variant
[1]
QAnyStringView name
QAnyStringView type
Definition moc.h:23