PageRenderTime 169ms CodeModel.GetById 60ms app.highlight 71ms RepoModel.GetById 30ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/jspubtd.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C++ Header | 727 lines | 246 code | 81 blank | 400 comment | 4 complexity | 7fbd325b9feda3d4dd032dacd41c18a7 MD5 | raw file
  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
 48JS_BEGIN_EXTERN_C
 49
 50/* Scalar typedefs. */
 51typedef uint16    jschar;
 52typedef int32     jsint;
 53typedef uint32    jsuint;
 54typedef float64   jsdouble;
 55typedef jsword    jsval;
 56typedef jsword    jsid;
 57typedef 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 */
 64typedef 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. */
 84typedef 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. */
 97typedef 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. */
105typedef 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 liveconnect 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 */
126typedef 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. */
133typedef struct JSClass           JSClass;
134typedef struct JSExtendedClass   JSExtendedClass;
135typedef struct JSConstDoubleSpec JSConstDoubleSpec;
136typedef struct JSContext         JSContext;
137typedef struct JSErrorReport     JSErrorReport;
138typedef struct JSFunction        JSFunction;
139typedef struct JSFunctionSpec    JSFunctionSpec;
140typedef struct JSTracer          JSTracer;
141typedef struct JSIdArray         JSIdArray;
142typedef struct JSProperty        JSProperty;
143typedef struct JSPropertySpec    JSPropertySpec;
144typedef struct JSObject          JSObject;
145typedef struct JSObjectMap       JSObjectMap;
146typedef struct JSObjectOps       JSObjectOps;
147typedef struct JSXMLObjectOps    JSXMLObjectOps;
148typedef struct JSRuntime         JSRuntime;
149typedef struct JSRuntime         JSTaskState;   /* XXX deprecated name */
150typedef struct JSScript          JSScript;
151typedef struct JSStackFrame      JSStackFrame;
152typedef struct JSString          JSString;
153typedef struct JSXDRState        JSXDRState;
154typedef struct JSExceptionState  JSExceptionState;
155typedef struct JSLocaleCallbacks JSLocaleCallbacks;
156typedef struct JSSecurityCallbacks JSSecurityCallbacks;
157typedef struct JSONParser        JSONParser;
158
159/* JSClass (and JSObjectOps where appropriate) function pointer typedefs. */
160
161/*
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).
167 */
168typedef JSBool
169(* JSPropertyOp)(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
170
171/*
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:
174 *
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).
178 *
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.
184 *
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.
190 *
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.
194 *
195 * The return value is used to indicate success, with a value of JS_FALSE
196 * indicating failure.
197 */
198typedef JSBool
199(* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
200                     jsval *statep, jsid *idp);
201
202/*
203 * The old-style JSClass.enumerate op should define all lazy properties not
204 * yet reflected in obj.
205 */
206typedef JSBool
207(* JSEnumerateOp)(JSContext *cx, JSObject *obj);
208
209/*
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.
213 *
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.
218 *
219 * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties.
220 */
221typedef JSBool
222(* JSResolveOp)(JSContext *cx, JSObject *obj, jsval id);
223
224/*
225 * Like JSResolveOp, but flags provide contextual information as follows:
226 *
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
232 *
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.
236 *
237 * This hook instead of JSResolveOp is called via the JSClass.resolve member
238 * if JSCLASS_NEW_RESOLVE is set in JSClass.flags.
239 *
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.
245 *
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.
252 */
253typedef JSBool
254(* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsval id, uintN flags,
255                   JSObject **objp);
256
257/*
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.
260 */
261typedef JSBool
262(* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
263
264/*
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.
268 */
269typedef void
270(* JSFinalizeOp)(JSContext *cx, JSObject *obj);
271
272/*
273 * Used by JS_AddExternalStringFinalizer and JS_RemoveExternalStringFinalizer
274 * to extend and reduce the set of string types finalized by the GC.
275 */
276typedef void
277(* JSStringFinalizeOp)(JSContext *cx, JSString *str);
278
279/*
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.
287 *
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.
293 *
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.
298 *
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.
302 */
303typedef JSObjectOps *
304(* JSGetObjectOps)(JSContext *cx, JSClass *clasp);
305
306/*
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.
311 *
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.
317 */
318typedef JSBool
319(* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsval id, JSAccessMode mode,
320                    jsval *vp);
321
322/*
323 * Encode or decode an object, given an XDR state record representing external
324 * data.  See jsxdrapi.h.
325 */
326typedef JSBool
327(* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp);
328
329/*
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.
333 */
334typedef JSBool
335(* JSHasInstanceOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
336
337/*
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.
341 */
342typedef uint32
343(* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);
344
345/*
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
349 *
350 *    JS_CallTracer(trc, thing, kind);
351 *
352 * or one of its convenience macros as described in jsapi.h.
353 *
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.
361 *
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.
366 */
367typedef void
368(* JSTraceOp)(JSTracer *trc, JSObject *obj);
369
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)
375
376extern JSMarkOp js_WrongTypeForClassTracer;
377
378#else
379# define JS_CLASS_TRACE(method) ((JSMarkOp)(method))
380#endif
381
382/*
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.
388 *
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.
393 */
394typedef void
395(* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
396
397/*
398 * DEBUG only callback that JSTraceOp implementation can provide to return
399 * a string describing the reference traced with JS_CallTracer.
400 */
401#ifdef DEBUG
402typedef void
403(* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
404#endif
405
406/*
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.
413 *
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.
417 */
418typedef uint32
419(* JSReserveSlotsOp)(JSContext *cx, JSObject *obj);
420
421/* JSObjectOps function pointer typedefs. */
422
423/*
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.
428 *
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.
435 */
436typedef JSObjectMap *
437(* JSNewObjectMapOp)(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops,
438                     JSClass *clasp, JSObject *obj);
439
440/*
441 * Generic type for an infallible JSObjectMap operation, used currently by
442 * JSObjectOps.destroyObjectMap.
443 */
444typedef void
445(* JSObjectMapOp)(JSContext *cx, JSObjectMap *map);
446
447/*
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.
453 *
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.
458 *
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.
463 */
464typedef JSBool
465(* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
466                   JSProperty **propp);
467
468/*
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.
475 *
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.
479 */
480typedef JSBool
481(* JSDefinePropOp)(JSContext *cx, JSObject *obj, jsid id, jsval value,
482                   JSPropertyOp getter, JSPropertyOp setter, uintN attrs,
483                   JSProperty **propp);
484
485/*
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).
492 */
493typedef JSBool
494(* JSPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
495
496/*
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.
501 */
502typedef JSBool
503(* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop,
504                   uintN *attrsp);
505
506/*
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.
510 */
511typedef JSBool
512(* JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
513                      jsval *vp, uintN *attrsp);
514
515/*
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.
519 */
520typedef JSObject *
521(* JSObjectOp)(JSContext *cx, JSObject *obj);
522
523/*
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.
526 */
527typedef JSObject *
528(* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly);
529
530/*
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).
535 */
536typedef void
537(* JSPropertyRefOp)(JSContext *cx, JSObject *obj, JSProperty *prop);
538
539/*
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.
543 */
544typedef JSBool
545(* JSSetObjectSlotOp)(JSContext *cx, JSObject *obj, uint32 slot,
546                      JSObject *pobj);
547
548/*
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.
554 *
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.
560 */
561typedef jsval
562(* JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot);
563
564typedef JSBool
565(* JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot, jsval v);
566
567typedef JSObject *
568(* JSGetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
569
570typedef JSBool
571(* JSSetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
572
573typedef JSBool
574(* JSEnumerateValuesOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
575                        jsval *statep, jsid *idp, jsval *vp);
576
577typedef JSBool
578(* JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
579
580typedef JSBool
581(* JSConcatenateOp)(JSContext *cx, JSObject *obj, jsval v, jsval *vp);
582
583/* Typedef for native functions called by the JS VM. */
584
585typedef JSBool
586(* JSNative)(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
587             jsval *rval);
588
589/* See jsapi.h, the JS_CALLEE, JS_THIS, etc. macros. */
590typedef JSBool
591(* JSFastNative)(JSContext *cx, uintN argc, jsval *vp);
592
593/* Callbacks and their arguments. */
594
595typedef enum JSContextOp {
596    JSCONTEXT_NEW,
597    JSCONTEXT_DESTROY
598} JSContextOp;
599
600/*
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.
612 */
613typedef JSBool
614(* JSContextCallback)(JSContext *cx, uintN contextOp);
615
616typedef enum JSGCStatus {
617    JSGC_BEGIN,
618    JSGC_END,
619    JSGC_MARK_END,
620    JSGC_FINALIZE_END
621} JSGCStatus;
622
623typedef JSBool
624(* JSGCCallback)(JSContext *cx, JSGCStatus status);
625
626/*
627 * Generic trace operation that calls JS_CallTracer on each traceable thing
628 * stored in data.
629 */
630typedef void
631(* JSTraceDataOp)(JSTracer *trc, void *data);
632
633typedef JSBool
634(* JSOperationCallback)(JSContext *cx);
635
636/*
637 * Deprecated form of JSOperationCallback.
638 */
639typedef JSBool
640(* JSBranchCallback)(JSContext *cx, JSScript *script);
641
642typedef void
643(* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report);
644
645/*
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.
649 */
650typedef 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;
662
663typedef struct JSErrorFormatString {
664    /* The error format string (UTF-8 if js_CStringsAreUTF8). */
665    const char *format;
666
667    /* The number of arguments to expand in the formatted error message. */
668    uint16 argCount;
669
670    /* One of the JSExnType constants above. */
671    int16 exnType;
672} JSErrorFormatString;
673
674typedef const JSErrorFormatString *
675(* JSErrorCallback)(void *userRef, const char *locale,
676                    const uintN errorNumber);
677
678#ifdef va_start
679#define JS_ARGUMENT_FORMATTER_DEFINED 1
680
681typedef JSBool
682(* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS,
683                        jsval **vpp, va_list *app);
684#endif
685
686typedef JSBool
687(* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval);
688
689typedef JSBool
690(* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval);
691
692typedef JSBool
693(* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2,
694                    jsval *rval);
695
696typedef JSBool
697(* JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval);
698
699/*
700 * Security protocol types.
701 */
702typedef struct JSPrincipals JSPrincipals;
703
704/*
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.
710 */
711typedef JSBool
712(* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp);
713
714/*
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.
721 */
722typedef JSPrincipals *
723(* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj);
724
725JS_END_EXTERN_C
726
727#endif /* jspubtd_h___ */