Bug 1867190 - Add prefs for PHC probablities r=glandium
[gecko.git] / js / public / TypeDecls.h
blob1686b19173df3b449311c99ffea7184862200e7b
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
9 // here.
11 // It includes only:
12 // - forward declarations of structs and classes;
13 // - typedefs;
14 // - enums (maybe).
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;
28 struct JSClass;
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;
35 struct JSPrincipals;
37 namespace js {
38 class JS_PUBLIC_API TempAllocPolicy;
39 }; // namespace js
41 namespace JS {
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;
53 #endif
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;
61 template <typename T>
62 class Handle;
63 template <typename T>
64 class MutableHandle;
65 template <typename T>
66 class Rooted;
67 template <typename T>
68 class PersistentRooted;
69 template <typename T>
70 class RootedVector;
71 template <typename T>
72 class PersistentRootedVector;
73 template <typename T, typename AllocPolicy = js::TempAllocPolicy>
74 class StackGCVector;
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>>;
129 } // namespace JS
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
136 // param:
137 // IF_RECORD_TUPLE(doThis)
138 // IF_RECORD_TUPLE(doThis, elseThis)
139 # define IF_RECORD_TUPLE(x, ...) x
140 #else
141 # define IF_RECORD_TUPLE(x, ...) __VA_ARGS__
142 #endif
144 // Follows the same pattern as IF_RECORD_TUPLE
145 #ifdef ENABLE_DECORATORS
146 # define IF_DECORATORS(x, ...) x
147 #else
148 # define IF_DECORATORS(x, ...) __VA_ARGS__
149 #endif
151 #endif /* js_TypeDecls_h */