Bug 726960 - Introduce xpc::NonVoidStringToJsval; r=bholley

This commit is contained in:
Ms2ger 2012-02-21 10:34:02 +01:00
parent f0746b81d8
commit f425afc45a
2 changed files with 9 additions and 2 deletions

View File

@ -1048,14 +1048,20 @@ xpc_qsJsvalToWcharStr(JSContext *cx, jsval v, jsval *pval, const PRUnichar **pst
namespace xpc {
bool
StringToJsval(JSContext *cx, nsString &str, JS::Value *rval)
StringToJsval(JSContext *cx, nsAString &str, JS::Value *rval)
{
// From the T_DOMSTRING case in XPCConvert::NativeData2JS.
if (str.IsVoid()) {
*rval = JSVAL_NULL;
return true;
}
return NonVoidStringToJsval(cx, str, rval);
}
bool
NonVoidStringToJsval(JSContext *cx, nsAString &str, JS::Value *rval)
{
MOZ_ASSERT(!str.IsVoid());
nsStringBuffer* sharedBuffer;
jsval jsstr = XPCStringConvert::ReadableToJSVal(cx, str, &sharedBuffer);
if (JSVAL_IS_NULL(jsstr))

View File

@ -219,7 +219,8 @@ bool Base64Decode(JSContext *cx, JS::Value val, JS::Value *out);
* Note, the ownership of the string buffer may be moved from str to rval.
* If that happens, str will point to an empty string after this call.
*/
bool StringToJsval(JSContext *cx, nsString &str, JS::Value *rval);
bool StringToJsval(JSContext *cx, nsAString &str, JS::Value *rval);
bool NonVoidStringToJsval(JSContext *cx, nsAString &str, JS::Value *rval);
void *GetCompartmentName(JSContext *cx, JSCompartment *c);
void DestroyCompartmentName(void *string);