JS_GET_CLASS 编辑

Obsolete since JSAPI 13
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.

Retrieves the class associated with an object.

This macro was removed in SpiderMonkey 1.8.8 when the signature of JS_GetClass() was changed to take only an object pointer.

Syntax

#ifdef JS_THREADSAFE
#define JS_GET_CLASS(cx,obj) JS_GetClass(cx, obj)
#else
#define JS_GET_CLASS(cx,obj) JS_GetClass(obj)
#endif
ParameterTypeDescription
cxJSContext *Any context associated with the runtime in which obj exists.
objJSObject *Object to get the class from.
Note: In SpiderMonkey versions prior to SpiderMonkey 1.8.8, JS_GetClass took both a JSContext* and a JSObject* as arguments in thread-safe builds, and in non-thread-safe builds it took only a JSObject*.  The JS_GET_CLASS(cx, obj) macro abstracted away this detail.  Newer versions have removed the context argument, so that the same signature is used regardless whether or not the build is thread-safe.

Description

JS_GET_CLASS returns a pointer to the JSClass associated with a specified JS object, obj. The application must treat the JSClass as read-only.

To check the type of an object, use JS_HasInstance instead. For a stricter, exact-match-only check, use JS_InstanceOf or JS_GetInstancePrivate.

The JS_GET_CLASS abstracted away signature differences in the JS_GetClass method in threadsafe and non-threadsafe builds.  As of SpiderMonkey 1.8.8 it no longer exists, because JS_GetClass's signature is the same in all build environments.

See Also

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

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

发布评论

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

词条统计

浏览:114 次

字数:4462

最后编辑:7年前

编辑次数:0 次

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