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 // This file contains public type declarations that are used *frequently*. If
8 // it doesn't occur at least 10 times in Gecko, it probably shouldn't be in
12 // - forward declarations of structs and classes;
15 // It does *not* contain any struct or class definitions.
17 #ifndef js_TypeDecls_h
18 #define js_TypeDecls_h
20 #include <stdint.h> // uint8_t
22 #include "jstypes.h" // JS_PUBLIC_API
24 typedef uint8_t jsbytecode
;
26 class JS_PUBLIC_API JSAtom
;
27 struct JS_PUBLIC_API JSContext
;
29 class JS_PUBLIC_API JSFunction
;
30 class JS_PUBLIC_API JSObject
;
31 struct JS_PUBLIC_API JSRuntime
;
32 class JS_PUBLIC_API JSScript
;
33 class JS_PUBLIC_API JSString
;
38 class JS_PUBLIC_API TempAllocPolicy
;
43 class JS_PUBLIC_API GCContext
;
44 class JS_PUBLIC_API PropertyKey
;
46 typedef unsigned char Latin1Char
;
48 class JS_PUBLIC_API Symbol
;
49 class JS_PUBLIC_API BigInt
;
50 #ifdef ENABLE_RECORD_TUPLE
51 class JS_PUBLIC_API RecordType
;
52 class JS_PUBLIC_API TupleType
;
54 class JS_PUBLIC_API Value
;
56 class JS_PUBLIC_API Compartment
;
57 class JS_PUBLIC_API Realm
;
58 struct JS_PUBLIC_API Runtime
;
59 class JS_PUBLIC_API Zone
;
68 class PersistentRooted
;
72 class PersistentRootedVector
;
73 template <typename T
, typename AllocPolicy
= js::TempAllocPolicy
>
76 typedef Handle
<JSFunction
*> HandleFunction
;
77 typedef Handle
<PropertyKey
> HandleId
;
78 typedef Handle
<JSObject
*> HandleObject
;
79 typedef Handle
<JSScript
*> HandleScript
;
80 typedef Handle
<JSString
*> HandleString
;
81 typedef Handle
<JS::Symbol
*> HandleSymbol
;
82 typedef Handle
<JS::BigInt
*> HandleBigInt
;
83 typedef Handle
<Value
> HandleValue
;
84 typedef Handle
<StackGCVector
<Value
>> HandleValueVector
;
85 typedef Handle
<StackGCVector
<JSObject
*>> HandleObjectVector
;
86 typedef Handle
<StackGCVector
<JS::PropertyKey
>> HandleIdVector
;
88 typedef MutableHandle
<JSFunction
*> MutableHandleFunction
;
89 typedef MutableHandle
<PropertyKey
> MutableHandleId
;
90 typedef MutableHandle
<JSObject
*> MutableHandleObject
;
91 typedef MutableHandle
<JSScript
*> MutableHandleScript
;
92 typedef MutableHandle
<JSString
*> MutableHandleString
;
93 typedef MutableHandle
<JS::Symbol
*> MutableHandleSymbol
;
94 typedef MutableHandle
<JS::BigInt
*> MutableHandleBigInt
;
95 typedef MutableHandle
<Value
> MutableHandleValue
;
96 typedef MutableHandle
<StackGCVector
<Value
>> MutableHandleValueVector
;
97 typedef MutableHandle
<StackGCVector
<JSObject
*>> MutableHandleObjectVector
;
98 typedef MutableHandle
<StackGCVector
<JS::PropertyKey
>> MutableHandleIdVector
;
100 typedef Rooted
<JSObject
*> RootedObject
;
101 typedef Rooted
<JSFunction
*> RootedFunction
;
102 typedef Rooted
<JSScript
*> RootedScript
;
103 typedef Rooted
<JSString
*> RootedString
;
104 typedef Rooted
<JS::Symbol
*> RootedSymbol
;
105 typedef Rooted
<JS::BigInt
*> RootedBigInt
;
106 typedef Rooted
<PropertyKey
> RootedId
;
107 typedef Rooted
<JS::Value
> RootedValue
;
109 typedef RootedVector
<JS::Value
> RootedValueVector
;
110 typedef RootedVector
<JSObject
*> RootedObjectVector
;
111 typedef RootedVector
<JS::PropertyKey
> RootedIdVector
;
113 typedef PersistentRooted
<JSFunction
*> PersistentRootedFunction
;
114 typedef PersistentRooted
<PropertyKey
> PersistentRootedId
;
115 typedef PersistentRooted
<JSObject
*> PersistentRootedObject
;
116 typedef PersistentRooted
<JSScript
*> PersistentRootedScript
;
117 typedef PersistentRooted
<JSString
*> PersistentRootedString
;
118 typedef PersistentRooted
<JS::Symbol
*> PersistentRootedSymbol
;
119 typedef PersistentRooted
<JS::BigInt
*> PersistentRootedBigInt
;
120 typedef PersistentRooted
<Value
> PersistentRootedValue
;
122 typedef PersistentRootedVector
<PropertyKey
> PersistentRootedIdVector
;
123 typedef PersistentRootedVector
<JSObject
*> PersistentRootedObjectVector
;
125 template <typename T
>
126 using HandleVector
= Handle
<StackGCVector
<T
>>;
127 template <typename T
>
128 using MutableHandleVector
= MutableHandle
<StackGCVector
<T
>>;
131 using jsid
= JS::PropertyKey
;
133 #ifdef ENABLE_RECORD_TUPLE
134 // This takes 1 or 2 parameters. ... is just used so that
135 // it's possible to omit the comma when passing a single
137 // IF_RECORD_TUPLE(doThis)
138 // IF_RECORD_TUPLE(doThis, elseThis)
139 # define IF_RECORD_TUPLE(x, ...) x
141 # define IF_RECORD_TUPLE(x, ...) __VA_ARGS__
144 // Follows the same pattern as IF_RECORD_TUPLE
145 #ifdef ENABLE_DECORATORS
146 # define IF_DECORATORS(x, ...) x
148 # define IF_DECORATORS(x, ...) __VA_ARGS__
151 #endif /* js_TypeDecls_h */