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
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/qv4compileddata_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
42 bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums);
43
44 void doDynamicTypeCheck();
45
46 QQmlType type() const { return m_type; }
47 void setType(QQmlType type) { m_type = std::move(type); }
48
49 QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit()
50 {
51 return m_compilationUnit;
52 }
53
54 void setCompilationUnit(QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit)
55 {
56 if (m_compilationUnit == unit.data())
57 return;
58 if (m_stronglyReferencesCompilationUnit) {
59 if (m_compilationUnit)
60 m_compilationUnit->release();
61 m_compilationUnit = unit.take();
62 } else {
63 m_compilationUnit = unit.data();
64 }
65 }
66
67 bool referencesCompilationUnit() const { return m_stronglyReferencesCompilationUnit; }
68 void setReferencesCompilationUnit(bool doReference)
69 {
70 if (doReference == m_stronglyReferencesCompilationUnit)
71 return;
72 m_stronglyReferencesCompilationUnit = doReference;
73 if (!m_compilationUnit)
74 return;
75 if (doReference) {
76 m_compilationUnit->addref();
77 } else if (m_compilationUnit->count() == 1) {
78 m_compilationUnit->release();
79 m_compilationUnit = nullptr;
80 } else {
81 m_compilationUnit->release();
82 }
83 }
84
85 QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; }
87 {
88 m_typePropertyCache = std::move(cache);
89 }
90
91 QTypeRevision version() const { return m_version; }
92 void setVersion(QTypeRevision version) { m_version = version; }
93
94 bool isFullyDynamicType() const { return m_isFullyDynamicType; }
95 void setFullyDynamicType(bool fullyDynamic) { m_isFullyDynamicType = fullyDynamic; }
96
97private:
98 QQmlType m_type;
99 QQmlPropertyCache::ConstPtr m_typePropertyCache;
100 QV4::CompiledData::CompilationUnit *m_compilationUnit = nullptr;
101
103 // Types such as QQmlPropertyMap can add properties dynamically at run-time and
104 // therefore cannot have a property cache installed when instantiated.
105 bool m_isFullyDynamicType = false;
106 bool m_stronglyReferencesCompilationUnit = true;
107};
108
109} // namespace QV4
110
112
113#endif // QV4RESOLVEDTYPEREFERNCE_P_H
void addref() const
int count() const
void release() 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)
void setCompilationUnit(QQmlRefPointer< QV4::CompiledData::CompilationUnit > unit)
QQmlRefPointer< QV4::CompiledData::CompilationUnit > compilationUnit()
void setFullyDynamicType(bool fullyDynamic)
void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
void setVersion(QTypeRevision version)
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.
GLenum type