JSConvertOp 编辑

JSConvertOp is the type of JSClass.convert.

Syntax

typedef bool
(* JSConvertOp)(JSContext *cx, JS::HandleObject obj, JSType type,
                JS::MutableHandleValue vp);
NameTypeDescription
cxJSContext *The context in which the convert is taking place.
objJS::HandleObjectThe object to be converted.
hintJSTypeThe hint to pass to the [[DefaultValue]] hook when converting the object. hint will be JSTYPE_STRING or JSTYPE_NUMBER to pass the corresponding type as a hint, or JSTYPE_VOID to pass no hint. Other types may be passed as hints, but such behavior is deprecated.
vpJS::MutableHandleValueOut parameter. On success, *vp receives the converted value.

Description

JSConvertOp callback specifies conversion behavior for objects having this class, implementing the ECMAScript [[DefaultValue]] behavior for them. On success it must return a primitive value in *vp.

Implementations of this hook have historically been required to accept any type. However, the engine itself only requires support for JSTYPE_STRING, JSTYPE_NUMBER, and JSTYPE_VOID, if JS_ConvertValue is not used. If you do not use the JS_ConvertValue method, you may omit support for other types. (Support for the other types may eventually be removed.)

The callback returns true to indicate success or false to indicate failure.

JSClass hooks

JSClass offers the following hook:

  • The JSClass.convert callback implements the [[DefaultValue]] behavior for objects having that class.

See Also

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

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

发布评论

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

词条统计

浏览:24 次

字数:4270

最后编辑:7年前

编辑次数:0 次

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