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
qv4persistent_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
QV4PERSISTENT_H
5
#
define
QV4PERSISTENT_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
"qv4value_p.h"
19
#
include
"qv4managed_p.h"
20
21
QT_BEGIN_NAMESPACE
22
23
namespace
QV4
{
24
25
struct
Q_QML_EXPORT
PersistentValueStorage
26
{
27
PersistentValueStorage
(
ExecutionEngine
*
engine
);
28
~
PersistentValueStorage
();
29
30
Value
*
allocate
();
31
static
void
free
(
Value
*
v
)
32
{
33
if
(
v
)
34
freeUnchecked
(
v
);
35
}
36
37
void
mark
(
MarkStack
*
markStack
);
38
39
struct
Iterator
{
40
Iterator
(
void
*
p
,
int
idx
);
41
Iterator
(
const
Iterator
&
o
);
42
Iterator
&
operator
=(
const
Iterator
&
o
);
43
~
Iterator
();
44
void
*
p
;
45
int
index
;
46
Iterator
&
operator
++();
47
bool
operator
!=(
const
Iterator
&
other
) {
48
return
p
!=
other
.
p
||
index
!=
other
.
index
;
49
}
50
Value
&
operator
*();
51
};
52
Iterator
begin
() {
return
Iterator
(
firstPage
, 0); }
53
Iterator
end
() {
return
Iterator
(
nullptr
, 0); }
54
55
void
clearFreePageHint
();
56
57
static
ExecutionEngine
*
getEngine
(
const
Value
*
v
);
58
59
ExecutionEngine
*
engine
;
60
void
*
firstPage
;
61
void
*
freePageHint
=
nullptr
;
62
private
:
63
static
void
freeUnchecked
(
Value
*
v
);
64
static
void
freePage
(
void
*
page
);
65
};
66
67
class
Q_QML_EXPORT
PersistentValue
68
{
69
public
:
70
constexpr
PersistentValue
()
noexcept
=
default
;
71
PersistentValue
(
const
PersistentValue
&
other
);
72
PersistentValue
&
operator
=(
const
PersistentValue
&
other
);
73
74
PersistentValue
(
PersistentValue
&&
other
)
noexcept
:
val
(
std
::
exchange
(
other
.
val
,
nullptr
)) {}
75
void
swap
(
PersistentValue
&
other
)
noexcept
{
qt_ptr_swap
(
val
,
other
.
val
); }
76
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP
(
PersistentValue
)
77
~
PersistentValue
() {
PersistentValueStorage
::
free
(
val
); }
78
79
PersistentValue
&
operator
=(
const
WeakValue
&
other
);
80
PersistentValue
&
operator
=(
Object
*
object
);
81
82
PersistentValue
(
ExecutionEngine
*
engine
,
const
Value
&
value
);
83
PersistentValue
(
ExecutionEngine
*
engine
,
ReturnedValue
value
);
84
PersistentValue
(
ExecutionEngine
*
engine
,
Object
*
object
);
85
86
void
set
(
ExecutionEngine
*
engine
,
const
Value
&
value
);
87
void
set
(
ExecutionEngine
*
engine
,
ReturnedValue
value
);
88
void
set
(
ExecutionEngine
*
engine
,
Heap
::
Base
*
obj
);
89
90
ReturnedValue
value
()
const
{
91
return
(
val
?
val
->
asReturnedValue
() :
Encode
::
undefined
());
92
}
93
Value
*
valueRef
()
const
{
94
return
val
;
95
}
96
Managed
*
asManaged
()
const
{
97
if
(!
val
)
98
return
nullptr
;
99
return
val
->
managed
();
100
}
101
template
<
typename
T
>
102
T
*
as
()
const
{
103
if
(!
val
)
104
return
nullptr
;
105
return
val
->
as
<
T
>();
106
}
107
108
ExecutionEngine
*
engine
()
const
{
109
if
(!
val
)
110
return
nullptr
;
111
return
PersistentValueStorage
::
getEngine
(
val
);
112
}
113
114
bool
isUndefined
()
const
{
return
!
val
||
val
->
isUndefined
(); }
115
bool
isNullOrUndefined
()
const
{
return
!
val
||
val
->
isNullOrUndefined
(); }
116
void
clear
() {
117
PersistentValueStorage
::
free
(
val
);
118
val
=
nullptr
;
119
}
120
bool
isEmpty
() {
return
!
val
; }
121
122
private
:
123
Value
*
val
=
nullptr
;
124
};
125
126
class
Q_QML_EXPORT
WeakValue
127
{
128
public
:
129
WeakValue
() {}
130
WeakValue
(
const
WeakValue
&
other
);
131
WeakValue
(
ExecutionEngine
*
engine
,
const
Value
&
value
);
132
WeakValue
&
operator
=(
const
WeakValue
&
other
);
133
~
WeakValue
();
134
135
void
set
(
ExecutionEngine
*
engine
,
const
Value
&
value
);
136
137
void
set
(
ExecutionEngine
*
engine
,
ReturnedValue
value
);
138
139
void
set
(
ExecutionEngine
*
engine
,
Heap
::
Base
*
obj
);
140
141
ReturnedValue
value
()
const
{
142
return
(
val
?
val
->
asReturnedValue
() :
Encode
::
undefined
());
143
}
144
Value
*
valueRef
()
const
{
145
return
val
;
146
}
147
Managed
*
asManaged
()
const
{
148
if
(!
val
)
149
return
nullptr
;
150
return
val
->
managed
();
151
}
152
template
<
typename
T
>
153
T
*
as
()
const
{
154
if
(!
val
)
155
return
nullptr
;
156
return
val
->
as
<
T
>();
157
}
158
159
ExecutionEngine
*
engine
()
const
{
160
if
(!
val
)
161
return
nullptr
;
162
return
PersistentValueStorage
::
getEngine
(
val
);
163
}
164
165
bool
isUndefined
()
const
{
return
!
val
||
val
->
isUndefined
(); }
166
bool
isNullOrUndefined
()
const
{
return
!
val
||
val
->
isNullOrUndefined
(); }
167
void
clear
() {
free
(); }
168
169
void
markOnce
(
MarkStack
*
markStack
);
170
171
private
:
172
Value
*
val
=
nullptr
;
173
174
private
:
175
Q_NEVER_INLINE
void
allocVal
(
ExecutionEngine
*
engine
);
176
177
void
free
();
178
};
179
180
}
// namespace QV4
181
182
QT_END_NAMESPACE
183
184
#
endif
QV4::PersistentValue
Definition
qv4persistent_p.h:68
QV4::WeakValue
Definition
qv4persistent_p.h:127
QPlatformGraphicsBufferHelper
\inmodule QtGui
QV4
Definition
qjsvalue.h:23
WTF
Definition
qv4engine_p.h:33
QV4::PersistentValueStorage
Definition
qv4persistent_p.h:26
qtdeclarative
src
qml
jsruntime
qv4persistent_p.h
Generated on
for Qt by
1.14.0