JSObjectOps
From MDC
Defines pointers to custom override methods for a class.
JSObjectOps is not a supported API. Details of the API may change from one release to the next. This documentation should be considered SpiderMonkey internals documentation, not API documentation. See bug 408416.[edit] Syntax
struct JSObjectOps {
/* mandatory non-null function pointer members. */
JSNewObjectMapOp newObjectMap;
JSObjectMapOp destroyObjectMap;
JSLookupPropOp lookupProperty;
JSDefinePropOp defineProperty;
JSPropertyIdOp getProperty;
JSPropertyIdOp setProperty;
JSAttributesOp getAttributes;
JSAttributesOp setAttributes;
JSPropertyIdOp deleteProperty;
JSConvertOp defaultValue;
JSNewEnumerateOp enumerate;
JSCheckAccessIdOp checkAccess;
/* Optionally non-null members. */
JSObjectOp thisObject;
JSPropertyRefOp dropProperty;
JSNative call;
JSNative construct;
JSXDRObjectOp xdrObject; /* unused */
JSHasInstanceOp hasInstance;
JSSetObjectSlotOp setProto;
JSSetObjectSlotOp setParent;
JSTraceOp trace;
JSFinalizeOp clear;
JSGetRequiredSlotOp getRequiredSlot;
JSSetRequiredSlotOp setRequiredSlot;
};
| Name | Type | Description |
|---|---|---|
newObjectMap |
JSNewObjectMapOp |
Create a JSObjectMap. |
destroyObjectMap |
JSObjectMapOp |
Destroy a JSObjectMap. |
lookupProperty |
JSLookupPropOp |
Look up a property, following the prototype chain etc. Implements the main part of JS_LookupProperty. |
defineProperty |
JSDefinePropOp |
Define a new property on an object. Implements JS_DefineProperty. |
getProperty |
JSPropertyIdOp |
High-level method to get the value of a property. Implements JS_GetProperty. |
setProperty |
JSPropertyIdOp |
High-level method to assign to a property. May create a new property. Implements JS_SetProperty. |
getAttributes |
JSAttributesOp |
Get property attributes. Implements JS_GetPropertyAttributes. |
setAttributes |
JSAttributesOp |
Set property attributes. Implements JS_SetPropertyAttributes. |
deleteProperty |
JSPropertyIdOp |
Delete a property. |
defaultValue |
JSConvertOp |
Convert the given object to a given type. |
enumerate |
JSNewEnumerateOp |
Enumerate object properties. |
checkAccess |
JSCheckAccessIdOp |
Custom access control method. Implements JS_CheckAccess. |
thisObject |
JSObjectOp |
? |
dropProperty |
JSPropertyRefOp |
Reference counting method. Release a property obtained via lookupProperty or defineProperty. |
call |
JSNative |
Call an object as though it were a function. |
construct |
JSNative |
Constructor. |
xdrObject |
JSXDRObjectOp |
Reserved. Set this field to NULL. |
hasInstance |
JSHasInstanceOp |
? |
setProto |
JSSetObjectSlotOp |
Set an object's __proto__. Implements JS_SetPrototype. |
setParent |
JSSetObjectSlotOp |
Set an object's __parent__. Implements JS_SetParent. |
trace |
JSTraceOp |
? |
clear |
JSFinalizeOp |
Remove all the object's own properties. Implements JS_ClearScope. |
getRequiredSlot |
JSGetRequiredSlotOp |
Get the value of an object slot. Implements JS_GetReservedSlot and others. |
setRequiredSlot |
JSSetRequiredSlotOp |
Set an object slot. Implements JS_SetReservedSlot and others. |
[edit] Description
See JSClass for more information about customizing the behavior of custom objects.
Use JSObjectOps to define an optional structure of pointers to custom property methods for a class. If you define JSObjectOps, you can create methods to override the default methods used by JSClass.
If you create a JSObjectOps structure for a given class, then you must also supply or create methods for creating and destroying the object map used by this object, and you must create custom methods for looking up, defining, getting, setting, and deleting properties. You must also create methods for getting and setting property attributes, checking object access privileges, converting property values, and enumerating properties. All other fields are optional, and if not used, should be set to NULL.
