Description
JS_ValueToECMAInt32 converts a JS value, v , to a JS double, and then to an ECMA-standard, 32-bit, signed integer. The fractional portion of the double is dropped silently during conversion to an integer value. If the double is out of range, the result is computed modulo 2**32; if the result is then greater than or equal to 2**31, this function subtracts 2**32, yielding a negative result.
You can convert a JS value to an integer if the JS value to convert is a JSVAL_INT , JSVAL_DOUBLE , or JSVAL_BOOLEAN . If the JS value is a JSVAL_STRING that contains a well formed numeric literal (ignoring leading and trailing whitespace) conversion also succeeds. If the JS value is a JSVAL_OBJECT , conversion is successful if the object's convert operation returns a primitive value that can be converted.
If the conversion is successful, JS_ValueToECMAInt32 returns JS_TRUE . Otherwise, it reports an error and returns JS_FALSE .
|