Bug 463806 - [PATCH][@font-face] Downloaded font activation on Mac may fail due to...
[wine-gecko.git] / js / src / jspubtd.h
blob1e3f33aff06d5a2f9d37c664657f1b7697486869
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___
43 * JS public API typedefs.
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 */
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.
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;
80 #define JSVERSION_IS_ECMA(version) \
81 ((version) == JSVERSION_DEFAULT || (version) >= JSVERSION_1_3)
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;
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;
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 */
110 * enum value #2 formerly called JSACC_IMPORT,
111 * gap preserved for liveconnect ABI compatibility.
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;
120 #define JSACC_TYPEMASK (JSACC_WRITE - 1)
123 * This enum type is used to control the behavior of a JSObject property
124 * iterator function that has type JSNewEnumerate.
126 typedef enum JSIterateOp {
127 JSENUMERATE_INIT, /* Create new iterator state */
128 JSENUMERATE_NEXT, /* Iterate once */
129 JSENUMERATE_DESTROY /* Destroy iterator state */
130 } JSIterateOp;
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 JSProperty JSProperty;
143 typedef struct JSPropertySpec JSPropertySpec;
144 typedef struct JSObject JSObject;
145 typedef struct JSObjectMap JSObjectMap;
146 typedef struct JSObjectOps JSObjectOps;
147 typedef struct JSXMLObjectOps JSXMLObjectOps;
148 typedef struct JSRuntime JSRuntime;
149 typedef struct JSRuntime JSTaskState; /* XXX deprecated name */
150 typedef struct JSScript JSScript;
151 typedef struct JSStackFrame JSStackFrame;
152 typedef struct JSString JSString;
153 typedef struct JSXDRState JSXDRState;
154 typedef struct JSExceptionState JSExceptionState;
155 typedef struct JSLocaleCallbacks JSLocaleCallbacks;
156 typedef struct JSSecurityCallbacks JSSecurityCallbacks;
157 typedef struct JSONParser JSONParser;
159 /* JSClass (and JSObjectOps where appropriate) function pointer typedefs. */
162 * Add, delete, get or set a property named by id in obj. Note the jsval id
163 * type -- id may be a string (Unicode property identifier) or an int (element
164 * index). The *vp out parameter, on success, is the new property value after
165 * an add, get, or set. After a successful delete, *vp is JSVAL_FALSE iff
166 * obj[id] can't be deleted (because it's permanent).
168 typedef JSBool
169 (* JSPropertyOp)(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
172 * This function type is used for callbacks that enumerate the properties of
173 * a JSObject. The behavior depends on the value of enum_op:
175 * JSENUMERATE_INIT
176 * A new, opaque iterator state should be allocated and stored in *statep.
177 * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored).
179 * The number of properties that will be enumerated should be returned as
180 * an integer jsval in *idp, if idp is non-null, and provided the number of
181 * enumerable properties is known. If idp is non-null and the number of
182 * enumerable properties can't be computed in advance, *idp should be set
183 * to JSVAL_ZERO.
185 * JSENUMERATE_NEXT
186 * A previously allocated opaque iterator state is passed in via statep.
187 * Return the next jsid in the iteration using *idp. The opaque iterator
188 * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL
189 * if there are no properties left to enumerate.
191 * JSENUMERATE_DESTROY
192 * Destroy the opaque iterator state previously allocated in *statep by a
193 * call to this function when enum_op was JSENUMERATE_INIT.
195 * The return value is used to indicate success, with a value of JS_FALSE
196 * indicating failure.
198 typedef JSBool
199 (* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
200 jsval *statep, jsid *idp);
203 * The old-style JSClass.enumerate op should define all lazy properties not
204 * yet reflected in obj.
206 typedef JSBool
207 (* JSEnumerateOp)(JSContext *cx, JSObject *obj);
210 * Resolve a lazy property named by id in obj by defining it directly in obj.
211 * Lazy properties are those reflected from some peer native property space
212 * (e.g., the DOM attributes for a given node reflected as obj) on demand.
214 * JS looks for a property in an object, and if not found, tries to resolve
215 * the given id. If resolve succeeds, the engine looks again in case resolve
216 * defined obj[id]. If no such property exists directly in obj, the process
217 * is repeated with obj's prototype, etc.
219 * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties.
221 typedef JSBool
222 (* JSResolveOp)(JSContext *cx, JSObject *obj, jsval id);
225 * Like JSResolveOp, but flags provide contextual information as follows:
227 * JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not id
228 * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment
229 * JSRESOLVE_DETECTING 'if (o.p)...' or similar detection opcode sequence
230 * JSRESOLVE_DECLARING var, const, or function prolog declaration opcode
231 * JSRESOLVE_CLASSNAME class name used when constructing
233 * The *objp out parameter, on success, should be null to indicate that id
234 * was not resolved; and non-null, referring to obj or one of its prototypes,
235 * if id was resolved.
237 * This hook instead of JSResolveOp is called via the JSClass.resolve member
238 * if JSCLASS_NEW_RESOLVE is set in JSClass.flags.
240 * Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further
241 * extends this hook by passing in the starting object on the prototype chain
242 * via *objp. Thus a resolve hook implementation may define the property id
243 * being resolved in the object in which the id was first sought, rather than
244 * in a prototype object whose class led to the resolve hook being called.
246 * When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore
247 * null *objp to signify "not resolved". With only JSCLASS_NEW_RESOLVE and no
248 * JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry.
249 * This is not good practice, but enough existing hook implementations count
250 * on it that we can't break compatibility by passing the starting object in
251 * *objp without a new JSClass flag.
253 typedef JSBool
254 (* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsval id, uintN flags,
255 JSObject **objp);
258 * Convert obj to the given type, returning true with the resulting value in
259 * *vp on success, and returning false on error or exception.
261 typedef JSBool
262 (* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
265 * Finalize obj, which the garbage collector has determined to be unreachable
266 * from other live objects or from GC roots. Obviously, finalizers must never
267 * store a reference to obj.
269 typedef void
270 (* JSFinalizeOp)(JSContext *cx, JSObject *obj);
273 * Used by JS_AddExternalStringFinalizer and JS_RemoveExternalStringFinalizer
274 * to extend and reduce the set of string types finalized by the GC.
276 typedef void
277 (* JSStringFinalizeOp)(JSContext *cx, JSString *str);
280 * The signature for JSClass.getObjectOps, used by JS_NewObject's internals
281 * to discover the set of high-level object operations to use for new objects
282 * of the given class. All native objects have a JSClass, which is stored as
283 * a private (int-tagged) pointer in obj slots. In contrast, all native and
284 * host objects have a JSObjectMap at obj->map, which may be shared among a
285 * number of objects, and which contains the JSObjectOps *ops pointer used to
286 * dispatch object operations from API calls.
288 * Thus JSClass (which pre-dates JSObjectOps in the API) provides a low-level
289 * interface to class-specific code and data, while JSObjectOps allows for a
290 * higher level of operation, which does not use the object's class except to
291 * find the class's JSObjectOps struct, by calling clasp->getObjectOps, and to
292 * finalize the object.
294 * If this seems backwards, that's because it is! API compatibility requires
295 * a JSClass *clasp parameter to JS_NewObject, etc. Most host objects do not
296 * need to implement the larger JSObjectOps, and can share the common JSScope
297 * code and data used by the native (js_ObjectOps, see jsobj.c) ops.
299 * Further extension to preserve API compatibility: if this function returns
300 * a pointer to JSXMLObjectOps.base, not to JSObjectOps, then the engine calls
301 * extended hooks needed for E4X.
303 typedef JSObjectOps *
304 (* JSGetObjectOps)(JSContext *cx, JSClass *clasp);
307 * JSClass.checkAccess type: check whether obj[id] may be accessed per mode,
308 * returning false on error/exception, true on success with obj[id]'s last-got
309 * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id
310 * is either a string or an int jsval.
312 * See JSCheckAccessIdOp, below, for the JSObjectOps counterpart, which takes
313 * a jsid (a tagged int or aligned, unique identifier pointer) rather than a
314 * jsval. The native js_ObjectOps.checkAccess simply forwards to the object's
315 * clasp->checkAccess, so that both JSClass and JSObjectOps implementors may
316 * specialize access checks.
318 typedef JSBool
319 (* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
320 jsval *vp);
323 * Encode or decode an object, given an XDR state record representing external
324 * data. See jsxdrapi.h.
326 typedef JSBool
327 (* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp);
330 * Check whether v is an instance of obj. Return false on error or exception,
331 * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in
332 * *bp otherwise.
334 typedef JSBool
335 (* JSHasInstanceOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
338 * Deprecated function type for JSClass.mark. All new code should define
339 * JSTraceOp instead to ensure the traversal of traceable things stored in
340 * the native structures.
342 typedef uint32
343 (* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);
346 * Function type for trace operation of the class called to enumerate all
347 * traceable things reachable from obj's private data structure. For each such
348 * thing, a trace implementation must call
350 * JS_CallTracer(trc, thing, kind);
352 * or one of its convenience macros as described in jsapi.h.
354 * JSTraceOp implementation can assume that no other threads mutates object
355 * state. It must not change state of the object or corresponding native
356 * structures. The only exception for this rule is the case when the embedding
357 * needs a tight integration with GC. In that case the embedding can check if
358 * the traversal is a part of the marking phase through calling
359 * JS_IsGCMarkingTracer and apply a special code like emptying caches or
360 * marking its native structures.
362 * To define the tracer for a JSClass, the implementation must add
363 * JSCLASS_MARK_IS_TRACE to class flags and use JS_CLASS_TRACE(method)
364 * macro below to convert JSTraceOp to JSMarkOp when initializing or
365 * assigning JSClass.mark field.
367 typedef void
368 (* JSTraceOp)(JSTracer *trc, JSObject *obj);
370 #if defined __GNUC__ && __GNUC__ >= 4 && !defined __cplusplus
371 # define JS_CLASS_TRACE(method) \
372 (__builtin_types_compatible_p(JSTraceOp, __typeof(&(method))) \
373 ? (JSMarkOp)(method) \
374 : js_WrongTypeForClassTracer)
376 extern JSMarkOp js_WrongTypeForClassTracer;
378 #else
379 # define JS_CLASS_TRACE(method) ((JSMarkOp)(method))
380 #endif
383 * Tracer callback, called for each traceable thing directly refrenced by a
384 * particular object or runtime structure. It is the callback responsibility
385 * to ensure the traversal of the full object graph via calling eventually
386 * JS_TraceChildren on the passed thing. In this case the callback must be
387 * prepared to deal with cycles in the traversal graph.
389 * kind argument is one of JSTRACE_OBJECT, JSTRACE_DOUBLE, JSTRACE_STRING or
390 * a tag denoting internal implementation-specific traversal kind. In the
391 * latter case the only operations on thing that the callback can do is to call
392 * JS_TraceChildren or DEBUG-only JS_PrintTraceThingInfo.
394 typedef void
395 (* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
398 * DEBUG only callback that JSTraceOp implementation can provide to return
399 * a string describing the reference traced with JS_CallTracer.
401 #ifdef DEBUG
402 typedef void
403 (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
404 #endif
407 * The optional JSClass.reserveSlots hook allows a class to make computed
408 * per-instance object slots reservations, in addition to or instead of using
409 * JSCLASS_HAS_RESERVED_SLOTS(n) in the JSClass.flags initializer to reserve
410 * a constant-per-class number of slots. Implementations of this hook should
411 * return the number of slots to reserve, not including any reserved by using
412 * JSCLASS_HAS_RESERVED_SLOTS(n) in JSClass.flags.
414 * NB: called with obj locked by the JSObjectOps-specific mutual exclusion
415 * mechanism appropriate for obj, so don't nest other operations that might
416 * also lock obj.
418 typedef uint32
419 (* JSReserveSlotsOp)(JSContext *cx, JSObject *obj);
421 /* JSObjectOps function pointer typedefs. */
424 * Create a new subclass of JSObjectMap (see jsobj.h), with the nrefs and ops
425 * members initialized from the same-named parameters, and with the nslots and
426 * freeslot members initialized according to ops and clasp. Return null on
427 * error, non-null on success.
429 * JSObjectMaps are reference-counted by generic code in the engine. Usually,
430 * the nrefs parameter to JSObjectOps.newObjectMap will be 1, to count the ref
431 * returned to the caller on success. After a successful construction, some
432 * number of js_HoldObjectMap and js_DropObjectMap calls ensue. When nrefs
433 * reaches 0 due to a js_DropObjectMap call, JSObjectOps.destroyObjectMap will
434 * be called to dispose of the map.
436 typedef JSObjectMap *
437 (* JSNewObjectMapOp)(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops,
438 JSClass *clasp, JSObject *obj);
441 * Generic type for an infallible JSObjectMap operation, used currently by
442 * JSObjectOps.destroyObjectMap.
444 typedef void
445 (* JSObjectMapOp)(JSContext *cx, JSObjectMap *map);
448 * Look for id in obj and its prototype chain, returning false on error or
449 * exception, true on success. On success, return null in *propp if id was
450 * not found. If id was found, return the first object searching from obj
451 * along its prototype chain in which id names a direct property in *objp, and
452 * return a non-null, opaque property pointer in *propp.
454 * If JSLookupPropOp succeeds and returns with *propp non-null, that pointer
455 * may be passed as the prop parameter to a JSAttributesOp, as a short-cut
456 * that bypasses id re-lookup. In any case, a non-null *propp result after a
457 * successful lookup must be dropped via JSObjectOps.dropProperty.
459 * NB: successful return with non-null *propp means the implementation may
460 * have locked *objp and added a reference count associated with *propp, so
461 * callers should not risk deadlock by nesting or interleaving other lookups
462 * or any obj-bearing ops before dropping *propp.
464 typedef JSBool
465 (* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
466 JSProperty **propp);
469 * Define obj[id], a direct property of obj named id, having the given initial
470 * value, with the specified getter, setter, and attributes. If the propp out
471 * param is non-null, *propp on successful return contains an opaque property
472 * pointer usable as a speedup hint with JSAttributesOp. But note that propp
473 * may be null, indicating that the caller is not interested in recovering an
474 * opaque pointer to the newly-defined property.
476 * If propp is non-null and JSDefinePropOp succeeds, its caller must be sure
477 * to drop *propp using JSObjectOps.dropProperty in short order, just as with
478 * JSLookupPropOp.
480 typedef JSBool
481 (* JSDefinePropOp)(JSContext *cx, JSObject *obj, jsid id, jsval value,
482 JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
483 JSProperty **propp);
486 * Get, set, or delete obj[id], returning false on error or exception, true
487 * on success. If getting or setting, the new value is returned in *vp on
488 * success. If deleting without error, *vp will be JSVAL_FALSE if obj[id] is
489 * permanent, and JSVAL_TRUE if id named a direct property of obj that was in
490 * fact deleted, or if id names no direct property of obj (id could name a
491 * prototype property, or no property in obj or its prototype chain).
493 typedef JSBool
494 (* JSPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
497 * Get or set attributes of the property obj[id]. Return false on error or
498 * exception, true with current attributes in *attrsp. If prop is non-null,
499 * it must come from the *propp out parameter of a prior JSDefinePropOp or
500 * JSLookupPropOp call.
502 typedef JSBool
503 (* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
504 uintN *attrsp);
507 * JSObjectOps.checkAccess type: check whether obj[id] may be accessed per
508 * mode, returning false on error/exception, true on success with obj[id]'s
509 * last-got value in *vp, and its attributes in *attrsp.
511 typedef JSBool
512 (* JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
513 jsval *vp, uintN *attrsp);
516 * A generic type for functions mapping an object to another object, or null
517 * if an error or exception was thrown on cx. Used by JSObjectOps.thisObject
518 * at present.
520 typedef JSObject *
521 (* JSObjectOp)(JSContext *cx, JSObject *obj);
524 * Hook that creates an iterator object for a given object. Returns the
525 * iterator object or null if an error or exception was thrown on cx.
527 typedef JSObject *
528 (* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly);
531 * A generic type for functions taking a context, object, and property, with
532 * no return value. Used by JSObjectOps.dropProperty currently (see above,
533 * JSDefinePropOp and JSLookupPropOp, for the object-locking protocol in which
534 * dropProperty participates).
536 typedef void
537 (* JSPropertyRefOp)(JSContext *cx, JSObject *obj, JSProperty *prop);
540 * Function pointer type for JSObjectOps.setProto and JSObjectOps.setParent.
541 * These hooks must check for cycles without deadlocking, and otherwise take
542 * special steps. See jsobj.c and jsgc.c for details.
544 typedef JSBool
545 (* JSSetObjectSlotOp)(JSContext *cx, JSObject *obj, uint32 slot,
546 JSObject *pobj);
549 * Get and set a required slot, one that should already have been allocated.
550 * These operations are infallible, so required slots must be pre-allocated,
551 * or implementations must suppress out-of-memory errors. The native ops
552 * (js_ObjectOps, see jsobj.c) access slots reserved by including a call to
553 * the JSCLASS_HAS_RESERVED_SLOTS(n) macro in the JSClass.flags initializer.
555 * NB: the slot parameter is a zero-based index into obj slots, unlike the
556 * index parameter to the JS_GetReservedSlot and JS_SetReservedSlot API entry
557 * points, which is a zero-based index into the JSCLASS_RESERVED_SLOTS(clasp)
558 * reserved slots that come after the initial well-known slots: proto, parent,
559 * class, and optionally, the private data slot.
561 typedef jsval
562 (* JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot);
564 typedef JSBool
565 (* JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot, jsval v);
567 typedef JSObject *
568 (* JSGetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
570 typedef JSBool
571 (* JSSetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
573 typedef JSBool
574 (* JSEnumerateValuesOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
575 jsval *statep, jsid *idp, jsval *vp);
577 typedef JSBool
578 (* JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
580 typedef JSBool
581 (* JSConcatenateOp)(JSContext *cx, JSObject *obj, jsval v, jsval *vp);
583 /* Typedef for native functions called by the JS VM. */
585 typedef JSBool
586 (* JSNative)(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
587 jsval *rval);
589 /* See jsapi.h, the JS_CALLEE, JS_THIS, etc. macros. */
590 typedef JSBool
591 (* JSFastNative)(JSContext *cx, uintN argc, jsval *vp);
593 /* Callbacks and their arguments. */
595 typedef enum JSContextOp {
596 JSCONTEXT_NEW,
597 JSCONTEXT_DESTROY
598 } JSContextOp;
601 * The possible values for contextOp when the runtime calls the callback are:
602 * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext
603 * instance. The callback can initialize the instance as
604 * required. If the callback returns false, the instance
605 * will be destroyed and JS_NewContext returns null. In
606 * this case the callback is not called again.
607 * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The
608 * callback may perform its own cleanup and must always
609 * return true.
610 * Any other value For future compatibility the callback must do nothing
611 * and return true in this case.
613 typedef JSBool
614 (* JSContextCallback)(JSContext *cx, uintN contextOp);
616 typedef enum JSGCStatus {
617 JSGC_BEGIN,
618 JSGC_END,
619 JSGC_MARK_END,
620 JSGC_FINALIZE_END
621 } JSGCStatus;
623 typedef JSBool
624 (* JSGCCallback)(JSContext *cx, JSGCStatus status);
627 * Generic trace operation that calls JS_CallTracer on each traceable thing
628 * stored in data.
630 typedef void
631 (* JSTraceDataOp)(JSTracer *trc, void *data);
633 typedef JSBool
634 (* JSOperationCallback)(JSContext *cx);
637 * Deprecated form of JSOperationCallback.
639 typedef JSBool
640 (* JSBranchCallback)(JSContext *cx, JSScript *script);
642 typedef void
643 (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report);
646 * Possible exception types. These types are part of a JSErrorFormatString
647 * structure. They define which error to throw in case of a runtime error.
648 * JSEXN_NONE marks an unthrowable error.
650 typedef enum JSExnType {
651 JSEXN_NONE = -1,
652 JSEXN_ERR,
653 JSEXN_INTERNALERR,
654 JSEXN_EVALERR,
655 JSEXN_RANGEERR,
656 JSEXN_REFERENCEERR,
657 JSEXN_SYNTAXERR,
658 JSEXN_TYPEERR,
659 JSEXN_URIERR,
660 JSEXN_LIMIT
661 } JSExnType;
663 typedef struct JSErrorFormatString {
664 /* The error format string (UTF-8 if js_CStringsAreUTF8). */
665 const char *format;
667 /* The number of arguments to expand in the formatted error message. */
668 uint16 argCount;
670 /* One of the JSExnType constants above. */
671 int16 exnType;
672 } JSErrorFormatString;
674 typedef const JSErrorFormatString *
675 (* JSErrorCallback)(void *userRef, const char *locale,
676 const uintN errorNumber);
678 #ifdef va_start
679 #define JS_ARGUMENT_FORMATTER_DEFINED 1
681 typedef JSBool
682 (* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS,
683 jsval **vpp, va_list *app);
684 #endif
686 typedef JSBool
687 (* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval);
689 typedef JSBool
690 (* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval);
692 typedef JSBool
693 (* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2,
694 jsval *rval);
696 typedef JSBool
697 (* JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval);
700 * Security protocol types.
702 typedef struct JSPrincipals JSPrincipals;
705 * XDR-encode or -decode a principals instance, based on whether xdr->mode is
706 * JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE,
707 * in which case implementations must return a held (via JSPRINCIPALS_HOLD),
708 * non-null *principalsp out parameter. Return true on success, false on any
709 * error, which the implementation must have reported.
711 typedef JSBool
712 (* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp);
715 * Return a weak reference to the principals associated with obj, possibly via
716 * the immutable parent chain leading from obj to a top-level container (e.g.,
717 * a window object in the DOM level 0). If there are no principals associated
718 * with obj, return null. Therefore null does not mean an error was reported;
719 * in no event should an error be reported or an exception be thrown by this
720 * callback's implementation.
722 typedef JSPrincipals *
723 (* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj);
725 JS_END_EXTERN_C
727 #endif /* jspubtd_h___ */