blob: 4aaafdd71c19d03b79a765b5e0b8930fbd3cd399 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QV4RESOLVEDTYPEREFERNCE_P_H
#define QV4RESOLVEDTYPEREFERNCE_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtQml/private/qtqmlglobal_p.h>
#include <QtQml/private/qqmlrefcount_p.h>
#include <QtQml/private/qqmlpropertycache_p.h>
#include <QtQml/private/qqmltype_p.h>
#include <QtQml/private/qv4compileddata_p.h>
QT_BEGIN_NAMESPACE
class QCryptographicHash;
namespace QV4 {
class ResolvedTypeReference
{
Q_DISABLE_COPY_MOVE(ResolvedTypeReference)
public:
ResolvedTypeReference() = default;
~ResolvedTypeReference()
{
if (m_stronglyReferencesCompilationUnit && m_compilationUnit)
m_compilationUnit->release();
}
QQmlPropertyCache::ConstPtr propertyCache() const;
QQmlPropertyCache::ConstPtr createPropertyCache();
bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums);
void doDynamicTypeCheck();
QQmlType type() const { return m_type; }
void setType(QQmlType type) { m_type = std::move(type); }
QQmlRefPointer<QV4::CompiledData::CompilationUnit> compilationUnit()
{
return m_compilationUnit;
}
void setCompilationUnit(QQmlRefPointer<QV4::CompiledData::CompilationUnit> unit)
{
if (m_compilationUnit == unit.data())
return;
if (m_stronglyReferencesCompilationUnit) {
if (m_compilationUnit)
m_compilationUnit->release();
m_compilationUnit = unit.take();
} else {
m_compilationUnit = unit.data();
}
}
bool referencesCompilationUnit() const { return m_stronglyReferencesCompilationUnit; }
void setReferencesCompilationUnit(bool doReference)
{
if (doReference == m_stronglyReferencesCompilationUnit)
return;
m_stronglyReferencesCompilationUnit = doReference;
if (!m_compilationUnit)
return;
if (doReference) {
m_compilationUnit->addref();
} else if (m_compilationUnit->count() == 1) {
m_compilationUnit->release();
m_compilationUnit = nullptr;
} else {
m_compilationUnit->release();
}
}
QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; }
void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
{
m_typePropertyCache = std::move(cache);
}
QTypeRevision version() const { return m_version; }
void setVersion(QTypeRevision version) { m_version = version; }
bool isFullyDynamicType() const { return m_isFullyDynamicType; }
void setFullyDynamicType(bool fullyDynamic) { m_isFullyDynamicType = fullyDynamic; }
private:
QQmlType m_type;
QQmlPropertyCache::ConstPtr m_typePropertyCache;
QV4::CompiledData::CompilationUnit *m_compilationUnit = nullptr;
QTypeRevision m_version = QTypeRevision::zero();
// Types such as QQmlPropertyMap can add properties dynamically at run-time and
// therefore cannot have a property cache installed when instantiated.
bool m_isFullyDynamicType = false;
bool m_stronglyReferencesCompilationUnit = true;
};
} // namespace QV4
QT_END_NAMESPACE
#endif // QV4RESOLVEDTYPEREFERNCE_P_H
|