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
25QT_BEGIN_NAMESPACE
26
27class QCryptographicHash;
28namespace QV4 {
29
31{
33public:
35
37 bool addToHash(QCryptographicHash *hash, QHash<quintptr, QByteArray> *checksums);
38
39 void doDynamicTypeCheck();
40
41 QQmlType type() const { return m_type; }
42 void setType(QQmlType type) { m_type = std::move(type); }
43
44 // The compilation unit is only stored for type references we need to create objects from.
45 // For everything else the QQmlType and QQmlPropertyCache are enough.
46 // Furthermore, if the reference points to a type from the same compilation unit, it also won't
47 // hold a compilation unit since the object creator can just use the one it has already.
49 {
50 Q_ASSERT(!m_isSelfReference);
51 return m_compilationUnit;
52 }
53
54 void setCompilationUnit(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &unit)
55 {
56 Q_ASSERT(!m_isSelfReference);
57 m_compilationUnit = unit;
58 }
59
60 QQmlPropertyCache::ConstPtr typePropertyCache() const { return m_typePropertyCache; }
61 void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
62 {
63 m_typePropertyCache = std::move(cache);
64 }
65
66 QTypeRevision version() const { return m_version; }
67 void setVersion(QTypeRevision version) { m_version = version; }
68
69 bool isFullyDynamicType() const { return m_isFullyDynamicType; }
70 void setFullyDynamicType(bool fullyDynamic) { m_isFullyDynamicType = fullyDynamic; }
71
72 // Whether the reference points to a type from the same compilation unit. This doesn't
73 // have to be the top-level type but can also be an inline component.
74 bool isSelfReference() const { return m_isSelfReference; }
75 void setIsSelfReference(bool selfReference) { m_isSelfReference = selfReference; }
76
77private:
78 QQmlType m_type;
79 QQmlPropertyCache::ConstPtr m_typePropertyCache;
80 QQmlRefPointer<QV4::CompiledData::CompilationUnit> m_compilationUnit;
81
82 QTypeRevision m_version = QTypeRevision::zero();
83 // Types such as QQmlPropertyMap can add properties dynamically at run-time and
84 // therefore cannot have a property cache installed when instantiated.
85 bool m_isFullyDynamicType = false;
86 bool m_isSelfReference = false;
87};
88
89} // namespace QV4
90
91QT_END_NAMESPACE
92
93#endif // QV4RESOLVEDTYPEREFERNCE_P_H
QQmlPropertyCache::ConstPtr typePropertyCache() const
bool addToHash(QCryptographicHash *hash, QHash< quintptr, QByteArray > *checksums)
QQmlRefPointer< QV4::CompiledData::CompilationUnit > compilationUnit()
void setFullyDynamicType(bool fullyDynamic)
void setIsSelfReference(bool selfReference)
void setTypePropertyCache(QQmlPropertyCache::ConstPtr cache)
void setCompilationUnit(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &unit)
void setVersion(QTypeRevision version)
QQmlPropertyCache::ConstPtr createPropertyCache()
Returns the property cache, creating one if it doesn't already exist.
Definition qjsvalue.h:23
bool qtTypeInherits(const QMetaObject *mo)