Annotation of sbbs/include/mozilla/js/jspubtd.h, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.