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
qqmlvaluetypewrapper_p.h
Go to the documentation of this file.
1
// Copyright (C) 2016 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
QQMLVALUETYPEWRAPPER_P_H
6
#
define
QQMLVALUETYPEWRAPPER_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
<
QtCore
/
qglobal
.
h
>
20
#
include
<
private
/
qtqmlglobal_p
.
h
>
21
22
#
include
<
private
/
qv4referenceobject_p
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
class
QQmlValueType;
27
28
namespace
QV4
{
29
30
namespace
Heap
{
31
32
#
define
QQmlValueTypeWrapperMembers
(
class
,
Member
)
33
34
DECLARE_HEAP_OBJECT
(
QQmlValueTypeWrapper
,
ReferenceObject
) {
35
DECLARE_MARKOBJECTS(QQmlValueTypeWrapper);
36
37
void
init(
38
const
void
*data, QMetaType metaType,
const
QMetaObject *metaObject,
39
Object *object,
int
property, Flags flags)
40
{
41
ReferenceObject::init(object, property, flags | IsDirty);
42
setMetaType(metaType);
43
setMetaObject(metaObject);
44
if
(data)
45
setData(data);
46
}
47
48
QQmlValueTypeWrapper *detached()
const
;
49
50
void
destroy();
51
52
QMetaType metaType()
const
53
{
54
Q_ASSERT(m_metaType !=
nullptr
);
55
return
QMetaType(m_metaType);
56
}
57
58
void
setGadgetPtr(
void
*gadgetPtr) { m_gadgetPtr = gadgetPtr; }
59
void
*gadgetPtr()
const
{
return
m_gadgetPtr; }
60
61
const
QMetaObject *metaObject()
const
{
return
m_metaObject; }
62
63
void
setData(
const
void
*data)
64
{
65
const
QMetaType type = metaType();
66
void
*gadget = gadgetPtr();
67
if
(gadget) {
68
type.destruct(gadget);
69
}
else
{
70
gadget = ::operator
new
(type.sizeOf());
71
setGadgetPtr(gadget);
72
}
73
type.construct(gadget, data);
74
}
75
76
QVariant toVariant()
const
;
77
78
void
*storagePointer();
79
bool
setVariant(
const
QVariant &variant);
80
81
bool
readReference();
82
bool
writeBack(
int
propertyIndex = QV4::ReferenceObject::AllProperties);
83
84
private
:
85
void
setMetaObject(
const
QMetaObject *metaObject) { m_metaObject = metaObject; }
86
void
setMetaType(QMetaType metaType)
87
{
88
Q_ASSERT(metaType.isValid());
89
m_metaType = metaType.iface();
90
}
91
92
void
*m_gadgetPtr;
93
const
QtPrivate::QMetaTypeInterface *m_metaType;
94
const
QMetaObject *m_metaObject;
95
};
96
97
}
98
99
struct
Q_QML_EXPORT
QQmlValueTypeWrapper
:
public
ReferenceObject
100
{
101
V4_OBJECT2
(
QQmlValueTypeWrapper
,
ReferenceObject
)
102
V4_PROTOTYPE
(
valueTypeWrapperPrototype
)
103
Q_MANAGED_TYPE
(
QMLValueTypeWrapper
)
104
V4_NEEDS_DESTROY
105
106
public
:
107
108
static
ReturnedValue
create
(
109
ExecutionEngine
*
engine
,
const
void
*
data
,
const
QMetaObject
*
metaObject
,
110
QMetaType
type
,
Heap
::
Object
*
object
,
int
property
,
Heap
::
ReferenceObject
::
Flags
flags
);
111
static
ReturnedValue
create
(
112
ExecutionEngine
*
engine
,
Heap
::
QQmlValueTypeWrapper
*
cloneFrom
,
Heap
::
Object
*
object
);
113
static
ReturnedValue
create
(
114
ExecutionEngine
*
engine
,
const
void
*,
const
QMetaObject
*
metaObject
,
QMetaType
type
);
115
116
QVariant
toVariant
()
const
;
117
118
template
<
typename
ValueType
>
119
ValueType
*
cast
()
const
120
{
121
if
(
QMetaType
::
fromType
<
ValueType
>() !=
d
()->
metaType
())
122
return
nullptr
;
123
if
(
d
()->
isReference
() && !
readReferenceValue
())
124
return
nullptr
;
125
return
static_cast
<
ValueType
*>(
d
()->
gadgetPtr
());
126
}
127
128
bool
toGadget
(
void
*
data
)
const
;
129
bool
isEqual
(
const
QVariant
&
value
)
const
;
130
int
typeId
()
const
;
131
QMetaType
type
()
const
;
132
bool
write
(
QObject
*
target
,
int
propertyIndex
)
const
;
133
bool
readReferenceValue
()
const
{
return
d
()->
readReference
(); }
134
const
QMetaObject
*
metaObject
()
const
{
return
d
()->
metaObject
(); }
135
136
QQmlPropertyData
dataForPropertyKey
(
PropertyKey
id
)
const
;
137
138
static
ReturnedValue
virtualGet
(
const
Managed
*
m
,
PropertyKey
id
,
const
Value
*
receiver
,
bool
*
hasProperty
);
139
static
bool
virtualPut
(
Managed
*
m
,
PropertyKey
id
,
const
Value
&
value
,
Value
*
receiver
);
140
static
bool
virtualIsEqualTo
(
Managed
*
m
,
Managed
*
other
);
141
static
bool
virtualHasProperty
(
const
Managed
*
m
,
PropertyKey
id
);
142
static
PropertyAttributes
virtualGetOwnProperty
(
const
Managed
*
m
,
PropertyKey
id
,
Property
*
p
);
143
static
OwnPropertyKeyIterator
*
virtualOwnPropertyKeys
(
const
Object
*
m
,
Value
*
target
);
144
static
ReturnedValue
method_toString
(
const
FunctionObject
*
b
,
const
Value
*
thisObject
,
const
Value
*
argv
,
int
argc
);
145
static
ReturnedValue
virtualResolveLookupGetter
(
const
Object
*
object
,
ExecutionEngine
*
engine
,
Lookup
*
lookup
);
146
static
bool
virtualResolveLookupSetter
(
Object
*
object
,
ExecutionEngine
*
engine
,
Lookup
*
lookup
,
const
Value
&
value
);
147
148
static
void
initProto
(
ExecutionEngine
*
v4
);
149
static
int
virtualMetacall
(
Object
*
object
,
QMetaObject
::
Call
call
,
int
index
,
void
**
a
);
150
151
static
ReturnedValue
getGadgetProperty
(
152
ExecutionEngine
*
engine
,
Heap
::
QQmlValueTypeWrapper
*
valueTypeWrapper
,
153
QMetaType
metaType
,
quint16
coreIndex
,
bool
isFunction
,
bool
isEnum
);
154
};
155
156
}
157
158
QT_END_NAMESPACE
159
160
#
endif
// QQMLVALUETYPEWRAPPER_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
Definition
qjsvalue.h:24
QV4::referenceFlags
static Heap::ReferenceObject::Flags referenceFlags(const QMetaObject *metaObject, int index)
Definition
qqmlvaluetypewrapper.cpp:270
QV4::doStaticReadCall
static void doStaticReadCall(const QMetaObject *metaObject, Heap::QQmlValueTypeWrapper *valueTypeWrapper, int index, void **args)
Definition
qqmlvaluetypewrapper.cpp:277
VALUE_TYPE_LOAD
#define VALUE_TYPE_LOAD(metatype, cpptype, constructor)
QV4::QQmlValueTypeWrapperOwnPropertyKeyIterator
Definition
qqmlvaluetypewrapper.cpp:435
QV4::QQmlValueTypeWrapperOwnPropertyKeyIterator::next
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
Definition
qqmlvaluetypewrapper.cpp:442
QV4::QQmlValueTypeWrapperOwnPropertyKeyIterator::~QQmlValueTypeWrapperOwnPropertyKeyIterator
~QQmlValueTypeWrapperOwnPropertyKeyIterator() override=default
QV4::QQmlValueTypeWrapperOwnPropertyKeyIterator::propertyIndex
int propertyIndex
Definition
qqmlvaluetypewrapper.cpp:436
QV4::QQmlValueTypeWrapper
Definition
qqmlvaluetypewrapper_p.h:100
qtdeclarative
src
qml
qml
qqmlvaluetypewrapper_p.h
Generated on
for Qt by
1.18.0