JSConvertOp 编辑
JSConvertOp
is the type of JSClass.convert
.
Syntax
typedef bool
(* JSConvertOp)(JSContext *cx, JS::HandleObject obj, JSType type,
JS::MutableHandleValue vp);
Name | Type | Description |
---|---|---|
cx | JSContext * | The context in which the convert is taking place. |
obj | JS::HandleObject | The object to be converted. |
hint | JSType | The 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. |
vp | JS::MutableHandleValue | Out 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论