Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qv4variantassociationobject_p.h
Go to the documentation of this file.
1
// Copyright (C) 2024 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
QV4VARIANTASSOCIATIONOBJECT_P_H_
6
#
define
QV4VARIANTASSOCIATIONOBJECT_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
<
private
/
qv4object_p
.
h
>
20
#
include
<
private
/
qv4referenceobject_p
.
h
>
21
#
include
<
private
/
qv4value_p
.
h
>
22
23
#
include
<
QtCore
/
QVariantMap
>
24
#
include
<
QtCore
/
QVariantHash
>
25
26
QT_BEGIN_NAMESPACE
27
28
namespace
QV4
{
29
30
struct
Q_QML_EXPORT
VariantAssociationPrototype
:
public
QV4
::
Object
31
{
32
V4_PROTOTYPE
(
objectPrototype
);
33
34
static
ReturnedValue
fromQVariantMap
(
35
ExecutionEngine
*
engine
,
const
QVariantMap
&
variantMap
,
QV4
::
Heap
::
Object
*
container
,
36
int
property
,
Heap
::
ReferenceObject
::
Flags
flags
);
37
38
static
ReturnedValue
fromQVariantHash
(
39
ExecutionEngine
*
engine
,
const
QVariantHash
&
variantHash
,
QV4
::
Heap
::
Object
*
container
,
40
int
property
,
Heap
::
ReferenceObject
::
Flags
flags
);
41
};
42
43
namespace
Heap
{
44
45
#
define
VariantAssociationObjectMembers
(
class
,
Member
)
46
Member
(
class
,
Pointer
,
ArrayObject
*
,
propertyIndexMapping
)
;
47
48
DECLARE_HEAP_OBJECT
(
VariantAssociationObject
,
ReferenceObject
)
49
{
50
DECLARE_MARKOBJECTS(VariantAssociationObject)
51
52
enum
class
AssociationType: quint8
53
{
54
VariantMap,
55
VariantHash
56
};
57
58
void
init(
59
const
QVariantMap &variantMap, QV4::Heap::Object *container,
int
property,
60
Heap::ReferenceObject::Flags flags);
61
62
void
init(
63
const
QVariantHash &variantHash, QV4::Heap::Object *container,
int
property,
64
Heap::ReferenceObject::Flags flags);
65
66
void
destroy();
67
68
void
*storagePointer() {
return
&m_variantAssociation; }
69
70
QVariant toVariant();
71
bool
setVariant(
const
QVariant &variant);
72
73
template
<
typename
Association>
74
void
createElementWrappers(
const
Association &association)
75
{
76
Q_ASSERT(!object());
77
78
QV4::Scope scope(internalClass->engine);
79
QV4::ScopedObject self(scope,
this
);
80
QV4::ScopedString key(scope);
81
QV4::ScopedValue val(scope);
82
for
(
auto
it = association.begin(), end = association.end(); it != end; ++it) {
83
key = scope.engine->newString(it.key());
84
val = scope.engine->fromVariant(*it);
85
self->put(key, val);
86
}
87
}
88
89
QV4::ReturnedValue getElement(
const
QString &id,
bool
*hasProperty);
90
91
VariantAssociationObject *detached();
92
93
// The alignment calculation needs to be out of the
94
// `alignas` due to a GCC 8.3 bug (that at the time of
95
// writing is used on the QNX 7.1 platform).
96
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94929
97
static
constexpr
auto
alignment = std::max(
alignof
(QVariantMap),
alignof
(QVariantHash));
98
alignas
(alignment)
99
std::byte m_variantAssociation[std::max(
sizeof
(QVariantMap),
sizeof
(QVariantHash))];
100
101
AssociationType m_type;
102
};
103
104
}
// namespace Heap
105
106
struct
Q_QML_EXPORT
VariantAssociationObject
:
public
QV4
::
ReferenceObject
107
{
108
V4_OBJECT2
(
VariantAssociationObject
,
QV4
::
ReferenceObject
);
109
V4_PROTOTYPE
(
variantAssociationPrototype
);
110
V4_NEEDS_DESTROY
111
112
static
bool
virtualPut
(
113
Managed
*
that
,
PropertyKey
id
,
const
QV4
::
Value
&
value
,
Value
*
receiver
);
114
static
QV4
::
ReturnedValue
virtualGet
(
115
const
QV4
::
Managed
*
that
,
PropertyKey
id
,
const
Value
*
receiver
,
bool
*
hasProperty
);
116
117
static
bool
virtualDeleteProperty
(
QV4
::
Managed
*
that
,
PropertyKey
id
);
118
119
static
QV4
::
OwnPropertyKeyIterator
*
virtualOwnPropertyKeys
(
const
Object
*
m
,
Value
*
target
);
120
121
static
PropertyAttributes
virtualGetOwnProperty
(
const
Managed
*
m
,
PropertyKey
id
,
Property
*
p
);
122
123
static
int
virtualMetacall
(
Object
*
object
,
QMetaObject
::
Call
call
,
int
index
,
void
**
a
);
124
};
125
126
}
// namespace QV4
127
128
QT_END_NAMESPACE
129
130
#
endif
// QV4VARIANTASSOCIATIONOBJECT_P_H_
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QV4::Heap
Definition
qv4compileddata_p.h:76
QV4::Heap::DECLARE_HEAP_OBJECT
DECLARE_HEAP_OBJECT(QmlContext, ExecutionContext)
Definition
qv4qmlcontext_p.h:50
QV4::Heap::createDetached
VariantAssociationObject * createDetached(QV4::ExecutionEngine *engine, const Association &association)
Definition
qv4variantassociationobject.cpp:199
QV4
Definition
qjsvalue.h:24
visitVariantAssociation
Return visitVariantAssociation(const QV4::Heap::VariantAssociationObject *association, Callable &&callable)
Definition
qv4variantassociationobject.cpp:79
visitVariantAssociation
Return visitVariantAssociation(QV4::Heap::VariantAssociationObject *association, MapCallable &&mapCallable, HashCallable &&hashCallable)
Definition
qv4variantassociationobject.cpp:61
visitVariantAssociation
Return visitVariantAssociation(QV4::Heap::VariantAssociationObject *association, Callable &&callable)
Definition
qv4variantassociationobject.cpp:86
QV4::VariantAssociationObject
Definition
qv4variantassociationobject_p.h:107
QV4::VariantAssociationPrototype
Definition
qv4variantassociationobject_p.h:31
qtdeclarative
src
qml
jsruntime
qv4variantassociationobject_p.h
Generated on
for Qt by
1.18.0