summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Forward.h
blob: f4511a66a80cde27b401c9309daadb675cafd1ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
 * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#define JS_DECLARE_NATIVE_FUNCTION(name) \
    static JS::Value name(JS::VM&, JS::GlobalObject&)

#define JS_DECLARE_NATIVE_GETTER(name) \
    static JS::Value name(JS::VM&, JS::GlobalObject&)

#define JS_DECLARE_NATIVE_SETTER(name) \
    static void name(JS::VM&, JS::GlobalObject&, JS::Value)

#define JS_DEFINE_NATIVE_FUNCTION(name) \
    JS::Value name([[maybe_unused]] JS::VM& vm, [[maybe_unused]] JS::GlobalObject& global_object)

#define JS_DEFINE_NATIVE_GETTER(name) \
    JS::Value name([[maybe_unused]] JS::VM& vm, [[maybe_unused]] JS::GlobalObject& global_object)

#define JS_DEFINE_NATIVE_SETTER(name) \
    void name([[maybe_unused]] JS::VM& vm, [[maybe_unused]] JS::GlobalObject& global_object, [[maybe_unused]] JS::Value value)

// NOTE: Proxy is not included here as it doesn't have a prototype - m_proxy_constructor is initialized separately.
#define JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES                                                                               \
    __JS_ENUMERATE(AggregateError, aggregate_error, AggregateErrorPrototype, AggregateErrorConstructor, void)                         \
    __JS_ENUMERATE(Array, array, ArrayPrototype, ArrayConstructor, void)                                                              \
    __JS_ENUMERATE(ArrayBuffer, array_buffer, ArrayBufferPrototype, ArrayBufferConstructor, void)                                     \
    __JS_ENUMERATE(BigIntObject, bigint, BigIntPrototype, BigIntConstructor, void)                                                    \
    __JS_ENUMERATE(BooleanObject, boolean, BooleanPrototype, BooleanConstructor, void)                                                \
    __JS_ENUMERATE(DataView, data_view, DataViewPrototype, DataViewConstructor, void)                                                 \
    __JS_ENUMERATE(Date, date, DatePrototype, DateConstructor, void)                                                                  \
    __JS_ENUMERATE(Error, error, ErrorPrototype, ErrorConstructor, void)                                                              \
    __JS_ENUMERATE(FinalizationRegistry, finalization_registry, FinalizationRegistryPrototype, FinalizationRegistryConstructor, void) \
    __JS_ENUMERATE(FunctionObject, function, FunctionPrototype, FunctionConstructor, void)                                            \
    __JS_ENUMERATE(GeneratorFunction, generator_function, GeneratorFunctionPrototype, GeneratorFunctionConstructor, void)             \
    __JS_ENUMERATE(Map, map, MapPrototype, MapConstructor, void)                                                                      \
    __JS_ENUMERATE(NumberObject, number, NumberPrototype, NumberConstructor, void)                                                    \
    __JS_ENUMERATE(Object, object, ObjectPrototype, ObjectConstructor, void)                                                          \
    __JS_ENUMERATE(Promise, promise, PromisePrototype, PromiseConstructor, void)                                                      \
    __JS_ENUMERATE(RegExpObject, regexp, RegExpPrototype, RegExpConstructor, void)                                                    \
    __JS_ENUMERATE(Set, set, SetPrototype, SetConstructor, void)                                                                      \
    __JS_ENUMERATE(StringObject, string, StringPrototype, StringConstructor, void)                                                    \
    __JS_ENUMERATE(SymbolObject, symbol, SymbolPrototype, SymbolConstructor, void)                                                    \
    __JS_ENUMERATE(WeakMap, weak_map, WeakMapPrototype, WeakMapConstructor, void)                                                     \
    __JS_ENUMERATE(WeakRef, weak_ref, WeakRefPrototype, WeakRefConstructor, void)                                                     \
    __JS_ENUMERATE(WeakSet, weak_set, WeakSetPrototype, WeakSetConstructor, void)

#define JS_ENUMERATE_NATIVE_OBJECTS                 \
    JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES \
    __JS_ENUMERATE(TypedArray, typed_array, TypedArrayPrototype, TypedArrayConstructor, void)

