Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qv4resolvedtypereference_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QV4RESOLVEDTYPEREFERNCE_P_H
5#define QV4RESOLVEDTYPEREFERNCE_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
18#include <QtQml/private/qtqmlglobal_p.h>
19#include <QtQml/private/qqmlrefcount_p.h>
20#include <QtQml/private/qqmlpropertycache_p.h>
21#include <QtQml/private/qqmltype_p.h>
22#include <QtQml/private/qv4executablecompilationunit_p.h>
23
25
27namespace QV4 {
28
30{
31 Q_DISABLE_COPY_MOVE(ResolvedTypeReference)
32public:
35 {
36 if (m_stronglyReferencesCompilationUnit && m_compilationUnit)
37 m_compilationUnit->release();
38 }
39
43
44 void doDynamicTypeCheck();
45
46 QQmlType type() const { return m_type; }
47 void setType(QQmlType type) { m_type = std::move(type); }
48
51 {
52 if (m_compilationUnit == unit.data())
53 return;
54 if (m_stronglyReferencesCompilationUnit) {
55 if (m_compilationUnit)
56 m_compilationUnit->release();
57 m_compilationUnit = unit.take();
58 } else {
59 m_compilationUnit = unit.data();
60 }
61 }
62
63 bool referencesCompilationUnit() const { return m_stronglyReferencesCompilationUnit; }
64 void setReferencesCompilationUnit(bool doReference)
65 {
66 if (doReference == m_stronglyReferencesCompilationUnit)
67 return;
68 m_stronglyReferencesCompilationUnit = doReference;
69 if (!m_compilationUnit)
70 return;
71 if (doReference) {
72 m_compilationUnit->addref();
73 } else if (m_compilationUnit->count() == 1) {
74 m_compilationUnit->release();
75 m_compilationUnit = nullptr;
76 } else {
77 m_compilationUnit->release();
78 }
79 }
80
81 QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; }
83 {
84 m_typePropertyCache = std::move(cache);
85 }
86
87 QTypeRevision version() const { return m_version; }
88 void setVersion(QTypeRevision version) { m_version = version; }
89
90 bool isFullyDynamicType() const { return m_isFullyDynamicType; }
91 void setFullyDynamicType(bool fullyDynamic) { m_isFullyDynamicType = fullyDynamic; }
92
93private:
94 QQmlType m_type;
95 QQmlPropertyCache::ConstPtr m_typePropertyCache;
96 QV4::ExecutableCompilationUnit *m_compilationUnit = nullptr;
97
99 // Types such as QQmlPropertyMap can add properties dynamically at run-time and
100 // therefore cannot have a property cache installed when instantiated.
101 bool m_isFullyDynamicType = false;
102 bool m_stronglyReferencesCompilationUnit = true;
103};
104
105} // namespace QV4
106
108
109#endif // QV4RESOLVEDTYPEREFERNCE_P_H
\inmodule QtCore
Definition qhash.h:818
void addref() const
int count() const
void release() const
T * data() const
\inmodule QtCore
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
QQmlPropertyCache::ConstPtr typePropertyCache() const
void setReferencesCompilationUnit(bool doReference)
bool addToHash(QCryptographicHash *hash, QHash< quintptr, QByteArray > *checksums)
QQmlRefPointer< QV4::ExecutableCompilationUnit > compilationUnit()
void setFullyDynamicType(bool fullyDynamic)
void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
void setVersion(QTypeRevision version)
void setCompilationUnit(QQmlRefPointer< QV4::ExecutableCompilationUnit > unit)
QQmlPropertyCache::ConstPtr propertyCache() const
Returns the property cache, if one alread exists.
QQmlPropertyCache::ConstPtr createPropertyCache()
Returns the property cache, creating one if it doesn't already exist.
QHash< int, QWidget * > hash
[35multi]
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
GLenum type