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
qqmljsmetatypes_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 GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QQMLJSMETATYPES_P_H
5#define QQMLJSMETATYPES_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#include <qtqmlcompilerexports.h>
18
19#include <QtCore/qstring.h>
20#include <QtCore/qstringlist.h>
21#include <QtCore/qsharedpointer.h>
22#include <QtCore/qvariant.h>
23#include <QtCore/qhash.h>
24
25#include <QtQml/private/qqmljssourcelocation_p.h>
26#include <QtQml/private/qqmltranslation_p.h>
27
28#include "qqmlsaconstants.h"
29#include "qqmlsa.h"
30#include "qqmljsannotation_p.h"
31
32// MetaMethod and MetaProperty have both type names and actual QQmlJSScope types.
33// When parsing the information from the relevant QML or qmltypes files, we only
34// see the names and don't have a complete picture of the types, yet. In a second
35// pass we typically fill in the types. The types may have multiple exported names
36// and the the name property of MetaProperty and MetaMethod still carries some
37// significance regarding which name was chosen to refer to the type. In a third
38// pass we may further specify the type if the context provides additional information.
39// The parent of an Item, for example, is typically not just a QtObject, but rather
40// some other Item with custom properties.
41
43
44enum ScriptBindingValueType : unsigned int {
46 ScriptValue_Undefined // property int p: undefined
47};
48
50
52class QQmlJSScope;
54{
55 QStringList m_keys;
56 QList<int> m_values; // empty if values unknown.
57 QString m_name;
58 QString m_alias;
59 QString m_typeName;
60 QSharedPointer<const QQmlJSScope> m_type;
61 bool m_isFlag = false;
62 bool m_isScoped = false;
63 bool m_isQml = false;
64
65public:
66 QQmlJSMetaEnum() = default;
67 explicit QQmlJSMetaEnum(QString name) : m_name(std::move(name)) {}
68
69 bool isValid() const { return !m_name.isEmpty(); }
70
71 QString name() const { return m_name; }
72 void setName(const QString &name) { m_name = name; }
73
74 QString alias() const { return m_alias; }
75 void setAlias(const QString &alias) { m_alias = alias; }
76
77 bool isFlag() const { return m_isFlag; }
78 void setIsFlag(bool isFlag) { m_isFlag = isFlag; }
79
80 bool isScoped() const { return m_isScoped; }
81 void setIsScoped(bool v) { m_isScoped = v; }
82
83 bool isQml() const { return m_isQml; }
84 void setIsQml(bool v) { m_isQml = v; }
85
86 void addKey(const QString &key) { m_keys.append(key); }
87 QStringList keys() const { return m_keys; }
88
89 void addValue(int value) { m_values.append(value); }
90 QList<int> values() const { return m_values; }
91
92 bool hasValues() const { return !m_values.isEmpty(); }
93 int value(const QString &key) const { return m_values.value(m_keys.indexOf(key)); }
94 bool hasKey(const QString &key) const { return m_keys.indexOf(key) != -1; }
95
96 QString typeName() const { return m_typeName; }
97 void setTypeName(const QString &typeName) { m_typeName = typeName; }
98
99 QSharedPointer<const QQmlJSScope> type() const { return m_type; }
100 void setType(const QSharedPointer<const QQmlJSScope> &type) { m_type = type; }
101
102 friend bool operator==(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
103 {
104 return a.m_keys == b.m_keys
105 && a.m_values == b.m_values
106 && a.m_name == b.m_name
107 && a.m_alias == b.m_alias
108 && a.m_isFlag == b.m_isFlag
109 && a.m_type == b.m_type
110 && a.m_isScoped == b.m_isScoped;
111 }
112
113 friend bool operator!=(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
114 {
115 return !(a == b);
116 }
117
118 friend size_t qHash(const QQmlJSMetaEnum &e, size_t seed = 0)
119 {
120 return qHashMulti(
121 seed, e.m_keys, e.m_values, e.m_name, e.m_alias, e.m_isFlag, e.m_type, e.m_isScoped);
122 }
123};
124
126{
127public:
137 };
138
141 QWeakPointer<const QQmlJSScope> type = {})
142 : m_name(std::move(name)),
143 m_typeName(std::move(typeName)),
144 m_type(type),
145 m_typeQualifier(typeQualifier)
146 {
147 }
148
149 QString name() const { return m_name; }
150 void setName(const QString &name) { m_name = name; }
151 QString typeName() const { return m_typeName; }
152 void setTypeName(const QString &typeName) { m_typeName = typeName; }
153 QSharedPointer<const QQmlJSScope> type() const { return m_type.toStrongRef(); }
154 void setType(QWeakPointer<const QQmlJSScope> type) { m_type = type; }
155 Constness typeQualifier() const { return m_typeQualifier; }
157 bool isPointer() const { return m_isPointer; }
158 void setIsPointer(bool isPointer) { m_isPointer = isPointer; }
159 bool isList() const { return m_isList; }
160 void setIsList(bool isList) { m_isList = isList; }
161
163 {
164 return a.m_name == b.m_name && a.m_typeName == b.m_typeName
165 && a.m_type.owner_equal(b.m_type)
166 && a.m_typeQualifier == b.m_typeQualifier;
167 }
168
170 {
171 return !(a == b);
172 }
173
174 friend size_t qHash(const QQmlJSMetaParameter &e, size_t seed = 0)
175 {
176 return qHashMulti(seed, e.m_name, e.m_typeName, e.m_type.owner_hash(),
177 e.m_typeQualifier);
178 }
179
180private:
181 QString m_name;
182 QString m_typeName;
183 QWeakPointer<const QQmlJSScope> m_type;
184 Constness m_typeQualifier = NonConst;
185 bool m_isPointer = false;
186 bool m_isList = false;
187};
188
190
192{
193public:
196
197public:
204 enum class RelativeFunctionIndex : int { Invalid = -1 };
205
212 enum class AbsoluteFunctionIndex : int { Invalid = -1 };
213
214 QQmlJSMetaMethod() = default;
216 : m_name(std::move(name)),
217 m_returnType(QString(), std::move(returnType)),
218 m_methodType(MethodType::Method)
219 {}
220
221 QString methodName() const { return m_name; }
222 void setMethodName(const QString &name) { m_name = name; }
223
224 QQmlJS::SourceLocation sourceLocation() const { return m_sourceLocation; }
226
227 QQmlJSMetaReturnType returnValue() const { return m_returnType; }
229 QString returnTypeName() const { return m_returnType.typeName(); }
230 void setReturnTypeName(const QString &typeName) { m_returnType.setTypeName(typeName); }
231 QSharedPointer<const QQmlJSScope> returnType() const { return m_returnType.type(); }
232 void setReturnType(QWeakPointer<const QQmlJSScope> type) { m_returnType.setType(type); }
233
234 QList<QQmlJSMetaParameter> parameters() const { return m_parameters; }
235 QPair<QList<QQmlJSMetaParameter>::iterator, QList<QQmlJSMetaParameter>::iterator>
237 {
238 return { m_parameters.begin(), m_parameters.end() };
239 }
240
242 {
244 for (const auto &p : m_parameters)
245 names.append(p.name());
246
247 return names;
248 }
249
250 void setParameters(const QList<QQmlJSMetaParameter> &parameters) { m_parameters = parameters; }
251
252 void addParameter(const QQmlJSMetaParameter &p) { m_parameters.append(p); }
253
254 QQmlJSMetaMethodType methodType() const { return m_methodType; }
256
257 Access access() const { return m_methodAccess; }
258
259 int revision() const { return m_revision; }
260 void setRevision(int r) { m_revision = r; }
261
262 bool isCloned() const { return m_isCloned; }
263 void setIsCloned(bool isCloned) { m_isCloned= isCloned; }
264
265 bool isConstructor() const { return m_isConstructor; }
266 void setIsConstructor(bool isConstructor) { m_isConstructor = isConstructor; }
267
268 bool isJavaScriptFunction() const { return m_isJavaScriptFunction; }
270 {
271 m_isJavaScriptFunction = isJavaScriptFunction;
272 }
273
274 bool isImplicitQmlPropertyChangeSignal() const { return m_isImplicitQmlPropertyChangeSignal; }
275 void setIsImplicitQmlPropertyChangeSignal(bool isPropertyChangeSignal)
276 {
277 m_isImplicitQmlPropertyChangeSignal = isPropertyChangeSignal;
278 }
279
280 bool isValid() const { return !m_name.isEmpty(); }
281
282 const QVector<QQmlJSAnnotation>& annotations() const { return m_annotations; }
283 void setAnnotations(QVector<QQmlJSAnnotation> annotations) { m_annotations = annotations; }
284
286 {
287 Q_ASSERT(!m_isConstructor);
288 m_relativeFunctionIndex = index;
289 }
290
292 {
293 Q_ASSERT(!m_isConstructor);
294 return m_relativeFunctionIndex;
295 }
296
298 {
299 Q_ASSERT(m_isConstructor);
300 m_relativeFunctionIndex = index;
301 }
302
304 {
305 Q_ASSERT(m_isConstructor);
306 return m_relativeFunctionIndex;
307 }
308
309 friend bool operator==(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b)
310 {
311 return a.m_name == b.m_name && a.m_returnType == b.m_returnType
312 && a.m_parameters == b.m_parameters && a.m_annotations == b.m_annotations
313 && a.m_methodType == b.m_methodType && a.m_methodAccess == b.m_methodAccess
314 && a.m_revision == b.m_revision && a.m_isConstructor == b.m_isConstructor;
315 }
316
317 friend bool operator!=(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b)
318 {
319 return !(a == b);
320 }
321
322 friend size_t qHash(const QQmlJSMetaMethod &method, size_t seed = 0)
323 {
325
326 seed = combine(seed, method.m_name);
327 seed = combine(seed, method.m_returnType);
328 seed = combine(seed, method.m_annotations);
329 seed = combine(seed, method.m_methodType);
330 seed = combine(seed, method.m_methodAccess);
331 seed = combine(seed, method.m_revision);
332 seed = combine(seed, method.m_isConstructor);
333
334 for (const auto &type : method.m_parameters) {
335 seed = combine(seed, type);
336 }
337
338 return seed;
339 }
340
341private:
342 QString m_name;
343
344 QQmlJS::SourceLocation m_sourceLocation;
345
346 QQmlJSMetaReturnType m_returnType;
347 QList<QQmlJSMetaParameter> m_parameters;
348 QList<QQmlJSAnnotation> m_annotations;
349
350 MethodType m_methodType = MethodType::Signal;
351 Access m_methodAccess = Public;
352 int m_revision = 0;
354 bool m_isCloned = false;
355 bool m_isConstructor = false;
356 bool m_isJavaScriptFunction = false;
357 bool m_isImplicitQmlPropertyChangeSignal = false;
358};
359
361{
362 QString m_propertyName;
363 QString m_typeName;
364 QString m_read;
365 QString m_write;
366 QString m_reset;
367 QString m_bindable;
368 QString m_notify;
369 QString m_privateClass;
370 QString m_aliasExpr;
371 QWeakPointer<const QQmlJSScope> m_type;
372 QVector<QQmlJSAnnotation> m_annotations;
373 bool m_isList = false;
374 bool m_isWritable = false;
375 bool m_isPointer = false;
376 bool m_isTypeConstant = false;
377 bool m_isFinal = false;
378 bool m_isPropertyConstant = false;
379 int m_revision = 0;
380 int m_index = -1; // relative property index within owning QQmlJSScope
381
382public:
384
385 void setPropertyName(const QString &propertyName) { m_propertyName = propertyName; }
386 QString propertyName() const { return m_propertyName; }
387
388 void setTypeName(const QString &typeName) { m_typeName = typeName; }
389 QString typeName() const { return m_typeName; }
390
391 void setRead(const QString &read) { m_read = read; }
392 QString read() const { return m_read; }
393
394 void setWrite(const QString &write) { m_write = write; }
395 QString write() const { return m_write; }
396
397 void setReset(const QString &reset) { m_reset = reset; }
398 QString reset() const { return m_reset; }
399
400 void setBindable(const QString &bindable) { m_bindable = bindable; }
401 QString bindable() const { return m_bindable; }
402
403 void setNotify(const QString &notify) { m_notify = notify; }
404 QString notify() const { return m_notify; }
405
406 void setPrivateClass(const QString &privateClass) { m_privateClass = privateClass; }
407 QString privateClass() const { return m_privateClass; }
408 bool isPrivate() const { return !m_privateClass.isEmpty(); } // exists for convenience
409
410 void setType(const QSharedPointer<const QQmlJSScope> &type) { m_type = type; }
411 QSharedPointer<const QQmlJSScope> type() const { return m_type.toStrongRef(); }
412
413 void setAnnotations(const QList<QQmlJSAnnotation> &annotation) { m_annotations = annotation; }
414 const QList<QQmlJSAnnotation> &annotations() const { return m_annotations; }
415
416 void setIsList(bool isList) { m_isList = isList; }
417 bool isList() const { return m_isList; }
418
419 void setIsWritable(bool isWritable) { m_isWritable = isWritable; }
420 bool isWritable() const { return m_isWritable; }
421
422 void setIsPointer(bool isPointer) { m_isPointer = isPointer; }
423 bool isPointer() const { return m_isPointer; }
424
425 void setIsTypeConstant(bool isTypeConstant) { m_isTypeConstant = isTypeConstant; }
426 bool isTypeConstant() const { return m_isTypeConstant; }
427
428 void setAliasExpression(const QString &aliasString) { m_aliasExpr = aliasString; }
429 QString aliasExpression() const { return m_aliasExpr; }
430 bool isAlias() const { return !m_aliasExpr.isEmpty(); } // exists for convenience
431
432 void setIsFinal(bool isFinal) { m_isFinal = isFinal; }
433 bool isFinal() const { return m_isFinal; }
434
435 void setIsPropertyConstant(bool isPropertyConstant) { m_isPropertyConstant = isPropertyConstant; }
436 bool isPropertyConstant() const { return m_isPropertyConstant; }
437
438 void setRevision(int revision) { m_revision = revision; }
439 int revision() const { return m_revision; }
440
441 void setIndex(int index) { m_index = index; }
442 int index() const { return m_index; }
443
444 bool isValid() const { return !m_propertyName.isEmpty(); }
445
447 {
448 return a.m_index == b.m_index && a.m_propertyName == b.m_propertyName
449 && a.m_typeName == b.m_typeName && a.m_bindable == b.m_bindable
450 && a.m_type.owner_equal(b.m_type) && a.m_isList == b.m_isList
451 && a.m_isWritable == b.m_isWritable && a.m_isPointer == b.m_isPointer
452 && a.m_aliasExpr == b.m_aliasExpr && a.m_revision == b.m_revision
453 && a.m_isFinal == b.m_isFinal;
454 }
455
457 {
458 return !(a == b);
459 }
460
461 friend size_t qHash(const QQmlJSMetaProperty &prop, size_t seed = 0)
462 {
463 return qHashMulti(seed, prop.m_propertyName, prop.m_typeName, prop.m_bindable,
464 prop.m_type.toStrongRef().data(), prop.m_isList, prop.m_isWritable,
465 prop.m_isPointer, prop.m_aliasExpr, prop.m_revision, prop.m_isFinal,
466 prop.m_index);
467 }
468};
469
479class Q_QMLCOMPILER_EXPORT QQmlJSMetaPropertyBinding
480{
483
484 // needs to be kept in sync with the BindingType enum
485 struct Content {
486 using Invalid = std::monostate;
487 struct BoolLiteral {
488 bool value;
489 friend bool operator==(BoolLiteral a, BoolLiteral b) { return a.value == b.value; }
490 friend bool operator!=(BoolLiteral a, BoolLiteral b) { return !(a == b); }
491 };
494 QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
495 QT_WARNING_DISABLE_GCC("-Wfloat-equal")
496 friend bool operator==(NumberLiteral a, NumberLiteral b) { return a.value == b.value; }
497 friend bool operator!=(NumberLiteral a, NumberLiteral b) { return !(a == b); }
499
500 double value; // ### TODO: int?
501 };
503 friend bool operator==(StringLiteral a, StringLiteral b) { return a.value == b.value; }
504 friend bool operator!=(StringLiteral a, StringLiteral b) { return !(a == b); }
506 };
508 friend bool operator==(RegexpLiteral a, RegexpLiteral b) { return a.value == b.value; }
509 friend bool operator!=(RegexpLiteral a, RegexpLiteral b) { return !(a == b); }
511 };
512 struct Null {
513 friend bool operator==(Null , Null ) { return true; }
514 friend bool operator!=(Null a, Null b) { return !(a == b); }
515 };
518 {
519 return a.text == b.text && a.comment == b.comment && a.number == b.number && a.context == b.context;
520 }
521 friend bool operator!=(TranslationString a, TranslationString b) { return !(a == b); }
526 };
529 {
530 return a.id == b.id && a.number == b.number;
531 }
532 friend bool operator!=(TranslationById a, TranslationById b) { return !(a == b); }
535 };
536 struct Script {
537 friend bool operator==(Script a, Script b)
538 {
539 return a.index == b.index && a.kind == b.kind;
540 }
541 friend bool operator!=(Script a, Script b) { return !(a == b); }
544 ScriptBindingKind kind = ScriptBindingKind::Invalid;
546 };
547 struct Object {
548 friend bool operator==(Object a, Object b) { return a.value.owner_equal(b.value) && a.typeName == b.typeName; }
549 friend bool operator!=(Object a, Object b) { return !(a == b); }
551 QWeakPointer<const QQmlJSScope> value;
552 };
553 struct Interceptor {
555 {
556 return a.value.owner_equal(b.value) && a.typeName == b.typeName;
557 }
558 friend bool operator!=(Interceptor a, Interceptor b) { return !(a == b); }
560 QWeakPointer<const QQmlJSScope> value;
561 };
562 struct ValueSource {
564 {
565 return a.value.owner_equal(b.value) && a.typeName == b.typeName;
566 }
567 friend bool operator!=(ValueSource a, ValueSource b) { return !(a == b); }
569 QWeakPointer<const QQmlJSScope> value;
570 };
572 /*
573 AttachedProperty binding is a grouping for a series of bindings
574 belonging to the same scope(QQmlJSScope::AttachedPropertyScope).
575 Thus, the attached property binding itself only exposes the
576 attaching type object. Such object is unique per the enclosing
577 scope, so attaching types attached to different QML scopes are
578 different (think of them as objects in C++ terms).
579
580 An attaching type object, being a QQmlJSScope, has bindings
581 itself. For instance:
582 ```
583 Type {
584 Keys.enabled: true
585 }
586 ```
587 tells us that "Type" has an AttachedProperty binding with
588 property name "Keys". The attaching object of that binding
589 (binding.attachingType()) has type "Keys" and a BoolLiteral
590 binding with property name "enabled".
591 */
593 {
594 return a.value.owner_equal(b.value);
595 }
596 friend bool operator!=(AttachedProperty a, AttachedProperty b) { return !(a == b); }
597 QWeakPointer<const QQmlJSScope> value;
598 };
600 /* Given a group property declaration like
601 anchors.left: root.left
602 the QQmlJSMetaPropertyBinding will have name "anchors", and a m_bindingContent
603 of type GroupProperty, with groupScope pointing to the scope introudced by anchors
604 In that scope, there will be another QQmlJSMetaPropertyBinding, with name "left" and
605 m_bindingContent Script (for root.left).
606 There should never be more than one GroupProperty for the same name in the same
607 scope, though: If the scope also contains anchors.top: root.top that should reuse the
608 GroupProperty content (and add a top: root.top binding in it). There might however
609 still be an additional object or script binding ( anchors: {left: foo, right: bar };
610 anchors: root.someFunction() ) or another binding to the property in a "derived"
611 type.
612
613 ### TODO: Obtaining the effective binding result requires some resolving function
614 */
615 QWeakPointer<const QQmlJSScope> groupScope;
616 friend bool operator==(GroupProperty a, GroupProperty b) { return a.groupScope.owner_equal(b.groupScope); }
617 friend bool operator!=(GroupProperty a, GroupProperty b) { return !(a == b); }
618 };
619 using type = std::variant<Invalid, BoolLiteral, NumberLiteral, StringLiteral,
620 RegexpLiteral, Null, TranslationString,
621 TranslationById, Script, Object, Interceptor,
622 ValueSource, AttachedProperty, GroupProperty
623 >;
624 };
625 using BindingContent = Content::type;
626
627 QQmlJS::SourceLocation m_sourceLocation;
628 QString m_propertyName; // TODO: this is a debug-only information
629 BindingContent m_bindingContent;
630
631 void ensureSetBindingTypeOnce()
632 {
633 Q_ASSERT(bindingType() == BindingType::Invalid);
634 }
635
636 bool isLiteralBinding() const { return isLiteralBinding(bindingType()); }
637
638
639public:
641 {
642 return type == BindingType::BoolLiteral || type == BindingType::NumberLiteral
643 || type == BindingType::StringLiteral || type == BindingType::RegExpLiteral
644 || type == BindingType::Null; // special. we record it as literal
645 }
646
650 : m_sourceLocation(location), m_propertyName(propName)
651 {
652 }
654 const QQmlJSMetaProperty &prop)
655 : QQmlJSMetaPropertyBinding(location, prop.propertyName())
656 {
657 }
658
659 void setPropertyName(const QString &propertyName) { m_propertyName = propertyName; }
660 QString propertyName() const { return m_propertyName; }
661
662 const QQmlJS::SourceLocation &sourceLocation() const { return m_sourceLocation; }
663
664 BindingType bindingType() const { return BindingType(m_bindingContent.index()); }
665
666 bool isValid() const;
667
669 {
670 ensureSetBindingTypeOnce();
671 m_bindingContent = Content::StringLiteral { value.toString() };
672 }
673
674 void
677 {
678 ensureSetBindingTypeOnce();
679 m_bindingContent = Content::Script { value, kind, valueType };
680 }
681
682 void setGroupBinding(const QSharedPointer<const QQmlJSScope> &groupScope)
683 {
684 ensureSetBindingTypeOnce();
685 m_bindingContent = Content::GroupProperty { groupScope };
686 }
687
688 void setAttachedBinding(const QSharedPointer<const QQmlJSScope> &attachingScope)
689 {
690 ensureSetBindingTypeOnce();
691 m_bindingContent = Content::AttachedProperty { attachingScope };
692 }
693
695 {
696 ensureSetBindingTypeOnce();
697 m_bindingContent = Content::BoolLiteral { value };
698 }
699
701 {
702 ensureSetBindingTypeOnce();
703 m_bindingContent = Content::Null {};
704 }
705
707 {
708 ensureSetBindingTypeOnce();
709 m_bindingContent = Content::NumberLiteral { value };
710 }
711
713 {
714 ensureSetBindingTypeOnce();
715 m_bindingContent = Content::RegexpLiteral { value.toString() };
716 }
717
719 {
720 ensureSetBindingTypeOnce();
721 m_bindingContent =
722 Content::TranslationString{ text.toString(), comment.toString(), context.toString(), number };
723 }
724
726 {
727 ensureSetBindingTypeOnce();
728 m_bindingContent = Content::TranslationById{ id.toString(), number };
729 }
730
731 void setObject(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type)
732 {
733 ensureSetBindingTypeOnce();
734 m_bindingContent = Content::Object { typeName, type };
735 }
736
737 void setInterceptor(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type)
738 {
739 ensureSetBindingTypeOnce();
740 m_bindingContent = Content::Interceptor { typeName, type };
741 }
742
743 void setValueSource(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type)
744 {
745 ensureSetBindingTypeOnce();
746 m_bindingContent = Content::ValueSource { typeName, type };
747 }
748
749 // ### TODO: here and below: Introduce an allowConversion parameter, if yes, enable conversions e.g. bool -> number?
750 bool boolValue() const;
751
752 double numberValue() const;
753
754 QString stringValue() const;
755
756 QString regExpValue() const;
757
758 QQmlTranslation translationDataValue(QString qmlFileNameForContext = QStringLiteral("")) const;
759
760 QSharedPointer<const QQmlJSScope> literalType(const QQmlJSTypeResolver *resolver) const;
761
763 {
764 if (auto *script = std::get_if<Content::Script>(&m_bindingContent))
765 return script->index;
766 // warn
768 }
769
771 {
772 if (auto *script = std::get_if<Content::Script>(&m_bindingContent))
773 return script->kind;
774 // warn
775 return ScriptBindingKind::Invalid;
776 }
777
779 {
780 if (auto *script = std::get_if<Content::Script>(&m_bindingContent))
781 return script->valueType;
782 // warn
784 }
785
787 {
788 if (auto *object = std::get_if<Content::Object>(&m_bindingContent))
789 return object->typeName;
790 // warn
791 return {};
792 }
793 QSharedPointer<const QQmlJSScope> objectType() const
794 {
795 if (auto *object = std::get_if<Content::Object>(&m_bindingContent))
796 return object->value.lock();
797 // warn
798 return {};
799 }
800
802 {
803 if (auto *interceptor = std::get_if<Content::Interceptor>(&m_bindingContent))
804 return interceptor->typeName;
805 // warn
806 return {};
807 }
808 QSharedPointer<const QQmlJSScope> interceptorType() const
809 {
810 if (auto *interceptor = std::get_if<Content::Interceptor>(&m_bindingContent))
811 return interceptor->value.lock();
812 // warn
813 return {};
814 }
815
817 {
818 if (auto *valueSource = std::get_if<Content::ValueSource>(&m_bindingContent))
819 return valueSource->typeName;
820 // warn
821 return {};
822 }
823 QSharedPointer<const QQmlJSScope> valueSourceType() const
824 {
825 if (auto *valueSource = std::get_if<Content::ValueSource>(&m_bindingContent))
826 return valueSource->value.lock();
827 // warn
828 return {};
829 }
830
831 QSharedPointer<const QQmlJSScope> groupType() const
832 {
833 if (auto *group = std::get_if<Content::GroupProperty>(&m_bindingContent))
834 return group->groupScope.lock();
835 // warn
836 return {};
837 }
838
839 QSharedPointer<const QQmlJSScope> attachingType() const
840 {
841 if (auto *attached = std::get_if<Content::AttachedProperty>(&m_bindingContent))
842 return attached->value.lock();
843 // warn
844 return {};
845 }
846
847 bool hasLiteral() const
848 {
849 // TODO: Assumption: if the type is literal, we must have one
850 return isLiteralBinding();
851 }
852 bool hasObject() const { return bindingType() == BindingType::Object; }
853 bool hasInterceptor() const
854 {
855 return bindingType() == BindingType::Interceptor;
856 }
857 bool hasValueSource() const
858 {
859 return bindingType() == BindingType::ValueSource;
860 }
861
863 {
864 return a.m_propertyName == b.m_propertyName
865 && a.m_bindingContent == b.m_bindingContent
866 && a.m_sourceLocation == b.m_sourceLocation;
867 }
868
870 {
871 return !(a == b);
872 }
873
874 friend size_t qHash(const QQmlJSMetaPropertyBinding &binding, size_t seed = 0)
875 {
876 // we don't need to care about the actual binding content when hashing
877 return qHashMulti(seed, binding.m_propertyName, binding.m_sourceLocation,
878 binding.bindingType());
879 }
880};
881
882struct Q_QMLCOMPILER_EXPORT QQmlJSMetaSignalHandler
883{
886};
887
889
890#endif // QQMLJSMETATYPES_P_H
Definition main.cpp:8
\inmodule QtCore
iterator end()
Definition qlist.h:627
iterator begin()
Definition qlist.h:626
void append(parameter_type t)
Definition qlist.h:459
QString typeName() const
void setIsFlag(bool isFlag)
friend bool operator!=(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
void setName(const QString &name)
QQmlJSMetaEnum()=default
friend size_t qHash(const QQmlJSMetaEnum &e, size_t seed=0)
friend bool operator==(const QQmlJSMetaEnum &a, const QQmlJSMetaEnum &b)
void setTypeName(const QString &typeName)
bool hasKey(const QString &key) const
void setIsScoped(bool v)
void setType(const QSharedPointer< const QQmlJSScope > &type)
QSharedPointer< const QQmlJSScope > type() const
int value(const QString &key) const
bool isQml() const
void setIsQml(bool v)
void addValue(int value)
bool isScoped() const
QList< int > values() const
bool isFlag() const
QString alias() const
QStringList keys() const
bool isValid() const
void addKey(const QString &key)
void setAlias(const QString &alias)
QString name() const
QQmlJSMetaEnum(QString name)
bool hasValues() const
QQmlJSMetaReturnType returnValue() const
friend bool operator!=(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b)
bool isJavaScriptFunction() const
QStringList parameterNames() const
bool isConstructor() const
Access access() const
void setIsImplicitQmlPropertyChangeSignal(bool isPropertyChangeSignal)
void setIsConstructor(bool isConstructor)
QQmlJSMetaMethod()=default
void setReturnType(QWeakPointer< const QQmlJSScope > type)
RelativeFunctionIndex jsFunctionIndex() const
void setSourceLocation(QQmlJS::SourceLocation location)
void setIsJavaScriptFunction(bool isJavaScriptFunction)
QQmlJS::SourceLocation sourceLocation() const
QString methodName() const
friend size_t qHash(const QQmlJSMetaMethod &method, size_t seed=0)
QQmlJSMetaMethodType MethodType
void setMethodName(const QString &name)
RelativeFunctionIndex constructorIndex() const
void setMethodType(MethodType methodType)
void setAnnotations(QVector< QQmlJSAnnotation > annotations)
QPair< QList< QQmlJSMetaParameter >::iterator, QList< QQmlJSMetaParameter >::iterator > mutableParametersRange()
const QVector< QQmlJSAnnotation > & annotations() const
bool isImplicitQmlPropertyChangeSignal() const
void setReturnTypeName(const QString &typeName)
friend bool operator==(const QQmlJSMetaMethod &a, const QQmlJSMetaMethod &b)
void setJsFunctionIndex(RelativeFunctionIndex index)
QString returnTypeName() const
QQmlJSMetaMethod(QString name, QString returnType=QString())
QList< QQmlJSMetaParameter > parameters() const
void setReturnValue(const QQmlJSMetaReturnType returnValue)
void setIsCloned(bool isCloned)
void setParameters(const QList< QQmlJSMetaParameter > &parameters)
void setConstructorIndex(RelativeFunctionIndex index)
void addParameter(const QQmlJSMetaParameter &p)
QSharedPointer< const QQmlJSScope > returnType() const
QQmlJSMetaMethodType methodType() const
void setIsPointer(bool isPointer)
void setType(QWeakPointer< const QQmlJSScope > type)
void setIsList(bool isList)
friend bool operator!=(const QQmlJSMetaParameter &a, const QQmlJSMetaParameter &b)
friend size_t qHash(const QQmlJSMetaParameter &e, size_t seed=0)
void setName(const QString &name)
void setTypeName(const QString &typeName)
void setTypeQualifier(Constness typeQualifier)
Constness typeQualifier() const
QString typeName() const
QQmlJSMetaParameter(QString name=QString(), QString typeName=QString(), Constness typeQualifier=NonConst, QWeakPointer< const QQmlJSScope > type={})
friend bool operator==(const QQmlJSMetaParameter &a, const QQmlJSMetaParameter &b)
QSharedPointer< const QQmlJSScope > type() const
void setStringLiteral(QAnyStringView value)
void setScriptBinding(QQmlJSMetaMethod::RelativeFunctionIndex value, ScriptBindingKind kind, ScriptBindingValueType valueType=ScriptBindingValueType::ScriptValue_Unknown)
void setRegexpLiteral(QAnyStringView value)
void setInterceptor(const QString &typeName, const QSharedPointer< const QQmlJSScope > &type)
QSharedPointer< const QQmlJSScope > interceptorType() const
QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation location, const QString &propName)
void setTranslationId(QStringView id, int number)
QSharedPointer< const QQmlJSScope > objectType() const
QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation location, const QQmlJSMetaProperty &prop)
friend bool operator==(const QQmlJSMetaPropertyBinding &a, const QQmlJSMetaPropertyBinding &b)
static bool isLiteralBinding(BindingType type)
QString interceptorTypeName() const
void setObject(const QString &typeName, const QSharedPointer< const QQmlJSScope > &type)
void setGroupBinding(const QSharedPointer< const QQmlJSScope > &groupScope)
ScriptBindingKind scriptKind() const
void setPropertyName(const QString &propertyName)
QSharedPointer< const QQmlJSScope > groupType() const
ScriptBindingValueType scriptValueType() const
BindingType bindingType() const
const QQmlJS::SourceLocation & sourceLocation() const
QSharedPointer< const QQmlJSScope > valueSourceType() const
friend bool operator!=(const QQmlJSMetaPropertyBinding &a, const QQmlJSMetaPropertyBinding &b)
void setNumberLiteral(double value)
QQmlJSMetaPropertyBinding(QQmlJS::SourceLocation location)
QQmlJSMetaMethod::RelativeFunctionIndex scriptIndex() const
void setAttachedBinding(const QSharedPointer< const QQmlJSScope > &attachingScope)
void setTranslation(QStringView text, QStringView comment, QStringView context, int number)
QSharedPointer< const QQmlJSScope > attachingType() const
QString valueSourceTypeName() const
void setValueSource(const QString &typeName, const QSharedPointer< const QQmlJSScope > &type)
friend size_t qHash(const QQmlJSMetaPropertyBinding &binding, size_t seed=0)
friend bool operator!=(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b)
QString notify() const
QString aliasExpression() const
friend bool operator==(const QQmlJSMetaProperty &a, const QQmlJSMetaProperty &b)
void setPropertyName(const QString &propertyName)
void setAnnotations(const QList< QQmlJSAnnotation > &annotation)
void setIsList(bool isList)
QString bindable() const
QSharedPointer< const QQmlJSScope > type() const
void setPrivateClass(const QString &privateClass)
void setRead(const QString &read)
friend size_t qHash(const QQmlJSMetaProperty &prop, size_t seed=0)
void setBindable(const QString &bindable)
void setWrite(const QString &write)
void setIsPropertyConstant(bool isPropertyConstant)
QString reset() const
void setRevision(int revision)
void setIsFinal(bool isFinal)
QString typeName() const
QString write() const
void setIsTypeConstant(bool isTypeConstant)
const QList< QQmlJSAnnotation > & annotations() const
void setTypeName(const QString &typeName)
QQmlJSMetaProperty()=default
void setReset(const QString &reset)
QString privateClass() const
void setIsWritable(bool isWritable)
void setAliasExpression(const QString &aliasString)
void setIndex(int index)
void setNotify(const QString &notify)
bool isPropertyConstant() const
bool isTypeConstant() const
void setType(const QSharedPointer< const QQmlJSScope > &type)
QString propertyName() const
void setIsPointer(bool isPointer)
Tracks the types for the QmlCompiler.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1121
\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
size_t owner_hash() const noexcept
QSharedPointer< T > toStrongRef() const
Promotes this weak reference to a strong one and returns a QSharedPointer object holding that referen...
QString text
MethodType
Definition qqmlsa.h:49
Combined button and popup list for selecting options.
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_GCC(text)
#define QT_WARNING_PUSH
#define QT_WARNING_DISABLE_CLANG(text)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
constexpr QtPrivate::QHashMultiReturnType< T... > qHashMulti(size_t seed, const T &... args) noexcept(std::conjunction_v< QtPrivate::QNothrowHashable< T >... >)
@ Invalid
const char * typeName
GLint location
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLboolean r
[2]
GLenum type
GLboolean GLuint group
GLuint name
GLboolean reset
GLuint GLuint * names
GLfloat GLfloat p
[1]
QQmlSA::MethodType QQmlJSMetaMethodType
ScriptBindingValueType
@ ScriptValue_Unknown
@ ScriptValue_Undefined
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
BindingType
#define QStringLiteral(str)
friend bool operator!=(AttachedProperty a, AttachedProperty b)
friend bool operator==(AttachedProperty a, AttachedProperty b)
friend bool operator==(BoolLiteral a, BoolLiteral b)
friend bool operator!=(BoolLiteral a, BoolLiteral b)
friend bool operator!=(GroupProperty a, GroupProperty b)
friend bool operator==(GroupProperty a, GroupProperty b)
friend bool operator==(Interceptor a, Interceptor b)
friend bool operator!=(Interceptor a, Interceptor b)
friend bool operator!=(NumberLiteral a, NumberLiteral b)
QWeakPointer< const QQmlJSScope > value
friend bool operator!=(Object a, Object b)
friend bool operator==(Object a, Object b)
friend bool operator!=(RegexpLiteral a, RegexpLiteral b)
friend bool operator==(RegexpLiteral a, RegexpLiteral b)
friend bool operator==(Script a, Script b)
friend bool operator!=(Script a, Script b)
friend bool operator==(StringLiteral a, StringLiteral b)
friend bool operator!=(StringLiteral a, StringLiteral b)
friend bool operator!=(TranslationById a, TranslationById b)
friend bool operator==(TranslationById a, TranslationById b)
friend bool operator==(TranslationString a, TranslationString b)
friend bool operator!=(TranslationString a, TranslationString b)
friend bool operator!=(ValueSource a, ValueSource b)
friend bool operator==(ValueSource a, ValueSource b)