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
qv4estable_p.h
Go to the documentation of this file.
1
// Copyright (C) 2018 Crimson AS <info@crimson.no>
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
//
6
// W A R N I N G
7
// -------------
8
//
9
// This file is not part of the Qt API. It exists purely as an
10
// implementation detail. This header file may change from version to
11
// version without notice, or even be removed.
12
//
13
// We mean it.
14
//
15
16
#
ifndef
QV4ESTABLE_P_H
17
#
define
QV4ESTABLE_P_H
18
19
#
include
<
vector
>
20
#
include
<
limits
>
21
22
#
include
<
QtCore
/
q20vector
.
h
>
23
24
#
include
"qv4value_p.h"
25
26
class
tst_qv4estable;
27
28
QT_BEGIN_NAMESPACE
29
30
namespace
QV4
{
31
32
class
Q_AUTOTEST_EXPORT
ESTable
33
{
34
public
:
35
// Can be used to observe changes in the position of the element at index pivot by registering an instance
36
// with `observeShifts`.
37
// This is used by implementations of `forEach`, for `ESTable`
38
// backed collections, to respect the correct order of iteration
39
// in the face of a `callbackFn` that mutates the collection
40
// itself.
41
struct
ShiftObserver
{
42
static
constexpr
uint
OUT_OF_TABLE
=
std
::
numeric_limits
<
uint
>::
max
();
43
44
uint
pivot
= 0;
45
46
void
next
() {
47
pivot
=
pivot
==
OUT_OF_TABLE
? 0 :
pivot
+ 1;
48
}
49
};
50
51
public
:
52
ESTable
();
53
~
ESTable
();
54
55
void
markObjects
(
MarkStack
*
s
,
bool
isWeakMap
);
56
void
clear
();
57
void
set
(
const
Value
&
k
,
const
Value
&
v
);
58
bool
has
(
const
Value
&
k
)
const
;
59
ReturnedValue
get
(
const
Value
&
k
,
bool
*
hasValue
=
nullptr
)
const
;
60
bool
remove
(
const
Value
&
k
);
61
uint
size
()
const
;
62
void
iterate
(
uint
idx
,
Value
*
k
,
Value
*
v
);
63
64
void
removeUnmarkedKeys
();
65
66
inline
void
observeShifts
(
ShiftObserver
&
observer
) {
67
if
(
std
::
find
(
m_observers
.
cbegin
(),
m_observers
.
cend
(), &
observer
) ==
m_observers
.
cend
())
68
m_observers
.
push_back
(&
observer
);
69
}
70
inline
void
stopObservingShifts
(
ShiftObserver
&
observer
) {
71
q20
::
erase
(
m_observers
, &
observer
);
72
}
73
74
private
:
75
friend
class
::
tst_qv4estable
;
76
77
Value
*
m_keys
=
nullptr
;
78
Value
*
m_values
=
nullptr
;
79
uint
m_size
= 0;
80
uint
m_capacity
= 0;
81
82
std
::
vector
<
ShiftObserver
*>
m_observers
;
83
};
84
85
}
// namespace QV4
86
87
QT_END_NAMESPACE
88
89
#
endif
QV4::ESTable
Definition
qv4estable_p.h:33
QV4
Definition
qjsvalue.h:23
qtdeclarative
src
qml
jsruntime
qv4estable_p.h
Generated on
for Qt by
1.14.0