Backed out changeset 9d8b4c0b99ed (bug 1945683) for causing btime failures. CLOSED...
[gecko.git] / js / public / ProtoKey.h
blobda589c8c773c00a7885bbd5f36cb4c5713f475e3
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef js_ProtoKey_h
8 #define js_ProtoKey_h
10 /* A higher-order macro for enumerating all JSProtoKey values. */
12 * Consumers define macros as follows:
13 * MACRO(name, clasp)
14 * name: The canonical name of the class.
15 * clasp: The JSClass for this object, or "dummy" if it doesn't exist.
18 * Consumers wishing to iterate over all the JSProtoKey values, can use
19 * JS_FOR_EACH_PROTOTYPE. However, there are certain values that don't
20 * correspond to real constructors, like Null or constructors that are disabled
21 * via preprocessor directives. We still need to include these in the JSProtoKey
22 * list in order to maintain binary XDR compatibility, but we need to provide a
23 * tool to handle them differently. JS_FOR_PROTOTYPES fills this niche.
25 * Consumers pass two macros to JS_FOR_PROTOTYPES - |REAL| and |IMAGINARY|. The
26 * former is invoked for entries that have real client-exposed constructors, and
27 * the latter is called for the rest. Consumers that don't care about this
28 * distinction can simply pass the same macro to both, which is exactly what
29 * JS_FOR_EACH_PROTOTYPE does.
32 #define CLASP(NAME) (&NAME##Class)
33 #define OCLASP(NAME) (&NAME##Object::class_)
34 #define TYPED_ARRAY_CLASP(TYPE) \
35 (&TypedArrayObject::fixedLengthClasses[JS::Scalar::TYPE])
36 #define ERROR_CLASP(TYPE) (&ErrorObject::classes[TYPE])
38 #ifdef JS_HAS_INTL_API
39 # define IF_INTL(REAL, IMAGINARY) REAL
40 #else
41 # define IF_INTL(REAL, IMAGINARY) IMAGINARY
42 #endif
44 #ifdef JS_HAS_TEMPORAL_API
45 # define IF_TEMPORAL(REAL, IMAGINARY) REAL
46 #else
47 # define IF_TEMPORAL(REAL, IMAGINARY) IMAGINARY
48 #endif
50 #ifdef ENABLE_WASM_TYPE_REFLECTIONS
51 # define IF_WASM_TYPE(REAL, IMAGINARY) REAL
52 #else
53 # define IF_WASM_TYPE(REAL, IMAGINARY) IMAGINARY
54 #endif
56 #ifdef ENABLE_WASM_JSPI
57 # define IF_WASM_JSPI(REAL, IMAGINARY) REAL
58 #else
59 # define IF_WASM_JSPI(REAL, IMAGINARY) IMAGINARY
60 #endif
62 #ifdef NIGHTLY_BUILD
63 # define IF_NIGHTLY(REAL, IMAGINARY) REAL
64 #else
65 # define IF_NIGHTLY(REAL, IMAGINARY) IMAGINARY
66 #endif
68 #define JS_FOR_PROTOTYPES_(REAL, IMAGINARY, REAL_IF_INTL, REAL_IF_TEMPORAL, \
69 REAL_IF_WASM_TYPE, REAL_IF_WASM_JSPI, \
70 REAL_IF_NIGHTLY) \
71 IMAGINARY(Null, dummy) \
72 REAL(Object, OCLASP(Plain)) \
73 REAL(Function, &FunctionClass) \
74 IMAGINARY(BoundFunction, OCLASP(BoundFunction)) \
75 REAL(Array, OCLASP(Array)) \
76 REAL(Boolean, OCLASP(Boolean)) \
77 REAL(JSON, CLASP(JSON)) \
78 REAL(Date, OCLASP(Date)) \
79 REAL(Math, CLASP(Math)) \
80 REAL(Number, OCLASP(Number)) \
81 REAL(String, OCLASP(String)) \
82 REAL(RegExp, OCLASP(RegExp)) \
83 REAL(Error, ERROR_CLASP(JSEXN_ERR)) \
84 REAL(InternalError, ERROR_CLASP(JSEXN_INTERNALERR)) \
85 REAL(AggregateError, ERROR_CLASP(JSEXN_AGGREGATEERR)) \
86 REAL(EvalError, ERROR_CLASP(JSEXN_EVALERR)) \
87 REAL(RangeError, ERROR_CLASP(JSEXN_RANGEERR)) \
88 REAL(ReferenceError, ERROR_CLASP(JSEXN_REFERENCEERR)) \
89 IF_EXPLICIT_RESOURCE_MANAGEMENT( \
90 REAL(SuppressedError, ERROR_CLASP(JSEXN_SUPPRESSEDERR))) \
91 REAL(SyntaxError, ERROR_CLASP(JSEXN_SYNTAXERR)) \
92 REAL(TypeError, ERROR_CLASP(JSEXN_TYPEERR)) \
93 REAL(URIError, ERROR_CLASP(JSEXN_URIERR)) \
94 REAL(DebuggeeWouldRun, ERROR_CLASP(JSEXN_DEBUGGEEWOULDRUN)) \
95 REAL(CompileError, ERROR_CLASP(JSEXN_WASMCOMPILEERROR)) \
96 REAL(LinkError, ERROR_CLASP(JSEXN_WASMLINKERROR)) \
97 REAL(RuntimeError, ERROR_CLASP(JSEXN_WASMRUNTIMEERROR)) \
98 REAL(ArrayBuffer, OCLASP(FixedLengthArrayBuffer)) \
99 REAL(Int8Array, TYPED_ARRAY_CLASP(Int8)) \
100 REAL(Uint8Array, TYPED_ARRAY_CLASP(Uint8)) \
101 REAL(Int16Array, TYPED_ARRAY_CLASP(Int16)) \
102 REAL(Uint16Array, TYPED_ARRAY_CLASP(Uint16)) \
103 REAL(Int32Array, TYPED_ARRAY_CLASP(Int32)) \
104 REAL(Uint32Array, TYPED_ARRAY_CLASP(Uint32)) \
105 REAL(Float32Array, TYPED_ARRAY_CLASP(Float32)) \
106 REAL(Float64Array, TYPED_ARRAY_CLASP(Float64)) \
107 REAL(Uint8ClampedArray, TYPED_ARRAY_CLASP(Uint8Clamped)) \
108 REAL(BigInt64Array, TYPED_ARRAY_CLASP(BigInt64)) \
109 REAL(BigUint64Array, TYPED_ARRAY_CLASP(BigUint64)) \
110 REAL(Float16Array, TYPED_ARRAY_CLASP(Float16)) \
111 REAL(BigInt, OCLASP(BigInt)) \
112 REAL(Proxy, CLASP(Proxy)) \
113 REAL(WeakMap, OCLASP(WeakMap)) \
114 REAL(Map, OCLASP(Map)) \
115 REAL(Set, OCLASP(Set)) \
116 REAL(DataView, OCLASP(FixedLengthDataView)) \
117 REAL(Symbol, OCLASP(Symbol)) \
118 REAL(ShadowRealm, OCLASP(ShadowRealm)) \
119 REAL(SharedArrayBuffer, OCLASP(FixedLengthSharedArrayBuffer)) \
120 REAL_IF_INTL(Intl, CLASP(Intl)) \
121 REAL_IF_INTL(Collator, OCLASP(Collator)) \
122 REAL_IF_INTL(DateTimeFormat, OCLASP(DateTimeFormat)) \
123 REAL_IF_INTL(DisplayNames, OCLASP(DisplayNames)) \
124 REAL_IF_INTL(DurationFormat, OCLASP(DurationFormat)) \
125 REAL_IF_INTL(ListFormat, OCLASP(ListFormat)) \
126 REAL_IF_INTL(Locale, OCLASP(Locale)) \
127 REAL_IF_INTL(NumberFormat, OCLASP(NumberFormat)) \
128 REAL_IF_INTL(PluralRules, OCLASP(PluralRules)) \
129 REAL_IF_INTL(RelativeTimeFormat, OCLASP(RelativeTimeFormat)) \
130 REAL_IF_INTL(Segmenter, OCLASP(Segmenter)) \
131 REAL(Reflect, CLASP(Reflect)) \
132 REAL(WeakSet, OCLASP(WeakSet)) \
133 REAL(TypedArray, &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
134 REAL(Atomics, OCLASP(Atomics)) \
135 REAL(SavedFrame, &js::SavedFrame::class_) \
136 REAL(Promise, OCLASP(Promise)) \
137 REAL(AsyncFunction, CLASP(AsyncFunction)) \
138 REAL(GeneratorFunction, CLASP(GeneratorFunction)) \
139 REAL(AsyncGeneratorFunction, CLASP(AsyncGeneratorFunction)) \
140 REAL(WebAssembly, OCLASP(WasmNamespace)) \
141 REAL(WasmModule, OCLASP(WasmModule)) \
142 REAL(WasmInstance, OCLASP(WasmInstance)) \
143 REAL(WasmMemory, OCLASP(WasmMemory)) \
144 REAL(WasmTable, OCLASP(WasmTable)) \
145 REAL(WasmGlobal, OCLASP(WasmGlobal)) \
146 REAL(WasmTag, OCLASP(WasmTag)) \
147 REAL_IF_WASM_TYPE(WasmFunction, CLASP(WasmFunction)) \
148 REAL_IF_WASM_JSPI(WasmSuspending, OCLASP(WasmSuspending)) \
149 REAL(WasmException, OCLASP(WasmException)) \
150 REAL(FinalizationRegistry, OCLASP(FinalizationRegistry)) \
151 REAL(WeakRef, OCLASP(WeakRef)) \
152 REAL(Iterator, OCLASP(Iterator)) \
153 REAL(AsyncIterator, OCLASP(AsyncIterator)) \
154 IF_EXPLICIT_RESOURCE_MANAGEMENT( \
155 REAL(DisposableStack, OCLASP(DisposableStack))) \
156 IF_EXPLICIT_RESOURCE_MANAGEMENT( \
157 REAL(AsyncDisposableStack, OCLASP(AsyncDisposableStack))) \
158 REAL_IF_TEMPORAL(Temporal, OCLASP(temporal::Temporal)) \
159 REAL_IF_TEMPORAL(Duration, OCLASP(temporal::Duration)) \
160 REAL_IF_TEMPORAL(Instant, OCLASP(temporal::Instant)) \
161 REAL_IF_TEMPORAL(PlainDate, OCLASP(temporal::PlainDate)) \
162 REAL_IF_TEMPORAL(PlainDateTime, OCLASP(temporal::PlainDateTime)) \
163 REAL_IF_TEMPORAL(PlainMonthDay, OCLASP(temporal::PlainMonthDay)) \
164 REAL_IF_TEMPORAL(PlainYearMonth, OCLASP(temporal::PlainYearMonth)) \
165 REAL_IF_TEMPORAL(PlainTime, OCLASP(temporal::PlainTime)) \
166 REAL_IF_TEMPORAL(TemporalNow, OCLASP(temporal::TemporalNow)) \
167 REAL_IF_TEMPORAL(ZonedDateTime, OCLASP(temporal::ZonedDateTime)) \
168 IF_RECORD_TUPLE(REAL(Record, (&RecordType::class_))) \
169 IF_RECORD_TUPLE(REAL(Tuple, (&TupleType::class_)))
171 #define JS_FOR_PROTOTYPES(REAL, IMAGINARY) \
172 JS_FOR_PROTOTYPES_( \
173 REAL, IMAGINARY, IF_INTL(REAL, IMAGINARY), IF_TEMPORAL(REAL, IMAGINARY), \
174 IF_WASM_TYPE(REAL, IMAGINARY), IF_WASM_JSPI(REAL, IMAGINARY), \
175 IF_NIGHTLY(REAL, IMAGINARY))
177 #define JS_FOR_EACH_PROTOTYPE(MACRO) JS_FOR_PROTOTYPES(MACRO, MACRO)
179 #endif /* js_ProtoKey_h */