Code

fix 1243587 and misc fixes
[inkscape.git] / src / dom / js / jspubtd.h
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 ***** */
40 #ifndef jspubtd_h___
41 #define jspubtd_h___
42 /*
43  * JS public API typedefs.
44  */
45 #include "jstypes.h"
46 #include "jscompat.h"
48 JS_BEGIN_EXTERN_C
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 */
59 /*
60  * Run-time version enumeration.  See jsconfig.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_DEFAULT = 0,
74     JSVERSION_UNKNOWN = -1
75 } JSVersion;
77 #define JSVERSION_IS_ECMA(version) \
78     ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
80 /* Result of typeof operator enumeration. */
81 typedef enum JSType {
82     JSTYPE_VOID,                /* undefined */
83     JSTYPE_OBJECT,              /* object */
84     JSTYPE_FUNCTION,            /* function */
85     JSTYPE_STRING,              /* string */
86     JSTYPE_NUMBER,              /* number */
87     JSTYPE_BOOLEAN,             /* boolean */
88     JSTYPE_NULL,                /* null */
89     JSTYPE_XML,                 /* xml object */
90     JSTYPE_LIMIT
91 } JSType;
93 /* JSObjectOps.checkAccess mode enumeration. */
94 typedef enum JSAccessMode {
95     JSACC_PROTO  = 0,           /* XXXbe redundant w.r.t. id */
96     JSACC_PARENT = 1,           /* XXXbe redundant w.r.t. id */
97     JSACC_IMPORT = 2,           /* import foo.bar */
98     JSACC_WATCH  = 3,           /* a watchpoint on object foo for id 'bar' */
99     JSACC_READ   = 4,           /* a "get" of foo.bar */
100     JSACC_WRITE  = 8,           /* a "set" of foo.bar = baz */
101     JSACC_LIMIT
102 } JSAccessMode;
104 #define JSACC_TYPEMASK          (JSACC_WRITE - 1)
106 /*
107  * This enum type is used to control the behavior of a JSObject property
108  * iterator function that has type JSNewEnumerate.
109  */
110 typedef enum JSIterateOp {
111     JSENUMERATE_INIT,       /* Create new iterator state */
112     JSENUMERATE_NEXT,       /* Iterate once */
113     JSENUMERATE_DESTROY     /* Destroy iterator state */
114 } JSIterateOp;
116 /* Struct typedefs. */
117 typedef struct JSClass           JSClass;
118 typedef struct JSExtendedClass   JSExtendedClass;
119 typedef struct JSConstDoubleSpec JSConstDoubleSpec;
120 typedef struct JSContext         JSContext;
121 typedef struct JSErrorReport     JSErrorReport;
122 typedef struct JSFunction        JSFunction;
123 typedef struct JSFunctionSpec    JSFunctionSpec;
124 typedef struct JSIdArray         JSIdArray;
125 typedef struct JSProperty        JSProperty;
126 typedef struct JSPropertySpec    JSPropertySpec;
127 typedef struct JSObject          JSObject;
128 typedef struct JSObjectMap       JSObjectMap;
129 typedef struct JSObjectOps       JSObjectOps;
130 typedef struct JSXMLObjectOps    JSXMLObjectOps;
131 typedef struct JSRuntime         JSRuntime;
132 typedef struct JSRuntime         JSTaskState;   /* XXX deprecated name */
133 typedef struct JSScript          JSScript;
134 typedef struct JSString          JSString;
135 typedef struct JSXDRState        JSXDRState;
136 typedef struct JSExceptionState  JSExceptionState;
137 typedef struct JSLocaleCallbacks JSLocaleCallbacks;
139 /* JSClass (and JSObjectOps where appropriate) function pointer typedefs. */
141 /*
142  * Add, delete, get or set a property named by id in obj.  Note the jsval id
143  * type -- id may be a string (Unicode property identifier) or an int (element
144  * index).  The *vp out parameter, on success, is the new property value after
145  * an add, get, or set.  After a successful delete, *vp is JSVAL_FALSE iff
146  * obj[id] can't be deleted (because it's permanent).
147  */
148 typedef JSBool
149 (* JS_DLL_CALLBACK JSPropertyOp)(JSContext *cx, JSObject *obj, jsval id,
150                                  jsval *vp);
152 /*
153  * This function type is used for callbacks that enumerate the properties of
154  * a JSObject.  The behavior depends on the value of enum_op:
155  *
156  *  JSENUMERATE_INIT
157  *    A new, opaque iterator state should be allocated and stored in *statep.
158  *    (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored).
159  *
160  *    The number of properties that will be enumerated should be returned as
161  *    an integer jsval in *idp, if idp is non-null, and provided the number of
162  *    enumerable properties is known.  If idp is non-null and the number of
163  *    enumerable properties can't be computed in advance, *idp should be set
164  *    to JSVAL_ZERO.
165  *
166  *  JSENUMERATE_NEXT
167  *    A previously allocated opaque iterator state is passed in via statep.
168  *    Return the next jsid in the iteration using *idp.  The opaque iterator
169  *    state pointed at by statep is destroyed and *statep is set to JSVAL_NULL
170  *    if there are no properties left to enumerate.
171  *
172  *  JSENUMERATE_DESTROY
173  *    Destroy the opaque iterator state previously allocated in *statep by a
174  *    call to this function when enum_op was JSENUMERATE_INIT.
175  *
176  * The return value is used to indicate success, with a value of JS_FALSE
177  * indicating failure.
178  */
179 typedef JSBool
180 (* JS_DLL_CALLBACK JSNewEnumerateOp)(JSContext *cx, JSObject *obj,
181                                      JSIterateOp enum_op,
182                                      jsval *statep, jsid *idp);
184 /*
185  * The old-style JSClass.enumerate op should define all lazy properties not
186  * yet reflected in obj.
187  */
188 typedef JSBool
189 (* JS_DLL_CALLBACK JSEnumerateOp)(JSContext *cx, JSObject *obj);
191 /*
192  * Resolve a lazy property named by id in obj by defining it directly in obj.
193  * Lazy properties are those reflected from some peer native property space
194  * (e.g., the DOM attributes for a given node reflected as obj) on demand.
195  *
196  * JS looks for a property in an object, and if not found, tries to resolve
197  * the given id.  If resolve succeeds, the engine looks again in case resolve
198  * defined obj[id].  If no such property exists directly in obj, the process
199  * is repeated with obj's prototype, etc.
200  *
201  * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties.
202  */
203 typedef JSBool
204 (* JS_DLL_CALLBACK JSResolveOp)(JSContext *cx, JSObject *obj, jsval id);
206 /*
207  * Like JSResolveOp, but flags provide contextual information as follows:
208  *
209  *  JSRESOLVE_QUALIFIED   a qualified property id: obj.id or obj[id], not id
210  *  JSRESOLVE_ASSIGNING   obj[id] is on the left-hand side of an assignment
211  *  JSRESOLVE_DETECTING   'if (o.p)...' or similar detection opcode sequence
212  *  JSRESOLVE_DECLARING   var, const, or function prolog declaration opcode
213  *  JSRESOLVE_CLASSNAME   class name used when constructing
214  *
215  * The *objp out parameter, on success, should be null to indicate that id
216  * was not resolved; and non-null, referring to obj or one of its prototypes,
217  * if id was resolved.
218  *
219  * This hook instead of JSResolveOp is called via the JSClass.resolve member
220  * if JSCLASS_NEW_RESOLVE is set in JSClass.flags.
221  *
222  * Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further
223  * extends this hook by passing in the starting object on the prototype chain
224  * via *objp.  Thus a resolve hook implementation may define the property id
225  * being resolved in the object in which the id was first sought, rather than
226  * in a prototype object whose class led to the resolve hook being called.
227  *
228  * When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore
229  * null *objp to signify "not resolved".  With only JSCLASS_NEW_RESOLVE and no
230  * JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry.
231  * This is not good practice, but enough existing hook implementations count
232  * on it that we can't break compatibility by passing the starting object in
233  * *objp without a new JSClass flag.
234  */
235 typedef JSBool
236 (* JS_DLL_CALLBACK JSNewResolveOp)(JSContext *cx, JSObject *obj, jsval id,
237                                    uintN flags, JSObject **objp);
239 /*
240  * Convert obj to the given type, returning true with the resulting value in
241  * *vp on success, and returning false on error or exception.
242  */
243 typedef JSBool
244 (* JS_DLL_CALLBACK JSConvertOp)(JSContext *cx, JSObject *obj, JSType type,
245                                 jsval *vp);
247 /*
248  * Finalize obj, which the garbage collector has determined to be unreachable
249  * from other live objects or from GC roots.  Obviously, finalizers must never
250  * store a reference to obj.
251  */
252 typedef void
253 (* JS_DLL_CALLBACK JSFinalizeOp)(JSContext *cx, JSObject *obj);
255 /*
256  * Used by JS_AddExternalStringFinalizer and JS_RemoveExternalStringFinalizer
257  * to extend and reduce the set of string types finalized by the GC.
258  */
259 typedef void
260 (* JS_DLL_CALLBACK JSStringFinalizeOp)(JSContext *cx, JSString *str);
262 /*
263  * The signature for JSClass.getObjectOps, used by JS_NewObject's internals
264  * to discover the set of high-level object operations to use for new objects
265  * of the given class.  All native objects have a JSClass, which is stored as
266  * a private (int-tagged) pointer in obj->slots[JSSLOT_CLASS].  In contrast,
267  * all native and host objects have a JSObjectMap at obj->map, which may be
268  * shared among a number of objects, and which contains the JSObjectOps *ops
269  * pointer used to dispatch object operations from API calls.
270  *
271  * Thus JSClass (which pre-dates JSObjectOps in the API) provides a low-level
272  * interface to class-specific code and data, while JSObjectOps allows for a
273  * higher level of operation, which does not use the object's class except to
274  * find the class's JSObjectOps struct, by calling clasp->getObjectOps, and to
275  * finalize the object.
276  *
277  * If this seems backwards, that's because it is!  API compatibility requires
278  * a JSClass *clasp parameter to JS_NewObject, etc.  Most host objects do not
279  * need to implement the larger JSObjectOps, and can share the common JSScope
280  * code and data used by the native (js_ObjectOps, see jsobj.c) ops.
281  *
282  * Further extension to preserve API compatibility: if this function returns
283  * a pointer to JSXMLObjectOps.base, not to JSObjectOps, then the engine calls
284  * extended hooks needed for E4X.
285  */
286 typedef JSObjectOps *
287 (* JS_DLL_CALLBACK JSGetObjectOps)(JSContext *cx, JSClass *clasp);
289 /*
290  * JSClass.checkAccess type: check whether obj[id] may be accessed per mode,
291  * returning false on error/exception, true on success with obj[id]'s last-got
292  * value in *vp, and its attributes in *attrsp.  As for JSPropertyOp above, id
293  * is either a string or an int jsval.
294  *
295  * See JSCheckAccessIdOp, below, for the JSObjectOps counterpart, which takes
296  * a jsid (a tagged int or aligned, unique identifier pointer) rather than a
297  * jsval.  The native js_ObjectOps.checkAccess simply forwards to the object's
298  * clasp->checkAccess, so that both JSClass and JSObjectOps implementors may
299  * specialize access checks.
300  */
301 typedef JSBool
302 (* JS_DLL_CALLBACK JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsval id,
303                                     JSAccessMode mode, jsval *vp);
305 /*
306  * Encode or decode an object, given an XDR state record representing external
307  * data.  See jsxdrapi.h.
308  */
309 typedef JSBool
310 (* JS_DLL_CALLBACK JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp);
312 /*
313  * Check whether v is an instance of obj.  Return false on error or exception,
314  * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in
315  * *bp otherwise.
316  */
317 typedef JSBool
318 (* JS_DLL_CALLBACK JSHasInstanceOp)(JSContext *cx, JSObject *obj, jsval v,
319                                     JSBool *bp);
321 /*
322  * Function type for JSClass.mark and JSObjectOps.mark, called from the GC to
323  * scan live GC-things reachable from obj's private data structure.  For each
324  * such thing, a mark implementation must call
325  *
326  *    JS_MarkGCThing(cx, thing, name, arg);
327  *
328  * The trailing name and arg parameters are used for GC_MARK_DEBUG-mode heap
329  * dumping and ref-path tracing.  The mark function should pass a (typically
330  * literal) string naming the private data member for name, and it must pass
331  * the opaque arg parameter through from its caller.
332  *
333  * For the JSObjectOps.mark hook, the return value is the number of slots at
334  * obj->slots to scan.  For JSClass.mark, the return value is ignored.
335  *
336  * NB: JSMarkOp implementations cannot allocate new GC-things (JS_NewObject
337  * called from a mark function will fail silently, e.g.).
338  */
339 typedef uint32
340 (* JS_DLL_CALLBACK JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);
342 /*
343  * The optional JSClass.reserveSlots hook allows a class to make computed
344  * per-instance object slots reservations, in addition to or instead of using
345  * JSCLASS_HAS_RESERVED_SLOTS(n) in the JSClass.flags initializer to reserve
346  * a constant-per-class number of slots.  Implementations of this hook should
347  * return the number of slots to reserve, not including any reserved by using
348  * JSCLASS_HAS_RESERVED_SLOTS(n) in JSClass.flags.
349  *
350  * NB: called with obj locked by the JSObjectOps-specific mutual exclusion
351  * mechanism appropriate for obj, so don't nest other operations that might
352  * also lock obj.
353  */
354 typedef uint32
355 (* JS_DLL_CALLBACK JSReserveSlotsOp)(JSContext *cx, JSObject *obj);
357 /* JSObjectOps function pointer typedefs. */
359 /*
360  * Create a new subclass of JSObjectMap (see jsobj.h), with the nrefs and ops
361  * members initialized from the same-named parameters, and with the nslots and
362  * freeslot members initialized according to ops and clasp.  Return null on
363  * error, non-null on success.
364  *
365  * JSObjectMaps are reference-counted by generic code in the engine.  Usually,
366  * the nrefs parameter to JSObjectOps.newObjectMap will be 1, to count the ref
367  * returned to the caller on success.  After a successful construction, some
368  * number of js_HoldObjectMap and js_DropObjectMap calls ensue.  When nrefs
369  * reaches 0 due to a js_DropObjectMap call, JSObjectOps.destroyObjectMap will
370  * be called to dispose of the map.
371  */
372 typedef JSObjectMap *
373 (* JS_DLL_CALLBACK JSNewObjectMapOp)(JSContext *cx, jsrefcount nrefs,
374                                      JSObjectOps *ops, JSClass *clasp,
375                                      JSObject *obj);
377 /*
378  * Generic type for an infallible JSObjectMap operation, used currently by
379  * JSObjectOps.destroyObjectMap.
380  */
381 typedef void
382 (* JS_DLL_CALLBACK JSObjectMapOp)(JSContext *cx, JSObjectMap *map);
384 /*
385  * Look for id in obj and its prototype chain, returning false on error or
386  * exception, true on success.  On success, return null in *propp if id was
387  * not found.  If id was found, return the first object searching from obj
388  * along its prototype chain in which id names a direct property in *objp, and
389  * return a non-null, opaque property pointer in *propp.
390  *
391  * If JSLookupPropOp succeeds and returns with *propp non-null, that pointer
392  * may be passed as the prop parameter to a JSAttributesOp, as a short-cut
393  * that bypasses id re-lookup.  In any case, a non-null *propp result after a
394  * successful lookup must be dropped via JSObjectOps.dropProperty.
395  *
396  * NB: successful return with non-null *propp means the implementation may
397  * have locked *objp and added a reference count associated with *propp, so
398  * callers should not risk deadlock by nesting or interleaving other lookups
399  * or any obj-bearing ops before dropping *propp.
400  */
401 typedef JSBool
402 (* JS_DLL_CALLBACK JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id,
403                                    JSObject **objp, JSProperty **propp);
405 /*
406  * Define obj[id], a direct property of obj named id, having the given initial
407  * value, with the specified getter, setter, and attributes.  If the propp out
408  * param is non-null, *propp on successful return contains an opaque property
409  * pointer usable as a speedup hint with JSAttributesOp.  But note that propp
410  * may be null, indicating that the caller is not interested in recovering an
411  * opaque pointer to the newly-defined property.
412  *
413  * If propp is non-null and JSDefinePropOp succeeds, its caller must be sure
414  * to drop *propp using JSObjectOps.dropProperty in short order, just as with
415  * JSLookupPropOp.
416  */
417 typedef JSBool
418 (* JS_DLL_CALLBACK JSDefinePropOp)(JSContext *cx, JSObject *obj,
419                                    jsid id, jsval value,
420                                    JSPropertyOp getter, JSPropertyOp setter,
421                                    uintN attrs, JSProperty **propp);
423 /*
424  * Get, set, or delete obj[id], returning false on error or exception, true
425  * on success.  If getting or setting, the new value is returned in *vp on
426  * success.  If deleting without error, *vp will be JSVAL_FALSE if obj[id] is
427  * permanent, and JSVAL_TRUE if id named a direct property of obj that was in
428  * fact deleted, or if id names no direct property of obj (id could name a
429  * prototype property, or no property in obj or its prototype chain).
430  */
431 typedef JSBool
432 (* JS_DLL_CALLBACK JSPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id,
433                                    jsval *vp);
435 /*
436  * Get or set attributes of the property obj[id].  Return false on error or
437  * exception, true with current attributes in *attrsp.  If prop is non-null,
438  * it must come from the *propp out parameter of a prior JSDefinePropOp or
439  * JSLookupPropOp call.
440  */
441 typedef JSBool
442 (* JS_DLL_CALLBACK JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id,
443                                    JSProperty *prop, uintN *attrsp);
445 /*
446  * JSObjectOps.checkAccess type: check whether obj[id] may be accessed per
447  * mode, returning false on error/exception, true on success with obj[id]'s
448  * last-got value in *vp, and its attributes in *attrsp.
449  */
450 typedef JSBool
451 (* JS_DLL_CALLBACK JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id,
452                                       JSAccessMode mode, jsval *vp,
453                                       uintN *attrsp);
455 /*
456  * A generic type for functions mapping an object to another object, or null
457  * if an error or exception was thrown on cx.  Used by JSObjectOps.thisObject
458  * at present.
459  */
460 typedef JSObject *
461 (* JS_DLL_CALLBACK JSObjectOp)(JSContext *cx, JSObject *obj);
463 /*
464  * A generic type for functions taking a context, object, and property, with
465  * no return value.  Used by JSObjectOps.dropProperty currently (see above,
466  * JSDefinePropOp and JSLookupPropOp, for the object-locking protocol in which
467  * dropProperty participates).
468  */
469 typedef void
470 (* JS_DLL_CALLBACK JSPropertyRefOp)(JSContext *cx, JSObject *obj,
471                                     JSProperty *prop);
473 /*
474  * Function type for JSObjectOps.setProto and JSObjectOps.setParent.  These
475  * hooks must check for cycles without deadlocking, and otherwise take special
476  * steps.  See jsobj.c, js_SetProtoOrParent, for an example.
477  */
478 typedef JSBool
479 (* JS_DLL_CALLBACK JSSetObjectSlotOp)(JSContext *cx, JSObject *obj,
480                                       uint32 slot, JSObject *pobj);
482 /*
483  * Get and set a required slot, one that should already have been allocated.
484  * These operations are infallible, so required slots must be pre-allocated,
485  * or implementations must suppress out-of-memory errors.  The native ops
486  * (js_ObjectOps, see jsobj.c) access slots reserved by including a call to
487  * the JSCLASS_HAS_RESERVED_SLOTS(n) macro in the JSClass.flags initializer.
488  *
489  * NB: the slot parameter is a zero-based index into obj->slots[], unlike the
490  * index parameter to the JS_GetReservedSlot and JS_SetReservedSlot API entry
491  * points, which is a zero-based index into the JSCLASS_RESERVED_SLOTS(clasp)
492  * reserved slots that come after the initial well-known slots: proto, parent,
493  * class, and optionally, the private data slot.
494  */
495 typedef jsval
496 (* JS_DLL_CALLBACK JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj,
497                                         uint32 slot);
499 typedef JSBool
500 (* JS_DLL_CALLBACK JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj,
501                                         uint32 slot, jsval v);
503 typedef JSObject *
504 (* JS_DLL_CALLBACK JSGetMethodOp)(JSContext *cx, JSObject *obj, jsid id,
505                                   jsval *vp);
507 typedef JSBool
508 (* JS_DLL_CALLBACK JSSetMethodOp)(JSContext *cx, JSObject *obj, jsid id,
509                                   jsval *vp);
511 typedef JSBool
512 (* JS_DLL_CALLBACK JSEnumerateValuesOp)(JSContext *cx, JSObject *obj,
513                                         JSIterateOp enum_op,
514                                         jsval *statep, jsid *idp, jsval *vp);
516 typedef JSBool
517 (* JS_DLL_CALLBACK JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v,
518                                  JSBool *bp);
520 typedef JSBool
521 (* JS_DLL_CALLBACK JSConcatenateOp)(JSContext *cx, JSObject *obj, jsval v,
522                                     jsval *vp);
524 /* Typedef for native functions called by the JS VM. */
526 typedef JSBool
527 (* JS_DLL_CALLBACK JSNative)(JSContext *cx, JSObject *obj, uintN argc,
528                              jsval *argv, jsval *rval);
530 /* Callbacks and their arguments. */
532 typedef enum JSGCStatus {
533     JSGC_BEGIN,
534     JSGC_END,
535     JSGC_MARK_END,
536     JSGC_FINALIZE_END
537 } JSGCStatus;
539 typedef JSBool
540 (* JS_DLL_CALLBACK JSGCCallback)(JSContext *cx, JSGCStatus status);
542 typedef JSBool
543 (* JS_DLL_CALLBACK JSBranchCallback)(JSContext *cx, JSScript *script);
545 typedef void
546 (* JS_DLL_CALLBACK JSErrorReporter)(JSContext *cx, const char *message,
547                                     JSErrorReport *report);
549 typedef struct JSErrorFormatString {
550     /* The error format string (UTF-8 if JS_C_STRINGS_ARE_UTF8 is defined). */
551     const char *format;
553     /* The number of arguments to expand in the formatted error message. */
554     uint16 argCount;
556     /* One of the JSExnType constants above. */
557     int16 exnType;
558 } JSErrorFormatString;
560 typedef const JSErrorFormatString *
561 (* JS_DLL_CALLBACK JSErrorCallback)(void *userRef, const char *locale,
562                                     const uintN errorNumber);
564 #ifdef va_start
565 #define JS_ARGUMENT_FORMATTER_DEFINED 1
567 typedef JSBool
568 (* JS_DLL_CALLBACK JSArgumentFormatter)(JSContext *cx, const char *format,
569                                         JSBool fromJS, jsval **vpp,
570                                         va_list *app);
571 #endif
573 typedef JSBool
574 (* JS_DLL_CALLBACK JSLocaleToUpperCase)(JSContext *cx, JSString *src,
575                                         jsval *rval);
577 typedef JSBool
578 (* JS_DLL_CALLBACK JSLocaleToLowerCase)(JSContext *cx, JSString *src,
579                                         jsval *rval);
581 typedef JSBool
582 (* JS_DLL_CALLBACK JSLocaleCompare)(JSContext *cx,
583                                     JSString *src1, JSString *src2,
584                                     jsval *rval);
586 typedef JSBool
587 (* JS_DLL_CALLBACK JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval);
589 /*
590  * Security protocol types.
591  */
592 typedef struct JSPrincipals JSPrincipals;
594 /*
595  * XDR-encode or -decode a principals instance, based on whether xdr->mode is
596  * JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE,
597  * in which case implementations must return a held (via JSPRINCIPALS_HOLD),
598  * non-null *principalsp out parameter.  Return true on success, false on any
599  * error, which the implementation must have reported.
600  */
601 typedef JSBool
602 (* JS_DLL_CALLBACK JSPrincipalsTranscoder)(JSXDRState *xdr,
603                                            JSPrincipals **principalsp);
605 /*
606  * Return a weak reference to the principals associated with obj, possibly via
607  * the immutable parent chain leading from obj to a top-level container (e.g.,
608  * a window object in the DOM level 0).  If there are no principals associated
609  * with obj, return null.  Therefore null does not mean an error was reported;
610  * in no event should an error be reported or an exception be thrown by this
611  * callback's implementation.
612  */
613 typedef JSPrincipals *
614 (* JS_DLL_CALLBACK JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj);
616 JS_END_EXTERN_C
618 #endif /* jspubtd_h___ */