Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / js / public / ProtoKey.h
blob31dfae927cf27716aa0d97779272a3cea2b2fa83
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 #define JS_FOR_PROTOTYPES_(REAL, IMAGINARY, REAL_IF_INTL, REAL_IF_TEMPORAL, \
57 REAL_IF_WASM_TYPE) \
58 IMAGINARY(Null, dummy) \
59 REAL(Object, OCLASP(Plain)) \
60 REAL(Function, &FunctionClass) \
61 IMAGINARY(BoundFunction, OCLASP(BoundFunction)) \
62 REAL(Array, OCLASP(Array)) \
63 REAL(Boolean, OCLASP(Boolean)) \
64 REAL(JSON, CLASP(JSON)) \
65 REAL(Date, OCLASP(Date)) \
66 REAL(Math, CLASP(Math)) \
67 REAL(Number, OCLASP(Number)) \
68 REAL(String, OCLASP(String)) \
69 REAL(RegExp, OCLASP(RegExp)) \
70 REAL(Error, ERROR_CLASP(JSEXN_ERR)) \
71 REAL(InternalError, ERROR_CLASP(JSEXN_INTERNALERR)) \
72 REAL(AggregateError, ERROR_CLASP(JSEXN_AGGREGATEERR)) \
73 REAL(EvalError, ERROR_CLASP(JSEXN_EVALERR)) \
74 REAL(RangeError, ERROR_CLASP(JSEXN_RANGEERR)) \
75 REAL(ReferenceError, ERROR_CLASP(JSEXN_REFERENCEERR)) \
76 REAL(SyntaxError, ERROR_CLASP(JSEXN_SYNTAXERR)) \
77 REAL(TypeError, ERROR_CLASP(JSEXN_TYPEERR)) \
78 REAL(URIError, ERROR_CLASP(JSEXN_URIERR)) \
79 REAL(DebuggeeWouldRun, ERROR_CLASP(JSEXN_DEBUGGEEWOULDRUN)) \
80 REAL(CompileError, ERROR_CLASP(JSEXN_WASMCOMPILEERROR)) \
81 REAL(LinkError, ERROR_CLASP(JSEXN_WASMLINKERROR)) \
82 REAL(RuntimeError, ERROR_CLASP(JSEXN_WASMRUNTIMEERROR)) \
83 REAL(ArrayBuffer, OCLASP(FixedLengthArrayBuffer)) \
84 REAL(Int8Array, TYPED_ARRAY_CLASP(Int8)) \
85 REAL(Uint8Array, TYPED_ARRAY_CLASP(Uint8)) \
86 REAL(Int16Array, TYPED_ARRAY_CLASP(Int16)) \
87 REAL(Uint16Array, TYPED_ARRAY_CLASP(Uint16)) \
88 REAL(Int32Array, TYPED_ARRAY_CLASP(Int32)) \
89 REAL(Uint32Array, TYPED_ARRAY_CLASP(Uint32)) \
90 REAL(Float32Array, TYPED_ARRAY_CLASP(Float32)) \
91 REAL(Float64Array, TYPED_ARRAY_CLASP(Float64)) \
92 REAL(Uint8ClampedArray, TYPED_ARRAY_CLASP(Uint8Clamped)) \
93 REAL(BigInt64Array, TYPED_ARRAY_CLASP(BigInt64)) \
94 REAL(BigUint64Array, TYPED_ARRAY_CLASP(BigUint64)) \
95 REAL(BigInt, OCLASP(BigInt)) \
96 REAL(Proxy, CLASP(Proxy)) \
97 REAL(WeakMap, OCLASP(WeakMap)) \
98 REAL(Map, OCLASP(Map)) \
99 REAL(Set, OCLASP(Set)) \
100 REAL(DataView, OCLASP(FixedLengthDataView)) \
101 REAL(Symbol, OCLASP(Symbol)) \
102 REAL(ShadowRealm, OCLASP(ShadowRealm)) \
103 REAL(SharedArrayBuffer, OCLASP(FixedLengthSharedArrayBuffer)) \
104 REAL_IF_INTL(Intl, CLASP(Intl)) \
105 REAL_IF_INTL(Collator, OCLASP(Collator)) \
106 REAL_IF_INTL(DateTimeFormat, OCLASP(DateTimeFormat)) \
107 REAL_IF_INTL(DisplayNames, OCLASP(DisplayNames)) \
108 REAL_IF_INTL(ListFormat, OCLASP(ListFormat)) \
109 REAL_IF_INTL(Locale, OCLASP(Locale)) \
110 REAL_IF_INTL(NumberFormat, OCLASP(NumberFormat)) \
111 REAL_IF_INTL(PluralRules, OCLASP(PluralRules)) \
112 REAL_IF_INTL(RelativeTimeFormat, OCLASP(RelativeTimeFormat)) \
113 REAL_IF_INTL(Segmenter, OCLASP(Segmenter)) \
114 REAL(Reflect, CLASP(Reflect)) \
115 REAL(WeakSet, OCLASP(WeakSet)) \
116 REAL(TypedArray, &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
117 REAL(Atomics, OCLASP(Atomics)) \
118 REAL(SavedFrame, &js::SavedFrame::class_) \
119 REAL(Promise, OCLASP(Promise)) \
120 REAL(AsyncFunction, CLASP(AsyncFunction)) \
121 REAL(GeneratorFunction, CLASP(GeneratorFunction)) \
122 REAL(AsyncGeneratorFunction, CLASP(AsyncGeneratorFunction)) \
123 REAL(WebAssembly, OCLASP(WasmNamespace)) \
124 REAL(WasmModule, OCLASP(WasmModule)) \
125 REAL(WasmInstance, OCLASP(WasmInstance)) \
126 REAL(WasmMemory, OCLASP(WasmMemory)) \
127 REAL(WasmTable, OCLASP(WasmTable)) \
128 REAL(WasmGlobal, OCLASP(WasmGlobal)) \
129 REAL(WasmTag, OCLASP(WasmTag)) \
130 REAL_IF_WASM_TYPE(WasmFunction, CLASP(WasmFunction)) \
131 REAL(WasmException, OCLASP(WasmException)) \
132 REAL(FinalizationRegistry, OCLASP(FinalizationRegistry)) \
133 REAL(WeakRef, OCLASP(WeakRef)) \
134 REAL(Iterator, OCLASP(Iterator)) \
135 REAL(AsyncIterator, OCLASP(AsyncIterator)) \
136 REAL_IF_TEMPORAL(Temporal, OCLASP(temporal::Temporal)) \
137 REAL_IF_TEMPORAL(Calendar, OCLASP(temporal::Calendar)) \
138 REAL_IF_TEMPORAL(Duration, OCLASP(temporal::Duration)) \
139 REAL_IF_TEMPORAL(Instant, OCLASP(temporal::Instant)) \
140 REAL_IF_TEMPORAL(PlainDate, OCLASP(temporal::PlainDate)) \
141 REAL_IF_TEMPORAL(PlainDateTime, OCLASP(temporal::PlainDateTime)) \
142 REAL_IF_TEMPORAL(PlainMonthDay, OCLASP(temporal::PlainMonthDay)) \
143 REAL_IF_TEMPORAL(PlainYearMonth, OCLASP(temporal::PlainYearMonth)) \
144 REAL_IF_TEMPORAL(PlainTime, OCLASP(temporal::PlainTime)) \
145 REAL_IF_TEMPORAL(TemporalNow, OCLASP(temporal::TemporalNow)) \
146 REAL_IF_TEMPORAL(TimeZone, OCLASP(temporal::TimeZone)) \
147 REAL_IF_TEMPORAL(ZonedDateTime, OCLASP(temporal::ZonedDateTime)) \
148 IF_RECORD_TUPLE(REAL(Record, (&RecordType::class_))) \
149 IF_RECORD_TUPLE(REAL(Tuple, (&TupleType::class_)))
151 #define JS_FOR_PROTOTYPES(REAL, IMAGINARY) \
152 JS_FOR_PROTOTYPES_(REAL, IMAGINARY, IF_INTL(REAL, IMAGINARY), \
153 IF_TEMPORAL(REAL, IMAGINARY), \
154 IF_WASM_TYPE(REAL, IMAGINARY))
156 #define JS_FOR_EACH_PROTOTYPE(MACRO) JS_FOR_PROTOTYPES(MACRO, MACRO)
158 #endif /* js_ProtoKey_h */