Bug 752461 - Hide click-to-play overlays when choosing "never activate plugins.....
[gecko.git] / js / src / jspubtd.h
blobc4571818468fefd591eb6f59b493a5904f34e176
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
24 * Contributor(s):
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef jspubtd_h___
41 #define jspubtd_h___
44 * JS public API typedefs.
46 #include "jstypes.h"
49 * Allow headers to reference JS::Value without #including the whole jsapi.h.
50 * Unfortunately, typedefs (hence jsval) cannot be declared.
52 #ifdef __cplusplus
53 namespace JS { class Value; }
54 #endif
57 * In release builds, jsid is defined to be an integral type. This
58 * prevents many bugs from being caught at compile time. E.g.:
60 * jsid id = ...
61 * if (id == JS_TRUE) // error
62 * ...
64 * size_t n = id; // error
66 * To catch more errors, jsid is given a struct type in C++ debug builds.
67 * Struct assignment and (in C++) operator== allow correct code to be mostly
68 * oblivious to the change. This feature can be explicitly disabled in debug
69 * builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
71 #ifdef __cplusplus
73 # if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
74 # define JS_USE_JSID_STRUCT_TYPES
75 # endif
77 # ifdef JS_USE_JSID_STRUCT_TYPES
78 struct jsid
80 size_t asBits;
81 bool operator==(jsid rhs) const { return asBits == rhs.asBits; }
82 bool operator!=(jsid rhs) const { return asBits != rhs.asBits; }
84 # define JSID_BITS(id) (id.asBits)
85 # else /* defined(JS_USE_JSID_STRUCT_TYPES) */
86 typedef ptrdiff_t jsid;
87 # define JSID_BITS(id) (id)
88 # endif /* defined(JS_USE_JSID_STRUCT_TYPES) */
89 #else /* defined(__cplusplus) */
90 typedef ptrdiff_t jsid;
91 # define JSID_BITS(id) (id)
92 #endif
94 JS_BEGIN_EXTERN_C
96 #ifdef WIN32
97 typedef wchar_t jschar;
98 #else
99 typedef uint16_t jschar;
100 #endif
103 * Run-time version enumeration. See jsversion.h for compile-time counterparts
104 * to these values that may be selected by the JS_VERSION macro, and tested by
105 * #if expressions.
107 typedef enum JSVersion {
108 JSVERSION_1_0 = 100,
109 JSVERSION_1_1 = 110,
110 JSVERSION_1_2 = 120,
111 JSVERSION_1_3 = 130,
112 JSVERSION_1_4 = 140,
113 JSVERSION_ECMA_3 = 148,
114 JSVERSION_1_5 = 150,
115 JSVERSION_1_6 = 160,
116 JSVERSION_1_7 = 170,
117 JSVERSION_1_8 = 180,
118 JSVERSION_ECMA_5 = 185,
119 JSVERSION_DEFAULT = 0,
120 JSVERSION_UNKNOWN = -1,
121 JSVERSION_LATEST = JSVERSION_ECMA_5
122 } JSVersion;
124 #define JSVERSION_IS_ECMA(version) \
125 ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
127 /* Result of typeof operator enumeration. */
128 typedef enum JSType {
129 JSTYPE_VOID, /* undefined */
130 JSTYPE_OBJECT, /* object */
131 JSTYPE_FUNCTION, /* function */
132 JSTYPE_STRING, /* string */
133 JSTYPE_NUMBER, /* number */
134 JSTYPE_BOOLEAN, /* boolean */
135 JSTYPE_NULL, /* null */
136 JSTYPE_XML, /* xml object */
137 JSTYPE_LIMIT
138 } JSType;
140 /* Dense index into cached prototypes and class atoms for standard objects. */
141 typedef enum JSProtoKey {
142 #define JS_PROTO(name,code,init) JSProto_##name = code,
143 #include "jsproto.tbl"
144 #undef JS_PROTO
145 JSProto_LIMIT
146 } JSProtoKey;
148 /* js_CheckAccess mode enumeration. */
149 typedef enum JSAccessMode {
150 JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */
151 JSACC_PARENT = 1, /* XXXbe redundant w.r.t. id */
154 * enum value #2 formerly called JSACC_IMPORT,
155 * gap preserved for ABI compatibility.
158 JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */
159 JSACC_READ = 4, /* a "get" of foo.bar */
160 JSACC_WRITE = 8, /* a "set" of foo.bar = baz */
161 JSACC_LIMIT
162 } JSAccessMode;
164 #define JSACC_TYPEMASK (JSACC_WRITE - 1)
167 * This enum type is used to control the behavior of a JSObject property
168 * iterator function that has type JSNewEnumerate.
170 typedef enum JSIterateOp {
171 /* Create new iterator state over enumerable properties. */
172 JSENUMERATE_INIT,
174 /* Create new iterator state over all properties. */
175 JSENUMERATE_INIT_ALL,
177 /* Iterate once. */
178 JSENUMERATE_NEXT,
180 /* Destroy iterator state. */
181 JSENUMERATE_DESTROY
182 } JSIterateOp;
184 /* See JSVAL_TRACE_KIND and JSTraceCallback in jsapi.h. */
185 typedef enum {
186 JSTRACE_OBJECT,
187 JSTRACE_STRING,
188 JSTRACE_SCRIPT,
191 * Trace kinds internal to the engine. The embedding can only them if it
192 * implements JSTraceCallback.
194 #if JS_HAS_XML_SUPPORT
195 JSTRACE_XML,
196 #endif
197 JSTRACE_SHAPE,
198 JSTRACE_BASE_SHAPE,
199 JSTRACE_TYPE_OBJECT,
200 JSTRACE_LAST = JSTRACE_TYPE_OBJECT
201 } JSGCTraceKind;
203 /* Struct typedefs. */
204 typedef struct JSClass JSClass;
205 typedef struct JSCompartment JSCompartment;
206 typedef struct JSConstDoubleSpec JSConstDoubleSpec;
207 typedef struct JSContext JSContext;
208 typedef struct JSCrossCompartmentCall JSCrossCompartmentCall;
209 typedef struct JSErrorReport JSErrorReport;
210 typedef struct JSExceptionState JSExceptionState;
211 typedef struct JSFunction JSFunction;
212 typedef struct JSFunctionSpec JSFunctionSpec;
213 typedef struct JSIdArray JSIdArray;
214 typedef struct JSLocaleCallbacks JSLocaleCallbacks;
215 typedef struct JSObject JSObject;
216 typedef struct JSObjectMap JSObjectMap;
217 typedef struct JSPrincipals JSPrincipals;
218 typedef struct JSPropertyDescriptor JSPropertyDescriptor;
219 typedef struct JSPropertyName JSPropertyName;
220 typedef struct JSPropertySpec JSPropertySpec;
221 typedef struct JSRuntime JSRuntime;
222 typedef struct JSSecurityCallbacks JSSecurityCallbacks;
223 typedef struct JSStackFrame JSStackFrame;
224 typedef struct JSScript JSScript;
225 typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks;
226 typedef struct JSStructuredCloneReader JSStructuredCloneReader;
227 typedef struct JSStructuredCloneWriter JSStructuredCloneWriter;
228 typedef struct JSTracer JSTracer;
230 #ifdef __cplusplus
231 class JSFlatString;
232 class JSString;
233 #else
234 typedef struct JSFlatString JSFlatString;
235 typedef struct JSString JSString;
236 #endif /* !__cplusplus */
238 #ifdef JS_THREADSAFE
239 typedef struct PRCallOnceType JSCallOnceType;
240 #else
241 typedef JSBool JSCallOnceType;
242 #endif
243 typedef JSBool (*JSInitCallback)(void);
245 JS_END_EXTERN_C
247 #ifdef __cplusplus
249 namespace JS {
251 template <typename T>
252 class Root;
254 class SkipRoot;
256 enum ThingRootKind
258 THING_ROOT_OBJECT,
259 THING_ROOT_SHAPE,
260 THING_ROOT_BASE_SHAPE,
261 THING_ROOT_TYPE_OBJECT,
262 THING_ROOT_STRING,
263 THING_ROOT_SCRIPT,
264 THING_ROOT_XML,
265 THING_ROOT_ID,
266 THING_ROOT_VALUE,
267 THING_ROOT_LIMIT
270 struct ContextFriendFields {
271 JSRuntime *const runtime;
273 ContextFriendFields(JSRuntime *rt)
274 : runtime(rt) { }
276 static const ContextFriendFields *get(const JSContext *cx) {
277 return reinterpret_cast<const ContextFriendFields *>(cx);
280 static ContextFriendFields *get(JSContext *cx) {
281 return reinterpret_cast<ContextFriendFields *>(cx);
284 #ifdef JSGC_ROOT_ANALYSIS
287 * Stack allocated GC roots for stack GC heap pointers, which may be
288 * overwritten if moved during a GC.
290 Root<void*> *thingGCRooters[THING_ROOT_LIMIT];
292 #ifdef DEBUG
294 * Stack allocated list of stack locations which hold non-relocatable
295 * GC heap pointers (where the target is rooted somewhere else) or integer
296 * values which may be confused for GC heap pointers. These are used to
297 * suppress false positives which occur when a rooting analysis treats the
298 * location as holding a relocatable pointer, but have no other effect on
299 * GC behavior.
301 SkipRoot *skipGCRooters;
302 #endif
304 #endif /* JSGC_ROOT_ANALYSIS */
307 } /* namespace JS */
309 #endif /* __cplusplus */
311 #endif /* jspubtd_h___ */