📄 jspubtd.h
字号:
* * JS_MarkGCThing(cx, thing, name, arg); * * The trailing name and arg parameters are used for GC_MARK_DEBUG-mode heap * dumping and ref-path tracing. The mark function should pass a (typically * literal) string naming the private data member for name, and it must pass * the opaque arg parameter through from its caller. * * For the JSObjectOps.mark hook, the return value is the number of slots at * obj->slots to scan. For JSClass.mark, the return value is ignored. * * NB: JSMarkOp implementations cannot allocate new GC-things (JS_NewObject * called from a mark function will fail silently, e.g.). */typedef uint32(* JS_DLL_CALLBACK JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);/* * The optional JSClass.reserveSlots hook allows a class to make computed * per-instance object slots reservations, in addition to or instead of using * JSCLASS_HAS_RESERVED_SLOTS(n) in the JSClass.flags initializer to reserve * a constant-per-class number of slots. Implementations of this hook should * return the number of slots to reserve, not including any reserved by using * JSCLASS_HAS_RESERVED_SLOTS(n) in JSClass.flags. * * NB: called with obj locked by the JSObjectOps-specific mutual exclusion * mechanism appropriate for obj, so don't nest other operations that might * also lock obj. */typedef uint32(* JS_DLL_CALLBACK JSReserveSlotsOp)(JSContext *cx, JSObject *obj);/* JSObjectOps function pointer typedefs. *//* * Create a new subclass of JSObjectMap (see jsobj.h), with the nrefs and ops * members initialized from the same-named parameters, and with the nslots and * freeslot members initialized according to ops and clasp. Return null on * error, non-null on success. * * JSObjectMaps are reference-counted by generic code in the engine. Usually, * the nrefs parameter to JSObjectOps.newObjectMap will be 1, to count the ref * returned to the caller on success. After a successful construction, some * number of js_HoldObjectMap and js_DropObjectMap calls ensue. When nrefs * reaches 0 due to a js_DropObjectMap call, JSObjectOps.destroyObjectMap will * be called to dispose of the map. */typedef JSObjectMap *(* JS_DLL_CALLBACK JSNewObjectMapOp)(JSContext *cx, jsrefcount nrefs, JSObjectOps *ops, JSClass *clasp, JSObject *obj);/* * Generic type for an infallible JSObjectMap operation, used currently by * JSObjectOps.destroyObjectMap. */typedef void(* JS_DLL_CALLBACK JSObjectMapOp)(JSContext *cx, JSObjectMap *map);/* * Look for id in obj and its prototype chain, returning false on error or * exception, true on success. On success, return null in *propp if id was * not found. If id was found, return the first object searching from obj * along its prototype chain in which id names a direct property in *objp, and * return a non-null, opaque property pointer in *propp. * * If JSLookupPropOp succeeds and returns with *propp non-null, that pointer * may be passed as the prop parameter to a JSAttributesOp, as a short-cut * that bypasses id re-lookup. In any case, a non-null *propp result after a * successful lookup must be dropped via JSObjectOps.dropProperty. * * NB: successful return with non-null *propp means the implementation may * have locked *objp and added a reference count associated with *propp, so * callers should not risk deadlock by nesting or interleaving other lookups * or any obj-bearing ops before dropping *propp. */typedef JSBool(* JS_DLL_CALLBACK JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, JSProperty **propp);/* * Define obj[id], a direct property of obj named id, having the given initial * value, with the specified getter, setter, and attributes. If the propp out * param is non-null, *propp on successful return contains an opaque property * pointer usable as a speedup hint with JSAttributesOp. But note that propp * may be null, indicating that the caller is not interested in recovering an * opaque pointer to the newly-defined property. * * If propp is non-null and JSDefinePropOp succeeds, its caller must be sure * to drop *propp using JSObjectOps.dropProperty in short order, just as with * JSLookupPropOp. */typedef JSBool(* JS_DLL_CALLBACK JSDefinePropOp)(JSContext *cx, JSObject *obj, jsid id, jsval value, JSPropertyOp getter, JSPropertyOp setter, uintN attrs, JSProperty **propp);/* * Get, set, or delete obj[id], returning false on error or exception, true * on success. If getting or setting, the new value is returned in *vp on * success. If deleting without error, *vp will be JSVAL_FALSE if obj[id] is * permanent, and JSVAL_TRUE if id named a direct property of obj that was in * fact deleted, or if id names no direct property of obj (id could name a * prototype property, or no property in obj or its prototype chain). */typedef JSBool(* JS_DLL_CALLBACK JSPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);/* * Get or set attributes of the property obj[id]. Return false on error or * exception, true with current attributes in *attrsp. If prop is non-null, * it must come from the *propp out parameter of a prior JSDefinePropOp or * JSLookupPropOp call. */typedef JSBool(* JS_DLL_CALLBACK JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, JSProperty *prop, uintN *attrsp);/* * JSObjectOps.checkAccess type: check whether obj[id] may be accessed per * mode, returning false on error/exception, true on success with obj[id]'s * last-got value in *vp, and its attributes in *attrsp. */typedef JSBool(* JS_DLL_CALLBACK JSCheckAccessIdOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, jsval *vp, uintN *attrsp);/* * A generic type for functions mapping an object to another object, or null * if an error or exception was thrown on cx. Used by JSObjectOps.thisObject * at present. */typedef JSObject *(* JS_DLL_CALLBACK JSObjectOp)(JSContext *cx, JSObject *obj);/* * A generic type for functions taking a context, object, and property, with * no return value. Used by JSObjectOps.dropProperty currently (see above, * JSDefinePropOp and JSLookupPropOp, for the object-locking protocol in which * dropProperty participates). */typedef void(* JS_DLL_CALLBACK JSPropertyRefOp)(JSContext *cx, JSObject *obj, JSProperty *prop);/* * Function type for JSObjectOps.setProto and JSObjectOps.setParent. These * hooks must check for cycles without deadlocking, and otherwise take special * steps. See jsobj.c, js_SetProtoOrParent, for an example. */typedef JSBool(* JS_DLL_CALLBACK JSSetObjectSlotOp)(JSContext *cx, JSObject *obj, uint32 slot, JSObject *pobj);/* * Get and set a required slot, one that should already have been allocated. * These operations are infallible, so required slots must be pre-allocated, * or implementations must suppress out-of-memory errors. The native ops * (js_ObjectOps, see jsobj.c) access slots reserved by including a call to * the JSCLASS_HAS_RESERVED_SLOTS(n) macro in the JSClass.flags initializer. * * NB: the slot parameter is a zero-based index into obj->slots[], unlike the * index parameter to the JS_GetReservedSlot and JS_SetReservedSlot API entry * points, which is a zero-based index into the JSCLASS_RESERVED_SLOTS(clasp) * reserved slots that come after the initial well-known slots: proto, parent, * class, and optionally, the private data slot. */typedef jsval(* JS_DLL_CALLBACK JSGetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot);typedef JSBool(* JS_DLL_CALLBACK JSSetRequiredSlotOp)(JSContext *cx, JSObject *obj, uint32 slot, jsval v);typedef JSObject *(* JS_DLL_CALLBACK JSGetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);typedef JSBool(* JS_DLL_CALLBACK JSSetMethodOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);typedef JSBool(* JS_DLL_CALLBACK JSEnumerateValuesOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op, jsval *statep, jsid *idp, jsval *vp);typedef JSBool(* JS_DLL_CALLBACK JSEqualityOp)(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);typedef JSBool(* JS_DLL_CALLBACK JSConcatenateOp)(JSContext *cx, JSObject *obj, jsval v, jsval *vp);/* Typedef for native functions called by the JS VM. */typedef JSBool(* JS_DLL_CALLBACK JSNative)(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval);/* Callbacks and their arguments. */typedef enum JSContextOp { JSCONTEXT_NEW, JSCONTEXT_DESTROY} JSContextOp;/* * The possible values for contextOp when the runtime calls the callback are: * JSCONTEXT_NEW JS_NewContext succesfully created a new JSContext * instance. The callback can initialize the instance as * required. If the callback returns false, the instance * will be destroyed and JS_NewContext returns null. In * this case the callback is not called again. * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The * callback may perform its own cleanup and must always * return true. * Any other value For future compatibility the callback must do nothing * and return true in this case. */typedef JSBool(* JS_DLL_CALLBACK JSContextCallback)(JSContext *cx, uintN contextOp);typedef enum JSGCStatus { JSGC_BEGIN, JSGC_END, JSGC_MARK_END, JSGC_FINALIZE_END} JSGCStatus;typedef JSBool(* JS_DLL_CALLBACK JSGCCallback)(JSContext *cx, JSGCStatus status);typedef JSBool(* JS_DLL_CALLBACK JSBranchCallback)(JSContext *cx, JSScript *script);typedef void(* JS_DLL_CALLBACK JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report);/* * Possible exception types. These types are part of a JSErrorFormatString * structure. They define which error to throw in case of a runtime error. * JSEXN_NONE marks an unthrowable error. */typedef enum JSExnType { JSEXN_NONE = -1, JSEXN_ERR, JSEXN_INTERNALERR, JSEXN_EVALERR, JSEXN_RANGEERR, JSEXN_REFERENCEERR, JSEXN_SYNTAXERR, JSEXN_TYPEERR, JSEXN_URIERR, JSEXN_LIMIT} JSExnType;typedef struct JSErrorFormatString { /* The error format string (UTF-8 if JS_C_STRINGS_ARE_UTF8 is defined). */ const char *format; /* The number of arguments to expand in the formatted error message. */ uint16 argCount; /* One of the JSExnType constants above. */ int16 exnType;} JSErrorFormatString;typedef const JSErrorFormatString *(* JS_DLL_CALLBACK JSErrorCallback)(void *userRef, const char *locale, const uintN errorNumber);#ifdef va_start#define JS_ARGUMENT_FORMATTER_DEFINED 1typedef JSBool(* JS_DLL_CALLBACK JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS, jsval **vpp, va_list *app);#endiftypedef JSBool(* JS_DLL_CALLBACK JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval);typedef JSBool(* JS_DLL_CALLBACK JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval);typedef JSBool(* JS_DLL_CALLBACK JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2, jsval *rval);typedef JSBool(* JS_DLL_CALLBACK JSLocaleToUnicode)(JSContext *cx, char *src, jsval *rval);/* * Security protocol types. */typedef struct JSPrincipals JSPrincipals;/* * XDR-encode or -decode a principals instance, based on whether xdr->mode is * JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE, * in which case implementations must return a held (via JSPRINCIPALS_HOLD), * non-null *principalsp out parameter. Return true on success, false on any * error, which the implementation must have reported. */typedef JSBool(* JS_DLL_CALLBACK JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp);/* * Return a weak reference to the principals associated with obj, possibly via * the immutable parent chain leading from obj to a top-level container (e.g., * a window object in the DOM level 0). If there are no principals associated * with obj, return null. Therefore null does not mean an error was reported; * in no event should an error be reported or an exception be thrown by this * callback's implementation. */typedef JSPrincipals *(* JS_DLL_CALLBACK JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj);JS_END_EXTERN_C#endif /* jspubtd_h___ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -