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
qv4managed_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
#
ifndef
QMLJS_MANAGED_H
5
#
define
QMLJS_MANAGED_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
"qv4global_p.h"
19
#
include
"qv4value_p.h"
20
#
include
"qv4enginebase_p.h"
21
#
include
<
private
/
qv4heap_p
.
h
>
22
#
include
<
private
/
qv4vtable_p
.
h
>
23
24
QT_BEGIN_NAMESPACE
25
26
namespace
QV4
{
27
28
#
define
Q_MANAGED_CHECK
29
template
<
typename
Type
>
inline
void
qt_check_for_QMANAGED_macro
(
const
Type
*
_q_argument
)
const
30
{
int
i
=
qYouForgotTheQ_MANAGED_Macro
(
this
,
_q_argument
)
;
i
=
i
+
1
;
}
31
32
template
<
typename
T>
33
inline
int
qYouForgotTheQ_MANAGED_Macro
(T, T) {
return
0; }
34
35
template
<
typename
T1,
typename
T2>
36
inline
void
qYouForgotTheQ_MANAGED_Macro
(T1, T2) {}
37
38
#
define
V4_MANAGED_SIZE_TEST
void
__dataTest
(
)
{
static_assert
(
sizeof
(
*
this
)
==
sizeof
(
Managed
)
,
"Classes derived from Managed can't have own data members."
)
;
}
39
40
#
define
V4_NEEDS_DESTROY
static
void
virtualDestroy
(
QV4
::
Heap
::
Base
*
b
)
{
static_cast
<
Data
*
>
(
b
)
->
destroy
(
)
;
}
41
42
43
#
define
V4_MANAGED_ITSELF
(
DataClass
,
superClass
)
44
public
:
45
Q_MANAGED_CHECK
46
typedef
QV4
::
Heap
::
DataClass
Data
;
47
typedef
superClass
SuperClass
;
48
static
const
QV4
::
VTable
static_vtbl
;
49
static
inline
const
QV4
::
VTable
*
staticVTable
(
)
{
return
&
static_vtbl
;
}
50
V4_MANAGED_SIZE_TEST
51
QV4
::
Heap
::
DataClass
*
d
(
)
const
{
return
static_cast
<
QV4
::
Heap
::
DataClass
*
>
(
m
(
)
)
;
}
52
53
#
define
V4_MANAGED
(
DataClass
,
superClass
)
54
private
:
55
DataClass
(
)
=
delete
;
56
Q_DISABLE_COPY
(
DataClass
)
57
V4_MANAGED_ITSELF
(
DataClass
,
superClass
)
58
static_assert
(
std
::
is_trivially_copyable_v
<
QV4
::
Heap
::
DataClass
>
)
;
59
static_assert
(
std
::
is_trivially_default_constructible_v
<
QV4
::
Heap
::
DataClass
>
)
;
60
61
#
define
Q_MANAGED_TYPE
(
type
)
62
public
:
63
enum
{
MyType
=
Type_
##
type
}
;
64
65
#
define
V4_INTERNALCLASS
(
c
)
66
static
Heap
::
InternalClass
*
defaultInternalClass
(
QV4
::
EngineBase
*
e
)
67
{
return
e
->
internalClasses
(
QV4
::
EngineBase
::
Class_
##
c
)
;
}
68
69
struct
Q_QML_EXPORT
Managed
:
Value
,
VTableBase
70
{
71
V4_MANAGED_ITSELF
(
Base
,
Managed
)
72
enum
{
73
IsExecutionContext
=
false
,
74
IsString
=
false
,
75
IsStringOrSymbol
=
false
,
76
IsObject
=
false
,
77
IsTailCallable
=
false
,
78
IsErrorObject
=
false
,
79
IsArrayData
=
false
80
};
81
private
:
82
void
*
operator
new
(
size_t
);
83
Managed
() =
delete
;
84
Q_DISABLE_COPY
(
Managed
)
85
86
public
:
87
enum
{
NInlineProperties
= 0 };
88
89
enum
Type
{
90
Type_Invalid
,
91
Type_String
,
92
Type_Object
,
93
Type_Symbol
,
94
Type_ArrayObject
,
95
Type_FunctionObject
,
96
Type_GeneratorObject
,
97
Type_BooleanObject
,
98
Type_NumberObject
,
99
Type_StringObject
,
100
Type_SymbolObject
,
101
Type_DateObject
,
102
Type_RegExpObject
,
103
Type_ErrorObject
,
104
Type_ArgumentsObject
,
105
Type_JsonObject
,
106
Type_MathObject
,
107
Type_ProxyObject
,
108
Type_UrlObject
,
109
Type_UrlSearchParamsObject
,
110
111
Type_ExecutionContext
,
112
Type_InternalClass
,
113
Type_SetIteratorObject
,
114
Type_MapIteratorObject
,
115
Type_ArrayIteratorObject
,
116
Type_StringIteratorObject
,
117
Type_ForInIterator
,
118
Type_RegExp
,
119
120
Type_V4Sequence
,
121
Type_QmlListProperty
,
122
Type_V4QObjectWrapper
,
123
Type_QMLTypeWrapper
,
124
Type_V4ReferenceObject
,
125
Type_QMLValueTypeWrapper
,
126
Type_MemberData
,
127
Type_ArrayData
,
128
Type_StringOrSymbol
,
129
};
130
Q_MANAGED_TYPE
(
Invalid
)
131
132
static
QString
typeToString
(
Type
);
133
134
Heap
::
InternalClass
*
internalClass
()
const
{
return
d
()->
internalClass
; }
135
const
VTable
*
vtable
()
const
{
return
d
()->
internalClass
->
vtable
; }
136
inline
ExecutionEngine
*
engine
()
const
{
return
internalClass
()->
engine
; }
137
138
bool
isV4SequenceType
()
const
{
return
d
()->
internalClass
->
vtable
->
type
==
Type_V4Sequence
; }
139
bool
isV4QObjectWrapper
()
const
{
return
d
()->
internalClass
->
vtable
->
type
==
Type_V4QObjectWrapper
; }
140
bool
isQmlListPropertyType
()
const
{
return
d
()->
internalClass
->
vtable
->
type
==
Type_QmlListProperty
; }
141
bool
isArrayLike
()
const
{
return
isArrayObject
() ||
isV4SequenceType
() ||
isQmlListPropertyType
(); }
142
143
bool
isArrayObject
()
const
{
return
d
()->
internalClass
->
vtable
->
type
==
Type_ArrayObject
; }
144
bool
isStringObject
()
const
{
return
d
()->
internalClass
->
vtable
->
type
==
Type_StringObject
; }
145
bool
isSymbolObject
()
const
{
return
d
()->
internalClass
->
vtable
->
type
==
Type_SymbolObject
; }
146
147
QString
className
()
const
;
148
149
bool
isEqualTo
(
const
Managed
*
other
)
const
150
{
return
d
()->
internalClass
->
vtable
->
isEqualTo
(
const_cast
<
Managed
*>(
this
),
const_cast
<
Managed
*>(
other
)); }
151
152
bool
inUse
()
const
{
return
d
()->
inUse
(); }
153
bool
markBit
()
const
{
return
d
()->
isMarked
(); }
154
inline
void
mark
(
MarkStack
*
markStack
);
155
156
Q_ALWAYS_INLINE
Heap
::
Base
*
heapObject
()
const
{
157
return
m
();
158
}
159
160
template
<
typename
T
>
inline
T
*
cast
() {
161
return
static_cast
<
T
*>(
this
);
162
}
163
template
<
typename
T
>
inline
const
T
*
cast
()
const
{
164
return
static_cast
<
const
T
*>(
this
);
165
}
166
167
protected
:
168
static
bool
virtualIsEqualTo
(
Managed
*
m
,
Managed
*
other
);
169
170
private
:
171
friend
class
MemoryManager
;
172
friend
struct
Identifiers
;
173
friend
struct
ObjectIterator
;
174
};
175
176
inline
void
Managed
::
mark
(
MarkStack
*
markStack
)
177
{
178
Q_ASSERT
(
m
());
179
m
()->
mark
(
markStack
);
180
}
181
182
template
<>
183
inline
const
Managed
*
Value
::
as
()
const
{
184
return
managed
();
185
}
186
187
template
<>
188
inline
const
Object
*
Value
::
as
()
const
{
189
return
objectValue
();
190
}
191
192
193
struct
InternalClass
:
Managed
194
{
195
V4_MANAGED_ITSELF
(
InternalClass
, Managed)
196
Q_MANAGED_TYPE
(InternalClass)
197
V4_INTERNALCLASS
(Empty)
198
V4_NEEDS_DESTROY
199
200
Q_REQUIRED_RESULT
Heap
::
InternalClass
*
changeVTable
(
const
VTable
*
vt
) {
201
return
d
()->
changeVTable
(
vt
);
202
}
203
Q_REQUIRED_RESULT
Heap
::
InternalClass
*
changePrototype
(
Heap
::
Object
*
proto
) {
204
return
d
()->
changePrototype
(
proto
);
205
}
206
Q_REQUIRED_RESULT
Heap
::
InternalClass
*
addMember
(
PropertyKey
identifier
,
PropertyAttributes
data
,
InternalClassEntry
*
entry
=
nullptr
) {
207
return
d
()->
addMember
(
identifier
,
data
,
entry
);
208
}
209
210
Q_REQUIRED_RESULT
Heap
::
InternalClass
*
changeMember
(
PropertyKey
identifier
,
PropertyAttributes
data
,
InternalClassEntry
*
entry
=
nullptr
) {
211
return
d
()->
changeMember
(
identifier
,
data
,
entry
);
212
}
213
214
void
operator
=(
Heap
::
InternalClass
*
ic
) {
215
Value
::
operator
=(
ic
);
216
}
217
};
218
219
}
220
221
222
QT_END_NAMESPACE
223
224
#
endif
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(StrictArgumentsObject, Object)
Definition
qv4argumentsobject_p.h:44
QV4::Heap::DECLARE_EXPORTED_HEAP_OBJECT
DECLARE_EXPORTED_HEAP_OBJECT(Object, Base)
Definition
qv4object_p.h:37
QV4::Heap::DECLARE_HEAP_OBJECT
DECLARE_HEAP_OBJECT(ArgumentsObject, Object)
Definition
qv4argumentsobject_p.h:32
QV4
Definition
qjsvalue.h:24
QV4::qYouForgotTheQ_MANAGED_Macro
int qYouForgotTheQ_MANAGED_Macro(T, T)
Definition
qv4managed_p.h:33
QV4::qYouForgotTheQ_MANAGED_Macro
void qYouForgotTheQ_MANAGED_Macro(T1, T2)
Definition
qv4managed_p.h:36
DEFINE_OBJECT_VTABLE
DEFINE_OBJECT_VTABLE(StrictArgumentsObject)
DEFINE_OBJECT_VTABLE
DEFINE_OBJECT_VTABLE(ArgumentsObject)
V4_MANAGED_SIZE_TEST
#define V4_MANAGED_SIZE_TEST
Definition
qv4managed_p.h:38
V4_NEEDS_DESTROY
#define V4_NEEDS_DESTROY
Definition
qv4managed_p.h:40
V4_MANAGED_ITSELF
#define V4_MANAGED_ITSELF(DataClass, superClass)
Definition
qv4managed_p.h:43
Q_MANAGED_TYPE
#define Q_MANAGED_TYPE(type)
Definition
qv4managed_p.h:61
V4_INTERNALCLASS
#define V4_INTERNALCLASS(c)
Definition
qv4managed_p.h:65
Q_MANAGED_CHECK
#define Q_MANAGED_CHECK
Definition
qv4managed_p.h:28
QV4::ArgumentsObject
Definition
qv4argumentsobject_p.h:56
QV4::ArgumentsObject::virtualGetLength
static qint64 virtualGetLength(const Managed *m)
Definition
qv4argumentsobject.cpp:193
QV4::ArgumentsObject::virtualDefineOwnProperty
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs)
Definition
qv4argumentsobject.cpp:83
QV4::ArgumentsObject::context
Heap::CallContext * context() const
Definition
qv4argumentsobject_p.h:60
QV4::ArgumentsObject::fullyCreate
void fullyCreate()
Definition
qv4argumentsobject.cpp:68
QV4::ArgumentsObject::virtualGet
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
Definition
qv4argumentsobject.cpp:120
QV4::ArgumentsObject::virtualOwnPropertyKeys
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
Definition
qv4argumentsobject.cpp:199
QV4::ArgumentsObject::isNonStrictArgumentsObject
static bool isNonStrictArgumentsObject(Managed *m)
Definition
qv4argumentsobject_p.h:63
QV4::ArgumentsObject::virtualDeleteProperty
static bool virtualDeleteProperty(Managed *m, PropertyKey id)
Definition
qv4argumentsobject.cpp:161
QV4::ArgumentsObject::fullyCreated
bool fullyCreated() const
Definition
qv4argumentsobject_p.h:61
QV4::ArgumentsObject::removeMapping
void removeMapping(uint arg)
Definition
qv4argumentsobject_p.h:83
QV4::ArgumentsObject::virtualGetOwnProperty
static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
Definition
qv4argumentsobject.cpp:171
QV4::ArgumentsObject::isMapped
bool isMapped(uint arg) const
Definition
qv4argumentsobject_p.h:79
QV4::ArgumentsObject::virtualPut
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
Definition
qv4argumentsobject.cpp:142
QV4::ArrayObject
Definition
qv4object_p.h:449
QV4::ArrayObject::virtualDefineOwnProperty
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
Definition
qv4object.cpp:1204
QV4::ArrayObject::virtualGetLength
static qint64 virtualGetLength(const Managed *m)
Definition
qv4object.cpp:1181
QV4::ArrayObject::toQStringList
QStringList toQStringList() const
Definition
qv4object.cpp:1187
QV4::ArrayObject::init
void init(ExecutionEngine *engine)
QV4::BooleanObject
Definition
qv4object_p.h:432
QV4::BooleanObject::value
bool value() const
Definition
qv4object_p.h:437
QV4::Heap::ArrayObject
Definition
qv4object_p.h:413
QV4::Heap::ArrayObject::init
void init(const QStringList &list)
Definition
qv4object.cpp:1162
QV4::Heap::ArrayObject::LengthPropertyIndex
@ LengthPropertyIndex
Definition
qv4object_p.h:415
QV4::Heap::ArrayObject::init
void init()
Definition
qv4object_p.h:418
QV4::Heap::BooleanObject
Definition
qv4object_p.h:393
QV4::Heap::BooleanObject::b
bool b
Definition
qv4object_p.h:400
QV4::Heap::BooleanObject::init
void init()
Definition
qv4object_p.h:394
QV4::Heap::BooleanObject::init
void init(bool b)
Definition
qv4object_p.h:395
QV4::Heap::InternalClass
Definition
qv4internalclass_p.h:317
QV4::Heap::NumberObject
Definition
qv4object_p.h:403
QV4::Heap::NumberObject::value
double value
Definition
qv4object_p.h:410
QV4::Heap::NumberObject::init
void init()
Definition
qv4object_p.h:404
QV4::Heap::NumberObject::init
void init(double val)
Definition
qv4object_p.h:405
QV4::InternalClass
Definition
qv4managed_p.h:194
QV4::NumberObject
Definition
qv4object_p.h:441
QV4::NumberObject::value
double value() const
Definition
qv4object_p.h:446
QV4::ObjectOwnPropertyKeyIterator
Definition
qv4object_p.h:382
QV4::ObjectOwnPropertyKeyIterator::memberIndex
uint memberIndex
Definition
qv4object_p.h:384
QV4::ObjectOwnPropertyKeyIterator::next
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
Definition
qv4object.cpp:331
QV4::ObjectOwnPropertyKeyIterator::iterateOverSymbols
bool iterateOverSymbols
Definition
qv4object_p.h:385
QV4::OwnPropertyKeyIterator
Definition
qv4vtable_p.h:28
QV4::PropertyKey
Definition
qv4propertykey_p.h:30
QV4::Property
Definition
qv4property_p.h:27
QV4::StrictArgumentsObject
Definition
qv4argumentsobject_p.h:90
qtdeclarative
src
qml
jsruntime
qv4managed_p.h
Generated on
for Qt by
1.18.0