#define JS_ENUMERATE_NATIVE_ERRORS                                                                                                         \
    __JS_ENUMERATE(EvalError, eval_error, EvalErrorPrototype, EvalErrorConstructor, void)                                                  \
    __JS_ENUMERATE(InternalError, internal_error, InternalErrorPrototype, InternalErrorConstructor, void)                                  \
    __JS_ENUMERATE(InvalidCharacterError, invalid_character_error, InvalidCharacterErrorPrototype, InvalidCharacterErrorConstructor, void) \
    __JS_ENUMERATE(RangeError, range_error, RangeErrorPrototype, RangeErrorConstructor, void)                                              \
    __JS_ENUMERATE(ReferenceError, reference_error, ReferenceErrorPrototype, ReferenceErrorConstructor, void)                              \
    __JS_ENUMERATE(SyntaxError, syntax_error, SyntaxErrorPrototype, SyntaxErrorConstructor, void)                                          \
    __JS_ENUMERATE(TypeError, type_error, TypeErrorPrototype, TypeErrorConstructor, void)                                                  \
    __JS_ENUMERATE(URIError, uri_error, URIErrorPrototype, URIErrorConstructor, void)

#define JS_ENUMERATE_TYPED_ARRAYS                                                                                               \
    __JS_ENUMERATE(Uint8Array, uint8_array, Uint8ArrayPrototype, Uint8ArrayConstructor, u8)                                     \
    __JS_ENUMERATE(Uint8ClampedArray, uint8_clamped_array, Uint8ClampedArrayPrototype, Uint8ClampedArrayConstructor, ClampedU8) \
    __JS_ENUMERATE(Uint16Array, uint16_array, Uint16ArrayPrototype, Uint16ArrayConstructor, u16)                                \
    __JS_ENUMERATE(Uint32Array, uint32_array, Uint32ArrayPrototype, Uint32ArrayConstructor, u32)                                \
    __JS_ENUMERATE(BigUint64Array, big_uint64_array, BigUint64ArrayPrototype, BigUint64ArrayConstructor, u64)                   \
    __JS_ENUMERATE(Int8Array, int8_array, Int8ArrayPrototype, Int8ArrayConstructor, i8)                                         \
    __JS_ENUMERATE(Int16Array, int16_array, Int16ArrayPrototype, Int16ArrayConstructor, i16)                                    \
    __JS_ENUMERATE(Int32Array, int32_array, Int32ArrayPrototype, Int32ArrayConstructor, i32)                                    \
    __JS_ENUMERATE(BigInt64Array, big_int64_array, BigInt64ArrayPrototype, BigInt64ArrayConstructor, i64)                       \
    __JS_ENUMERATE(Float32Array, float32_array, Float32ArrayPrototype, Float32ArrayConstructor, float)                          \
    __JS_ENUMERATE(Float64Array, float64_array, Float64ArrayPrototype, Float64ArrayConstructor, double)

#define JS_ENUMERATE_INTL_OBJECTS                                                               \
    __JS_ENUMERATE(DisplayNames, display_names, DisplayNamesPrototype, DisplayNamesConstructor) \
    __JS_ENUMERATE(ListFormat, list_format, ListFormatPrototype, ListFormatConstructor)         \
    __JS_ENUMERATE(Locale, locale, LocalePrototype, LocaleConstructor)                          \
    __JS_ENUMERATE(NumberFormat, number_format, NumberFormatPrototype, NumberFormatConstructor)

#define JS_ENUMERATE_TEMPORAL_OBJECTS                                                                    \
    __JS_ENUMERATE(Calendar, calendar, CalendarPrototype, CalendarConstructor)                           \
    __JS_ENUMERATE(Duration, duration, DurationPrototype, DurationConstructor)                           \
    __JS_ENUMERATE(Instant, instant, InstantPrototype, InstantConstructor)                               \
    __JS_ENUMERATE(PlainDate, plain_date, PlainDatePrototype, PlainDateConstructor)                      \
    __JS_ENUMERATE(PlainDateTime, plain_date_time, PlainDateTimePrototype, PlainDateTimeConstructor)     \
    __JS_ENUMERATE(PlainMonthDay, plain_month_day, PlainMonthDayPrototype, PlainMonthDayConstructor)     \
    __JS_ENUMERATE(PlainTime, plain_time, PlainTimePrototype, PlainTimeConstructor)                      \
    __JS_ENUMERATE(PlainYearMonth, plain_year_month, PlainYearMonthPrototype, PlainYearMonthConstructor) \
    __JS_ENUMERATE(TimeZone, time_zone, TimeZonePrototype, TimeZoneConstructor)                          \
    __JS_ENUMERATE(ZonedDateTime, zoned_date_time, ZonedDateTimePrototype, ZonedDateTimeConstructor)

#define JS_ENUMERATE_ITERATOR_PROTOTYPES                         \
    __JS_ENUMERATE(Iterator, iterator)                           \
    __JS_ENUMERATE(ArrayIterator, array_iterator)                \
    __JS_ENUMERATE(MapIterator, map_iterator)                    \
    __JS_ENUMERATE(RegExpStringIterator, regexp_string_iterator) \
    __JS_ENUMERATE(SetIterator, set_iterator)                    \
    __JS_ENUMERATE(StringIterator, string_iterator)

