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 | |
4 | #ifndef QV4SETOBJECT_P_H |
5 | #define QV4SETOBJECT_P_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 "qv4object_p.h" |
19 | #include "qv4objectproto_p.h" |
20 | #include "qv4functionobject_p.h" |
21 | #include "qv4string_p.h" |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | namespace QV4 { |
26 | |
27 | class ESTable; |
28 | |
29 | namespace Heap { |
30 | |
31 | struct WeakSetCtor : FunctionObject { |
32 | void init(QV4::ExecutionContext *scope); |
33 | }; |
34 | |
35 | |
36 | struct SetCtor : WeakSetCtor { |
37 | void init(QV4::ExecutionContext *scope); |
38 | }; |
39 | |
40 | struct SetObject : Object { |
41 | static void markObjects(Heap::Base *that, MarkStack *markStack); |
42 | void init(); |
43 | void destroy(); |
44 | void removeUnmarkedKeys(); |
45 | |
46 | ESTable *esTable; |
47 | SetObject *nextWeakSet; |
48 | bool isWeakSet; |
49 | }; |
50 | |
51 | } |
52 | |
53 | |
54 | struct WeakSetCtor: FunctionObject |
55 | { |
56 | V4_OBJECT2(WeakSetCtor, FunctionObject) |
57 | |
58 | static ReturnedValue construct(const FunctionObject *f, const Value *argv, int argc, const Value *, bool weakSet); |
59 | |
60 | static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); |
61 | static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); |
62 | }; |
63 | |
64 | struct SetCtor : WeakSetCtor |
65 | { |
66 | V4_OBJECT2(SetCtor, WeakSetCtor) |
67 | |
68 | static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); |
69 | }; |
70 | |
71 | struct SetObject : Object |
72 | { |
73 | V4_OBJECT2(SetObject, Object) |
74 | V4_PROTOTYPE(setPrototype) |
75 | V4_NEEDS_DESTROY |
76 | }; |
77 | |
78 | struct WeakSetPrototype : Object |
79 | { |
80 | void init(ExecutionEngine *engine, Object *ctor); |
81 | |
82 | static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
83 | static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
84 | static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
85 | }; |
86 | |
87 | |
88 | struct SetPrototype : WeakSetPrototype |
89 | { |
90 | void init(ExecutionEngine *engine, Object *ctor); |
91 | |
92 | static ReturnedValue method_add(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
93 | static ReturnedValue method_clear(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
94 | static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
95 | static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
96 | static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
97 | static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
98 | static ReturnedValue method_get_size(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
99 | static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
100 | }; |
101 | |
102 | |
103 | } // namespace QV4 |
104 | |
105 | |
106 | QT_END_NAMESPACE |
107 | |
108 | #endif // QV4SETOBJECT_P_H |
109 | |