JSObjectOps.newObjectMap 编辑

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);
NameTypeDescription
cxJSContext *Pointer to the JS context in which the new object is being created.
nrefsjsrefcountThe initial reference count for the new JSObjectMap.
opsJSObjectOps *The ops for the new JSObjectMap.
claspJSClass *The JSClass of the new object.
objJSObject *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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:104 次

字数:4368

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文