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_isFinal = false;
377 bool m_isConstant = false;
378 int m_revision = 0;
379 int m_index = -1; // relative property index within owning QQmlJSScope
380
381public:
383
384 void setPropertyName(const QString &propertyName) { m_propertyName = propertyName; }
385 QString propertyName() const { return m_propertyName; }
386
387 void setTypeName(const QString &typeName) { m_typeName = typeName; }
388 QString typeName() const { return m_typeName; }
389
390 void setRead(const QString &read) { m_read = read; }
391 QString read() const { return m_read; }
392
393 void setWrite(const QString &write) { m_write = write; }
394 QString write() const { return m_write; }
395
396 void setReset(const QString &reset) { m_reset = reset; }
397 QString reset() const { return m_reset; }
398
399 void setBindable(const QString &bindable) { m_bindable = bindable; }
400 QString bindable() const { return m_bindable; }
401
402 void setNotify(const QString &notify) { m_notify = notify; }
403 QString notify() const { return m_notify; }
404
405 void setPrivateClass(const QString &privateClass) { m_privateClass = privateClass; }
406 QString privateClass() const { return m_privateClass; }
407 bool isPrivate() const { return !m_privateClass.isEmpty(); } // exists for convenience
408
409 void setType(const QSharedPointer<const QQmlJSScope> &type) { m_type = type; }
410 QSharedPointer<const QQmlJSScope> type() const { return m_type.toStrongRef(); }
411
412 void setAnnotations(const QList<QQmlJSAnnotation> &annotation) { m_annotations = annotation; }
413 const QList<QQmlJSAnnotation> &annotations() const { return m_annotations; }
414
415 void setIsList(bool isList) { m_isList = isList; }
416 bool isList() const { return m_isList; }
417
418 void setIsWritable(bool isWritable) { m_isWritable = isWritable; }
419 bool isWritable() const { return m_isWritable; }
420
421 void setIsPointer(bool isPointer) { m_isPointer = isPointer; }
422 bool isPointer() const { return m_isPointer; }
423
424 void setAliasExpression(const QString &aliasString) { m_aliasExpr = aliasString; }
425 QString aliasExpression() const { return m_aliasExpr; }
426 bool isAlias() const { return !m_aliasExpr.isEmpty(); } // exists for convenience
427
428 void setIsFinal(bool isFinal) { m_isFinal = isFinal; }
429 bool isFinal() const { return m_isFinal; }
430
431 void setIsConstant(bool isConstant) { m_isConstant = isConstant; }
432 bool isConstant() const { return m_isConstant; }
433
434 void setRevision(int revision) { m_revision = revision; }
435 int revision() const { return m_revision; }
436
437 void setIndex(int index) { m_index = index; }
438 int index() const { return m_index; }
439
440 bool isValid() const { return !m_propertyName.isEmpty(); }
441
443 {
444 return a.m_index == b.m_index && a.m_propertyName == b.m_propertyName
445 && a.m_typeName == b.m_typeName && a.m_bindable == b.m_bindable
446 && a.m_type.owner_equal(b.m_type) && a.m_isList == b.m_isList
447 && a.m_isWritable == b.m_isWritable && a.m_isPointer == b.m_isPointer
448 && a.m_aliasExpr == b.m_aliasExpr && a.m_revision == b.m_revision
449 && a.m_isFinal == b.m_isFinal;
450 }
451
453 {
454 return !(a == b);
455 }
456
457 friend size_t qHash(const QQmlJSMetaProperty &prop, size_t seed = 0)
458 {
459 return qHashMulti(seed, prop.m_propertyName, prop.m_typeName, prop.m_bindable,
460 prop.m_type.toStrongRef().data(), prop.m_isList, prop.m_isWritable,
461 prop.m_isPointer, prop.m_aliasExpr, prop.m_revision, prop.m_isFinal,
462 prop.m_index);
463 }
464};
465
475class Q_QMLCOMPILER_EXPORT QQmlJSMetaPropertyBinding
476{
479
480 // needs to be kept in sync with the BindingType enum
481 struct Content {
482 using Invalid = std::monostate;
483 struct BoolLiteral {
484 bool value;
485 friend bool operator==(BoolLiteral a, BoolLiteral b) { return a.value == b.value; }
486 friend bool operator!=(BoolLiteral a, BoolLiteral b) { return !(a == b); }
487 };
490 QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
491 QT_WARNING_DISABLE_GCC("-Wfloat-equal")
492 friend bool operator==(NumberLiteral a, NumberLiteral b) { return a.value == b.value; }
493 friend bool operator!=(NumberLiteral a, NumberLiteral b) { return !(a == b); }
495
496 double value; // ### TODO: int?
497 };
499 friend bool operator==(StringLiteral a, StringLiteral b) { return a.value == b.value; }
500 friend bool operator!=(StringLiteral a, StringLiteral b) { return !(a == b); }
502 };
504 friend bool operator==(RegexpLiteral a, RegexpLiteral b) { return a.value == b.value; }
505 friend bool operator!=(RegexpLiteral a, RegexpLiteral b) { return !(a == b); }
507 };
508 struct Null {
509 friend bool operator==(Null , Null ) { return true; }
510 friend bool operator!=(Null a, Null b) { return !(a == b); }
511 };
514 {
515 return a.text == b.text && a.comment == b.comment && a.number == b.number && a.context == b.context;
516 }
517 friend bool operator!=(TranslationString a, TranslationString b) { return !(a == b); }
522 };
525 {
526 return a.id == b.id && a.number == b.number;
527 }
528 friend bool operator!=(TranslationById a, TranslationById b) { return !(a == b); }
531 };
532 struct Script {
533 friend bool operator==(Script a, Script b)
534 {
535 return a.index == b.index && a.kind == b.kind;
536 }
537 friend bool operator!=(Script a, Script b) { return !(a == b); }
540 ScriptBindingKind kind = ScriptBindingKind::Invalid;
542 };
543 struct Object {
544 friend bool operator==(Object a, Object b) { return a.value.owner_equal(b.value) && a.typeName == b.typeName; }
545 friend bool operator!=(Object a, Object b) { return !(a == b); }
547 QWeakPointer<const QQmlJSScope> value;
548 };
549 struct Interceptor {
551 {
552 return a.value.owner_equal(b.value) && a.typeName == b.typeName;
553 }
554 friend bool operator!=(Interceptor a, Interceptor b) { return !(a == b); }
556 QWeakPointer<const QQmlJSScope> value;
557 };
558 struct ValueSource {
560 {
561 return a.value.owner_equal(b.value) && a.typeName == b.typeName;
562 }
563 friend bool operator!=(ValueSource a, ValueSource b) { return !(a == b); }
565 QWeakPointer<const QQmlJSScope> value;
566 };
568 /*
569 AttachedProperty binding is a grouping for a series of bindings
570 belonging to the same scope(QQmlJSScope::AttachedPropertyScope).
571 Thus, the attached property binding itself only exposes the
572 attaching type object. Such object is unique per the enclosing
573 scope, so attaching types attached to different QML scopes are
574 different (think of them as objects in C++ terms).
575
576 An attaching type object, being a QQmlJSScope, has bindings
577 itself. For instance:
578 ```
579 Type {
580 Keys.enabled: true
581 }
582 ```
583 tells us that "Type" has an AttachedProperty binding with
584 property name "Keys". The attaching object of that binding
585 (binding.attachingType()) has type "Keys" and a BoolLiteral
586 binding with property name "enabled".
587 */
589 {
590 return a.value.owner_equal(b.value);
591 }
592 friend bool operator!=(AttachedProperty a, AttachedProperty b) { return !(a == b); }
593 QWeakPointer<const QQmlJSScope> value;
594 };
596 /* Given a group property declaration like
597 anchors.left: root.left
598 the QQmlJSMetaPropertyBinding will have name "anchors", and a m_bindingContent
599 of type GroupProperty, with groupScope pointing to the scope introudced by anchors
600 In that scope, there will be another QQmlJSMetaPropertyBinding, with name "left" and
601 m_bindingContent Script (for root.left).
602 There should never be more than one GroupProperty for the same name in the same
603 scope, though: If the scope also contains anchors.top: root.top that should reuse the
604 GroupProperty content (and add a top: root.top binding in it). There might however
605 still be an additional object or script binding ( anchors: {left: foo, right: bar };
606 anchors: root.someFunction() ) or another binding to the property in a "derived"
607 type.
608
609 ### TODO: Obtaining the effective binding result requires some resolving function
610 */
611 QWeakPointer<const QQmlJSScope> groupScope;
612 friend bool operator==(GroupProperty a, GroupProperty b) { return a.groupScope.owner_equal(b.groupScope); }
613 friend bool operator!=(GroupProperty a, GroupProperty b) { return !(a == b); }
614 };
615 using type = std::variant<Invalid, BoolLiteral, NumberLiteral, StringLiteral,
616 RegexpLiteral, Null, TranslationString,
617 TranslationById, Script, Object, Interceptor,
618 ValueSource, AttachedProperty, GroupProperty
619 >;
620 };
621 using BindingContent = Content::type;
622
623 QQmlJS::SourceLocation m_sourceLocation;
624 QString m_propertyName; // TODO: this is a debug-only information
625 BindingContent m_bindingContent;
626
627 void ensureSetBindingTypeOnce()
628 {
629 Q_ASSERT(bindingType() == BindingType::Invalid);
630 }
631
632 bool isLiteralBinding() const { return isLiteralBinding(bindingType()); }
633
634
635public:
637 {
638 return type == BindingType::BoolLiteral || type == BindingType::NumberLiteral
639 || type == BindingType::StringLiteral || type == BindingType::RegExpLiteral
640 || type == BindingType::Null; // special. we record it as literal
641 }
642
646 : m_sourceLocation(location), m_propertyName(propName)
647 {
648 }
650 const QQmlJSMetaProperty &prop)
651 : QQmlJSMetaPropertyBinding(location, prop.propertyName())
652 {
653 }
654
655 void setPropertyName(const QString &propertyName) { m_propertyName = propertyName; }
656 QString propertyName() const { return m_propertyName; }
657
658 const QQmlJS::SourceLocation &sourceLocation() const { return m_sourceLocation; }
659
660 BindingType bindingType() const { return BindingType(m_bindingContent.index()); }
661
662 bool isValid() const;
663
665 {
666 ensureSetBindingTypeOnce();
667 m_bindingContent = Content::StringLiteral { value.toString() };
668 }
669
670 void
673 {
674 ensureSetBindingTypeOnce();
675 m_bindingContent = Content::Script { value, kind, valueType };
676 }
677
678 void setGroupBinding(const QSharedPointer<const QQmlJSScope> &groupScope)
679 {
680 ensureSetBindingTypeOnce();
681 m_bindingContent = Content::GroupProperty { groupScope };
682 }
683
684 void setAttachedBinding(const QSharedPointer<const QQmlJSScope> &attachingScope)
685 {
686 ensureSetBindingTypeOnce();
687 m_bindingContent = Content::AttachedProperty { attachingScope };
688 }
689
691 {
692 ensureSetBindingTypeOnce();
693 m_bindingContent = Content::BoolLiteral { value };
694 }
695
697 {
698 ensureSetBindingTypeOnce();
699 m_bindingContent = Content::Null {};
700 }
701
703 {
704 ensureSetBindingTypeOnce();
705 m_bindingContent = Content::NumberLiteral { value };
706 }
707
709 {
710 ensureSetBindingTypeOnce();
711 m_bindingContent = Content::RegexpLiteral { value.toString() };
712 }
713
715 {
716 ensureSetBindingTypeOnce();
717 m_bindingContent =
718 Content::TranslationString{ text.toString(), comment.toString(), context.toString(), number };
719 }
720
722 {
723 ensureSetBindingTypeOnce();
724 m_bindingContent = Content::TranslationById{ id.toString(), number };
725 }
726
727 void setObject(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type)
728 {
729 ensureSetBindingTypeOnce();
730 m_bindingContent = Content::Object { typeName, type };
731 }
732
733 void setInterceptor(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type)
734 {
735 ensureSetBindingTypeOnce();
736 m_bindingContent = Content::Interceptor { typeName, type };
737 }
738
739 void setValueSource(const QString &typeName, const QSharedPointer<const QQmlJSScope> &type)
740 {
741 ensureSetBindingTypeOnce();
742 m_bindingContent = Content::ValueSource { typeName, type };
743 }
744
745 // ### TODO: here and below: Introduce an allowConversion parameter, if yes, enable conversions e.g. bool -> number?
746 bool boolValue() const;
747
748 double numberValue() const;
749
750 QString stringValue() const;
751
752 QString regExpValue() const;
753
754 QQmlTranslation translationDataValue(QString qmlFileNameForContext = QStringLiteral("")) const;
755
756 QSharedPointer<const QQmlJSScope> literalType(const QQmlJSTypeResolver *resolver) const;
757
759 {
760 if (auto *script = std::get_if<Content::Script>(&m_bindingContent))
761 return script->index;
762 // warn
764 }
765
767 {
768 if (auto *script = std::get_if<Content::Script>(&m_bindingContent))
769 return script->kind;
770 // warn
771 return ScriptBindingKind::Invalid;
772 }
773
775 {
776 if (auto *script = std::get_if<Content::Script>(&m_bindingContent))
777 return script->valueType;
778 // warn
780 }
781
783 {
784 if (auto *object = std::get_if<Content::Object>(&m_bindingContent))
785 return object->typeName;
786 // warn
787 return {};
788 }
789 QSharedPointer<const QQmlJSScope> objectType() const
790 {
791 if (auto *object = std::get_if<Content::Object>(&m_bindingContent))
792 return object->value.lock();
793 // warn
794 return {};
795 }
796
798 {
799 if (auto *interceptor = std::get_if<Content::Interceptor>(&m_bindingContent))
800 return interceptor->typeName;
801 // warn
802 return {};
803 }
804 QSharedPointer<const QQmlJSScope> interceptorType() const
805 {
806 if (auto *interceptor = std::get_if<Content::Interceptor>(&m_bindingContent))
807 return interceptor->value.lock();
808 // warn
809 return {};
810 }
811
813 {
814 if (auto *valueSource = std::get_if<Content::ValueSource>(&m_bindingContent))
815 return valueSource->typeName;
816 // warn
817 return {};
818 }
819 QSharedPointer<const QQmlJSScope> valueSourceType() const
820 {
821 if (auto *valueSource = std::get_if<Content::ValueSource>(&m_bindingContent))
822 return valueSource->value.lock();
823 // warn
824 return {};
825 }
826
827 QSharedPointer<const QQmlJSScope> groupType() const
828 {
829 if (auto *group = std::get_if<Content::GroupProperty>(&m_bindingContent))
830 return group->groupScope.lock();
831 // warn
832 return {};
833 }
834
835 QSharedPointer<const QQmlJSScope> attachingType() const
836 {
837 if (auto *attached = std::get_if<Content::AttachedProperty>(&m_bindingContent))
838 return attached->value.lock();
839 // warn
840 return {};
841 }
842
843 bool hasLiteral() const
844 {
845 // TODO: Assumption: if the type is literal, we must have one
846 return isLiteralBinding();
847 }
848 bool hasObject() const { return bindingType() == BindingType::Object; }
849 bool hasInterceptor() const
850 {
851 return bindingType() == BindingType::Interceptor;
852 }
853 bool hasValueSource() const
854 {
855 return bindingType() == BindingType::ValueSource;
856 }
857
859 {
860 return a.m_propertyName == b.m_propertyName
861 && a.m_bindingContent == b.m_bindingContent
862 && a.m_sourceLocation == b.m_sourceLocation;
863 }
864
866 {
867 return !(a == b);
868 }
869
870 friend size_t qHash(const QQmlJSMetaPropertyBinding &binding, size_t seed = 0)
871 {
872 // we don't need to care about the actual binding content when hashing
873 return qHashMulti(seed, binding.m_propertyName, binding.m_sourceLocation,
874 binding.bindingType());
875 }
876};
877
878struct Q_QMLCOMPILER_EXPORT QQmlJSMetaSignalHandler
879{
882};
883
885
886#endif // QQMLJSMETATYPES_P_H
Definition main.cpp:8
\inmodule QtCore
iterator end()
Definition qlist.h:626
iterator begin()
Definition qlist.h:625
void append(parameter_type t)
Definition qlist.h:458
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)
QString reset() const
void setRevision(int revision)
void setIsFinal(bool isFinal)
void setIsConstant(bool isConstant)
QString typeName() const
QString write() const
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)
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.
static void * context
#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)