Qt 6.x
The Qt SDK
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 QString result = m_storedType->internalName() + u" of "_s;
17 const auto scope = [this]() -> QString {
18 if (m_scope.isNull())
19 return u"(invalid type)::"_s;
20 return (m_scope->internalName().isEmpty()
21 ? (m_scope->filePath().isEmpty()
22 ? u"??"_s
23 : (u"(component in "_s + m_scope->filePath() + u")"_s))
24 : m_scope->internalName())
25 + u"::"_s;
26 };
27
28 switch (m_content.index()) {
29 case Type:
30 return result + std::get<QQmlJSScope::ConstPtr>(m_content)->internalName();
31 case Property: {
32 const QQmlJSMetaProperty prop = std::get<QQmlJSMetaProperty>(m_content);
33 return result + scope() + prop.propertyName() + u" with type "_s + prop.typeName();
34 }
35 case Method: {
36 const auto methods = std::get<QList<QQmlJSMetaMethod>>(m_content);
37 if (methods.isEmpty())
38 return result + scope() + u"(unknown method)"_s;
39 else
40 return result + scope() + methods[0].methodName() + u"(...)"_s;
41 }
42 case Enum: {
43 const auto e = std::get<std::pair<QQmlJSMetaEnum, QString>>(m_content);
44 if (e.second.isEmpty())
45 return result + scope() + e.first.name();
46 else
47 return result + scope() + e.first.name() + u"::"_s + e.second;
48 }
49 case ImportNamespace: {
50 return u"import namespace %1"_s.arg(std::get<uint>(m_content));
51 }
52 case Conversion: {
53 return u"conversion to %1"_s.arg(
54 std::get<ConvertedTypes>(m_content).result->internalName());
55 }
56 }
57 Q_UNREACHABLE_RETURN(result + u"wat?"_s);
58}
59
61{
62 switch (m_content.index()) {
63 case Type:
64 return std::get<QQmlJSScope::ConstPtr>(m_content)->accessSemantics()
65 == QQmlJSScope::AccessSemantics::Sequence;
66 case Property:
67 return std::get<QQmlJSMetaProperty>(m_content).type()->accessSemantics()
68 == QQmlJSScope::AccessSemantics::Sequence;
69 case Conversion:
70 return std::get<ConvertedTypes>(m_content).result->accessSemantics()
71 == QQmlJSScope::AccessSemantics::Sequence;
72 default:
73 return false;
74 }
75}
76
78{
79 switch (m_content.index()) {
80 case Property:
81 return std::get<QQmlJSMetaProperty>(m_content).isWritable();
82
83 // TODO: What can we actually write?
84 default:
85 break;
86 }
87
88 return true;
89}
90
94 const QQmlJSScope::ConstPtr &scope)
95{
97 result.m_content = type;
98 return result;
99}
100
104 const QQmlJSScope::ConstPtr &scope)
105{
107 result.m_content = property;
108 return result;
109}
110
112 const QQmlJSMetaEnum &enumeration,
113 const QString &enumMember,
115 const QQmlJSScope::ConstPtr &scope)
116{
118 result.m_content = std::make_pair(enumeration, enumMember);
119 return result;
120}
121
125 const QQmlJSScope::ConstPtr &scope)
126{
128 result.m_content = methods;
129 return result;
130}
131
133 uint importNamespaceStringId,
135 const QQmlJSScope::ConstPtr &scope)
136{
138 result.m_content = importNamespaceStringId;
139 return result;
140}
141
144 const QQmlJSScope::ConstPtr &conversion,
146 const QQmlJSScope::ConstPtr &scope)
147{
149 result.m_content = ConvertedTypes { origins, conversion };
150 return result;
151}
152
static JNINativeMethod methods[]
Definition qlist.h:74
QString typeName() const
QString propertyName() const
QQmlJSMetaProperty property() const
static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType, const QQmlJSScope::ConstPtr &type, ContentVariant variant, const QQmlJSScope::ConstPtr &scope={})
ContentVariant variant() const
QQmlJSScope::ConstPtr type() const
QQmlJSScope::ConstPtr storedType() const
QQmlJSMetaEnum enumeration() const
QString filePath() const
QString internalName() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
double e
Combined button and popup list for selecting options.
static const QCssKnownValue origins[NumKnownOrigins - 1]
GLenum type
GLuint64EXT * result
[6]
unsigned int uint
Definition qtypes.h:29
const char property[13]
Definition qwizard.cpp:101
QVariant variant
[1]
Definition moc.h:24