Debian Codegraph @

js/public/TypeDecls.h

raw
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/. */
6
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.
10 //
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.
16
17 #ifndef js_TypeDecls_h
18 #define js_TypeDecls_h
19
20 #include <stdint.h> // uint8_t
21
22 #include "jstypes.h" // JS_PUBLIC_API
23
24 typedef uint8_t jsbytecode;
25
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;
34
35 struct JSPrincipals;
36
37 namespace js {
38 class JS_PUBLIC_API TempAllocPolicy;
39 }; // namespace js
40
41 namespace JS {
42
43 class JS_PUBLIC_API GCContext;
44 class JS_PUBLIC_API PropertyKey;
45
46 typedef unsigned char Latin1Char;
47
48 class JS_PUBLIC_API Symbol;
49 class JS_PUBLIC_API BigInt;
50 class JS_PUBLIC_API Value;
51
52 class JS_PUBLIC_API Compartment;
53 class JS_PUBLIC_API Realm;
54 struct JS_PUBLIC_API Runtime;
55 class JS_PUBLIC_API Zone;
56
57 template <typename T>
58 class Handle;
59 template <typename T>
60 class MutableHandle;
61 template <typename T>
62 class Rooted;
63 template <typename T>
64 class PersistentRooted;
65 template <typename T>
66 class RootedVector;
67 template <typename T>
68 class PersistentRootedVector;
69 template <typename T, typename AllocPolicy = js::TempAllocPolicy>
70 class StackGCVector;
71
72 typedef Handle<JSFunction*> HandleFunction;
73 typedef Handle<PropertyKey> HandleId;
74 typedef Handle<JSObject*> HandleObject;
75 typedef Handle<JSScript*> HandleScript;
76 typedef Handle<JSString*> HandleString;
77 typedef Handle<JS::Symbol*> HandleSymbol;
78 typedef Handle<JS::BigInt*> HandleBigInt;
79 typedef Handle<Value> HandleValue;
80 typedef Handle<StackGCVector<Value>> HandleValueVector;
81 typedef Handle<StackGCVector<JSObject*>> HandleObjectVector;
82 typedef Handle<StackGCVector<JS::PropertyKey>> HandleIdVector;
83
84 typedef MutableHandle<JSFunction*> MutableHandleFunction;
85 typedef MutableHandle<PropertyKey> MutableHandleId;
86 typedef MutableHandle<JSObject*> MutableHandleObject;
87 typedef MutableHandle<JSScript*> MutableHandleScript;
88 typedef MutableHandle<JSString*> MutableHandleString;
89 typedef MutableHandle<JS::Symbol*> MutableHandleSymbol;
90 typedef MutableHandle<JS::BigInt*> MutableHandleBigInt;
91 typedef MutableHandle<Value> MutableHandleValue;
92 typedef MutableHandle<StackGCVector<Value>> MutableHandleValueVector;
93 typedef MutableHandle<StackGCVector<JSObject*>> MutableHandleObjectVector;
94 typedef MutableHandle<StackGCVector<JS::PropertyKey>> MutableHandleIdVector;
95
96 typedef Rooted<JSObject*> RootedObject;
97 typedef Rooted<JSFunction*> RootedFunction;
98 typedef Rooted<JSScript*> RootedScript;
99 typedef Rooted<JSString*> RootedString;
100 typedef Rooted<JS::Symbol*> RootedSymbol;
101 typedef Rooted<JS::BigInt*> RootedBigInt;
102 typedef Rooted<PropertyKey> RootedId;
103 typedef Rooted<JS::Value> RootedValue;
104
105 typedef RootedVector<JS::Value> RootedValueVector;
106 typedef RootedVector<JSObject*> RootedObjectVector;
107 typedef RootedVector<JS::PropertyKey> RootedIdVector;
108
109 typedef PersistentRooted<JSFunction*> PersistentRootedFunction;
110 typedef PersistentRooted<PropertyKey> PersistentRootedId;
111 typedef PersistentRooted<JSObject*> PersistentRootedObject;
112 typedef PersistentRooted<JSScript*> PersistentRootedScript;
113 typedef PersistentRooted<JSString*> PersistentRootedString;
114 typedef PersistentRooted<JS::Symbol*> PersistentRootedSymbol;
115 typedef PersistentRooted<JS::BigInt*> PersistentRootedBigInt;
116 typedef PersistentRooted<Value> PersistentRootedValue;
117
118 typedef PersistentRootedVector<PropertyKey> PersistentRootedIdVector;
119 typedef PersistentRootedVector<JSObject*> PersistentRootedObjectVector;
120
121 template <typename T>
122 using HandleVector = Handle<StackGCVector<T>>;
123 template <typename T>
124 using MutableHandleVector = MutableHandle<StackGCVector<T>>;
125 } // namespace JS
126
127 using jsid = JS::PropertyKey;
128
129 #ifdef ENABLE_DECORATORS
130 # define IF_DECORATORS(x, ...) x
131 #else
132 # define IF_DECORATORS(x, ...) __VA_ARGS__
133 #endif
134
135 #ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
136 # define IF_EXPLICIT_RESOURCE_MANAGEMENT(x, ...) x
137 #else
138 # define IF_EXPLICIT_RESOURCE_MANAGEMENT(x, ...) __VA_ARGS__
139 #endif
140
141 // Helper macros to combine build flags
142 // TODO: need to find more generalised way to combine build flags
143 #if defined(ENABLE_EXPLICIT_RESOURCE_MANAGEMENT) || defined(ENABLE_DECORATORS)
144 # define IF_EXPLICIT_RESOURCE_MANAGEMENT_OR_DECORATORS(x, ...) x
145 #else
146 # define IF_EXPLICIT_RESOURCE_MANAGEMENT_OR_DECORATORS(x, ...) __VA_ARGS__
147 #endif
148
149 #endif /* js_TypeDecls_h */