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