1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 |
* |
3 |
* ***** BEGIN LICENSE BLOCK ***** |
4 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
5 |
* |
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/ |
10 |
* |
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. |
15 |
* |
16 |
* The Original Code is Mozilla Communicator client code, released |
17 |
* March 31, 1998. |
18 |
* |
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. |
23 |
* |
24 |
* Contributor(s): |
25 |
* |
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. |
37 |
* |
38 |
* ***** END LICENSE BLOCK ***** */ |
39 |
|
40 |
#ifndef jspubtd_h___ |
41 |
#define jspubtd_h___ |
42 |
/* |
43 |
* JS public API typedefs. |
44 |
*/ |
45 |
#include "jstypes.h" |
46 |
#include "jscompat.h" |
47 |
|
48 |
JS_BEGIN_EXTERN_C |
49 |
|
50 |
/* Scalar typedefs. */ |
51 |
typedef uint16 jschar; |
52 |
typedef int32 jsint; |
53 |
typedef uint32 jsuint; |
54 |
typedef float64 jsdouble; |
55 |
typedef jsword jsval; |
56 |
typedef jsword jsid; |
57 |
typedef int32 jsrefcount; /* PRInt32 if JS_THREADSAFE, see jslock.h */ |
58 |
|
59 |
/* |
60 |
* Run-time version enumeration. See jsversion.h for compile-time counterparts |
61 |
* to these values that may be selected by the JS_VERSION macro, and tested by |
62 |
* #if expressions. |
63 |
*/ |
64 |
typedef enum JSVersion { |
65 |
JSVERSION_1_0 = 100, |
66 |
JSVERSION_1_1 = 110, |
67 |
JSVERSION_1_2 = 120, |
68 |
JSVERSION_1_3 = 130, |
69 |
JSVERSION_1_4 = 140, |
70 |
JSVERSION_ECMA_3 = 148, |
71 |
JSVERSION_1_5 = 150, |
72 |
JSVERSION_1_6 = 160, |
73 |
JSVERSION_1_7 = 170, |
74 |
JSVERSION_1_8 = 180, |
75 |
JSVERSION_DEFAULT = 0, |
76 |
JSVERSION_UNKNOWN = -1, |
77 |
JSVERSION_LATEST = JSVERSION_1_8 |
78 |
} JSVersion; |
79 |
|
80 |
#define JSVERSION_IS_ECMA(version) \ |
81 |
((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3) |
82 |
|
83 |
/* Result of typeof operator enumeration. */ |
84 |
typedef enum JSType { |
85 |
JSTYPE_VOID, /* undefined */ |
86 |
JSTYPE_OBJECT, /* object */ |
87 |
JSTYPE_FUNCTION, /* function */ |
88 |
JSTYPE_STRING, /* string */ |
89 |
JSTYPE_NUMBER, /* number */ |
90 |
JSTYPE_BOOLEAN, /* boolean */ |
91 |
JSTYPE_NULL, /* null */ |
92 |
JSTYPE_XML, /* xml object */ |
93 |
JSTYPE_LIMIT |
94 |
} JSType; |
95 |
|
96 |
/* Dense index into cached prototypes and class atoms for standard objects. */ |
97 |
typedef enum JSProtoKey { |
98 |
#define JS_PROTO(name,code,init) JSProto_##name = code, |
99 |
#include "jsproto.tbl" |
100 |
#undef JS_PROTO |
101 |
JSProto_LIMIT |
102 |
} JSProtoKey; |
103 |
|
104 |
/* JSObjectOps.checkAccess mode enumeration. */ |
105 |
typedef enum JSAccessMode { |
106 |
JSACC_PROTO = 0, /* XXXbe redundant w.r.t. id */ |
107 |
JSACC_PARENT = 1, /* XXXbe redundant w.r.t. id */ |
108 |
|
109 |
/* |
110 |
* enum value #2 formerly called JSACC_IMPORT, |
111 |
* gap preserved for ABI compatibility. |
112 |
*/ |
113 |
|
114 |
JSACC_WATCH = 3, /* a watchpoint on object foo for id 'bar' */ |
115 |
JSACC_READ = 4, /* a "get" of foo.bar */ |
116 |
JSACC_WRITE = 8, /* a "set" of foo.bar = baz */ |
117 |
JSACC_LIMIT |
118 |
} JSAccessMode; |
119 |
|
120 |
#define JSACC_TYPEMASK (JSACC_WRITE - 1) |
121 |
|
122 |
/* |
123 |
* This enum type is used to control the behavior of a JSObject property |
124 |
* iterator function that has type JSNewEnumerate. |
125 |
*/ |
126 |
typedef enum JSIterateOp { |
127 |
JSENUMERATE_INIT, /* Create new iterator state */ |
128 |
JSENUMERATE_NEXT, /* Iterate once */ |
129 |
JSENUMERATE_DESTROY /* Destroy iterator state */ |
130 |
} JSIterateOp; |
131 |
|
132 |
/* Struct typedefs. */ |
133 |
typedef struct JSClass JSClass; |
134 |
typedef struct JSExtendedClass JSExtendedClass; |
135 |
typedef struct JSConstDoubleSpec JSConstDoubleSpec; |
136 |
typedef struct JSContext JSContext; |
137 |
typedef struct JSErrorReport JSErrorReport; |
138 |
typedef struct JSFunction JSFunction; |
139 |
typedef struct JSFunctionSpec JSFunctionSpec; |
140 |
typedef struct JSTracer JSTracer; |
141 |
typedef struct JSIdArray JSIdArray; |
142 |
typedef struct JSPropertyDescriptor JSPropertyDescriptor; |
143 |
typedef struct JSPropertySpec JSPropertySpec; |
144 |
typedef struct JSObject JSObject; |
145 |
typedef struct JSObjectMap JSObjectMap; |
146 |
typedef struct JSObjectOps JSObjectOps; |
147 |
typedef struct JSRuntime JSRuntime; |
148 |
typedef struct JSScript JSScript; |
149 |
typedef struct JSStackFrame JSStackFrame; |
150 |
typedef struct JSString JSString; |
151 |
typedef struct JSXDRState JSXDRState; |
152 |
typedef struct JSExceptionState JSExceptionState; |
153 |
typedef struct JSLocaleCallbacks JSLocaleCallbacks; |
154 |
typedef struct JSSecurityCallbacks JSSecurityCallbacks; |
155 |
typedef struct JSONParser JSONParser; |
156 |
|
157 |
/* JSClass (and JSObjectOps where appropriate) function pointer typedefs. */ |
158 |
|
159 |
/* |
160 |
* Add, delete, get or set a property named by id in obj. Note the jsval id |
161 |
* type -- id may be a string (Unicode property identifier) or an int (element |
162 |
* index). The *vp out parameter, on success, is the new property value after |
163 |
* an add, get, or set. After a successful delete, *vp is JSVAL_FALSE iff |
164 |
* obj[id] can't be deleted (because it's permanent). |
165 |
*/ |
166 |
typedef JSBool |
167 |
(* JSPropertyOp)(JSContext *cx, JSObject *obj, jsval id, jsval *vp); |
168 |
|
169 |
/* |
170 |
* This function type is used for callbacks that enumerate the properties of |
171 |
* a JSObject. The behavior depends on the value of enum_op: |
172 |
* |
173 |
* JSENUMERATE_INIT |
174 |
* A new, opaque iterator state should be allocated and stored in *statep. |
175 |
* (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored). |
176 |
* |
177 |
* The number of properties that will be enumerated should be returned as |
178 |
* an integer jsval in *idp, if idp is non-null, and provided the number of |
179 |
* enumerable properties is known. If idp is non-null and the number of |
180 |
* enumerable properties can't be computed in advance, *idp should be set |
181 |
* to JSVAL_ZERO. |
182 |
* |
183 |
* JSENUMERATE_NEXT |
184 |
* A previously allocated opaque iterator state is passed in via statep. |
185 |
* Return the next jsid in the iteration using *idp. The opaque iterator |
186 |
* state pointed at by statep is destroyed and *statep is set to JSVAL_NULL |
187 |
* if there are no properties left to enumerate. |
188 |
* |
189 |
* JSENUMERATE_DESTROY |
190 |
* Destroy the opaque iterator state previously allocated in *statep by a |
191 |
* call to this function when enum_op was JSENUMERATE_INIT. |
192 |
* |
193 |
* The return value is used to indicate success, with a value of JS_FALSE |
194 |
* indicating failure. |
195 |
*/ |
196 |
typedef JSBool |
197 |
(* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op, |
198 |
jsval *statep, jsid *idp); |
199 |
|
200 |
/* |
201 |
* The old-style JSClass.enumerate op should define all lazy properties not |
202 |
* yet reflected in obj. |
203 |
*/ |
204 |
typedef JSBool |
205 |
(* JSEnumerateOp)(JSContext *cx, JSObject *obj); |
206 |
|
207 |
/* |
208 |
* Resolve a lazy property named by id in obj by defining it directly in obj. |
209 |
* Lazy properties are those reflected from some peer native property space |
210 |
* (e.g., the DOM attributes for a given node reflected as obj) on demand. |
211 |
* |
212 |
* JS looks for a property in an object, and if not found, tries to resolve |
213 |
* the given id. If resolve succeeds, the engine looks again in case resolve |
214 |
* defined obj[id]. If no such property exists directly in obj, the process |
215 |
* is repeated with obj's prototype, etc. |
216 |
* |
217 |
* NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. |
218 |
*/ |
219 |
typedef JSBool |
220 |
(* JSResolveOp)(JSContext *cx, JSObject *obj, jsval id); |
221 |
|
222 |
/* |
223 |
* Like JSResolveOp, but flags provide contextual information as follows: |
224 |
* |
225 |
* JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not id |
226 |
* JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment |
227 |
* JSRESOLVE_DETECTING 'if (o.p)...' or similar detection opcode sequence |
228 |
* JSRESOLVE_DECLARING var, const, or function prolog declaration opcode |
229 |
* JSRESOLVE_CLASSNAME class name used when constructing |
230 |
* |
231 |
* The *objp out parameter, on success, should be null to indicate that id |
232 |
* was not resolved; and non-null, referring to obj or one of its prototypes, |
233 |
* if id was resolved. |
234 |
* |
235 |
* This hook instead of JSResolveOp is called via the JSClass.resolve member |
236 |
* if JSCLASS_NEW_RESOLVE is set in JSClass.flags. |
237 |
* |
238 |
* Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further |
239 |
* extends this hook by passing in the starting object on the prototype chain |
240 |
* via *objp. Thus a resolve hook implementation may define the property id |
241 |
* being resolved in the object in which the id was first sought, rather than |
242 |
* in a prototype object whose class led to the resolve hook being called. |
243 |
* |
244 |
* When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore |
245 |
* null *objp to signify "not resolved". With only JSCLASS_NEW_RESOLVE and no |
246 |
* JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry. |
247 |
* This is not good practice, but enough existing hook implementations count |
248 |
* on it that we can't break compatibility by passing the starting object in |
249 |
* *objp without a new JSClass flag. |
250 |
*/ |
251 |
typedef JSBool |
252 |
(* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsval id, uintN flags, |
253 |
JSObject **objp); |
254 |
|
255 |
/* |
256 |
* Convert obj to the given type, returning true with the resulting value in |
257 |
* *vp on success, and returning false on error or exception. |
258 |
*/ |
259 |
typedef JSBool |
260 |
(* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp); |
261 |
|
262 |
/* |
263 |
* Finalize obj, which the garbage collector has determined to be unreachable |
264 |
* from other live objects or from GC roots. Obviously, finalizers must never |
265 |
* store a reference to obj. |
266 |
*/ |
267 |
typedef void |
268 |
(* JSFinalizeOp)(JSContext *cx, JSObject *obj); |
269 |
|
270 |
/* |
271 |
* Used by JS_AddExternalStringFinalizer and JS_RemoveExternalStringFinalizer |
272 |
* to extend and reduce the set of string types finalized by the GC. |
273 |
*/ |
274 |
typedef void |
275 |
(* JSStringFinalizeOp)(JSContext *cx, JSString *str); |
276 |
|
277 |
/* |
278 |
* The signature for JSClass.getObjectOps, used by JS_NewObject's internals |
279 |
* to discover the set of high-level object operations to use for new objects |
280 |
* of the given class. All native objects have a JSClass, which is stored as |
281 |
* a private (int-tagged) pointer in obj slots. In contrast, all native and |
282 |
* host objects have a JSObjectMap at obj->map, which may be shared among a |
283 |
* number of objects, and which contains the JSObjectOps *ops pointer used to |
284 |
* dispatch object operations from API calls. |
285 |
* |
286 |
* Thus JSClass (which pre-dates JSObjectOps in the API) provides a low-level |
287 |
* interface to class-specific code and data, while JSObjectOps allows for a |
288 |
* higher level of operation, which does not use the object's class except to |
289 |
* find the class's JSObjectOps struct, by calling clasp->getObjectOps, and to |
290 |
* finalize the object. |
291 |
* |
292 |
* If this seems backwards, that's because it is! API compatibility requires |
293 |
* a JSClass *clasp parameter to JS_NewObject, etc. Most host objects do not |
294 |
* need to implement the larger JSObjectOps, and can share the common JSScope |
295 |
* code and data used by the native (js_ObjectOps, see jsobj.c) ops. |
296 |
*/ |
297 |
typedef JSObjectOps * |
298 |
(* JSGetObjectOps)(JSContext *cx, JSClass *clasp); |
299 |
|
300 |
/* |
301 |
* JSClass.checkAccess type: check whether obj[id] may be accessed per mode, |
302 |
* returning false on error/exception, true on success with obj[id]'s last-got |
303 |
* value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id |
304 |
* is either a string or an int jsval. |
305 |
* |
306 |
* See JSCheckAccessIdOp, below, for the JSObjectOps counterpart, which takes |
307 |
* a jsid (a tagged int or aligned, unique identifier pointer) rather than a |
308 |
* jsval. The native js_ObjectOps.checkAccess simply forwards to the object's |
309 |
* clasp->checkAccess, so that both JSClass and JSObjectOps implementors may |
310 |
* specialize access checks. |
311 |
*/ |
312 |
typedef JSBool |
313 |
(* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode, |
314 |
jsval *vp); |
315 |
|
316 |
/* |
317 |
* Encode or decode an object, given an XDR state record representing external |
318 |
* data. See jsxdrapi.h. |
319 |
*/ |
320 |
typedef JSBool |
321 |
(* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp); |
322 |
|
323 |
/* |
324 |
* Check whether v is an instance of obj. Return false on error or exception, |
325 |
* true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in |
326 |
* *bp otherwise. |
327 |
*/ |
328 |
typedef JSBool |
329 |
(* JSHasInstanceOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); |
330 |
|
331 |
/* |
332 |
* Deprecated function type for JSClass.mark. All new code should define |
333 |
* JSTraceOp instead to ensure the traversal of traceable things stored in |
334 |
* the native structures. |
335 |
*/ |
336 |
typedef uint32 |
337 |
(* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg); |
338 |
|
339 |
/* |
340 |
* Function type for trace operation of the class called to enumerate all |
341 |
* traceable things reachable from obj's private data structure. For each such |
342 |
* thing, a trace implementation must call |
343 |
* |
344 |
* JS_CallTracer(trc, thing, kind); |
345 |
* |
346 |
* or one of its convenience macros as described in jsapi.h. |
347 |
* |
348 |
* JSTraceOp implementation can assume that no other threads mutates object |
349 |
* state. It must not change state of the object or corresponding native |
350 |
* structures. The only exception for this rule is the case when the embedding |
351 |
* needs a tight integration with GC. In that case the embedding can check if |
352 |
* the traversal is a part of the marking phase through calling |
353 |
* JS_IsGCMarkingTracer and apply a special code like emptying caches or |
354 |
* marking its native structures. |
355 |
* |
356 |
* To define the tracer for a JSClass, the implementation must add |
357 |
* JSCLASS_MARK_IS_TRACE to class flags and use JS_CLASS_TRACE(method) |
358 |
* macro below to convert JSTraceOp to JSMarkOp when initializing or |
359 |
* assigning JSClass.mark field. |
360 |
*/ |
361 |
typedef void |
362 |
(* JSTraceOp)(JSTracer *trc, JSObject *obj); |
363 |
|
364 |
#if defined __GNUC__ && __GNUC__ >= 4 && !defined __cplusplus |
365 |
# define JS_CLASS_TRACE(method) \ |
366 |
(__builtin_types_compatible_p(JSTraceOp, __typeof(&(method))) \ |
367 |
? (JSMarkOp)(method) \ |
368 |
: js_WrongTypeForClassTracer) |
369 |
|
370 |
extern JSMarkOp js_WrongTypeForClassTracer; |
371 |
|
372 |
#else |
373 |
# define JS_CLASS_TRACE(method) ((JSMarkOp)(method)) |
374 |
#endif |
375 |
|
376 |
/* |
377 |
* Tracer callback, called for each traceable thing directly refrenced by a |
378 |
* particular object or runtime structure. It is the callback responsibility |
379 |
* to ensure the traversal of the full object graph via calling eventually |
380 |
* JS_TraceChildren on the passed thing. In this case the callback must be |
381 |
* prepared to deal with cycles in the traversal graph. |
382 |
* |
383 |
* kind argument is one of JSTRACE_OBJECT, JSTRACE_DOUBLE, JSTRACE_STRING or |
384 |
* a tag denoting internal implementation-specific traversal kind. In the |
385 |
* latter case the only operations on thing that the callback can do is to call |
386 |
* JS_TraceChildren or DEBUG-only JS_PrintTraceThingInfo. |
387 |
*/ |
388 |
typedef void |
389 |
(* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind); |
390 |
|
391 |
/* |
392 |
* DEBUG only callback that JSTraceOp implementation can provide to return |
393 |
* a string describing the reference traced with JS_CallTracer. |
394 |
*/ |
395 |
typedef void |
396 |
(* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); |
397 |
|
398 |
/* |
399 |
* The optional JSClass.reserveSlots hook allows a class to make computed |
400 |
* per-instance object slots reservations, in addition to or instead of using |
401 |
* JSCLASS_HAS_RESERVED_SLOTS(n) in the JSClass.flags initializer to reserve |
402 |
* a constant-per-class number of slots. Implementations of this hook should |
403 |
* return the number of slots to reserve, not including any reserved by using |
404 |
* JSCLASS_HAS_RESERVED_SLOTS(n) in JSClass.flags. |
405 |
* |
406 |
* NB: called with obj locked by the JSObjectOps-specific mutual exclusion |
407 |
* mechanism appropriate for obj, so don't nest other operations that might |
408 |
* also lock obj. |
409 |
*/ |
410 |
typedef uint32 |
411 |
(* JSReserveSlotsOp)(JSContext *cx, JSObject *obj); |
412 |
|
413 |
/* JSExtendedClass function pointer typedefs. */ |
414 |
|
415 |
typedef JSBool |
416 |
(* JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp); |
417 |
|
418 |
/* |
419 |
* A generic type for functions mapping an object to another object, or null |
420 |
* if an error or exception was thrown on cx. Used by JSObjectOps.thisObject |
421 |
* at present. |
422 |
*/ |
423 |
typedef JSObject * |
424 |
(* JSObjectOp)(JSContext *cx, JSObject *obj); |
425 |
|
426 |
/* |
427 |
* Hook that creates an iterator object for a given object. Returns the |
428 |
* iterator object or null if an error or exception was thrown on cx. |
429 |
*/ |
430 |
typedef JSObject * |
431 |
(* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly); |
432 |
|
433 |
/* Typedef for native functions called by the JS VM. */ |
434 |
|
435 |
typedef JSBool |
436 |
(* JSNative)(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, |
437 |
jsval *rval); |
438 |
|
439 |
/* See jsapi.h, the JS_CALLEE, JS_THIS, etc. macros. */ |
440 |
typedef JSBool |
441 |
(* JSFastNative)(JSContext *cx, uintN argc, jsval *vp); |
442 |
|
443 |
/* Callbacks and their arguments. */ |
444 |
|
445 |
typedef enum JSContextOp { |
446 |
JSCONTEXT_NEW, |
447 |
JSCONTEXT_DESTROY |
448 |
} JSContextOp; |
449 |
|
450 |
/* |
451 |
* The possible values for contextOp when the runtime calls the callback are: |
452 |
* JSCONTEXT_NEW JS_NewContext successfully created a new JSContext |
453 |
* instance. The callback can initialize the instance as |
454 |
* required. If the callback returns false, the instance |
455 |
* will be destroyed and JS_NewContext returns null. In |
456 |
* this case the callback is not called again. |
457 |
* JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The |
458 |
* callback may perform its own cleanup and must always |
459 |
* return true. |
460 |
* Any other value For future compatibility the callback must do nothing |
461 |
* and return true in this case. |
462 |
*/ |
463 |
typedef JSBool |
464 |
(* JSContextCallback)(JSContext *cx, uintN contextOp); |
465 |
|
466 |
#ifndef JS_THREADSAFE |
467 |
typedef void |
468 |
(* JSHeartbeatCallback)(JSRuntime *rt); |
469 |
#endif |
470 |
|
471 |
typedef enum JSGCStatus { |
472 |
JSGC_BEGIN, |
473 |
JSGC_END, |
474 |
JSGC_MARK_END, |
475 |
JSGC_FINALIZE_END |
476 |
} JSGCStatus; |
477 |
|
478 |
typedef JSBool |
479 |
(* JSGCCallback)(JSContext *cx, JSGCStatus status); |
480 |
|
481 |
/* |
482 |
* Generic trace operation that calls JS_CallTracer on each traceable thing |
483 |
* stored in data. |
484 |
*/ |
485 |
typedef void |
486 |
(* JSTraceDataOp)(JSTracer *trc, void *data); |
487 |
|
488 |
typedef JSBool |
489 |
(* JSOperationCallback)(JSContext *cx); |
490 |
|
491 |
/* |
492 |
* Deprecated form of JSOperationCallback. |
493 |
*/ |
494 |
typedef JSBool |
495 |
(* JSBranchCallback)(JSContext *cx, JSScript *script); |
496 |
|
497 |
typedef void |
498 |
(* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); |
499 |
|
500 |
/* |
501 |
* Possible exception types. These types are part of a JSErrorFormatString |
502 |
* structure. They define which error to throw in case of a runtime error. |
503 |
* JSEXN_NONE marks an unthrowable error. |
504 |
*/ |
505 |
typedef enum JSExnType { |
506 |
JSEXN_NONE = -1, |
507 |
JSEXN_ERR, |
508 |
JSEXN_INTERNALERR, |
509 |
JSEXN_EVALERR, |
510 |
JSEXN_RANGEERR, |
511 |
JSEXN_REFERENCEERR, |
512 |
JSEXN_SYNTAXERR, |
513 |
JSEXN_TYPEERR, |
514 |
JSEXN_URIERR, |
515 |
JSEXN_LIMIT |
516 |
} JSExnType; |
517 |
|
518 |
typedef struct JSErrorFormatString { |
519 |
/* The error format string (UTF-8 if js_CStringsAreUTF8). */ |
520 |
const char *format; |
521 |
|
522 |
/* The number of arguments to expand in the formatted error message. */ |
523 |
uint16 argCount; |
524 |
|
525 |
/* One of the JSExnType constants above. */ |
526 |
int16 exnType; |
527 |
} JSErrorFormatString; |
528 |
|
529 |
typedef const JSErrorFormatString * |
530 |
(* JSErrorCallback)(void *userRef, const char *locale, |
531 |
const uintN errorNumber); |
532 |
|
533 |
#ifdef va_start |
534 |
#define JS_ARGUMENT_FORMATTER_DEFINED 1 |
535 |
|
536 |
typedef JSBool |
537 |
(* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS, |
538 |
jsval **vpp, va_list *app); |
539 |
#endif |
540 |
|
541 |
typedef JSBool |
542 |
(* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval); |
543 |
|
544 |
typedef JSBool |
545 |
(* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval); |
546 |
|
547 |
typedef JSBool |
548 |
(* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2, |
549 |
jsval *rval); |
550 |
|
551 |
typedef JSBool |
552 |
(* JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval); |
553 |
|
554 |
/* |
555 |
* Security protocol types. |
556 |
*/ |
557 |
typedef struct JSPrincipals JSPrincipals; |
558 |
|
559 |
/* |
560 |
* XDR-encode or -decode a principals instance, based on whether xdr->mode is |
561 |
* JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE, |
562 |
* in which case implementations must return a held (via JSPRINCIPALS_HOLD), |
563 |
* non-null *principalsp out parameter. Return true on success, false on any |
564 |
* error, which the implementation must have reported. |
565 |
*/ |
566 |
typedef JSBool |
567 |
(* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp); |
568 |
|
569 |
/* |
570 |
* Return a weak reference to the principals associated with obj, possibly via |
571 |
* the immutable parent chain leading from obj to a top-level container (e.g., |
572 |
* a window object in the DOM level 0). If there are no principals associated |
573 |
* with obj, return null. Therefore null does not mean an error was reported; |
574 |
* in no event should an error be reported or an exception be thrown by this |
575 |
* callback's implementation. |
576 |
*/ |
577 |
typedef JSPrincipals * |
578 |
(* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj); |
579 |
|
580 |
JS_END_EXTERN_C |
581 |
|
582 |
#endif /* jspubtd_h___ */ |