User Guide

The C-level API 545
JSBool JS_ValueToInteger()
Usage
JSBool JS_ValueToInteger(JSContext *cx, jsval v, long *lp);
Description
Method; extracts a function argument from a jsval structure, converts it to an integer (if
possible), and passes the converted value back to the caller.
Arguments
JSContext *cx, jsval v, long *lp
The cx argument is the opaque JSContext pointer that passes to the JavaScript function.
The v argument is the jsval structure from which the integer is to be extracted.
The lp argument is a pointer to a 4-byte integer. This function stores the converted value
in
*lp.
Returns
A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure.
JSBool JS_ValueToDouble()
Usage
JSBool JS_ValueToDouble(JSContext *cx, jsval v, double *dp);
Description
Method; extracts a function argument from a jsval structure, converts it to a double (if
possible), and passes the converted value back to the caller.
Arguments
JSContext *cx, jsval v, double *dp
The cx argument is the opaque JSContext pointer that passed to the JavaScript function.
The v argument is the jsval structure from which the double is to be extracted.
The dp argument is a pointer to an 8-byte double. This function stores the converted
value in
*dp.
Returns
A Boolean value: JS_TRUE indicates success; JS_FALSE indicates failure.