Convert a jsval to a JSString.
JSString * JS_ValueToString(JSContext *cx, jsval v);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
The context in which to perform the conversion.
Requires request. (In a JS_THREADSAFE build, the caller must be in a request on this JSContext.)
|
v |
jsval |
The value to convert. |
JS_ValueToString converts a specified JS value, v, to a JS string. It implements the ToString operator specified in
ECMA 262-3 §9.8
. If v is an object, the actual conversion is performed by its JSClass.convert callback, which may call the JavaScript methods v.toString() and/or v.valueOf(). On success, JS_ValueToString returns a pointer to a string. On error or exception, it returns NULL. This happens, for example, if v is an object and v.toString() throws an exception.
The resulting JSString is subject to garbage collection unless you protect it using a local root, an object property, or the JS_AddRoot function.
Page last modified 20:07, 5 Sep 2008 by Jorend