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.hintwill beJSTYPE_STRINGorJSTYPE_NUMBERto pass the corresponding type as a hint, orJSTYPE_VOIDto pass no hint. Other types may be passed as hints, but such behavior is deprecated. | 
| vp | JS::MutableHandleValue | Out parameter. On success, *vpreceives 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.convertcallback implements the[[DefaultValue]]behavior for objects having that class.