js/src/jsprototypes.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     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 jsprototypes_h
     8 #define jsprototypes_h
    10 /* A higher-order macro for enumerating all JSProtoKey values. */
    11 /*
    12  * Consumers define macros as follows:
    13  * macro(name, code, init, clasp)
    14  *   name:    The canonical name of the class.
    15  *   code:    The enumerator code. There are part of the XDR API, and must not change.
    16  *   init:    Initialization function. These are |extern "C";|, and clients should use
    17  *            |extern "C" {}| as appropriate when using this macro.
    18  *   clasp:   The JSClass for this object, or "dummy" if it doesn't exist.
    19  *
    20  *
    21  * Consumers wishing to iterate over all the JSProtoKey values, can use
    22  * JS_FOR_EACH_PROTOTYPE. However, there are certain values that don't correspond
    23  * to real constructors, like Null or constructors that are disabled via
    24  * preprocessor directives. We still need to include these in the JSProtoKey list
    25  * in order to maintain binary XDR compatibility, but we need to provide a tool
    26  * to handle them differently. JS_FOR_PROTOTYPES fills this niche.
    27  *
    28  * Consumers pass two macros to JS_FOR_PROTOTYPES - |real| and |imaginary|. The
    29  * former is invoked for entries that have real client-exposed constructors, and
    30  * the latter is called for the rest. Consumers that don't care about this
    31  * distinction can simply pass the same macro to both, which is exactly what
    32  * JS_FOR_EACH_PROTOTYPE does.
    33  */
    35 #define CLASP(name)                 (&name##Class)
    36 #define OCLASP(name)                (&name##Object::class_)
    37 #define TYPED_ARRAY_CLASP(type)     (&TypedArrayObject::classes[ScalarTypeDescr::type])
    39 #ifdef ENABLE_PARALLEL_JS
    40 #define IF_PJS(real,imaginary) real
    41 #else
    42 #define IF_PJS(real,imaginary) imaginary
    43 #endif
    45 #ifdef EXPOSE_INTL_API
    46 #define IF_INTL(real,imaginary) real
    47 #else
    48 #define IF_INTL(real,imaginary) imaginary
    49 #endif
    51 #ifdef ENABLE_BINARYDATA
    52 #define IF_BDATA(real,imaginary) real
    53 #else
    54 #define IF_BDATA(real,imaginary) imaginary
    55 #endif
    57 #ifdef ENABLE_SHARED_ARRAY_BUFFER
    58 #define IF_SAB(real,imaginary) real
    59 #else
    60 #define IF_SAB(real,imaginary) imaginary
    61 #endif
    63 #define JS_FOR_PROTOTYPES(real,imaginary) \
    64     imaginary(Null,              0,     js_InitNullClass,          dummy) \
    65     real(Object,                 1,     js_InitObjectClass,        &JSObject::class_) \
    66     real(Function,               2,     js_InitFunctionClass,      &JSFunction::class_) \
    67     real(Array,                  3,     js_InitArrayClass,         OCLASP(Array)) \
    68     real(Boolean,                4,     js_InitBooleanClass,       OCLASP(Boolean)) \
    69     real(JSON,                   5,     js_InitJSONClass,          CLASP(JSON)) \
    70     real(Date,                   6,     js_InitViaClassSpec,       OCLASP(Date)) \
    71     real(Math,                   7,     js_InitMathClass,          CLASP(Math)) \
    72     real(Number,                 8,     js_InitNumberClass,        OCLASP(Number)) \
    73     real(String,                 9,     js_InitStringClass,        OCLASP(String)) \
    74     real(RegExp,                10,     js_InitRegExpClass,        OCLASP(RegExp)) \
    75     real(Error,                 11,     js_InitExceptionClasses,   OCLASP(Error)) \
    76     real(InternalError,         12,     js_InitExceptionClasses,   OCLASP(Error)) \
    77     real(EvalError,             13,     js_InitExceptionClasses,   OCLASP(Error)) \
    78     real(RangeError,            14,     js_InitExceptionClasses,   OCLASP(Error)) \
    79     real(ReferenceError,        15,     js_InitExceptionClasses,   OCLASP(Error)) \
    80     real(SyntaxError,           16,     js_InitExceptionClasses,   OCLASP(Error)) \
    81     real(TypeError,             17,     js_InitExceptionClasses,   OCLASP(Error)) \
    82     real(URIError,              18,     js_InitExceptionClasses,   OCLASP(Error)) \
    83     real(Iterator,              19,     js_InitIteratorClasses,    OCLASP(PropertyIterator)) \
    84     real(StopIteration,         20,     js_InitIteratorClasses,    OCLASP(StopIteration)) \
    85     real(ArrayBuffer,           21,     js_InitTypedArrayClasses,  &js::ArrayBufferObject::protoClass) \
    86     real(Int8Array,             22,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_INT8)) \
    87     real(Uint8Array,            23,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_UINT8)) \
    88     real(Int16Array,            24,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_INT16)) \
    89     real(Uint16Array,           25,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_UINT16)) \
    90     real(Int32Array,            26,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_INT32)) \
    91     real(Uint32Array,           27,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_UINT32)) \
    92     real(Float32Array,          28,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_FLOAT32)) \
    93     real(Float64Array,          29,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_FLOAT64)) \
    94     real(Uint8ClampedArray,     30,     js_InitTypedArrayClasses,  TYPED_ARRAY_CLASP(TYPE_UINT8_CLAMPED)) \
    95     real(Proxy,                 31,     js_InitProxyClass,         &ProxyObject::uncallableClass_) \
    96     real(WeakMap,               32,     js_InitWeakMapClass,       OCLASP(WeakMap)) \
    97     real(Map,                   33,     js_InitMapClass,           OCLASP(Map)) \
    98     real(Set,                   34,     js_InitSetClass,           OCLASP(Set)) \
    99     real(DataView,              35,     js_InitTypedArrayClasses,  OCLASP(DataView)) \
   100 IF_SAB(real,imaginary)(SharedArrayBuffer,       36,     js_InitSharedArrayBufferClass, &js::SharedArrayBufferObject::protoClass) \
   101 IF_INTL(real,imaginary) (Intl,                  37,     js_InitIntlClass,          CLASP(Intl)) \
   102 IF_BDATA(real,imaginary)(TypedObject,           38,     js_InitTypedObjectModuleObject,   OCLASP(TypedObjectModule)) \
   103     imaginary(GeneratorFunction,     39,     js_InitIteratorClasses, dummy) \
   104 IF_BDATA(real,imaginary)(SIMD,                  40,     js_InitSIMDClass, OCLASP(SIMD)) \
   106 #define JS_FOR_EACH_PROTOTYPE(macro) JS_FOR_PROTOTYPES(macro,macro)
   108 #endif /* jsprototypes_h */

mercurial