JavaScript-1.5 Reference

JS_ValueToObject Function

Summary

Converts a JS value to a JS object.

Syntax

JSBool JS_ValueToObject(JSContext *cx, jsval v,
    JSObject **objp);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
vjsvalThe JS value to convert.
objpJSObject **Pointer to the JS object into which to store the converted value.

Description

JS_ValueToObject converts a specified JS value, v, to a JS object. The converted object is stored in the object pointed to by objp. If the conversion is successful, JS_ValueToObject returns JS_TRUE. Otherwise it returns JS_FALSE.

You can successfully convert a JS value to an object if the JS value to convert is one of JSVAL_INT, JSVAL_DOUBLE, JSVAL_STRING, JSVAL_BOOLEAN, or JSVAL_OBJECT. Note that if v is already an object, the object returned in objp represents a converted version of v, rather than original version of v.

Notes

Converting a JS value to an object subjects the resulting object to garbage collection unless you protect against it using a local root, an object property, or the JS_AddRoot function.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JS_AddRoot | JS_ConvertArguments | JS_ConvertValue | JS_GetTypeName | JS_TypeOfValue | JS_ValueToBoolean | JS_ValueToFunction | JS_ValueToInt32 | JS_ValueToNumber | JS_ValueToString ]

This page was generated by APIDOC