Specifications

C-Level Extensibility 255
char *JS_ValueToString()
Description
Extracts a function argument from a jsval, converts it to a string, if possible, and passes the
converted value back to the caller.
Note: Do not modify the returned buffer pointer or you might corrupt the data structures of the JavaScript interpreter.
To change the string, you must copy the characters into another buffer and create a new JavaScript string.
Arguments
JSContext *cx, jsval v, unsigned int *pLength
cx is the opaque JSContext pointer that passed to the JavaScript function.
v is the jsval from which the string is to be extracted.
pLength is a pointer to an unsigned integer. This function sets *plength equal to the length
of the string in bytes.
Returns
A pointer to a null-terminated string on success or to NULL on failure. The calling routine must
not free this string when it is finished with it.
JSBool JS_ValueToInteger()
Description
Extracts a function argument from a jsval, converts it to an integer (if possible), and passes the
converted value back to the caller.
Arguments
JSContext *cx, jsval v, long *lp
cx is the opaque JSContext pointer that passed to the JavaScript function.
v is the jsval from which the integer is to be extracted.
lp is a pointer to a 4-byte integer. This function stores the converted value in *lp.
Returns
A Boolean value that indicates success (JS_TRUE) or failure (JS_FALSE).
JSBool JS_ValueToDouble()
Description
Extracts a function argument from a jsval, converts it to a double (if possible), and passes the
converted value back to the caller.
Arguments
JSContext *cx, jsval v, double *dp
cx is the opaque JSContext pointer that passed to the JavaScript function.
v is the jsval from which the double is to be extracted.
dp is a pointer to an 8-byte double. This function stores the converted value in *dp.
Returns
A Boolean value that indicates success (JS_TRUE) or failure (JS_FALSE).