JavaScript-1.5 Reference

JS_ValueToUint16 Function

Summary

Converts a JS value to an unsigned, 16-bit integer.

Syntax

JSBool JS_ValueToUint16(JSContext *cx, jsval v, uint16 *ip);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
vjsvalThe JS value to convert.
ipuint16 *Pointer to the JS value that contains the converted integer when the function returns.

Description

JS_ValueToUint16 converts a specified JS value, v, to a JS double, and then to a 16-bit integer, if it fits. The fractional portion of the double is dropped silently during conversion to an integer value. If the double is out of range, JS_ValueToUint16 reports an error and conversion fails. The converted value is stored in the uint16 pointed to by ip.

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 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.

If the conversion is successful, JS_ValueToInt32 returns JS_TRUE. Otherwise, it reports an error and returns JS_FALSE.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JS_ConvertArguments | JS_ValueToBoolean | JS_ValueToECMAInt32 | JS_ValueToECMAUint32 | JS_ValueToFunction | JS_ValueToId | JS_ValueToInt32 | JS_ValueToNumber | JS_ValueToObject | JS_ValueToString ]

This page was generated by APIDOC