Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JSConvertOp

This article needs a technical review. How you can help.

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

Document Tags and Contributors

 Contributors to this page: kscarfone, arai
 Last updated by: kscarfone,