Obsolete since JavaScript 1.8.5
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Warning! 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 for details.

The JSObjectOps.newObjectMap callback is called whenever a new object is created. It creates a JSObjectMap that completely controls the new object's behavior.

Syntax

typedef JSObjectMap * (*JSNewObjectMapOp)(JSContext *cx, jsrefcount nrefs,
    JSObjectOps *ops, JSClass *clasp, JSObject *obj);
Name Type Description
cx JSContext * Pointer to the JS context in which the new object is being created.
nrefs jsrefcount The initial reference count for the new JSObjectMap.
ops JSObjectOps * The ops for the new JSObjectMap.
clasp JSClass * The JSClass of the new object.
obj JSObject * The new object.

Description

Note: The JSAPI does not expose the data structure that would be necessary to develop new JSObjectMap subclasses. An application that implements JSObjectOps must therefore either implement the newObjectMap by including the non-public header jsobj.h, or obtain the default NewObjectMapOp by calling the JSClass.getObjectOps callback of a standard JSClass.

Create a new instance of (a concrete 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.