#define JS_ENUMERATE_BUILTIN_TYPES \
    JS_ENUMERATE_NATIVE_OBJECTS    \
    JS_ENUMERATE_NATIVE_ERRORS     \
    JS_ENUMERATE_TYPED_ARRAYS

#define JS_ENUMERATE_WELL_KNOWN_SYMBOLS                      \
    __JS_ENUMERATE(iterator, iterator)                       \
    __JS_ENUMERATE(asyncIterator, async_iterator)            \
    __JS_ENUMERATE(match, match)                             \
    __JS_ENUMERATE(matchAll, match_all)                      \
    __JS_ENUMERATE(replace, replace)                         \
    __JS_ENUMERATE(replaceAll, replace_all)                  \
    __JS_ENUMERATE(search, search)                           \
    __JS_ENUMERATE(split, split)                             \
    __JS_ENUMERATE(hasInstance, has_instance)                \
    __JS_ENUMERATE(isConcatSpreadable, is_concat_spreadable) \
    __JS_ENUMERATE(unscopables, unscopables)                 \
    __JS_ENUMERATE(species, species)                         \
    __JS_ENUMERATE(toPrimitive, to_primitive)                \
    __JS_ENUMERATE(toStringTag, to_string_tag)

#define JS_ENUMERATE_REGEXP_FLAGS              \
    __JS_ENUMERATE(hasIndices, has_indices, d) \
    __JS_ENUMERATE(global, global, g)          \
    __JS_ENUMERATE(ignoreCase, ignore_case, i) \
    __JS_ENUMERATE(multiline, multiline, m)    \
    __JS_ENUMERATE(dotAll, dot_all, s)         \
    __JS_ENUMERATE(unicode, unicode, u)        \
    __JS_ENUMERATE(sticky, sticky, y)

namespace JS {

class ASTNode;
class Accessor;
class BigInt;
class BoundFunction;
class Cell;
class CellAllocator;
class ClassExpression;
class Completion;
class Console;
class DeclarativeEnvironment;
class DeferGC;
class ECMAScriptFunctionObject;
class Environment;
class Error;
class ErrorType;
class Exception;
class Expression;
class FunctionEnvironment;
class FunctionNode;
class GlobalEnvironment;
class GlobalObject;
class HandleImpl;
class Heap;
class HeapBlock;
class Interpreter;
class MarkedValueList;
class NativeFunction;
class ObjectEnvironment;
class PrimitiveString;
class PromiseReaction;
class PromiseReactionJob;
class PromiseResolveThenableJob;
class PropertyAttributes;
class PropertyDescriptor;
class PropertyName;
class Realm;
class Reference;
class ScopeNode;
class Shape;
class Statement;
class StringOrSymbol;
class Symbol;
class Token;
class Utf16String;
class VM;
class Value;
class WeakContainer;
class WrappedFunction;
enum class DeclarationKind;
struct AlreadyResolved;
struct JobCallback;
struct PromiseCapability;

// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct prototype
class ProxyObject;
class ProxyConstructor;

// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
class GeneratorObjectPrototype;

class TypedArrayConstructor;
class TypedArrayPrototype;

// Tag type used to differentiate between u8 as used by Uint8Array and u8 as used by Uint8ClampedArray.
struct ClampedU8;

#define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName, ArrayType) \
    class ClassName;                                                                     \
    class ConstructorName;                                                               \
    class PrototypeName;
JS_ENUMERATE_NATIVE_OBJECTS_EXCLUDING_TEMPLATES
JS_ENUMERATE_NATIVE_ERRORS
JS_ENUMERATE_TYPED_ARRAYS
#undef __JS_ENUMERATE

namespace Intl {
#define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName) \
    class ClassName;                                                          \
    class ConstructorName;                                                    \
    class PrototypeName;
JS_ENUMERATE_INTL_OBJECTS
#undef __JS_ENUMERATE
};

namespace Temporal {
#define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName) \
    class ClassName;                                                          \
    class ConstructorName;                                                    \
    class PrototypeName;
JS_ENUMERATE_TEMPORAL_OBJECTS
#undef __JS_ENUMERATE
struct TemporalDuration;
};

template<typename T>
class ThrowCompletionOr;

template<class T>
class Handle;

namespace Bytecode {
class BasicBlock;
struct Executable;
class Generator;
class Instruction;
class Interpreter;
class Register;
}

}