Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant
4
5#ifndef QV4RESOLVEDTYPEREFERNCE_P_H
6#define QV4RESOLVEDTYPEREFERNCE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQml/private/qtqmlglobal_p.h>
20#include <QtQml/private/qqmlrefcount_p.h>
21#include <QtQml/private/qqmlpropertycache_p.h>
22#include <QtQml/private/qqmltype_p.h>
23#include <QtQml/private/qv4compileddata_p.h>
24
25#include <QtCore/qtyperevision.h>
26
27QT_BEGIN_NAMESPACE
28
29class QCryptographicHash;
30namespace QV4 {
31
33{
35public:
37
39 bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums);
40
41 void doDynamicTypeCheck();
42
43 QQmlType type() const { return m_type; }
44 void setType(QQmlType type) { m_type = std::move(type); }
45
46 // The compilation unit is stored for all composite type references that aren't
47 // self-references. It is needed both for object creation and for dependency
48 // checksum computation. Cyclic references between compilation units cannot
49 // occur because the type loader detects circular dependencies at resolution
50 // time, before buildTypeResolutionCaches runs.
51 // If the reference points to a type from the same compilation unit, it won't
52 // hold a compilation unit since the object creator can just use the one it has already.
54 {
55 Q_ASSERT(!m_isSelfReference);
56 return m_compilationUnit;
57 }
58
59 void setCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit)
60 {
61 Q_ASSERT(!m_isSelfReference);
62 m_compilationUnit = unit;
63 }
64
65 QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; }
66 void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
67 {
68 m_typePropertyCache = std::move(cache);
69 }
70
71 QTypeRevision version() const { return m_version; }
72 void setVersion(QTypeRevision version) { m_version = version; }
73
74 bool isFullyDynamicType() const { return m_isFullyDynamicType; }
75 void setFullyDynamicType(bool fullyDynamic) { m_isFullyDynamicType = fullyDynamic; }
76
77 // Whether the reference points to a type from the same compilation unit. This doesn't
78 // have to be the top-level type but can also be an inline component.
79 bool isSelfReference() const { return m_isSelfReference; }
80 void setIsSelfReference(bool selfReference) { m_isSelfReference = selfReference; }
81
82private:
83 QQmlType m_type;
84 QQmlPropertyCache::ConstPtr m_typePropertyCache;
85 QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_compilationUnit;
86
87 QTypeRevision m_version = QTypeRevision::zero();
88 // Types such as QQmlPropertyMap can add properties dynamically at run-time and
89 // therefore cannot have a property cache installed when instantiated.
90 bool m_isFullyDynamicType = false;
91 bool m_isSelfReference = false;
92};
93
94} // namespace QV4
95
96QT_END_NAMESPACE
97
98#endif // QV4RESOLVEDTYPEREFERNCE_P_H
QQmlPropertyCache::ConstPtr typePropertyCache() const
bool addToHash(QCryptographicHash *hash, QHash< quintptr, QByteArray > *checksums)
void setFullyDynamicType(bool fullyDynamic)
void setIsSelfReference(bool selfReference)
QQmlRefPointer< QV4::CompiledData::CompilationUnit > compilationUnit() const
void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
void setCompilationUnit(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &unit)
void setVersion(QTypeRevision version)
QQmlPropertyCache::ConstPtr createPropertyCache()
Combined button and popup list for selecting options.
Definition qjsvalue.h:24
bool qtTypeInherits(const QMetaObject *mo)