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 <stddef.h>
21 #include <stdint.h>
22 
23 #include "jstypes.h"
24 
25 typedef uint8_t jsbytecode;
26 
27 class JS_PUBLIC_API JSAtom;
28 struct JS_PUBLIC_API JSContext;
29 struct JSClass;
30 class JS_PUBLIC_API JSFunction;
31 class JS_PUBLIC_API JSFreeOp;
32 class JS_PUBLIC_API JSObject;
33 struct JS_PUBLIC_API JSRuntime;
34 class JS_PUBLIC_API JSScript;
35 class JS_PUBLIC_API JSString;
36 
37 struct JSPrincipals;
38 
39 namespace js {
40 class JS_PUBLIC_API TempAllocPolicy;
41 };  // namespace js
42 
43 namespace JS {
44 
45 struct JS_PUBLIC_API PropertyKey;
46 
47 typedef unsigned char Latin1Char;
48 
49 class JS_PUBLIC_API Symbol;
50 class JS_PUBLIC_API BigInt;
51 class JS_PUBLIC_API Value;
52 
53 class JS_PUBLIC_API Compartment;
54 class JS_PUBLIC_API Realm;
55 struct JS_PUBLIC_API Runtime;
56 class JS_PUBLIC_API Zone;
57 
58 template <typename T>
59 class Handle;
60 template <typename T>
61 class MutableHandle;
62 template <typename T>
63 class Rooted;
64 template <typename T>
65 class PersistentRooted;
66 template <typename T>
67 class RootedVector;
68 template <typename T>
69 class PersistentRootedVector;
70 template <typename T, typename AllocPolicy = js::TempAllocPolicy>
71 class StackGCVector;
72 
73 typedef Handle<JSFunction*> HandleFunction;
74 typedef Handle<PropertyKey> HandleId;
75 typedef Handle<JSObject*> HandleObject;
76 typedef Handle<JSScript*> HandleScript;
77 typedef Handle<JSString*> HandleString;
78 typedef Handle<JS::Symbol*> HandleSymbol;
79 typedef Handle<JS::BigInt*> HandleBigInt;
80 typedef Handle<Value> HandleValue;
81 typedef Handle<StackGCVector<Value>> HandleValueVector;
82 typedef Handle<StackGCVector<JSObject*>> HandleObjectVector;
83 typedef Handle<StackGCVector<JS::PropertyKey>> HandleIdVector;
84 
85 typedef MutableHandle<JSFunction*> MutableHandleFunction;
86 typedef MutableHandle<PropertyKey> MutableHandleId;
87 typedef MutableHandle<JSObject*> MutableHandleObject;
88 typedef MutableHandle<JSScript*> MutableHandleScript;
89 typedef MutableHandle<JSString*> MutableHandleString;
90 typedef MutableHandle<JS::Symbol*> MutableHandleSymbol;
91 typedef MutableHandle<JS::BigInt*> MutableHandleBigInt;
92 typedef MutableHandle<Value> MutableHandleValue;
93 typedef MutableHandle<StackGCVector<Value>> MutableHandleValueVector;
94 typedef MutableHandle<StackGCVector<JSObject*>> MutableHandleObjectVector;
95 typedef MutableHandle<StackGCVector<JS::PropertyKey>> MutableHandleIdVector;
96 
97 typedef Rooted<JSObject*> RootedObject;
98 typedef Rooted<JSFunction*> RootedFunction;
99 typedef Rooted<JSScript*> RootedScript;
100 typedef Rooted<JSString*> RootedString;
101 typedef Rooted<JS::Symbol*> RootedSymbol;
102 typedef Rooted<JS::BigInt*> RootedBigInt;
103 typedef Rooted<PropertyKey> RootedId;
104 typedef Rooted<JS::Value> RootedValue;
105 
106 typedef RootedVector<JS::Value> RootedValueVector;
107 typedef RootedVector<JSObject*> RootedObjectVector;
108 typedef RootedVector<JS::PropertyKey> RootedIdVector;
109 
110 typedef PersistentRooted<JSFunction*> PersistentRootedFunction;
111 typedef PersistentRooted<PropertyKey> PersistentRootedId;
112 typedef PersistentRooted<JSObject*> PersistentRootedObject;
113 typedef PersistentRooted<JSScript*> PersistentRootedScript;
114 typedef PersistentRooted<JSString*> PersistentRootedString;
115 typedef PersistentRooted<JS::Symbol*> PersistentRootedSymbol;
116 typedef PersistentRooted<JS::BigInt*> PersistentRootedBigInt;
117 typedef PersistentRooted<Value> PersistentRootedValue;
118 
119 typedef PersistentRootedVector<PropertyKey> PersistentRootedIdVector;
120 typedef PersistentRootedVector<JSObject*> PersistentRootedObjectVector;
121 
122 template <typename T>
123 using HandleVector = Handle<StackGCVector<T>>;
124 template <typename T>
125 using MutableHandleVector = MutableHandle<StackGCVector<T>>;
126 }  // namespace JS
127 
128 using jsid = JS::PropertyKey;
129 
130 #endif /* js_TypeDecls_h */
131