JS ValueToFunction
From MDC
Convert a jsval to a JSFunction.
[edit] Syntax
JSFunction * JS_ValueToFunction(JSContext *cx, jsval v);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
The context in which to perform the conversion.
Requires request. (In a |
v |
jsval |
The JS value to convert. |
[edit] Description
JS_ValueToFunction converts a specified JS value, v, to a JS function.
- If
vis aFunctionobject, this returns the associatedJSFunction. - If
visnull,undefined, a boolean, a number, or a string, an error is reported andJS_ValueToFunctionreturnsNULL. - Otherwise,
vis an object. The JavaScript engine attempts to convert it to a function. The actual conversion is performed by the object's convert operation. (Implementation note: the object'sJSObjectOps.defaultValuemethod is called withhint=JSTYPE_FUNCTION.)JS_ValueToFunctionreturns a pointer to the converted function. If conversion fails with an error or exception,JS_ValueToFunctionreturnsNULL.
[edit] See Also
LXR ID Search for JS_ValueToFunction
JS_ConvertArguments, JS_ConvertValue, JS_GetTypeName, JS_TypeOfValue, JS_ValueToBoolean, JS_ValueToInt32, JS_ValueToNumber, JS_ValueToObject, JS_ValueToString