Description
JS_ConvertValue converts a specified JS value, v, to a specified JS type, type . The converted value is stored in the jsval pointed to by vp . Typically users of this function set vp to point to v , so that if conversion is successful, v now contains the converted value.JS_ConvertValue calls other, type-specific conversion routines based on what you specify in type. These include JS_ValueToFunction , JS_ValueToString , JS_ValueToNumber , and JS_ValueToBoolean .
Converting any JS value to JSTYPE_VOID always succeeds.
Converting to JSTYPE_OBJECT is successful if the JS value to convert is one of JSVAL_INT , JSVAL_DOUBLE , JSVAL_STRING , JSVAL_BOOLEAN , or JSVAL_OBJECT .
Converting to JSTYPE_FUNCTION is successful if the JS value to convert is an object for which a function class has been defined, or if the JS value is already a function.
Converting any JS value to JSTYPE_STRING always succeeds.
Converting a JS value to JSTYPE_NUMBER succeeds 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 numeric values and signs only, conversion also succeeds. If the JS value is a JSVAL_OBJECT , conversion is successful if the object supports its own conversion function.
Converting any JS value to JSTYPE_BOOLEAN always succeeds, except when the JS value is a JSVAL_OBJECT that does not support its own conversion routine.
If the conversion is successful, JS_ConvertValue returns JS_TRUE , and vp points to the converted value. Otherwise, it returns JS_FALSE , and vp is either undefined, or points to the current value of v, depending on how you implement your code.
|