2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2018-11-30 18:39:55 +03:00
|
|
|
* vim: set ts=8 sts=2 et sw=2 tw=80:
|
2012-09-08 01:42:33 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2018-02-21 19:30:19 +03:00
|
|
|
#ifndef js_ProtoKey_h
|
|
|
|
#define js_ProtoKey_h
|
2012-09-08 01:42:33 +04:00
|
|
|
|
2013-11-22 22:55:42 +04:00
|
|
|
/* A higher-order macro for enumerating all JSProtoKey values. */
|
2012-09-08 01:42:33 +04:00
|
|
|
/*
|
2013-11-22 22:55:42 +04:00
|
|
|
* Consumers define macros as follows:
|
2018-11-19 16:05:09 +03:00
|
|
|
* MACRO(name, init, clasp)
|
2013-11-22 22:55:42 +04:00
|
|
|
* name: The canonical name of the class.
|
2018-11-21 21:12:57 +03:00
|
|
|
* init: Initialization function. These are |extern "C";|, and clients
|
|
|
|
* should use |extern "C" {}| as appropriate when using this macro.
|
2013-11-22 22:55:42 +04:00
|
|
|
* clasp: The JSClass for this object, or "dummy" if it doesn't exist.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Consumers wishing to iterate over all the JSProtoKey values, can use
|
|
|
|
* JS_FOR_EACH_PROTOTYPE. However, there are certain values that don't
|
|
|
|
* correspond to real constructors, like Null or constructors that are disabled
|
|
|
|
* via preprocessor directives. We still need to include these in the JSProtoKey
|
|
|
|
* list in order to maintain binary XDR compatibility, but we need to provide a
|
|
|
|
* tool to handle them differently. JS_FOR_PROTOTYPES fills this niche.
|
|
|
|
*
|
2018-11-19 16:05:09 +03:00
|
|
|
* Consumers pass two macros to JS_FOR_PROTOTYPES - |REAL| and |IMAGINARY|. The
|
2013-11-22 22:55:42 +04:00
|
|
|
* former is invoked for entries that have real client-exposed constructors, and
|
|
|
|
* the latter is called for the rest. Consumers that don't care about this
|
|
|
|
* distinction can simply pass the same macro to both, which is exactly what
|
|
|
|
* JS_FOR_EACH_PROTOTYPE does.
|
2012-09-08 01:42:33 +04:00
|
|
|
*/
|
|
|
|
|
2018-11-19 16:05:09 +03:00
|
|
|
#define CLASP(NAME) (&NAME##Class)
|
|
|
|
#define OCLASP(NAME) (&NAME##Object::class_)
|
|
|
|
#define TYPED_ARRAY_CLASP(TYPE) (&TypedArrayObject::classes[Scalar::TYPE])
|
|
|
|
#define ERROR_CLASP(TYPE) (&ErrorObject::classes[TYPE])
|
2013-11-22 22:55:42 +04:00
|
|
|
|
2019-08-09 22:43:19 +03:00
|
|
|
#ifdef ENABLE_INTL_API
|
2018-11-19 16:05:09 +03:00
|
|
|
# define IF_INTL(REAL, IMAGINARY) REAL
|
2013-11-22 22:55:42 +04:00
|
|
|
#else
|
2018-11-19 16:05:09 +03:00
|
|
|
# define IF_INTL(REAL, IMAGINARY) IMAGINARY
|
2013-11-22 22:55:42 +04:00
|
|
|
#endif
|
|
|
|
|
2019-02-14 14:44:25 +03:00
|
|
|
#ifdef ENABLE_TYPED_OBJECTS
|
|
|
|
# define IF_TYPEDOBJ(REAL, IMAGINARY) REAL
|
2013-11-22 22:55:42 +04:00
|
|
|
#else
|
2019-02-14 14:44:25 +03:00
|
|
|
# define IF_TYPEDOBJ(REAL, IMAGINARY) IMAGINARY
|
2013-11-22 22:55:42 +04:00
|
|
|
#endif
|
|
|
|
|
2014-02-21 02:49:09 +04:00
|
|
|
#ifdef ENABLE_SHARED_ARRAY_BUFFER
|
2018-11-19 16:05:09 +03:00
|
|
|
# define IF_SAB(REAL, IMAGINARY) REAL
|
2014-02-21 02:49:09 +04:00
|
|
|
#else
|
2018-11-19 16:05:09 +03:00
|
|
|
# define IF_SAB(REAL, IMAGINARY) IMAGINARY
|
2014-02-21 02:49:09 +04:00
|
|
|
#endif
|
|
|
|
|
2018-11-19 16:54:02 +03:00
|
|
|
#define JS_FOR_PROTOTYPES_(REAL, IMAGINARY, REAL_IF_INTL, REAL_IF_BDATA, \
|
2019-02-14 18:03:44 +03:00
|
|
|
REAL_IF_SAB) \
|
2018-11-19 16:05:09 +03:00
|
|
|
IMAGINARY(Null, InitNullClass, dummy) \
|
|
|
|
REAL(Object, InitViaClassSpec, OCLASP(Plain)) \
|
|
|
|
REAL(Function, InitViaClassSpec, &JSFunction::class_) \
|
|
|
|
REAL(Array, InitViaClassSpec, OCLASP(Array)) \
|
|
|
|
REAL(Boolean, InitBooleanClass, OCLASP(Boolean)) \
|
|
|
|
REAL(JSON, InitJSONClass, CLASP(JSON)) \
|
|
|
|
REAL(Date, InitViaClassSpec, OCLASP(Date)) \
|
|
|
|
REAL(Math, InitMathClass, CLASP(Math)) \
|
|
|
|
REAL(Number, InitNumberClass, OCLASP(Number)) \
|
|
|
|
REAL(String, InitStringClass, OCLASP(String)) \
|
|
|
|
REAL(RegExp, InitViaClassSpec, OCLASP(RegExp)) \
|
|
|
|
REAL(Error, InitViaClassSpec, ERROR_CLASP(JSEXN_ERR)) \
|
|
|
|
REAL(InternalError, InitViaClassSpec, ERROR_CLASP(JSEXN_INTERNALERR)) \
|
|
|
|
REAL(EvalError, InitViaClassSpec, ERROR_CLASP(JSEXN_EVALERR)) \
|
|
|
|
REAL(RangeError, InitViaClassSpec, ERROR_CLASP(JSEXN_RANGEERR)) \
|
|
|
|
REAL(ReferenceError, InitViaClassSpec, ERROR_CLASP(JSEXN_REFERENCEERR)) \
|
|
|
|
REAL(SyntaxError, InitViaClassSpec, ERROR_CLASP(JSEXN_SYNTAXERR)) \
|
|
|
|
REAL(TypeError, InitViaClassSpec, ERROR_CLASP(JSEXN_TYPEERR)) \
|
|
|
|
REAL(URIError, InitViaClassSpec, ERROR_CLASP(JSEXN_URIERR)) \
|
|
|
|
REAL(DebuggeeWouldRun, InitViaClassSpec, \
|
|
|
|
ERROR_CLASP(JSEXN_DEBUGGEEWOULDRUN)) \
|
|
|
|
REAL(CompileError, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMCOMPILEERROR)) \
|
|
|
|
REAL(LinkError, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMLINKERROR)) \
|
|
|
|
REAL(RuntimeError, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMRUNTIMEERROR)) \
|
|
|
|
REAL(ArrayBuffer, InitViaClassSpec, OCLASP(ArrayBuffer)) \
|
|
|
|
REAL(Int8Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \
|
|
|
|
REAL(Uint8Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8)) \
|
|
|
|
REAL(Int16Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Int16)) \
|
|
|
|
REAL(Uint16Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint16)) \
|
|
|
|
REAL(Int32Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Int32)) \
|
|
|
|
REAL(Uint32Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint32)) \
|
|
|
|
REAL(Float32Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Float32)) \
|
|
|
|
REAL(Float64Array, InitViaClassSpec, TYPED_ARRAY_CLASP(Float64)) \
|
|
|
|
REAL(Uint8ClampedArray, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8Clamped)) \
|
2019-04-02 20:11:13 +03:00
|
|
|
REAL(BigInt64Array, InitViaClassSpec, TYPED_ARRAY_CLASP(BigInt64)) \
|
|
|
|
REAL(BigUint64Array, InitViaClassSpec, TYPED_ARRAY_CLASP(BigUint64)) \
|
2019-02-14 18:03:44 +03:00
|
|
|
REAL(BigInt, InitViaClassSpec, OCLASP(BigInt)) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(Proxy, InitProxyClass, &js::ProxyClass) \
|
2018-11-20 14:21:32 +03:00
|
|
|
REAL(WeakMap, InitViaClassSpec, OCLASP(WeakMap)) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(Map, InitViaClassSpec, OCLASP(Map)) \
|
|
|
|
REAL(Set, InitViaClassSpec, OCLASP(Set)) \
|
|
|
|
REAL(DataView, InitViaClassSpec, OCLASP(DataView)) \
|
|
|
|
REAL(Symbol, InitSymbolClass, OCLASP(Symbol)) \
|
2018-11-20 01:36:35 +03:00
|
|
|
REAL(SharedArrayBuffer, InitViaClassSpec, OCLASP(SharedArrayBuffer)) \
|
2018-11-19 16:54:02 +03:00
|
|
|
REAL_IF_INTL(Intl, InitIntlClass, CLASP(Intl)) \
|
2019-10-16 15:34:06 +03:00
|
|
|
REAL_IF_INTL(Collator, InitViaClassSpec, OCLASP(Collator)) \
|
|
|
|
REAL_IF_INTL(DateTimeFormat, InitViaClassSpec, OCLASP(DateTimeFormat)) \
|
|
|
|
REAL_IF_INTL(Locale, InitViaClassSpec, OCLASP(Locale)) \
|
2019-10-16 19:05:06 +03:00
|
|
|
REAL_IF_INTL(ListFormat, InitViaClassSpec, OCLASP(ListFormat)) \
|
2019-10-16 15:34:06 +03:00
|
|
|
REAL_IF_INTL(NumberFormat, InitViaClassSpec, OCLASP(NumberFormat)) \
|
|
|
|
REAL_IF_INTL(PluralRules, InitViaClassSpec, OCLASP(PluralRules)) \
|
|
|
|
REAL_IF_INTL(RelativeTimeFormat, InitViaClassSpec, \
|
|
|
|
OCLASP(RelativeTimeFormat)) \
|
2018-11-19 16:54:02 +03:00
|
|
|
REAL_IF_BDATA(TypedObject, InitTypedObjectModuleObject, \
|
|
|
|
OCLASP(TypedObjectModule)) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(Reflect, InitReflect, nullptr) \
|
2018-11-20 14:21:32 +03:00
|
|
|
REAL(WeakSet, InitViaClassSpec, OCLASP(WeakSet)) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(TypedArray, InitViaClassSpec, \
|
|
|
|
&js::TypedArrayObject::sharedTypedArrayPrototypeClass) \
|
2018-11-20 01:36:35 +03:00
|
|
|
REAL(Atomics, InitAtomicsClass, OCLASP(Atomics)) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(SavedFrame, InitViaClassSpec, &js::SavedFrame::class_) \
|
|
|
|
REAL(Promise, InitViaClassSpec, OCLASP(Promise)) \
|
2019-10-16 15:34:46 +03:00
|
|
|
REAL(AsyncFunction, InitAsyncFunction, nullptr) \
|
2019-10-16 15:35:08 +03:00
|
|
|
REAL(GeneratorFunction, InitGeneratorFunction, nullptr) \
|
2019-10-16 15:35:36 +03:00
|
|
|
REAL(AsyncGeneratorFunction, InitAsyncGeneratorFunction, nullptr) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(ReadableStream, InitViaClassSpec, &js::ReadableStream::class_) \
|
|
|
|
REAL(ReadableStreamDefaultReader, InitViaClassSpec, \
|
|
|
|
&js::ReadableStreamDefaultReader::class_) \
|
|
|
|
REAL(ReadableStreamDefaultController, InitViaClassSpec, \
|
|
|
|
&js::ReadableStreamDefaultController::class_) \
|
|
|
|
REAL(ReadableByteStreamController, InitViaClassSpec, \
|
|
|
|
&js::ReadableByteStreamController::class_) \
|
2019-09-24 02:57:58 +03:00
|
|
|
REAL(WritableStream, InitViaClassSpec, &js::WritableStream::class_) \
|
2019-11-05 08:12:15 +03:00
|
|
|
REAL(WritableStreamDefaultController, InitViaClassSpec, \
|
|
|
|
&js::WritableStreamDefaultController::class_) \
|
|
|
|
REAL(WritableStreamDefaultWriter, InitViaClassSpec, \
|
|
|
|
&js::WritableStreamDefaultWriter::class_) \
|
2018-11-19 16:05:09 +03:00
|
|
|
REAL(ByteLengthQueuingStrategy, InitViaClassSpec, \
|
|
|
|
&js::ByteLengthQueuingStrategy::class_) \
|
|
|
|
REAL(CountQueuingStrategy, InitViaClassSpec, \
|
|
|
|
&js::CountQueuingStrategy::class_) \
|
|
|
|
REAL(WebAssembly, InitWebAssemblyClass, CLASP(WebAssembly)) \
|
|
|
|
IMAGINARY(WasmModule, dummy, dummy) \
|
|
|
|
IMAGINARY(WasmInstance, dummy, dummy) \
|
|
|
|
IMAGINARY(WasmMemory, dummy, dummy) \
|
|
|
|
IMAGINARY(WasmTable, dummy, dummy) \
|
2019-11-01 13:37:25 +03:00
|
|
|
IMAGINARY(WasmGlobal, dummy, dummy) \
|
|
|
|
REAL(FinalizationGroup, InitViaClassSpec, OCLASP(FinalizationGroup))
|
2013-11-22 22:55:42 +04:00
|
|
|
|
2018-11-19 16:54:02 +03:00
|
|
|
#define JS_FOR_PROTOTYPES(REAL, IMAGINARY) \
|
|
|
|
JS_FOR_PROTOTYPES_(REAL, IMAGINARY, IF_INTL(REAL, IMAGINARY), \
|
2019-02-14 14:44:25 +03:00
|
|
|
IF_TYPEDOBJ(REAL, IMAGINARY), IF_SAB(REAL, IMAGINARY))
|
2018-11-19 16:54:02 +03:00
|
|
|
|
2018-11-19 16:05:09 +03:00
|
|
|
#define JS_FOR_EACH_PROTOTYPE(MACRO) JS_FOR_PROTOTYPES(MACRO, MACRO)
|
2012-09-08 01:42:33 +04:00
|
|
|
|
2018-02-21 19:30:19 +03:00
|
|
|
#endif /* js_ProtoKey_h */
|