зеркало из https://github.com/mozilla/gecko-dev.git
Bug 858108 - GC: Root the Locale interface r=terrence r=bholley
This commit is contained in:
Родитель
3ea744b422
Коммит
c57a0f9499
|
@ -1107,17 +1107,17 @@ typedef const JSErrorFormatString *
|
|||
const unsigned errorNumber);
|
||||
|
||||
typedef JSBool
|
||||
(* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval);
|
||||
(* JSLocaleToUpperCase)(JSContext *cx, JSHandleString src, JSMutableHandleValue rval);
|
||||
|
||||
typedef JSBool
|
||||
(* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval);
|
||||
(* JSLocaleToLowerCase)(JSContext *cx, JSHandleString src, JSMutableHandleValue rval);
|
||||
|
||||
typedef JSBool
|
||||
(* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2,
|
||||
jsval *rval);
|
||||
(* JSLocaleCompare)(JSContext *cx, JSHandleString src1, JSHandleString src2,
|
||||
JSMutableHandleValue rval);
|
||||
|
||||
typedef JSBool
|
||||
(* JSLocaleToUnicode)(JSContext *cx, const char *src, jsval *rval);
|
||||
(* JSLocaleToUnicode)(JSContext *cx, const char *src, JSMutableHandleValue rval);
|
||||
|
||||
/*
|
||||
* Security protocol types.
|
||||
|
|
|
@ -2762,7 +2762,7 @@ ToLocaleFormatHelper(JSContext *cx, HandleObject obj, const char *format, Mutabl
|
|||
}
|
||||
|
||||
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeToUnicode)
|
||||
return cx->runtime->localeCallbacks->localeToUnicode(cx, buf, rval.address());
|
||||
return cx->runtime->localeCallbacks->localeToUnicode(cx, buf, rval);
|
||||
|
||||
RawString str = JS_NewStringCopyZ(cx, buf);
|
||||
if (!str)
|
||||
|
|
|
@ -725,7 +725,7 @@ num_toLocaleString_impl(JSContext *cx, CallArgs args)
|
|||
|
||||
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeToUnicode) {
|
||||
Rooted<Value> v(cx, StringValue(str));
|
||||
bool ok = !!cx->runtime->localeCallbacks->localeToUnicode(cx, buf, v.address());
|
||||
bool ok = !!cx->runtime->localeCallbacks->localeToUnicode(cx, buf, &v);
|
||||
if (ok)
|
||||
args.rval().set(v);
|
||||
js_free(buf);
|
||||
|
|
|
@ -687,7 +687,7 @@ str_toLocaleLowerCase(JSContext *cx, unsigned argc, Value *vp)
|
|||
if (!str)
|
||||
return false;
|
||||
|
||||
Value result;
|
||||
RootedValue result(cx);
|
||||
if (!cx->runtime->localeCallbacks->localeToLowerCase(cx, str, &result))
|
||||
return false;
|
||||
|
||||
|
@ -754,7 +754,7 @@ str_toLocaleUpperCase(JSContext *cx, unsigned argc, Value *vp)
|
|||
if (!str)
|
||||
return false;
|
||||
|
||||
Value result;
|
||||
RootedValue result(cx);
|
||||
if (!cx->runtime->localeCallbacks->localeToUpperCase(cx, str, &result))
|
||||
return false;
|
||||
|
||||
|
@ -780,7 +780,7 @@ str_localeCompare(JSContext *cx, unsigned argc, Value *vp)
|
|||
return false;
|
||||
|
||||
if (cx->runtime->localeCallbacks && cx->runtime->localeCallbacks->localeCompare) {
|
||||
Value result;
|
||||
RootedValue result(cx);
|
||||
if (!cx->runtime->localeCallbacks->localeCompare(cx, str, thatStr, &result))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -72,32 +72,32 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks
|
|||
}
|
||||
|
||||
static JSBool
|
||||
LocaleToUpperCase(JSContext *cx, JSString *src, jsval *rval)
|
||||
LocaleToUpperCase(JSContext *cx, JSHandleString src, JSMutableHandleValue rval)
|
||||
{
|
||||
return ChangeCase(cx, src, rval, ToUpperCase);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
LocaleToLowerCase(JSContext *cx, JSString *src, jsval *rval)
|
||||
LocaleToLowerCase(JSContext *cx, JSHandleString src, JSMutableHandleValue rval)
|
||||
{
|
||||
return ChangeCase(cx, src, rval, ToLowerCase);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
LocaleToUnicode(JSContext* cx, const char* src, jsval* rval)
|
||||
LocaleToUnicode(JSContext* cx, const char* src, JSMutableHandleValue rval)
|
||||
{
|
||||
return This(JS_GetRuntime(cx))->ToUnicode(cx, src, rval);
|
||||
}
|
||||
|
||||
static JSBool
|
||||
LocaleCompare(JSContext *cx, JSString *src1, JSString *src2, jsval *rval)
|
||||
LocaleCompare(JSContext *cx, JSHandleString src1, JSHandleString src2, JSMutableHandleValue rval)
|
||||
{
|
||||
return This(JS_GetRuntime(cx))->Compare(cx, src1, src2, rval);
|
||||
}
|
||||
|
||||
private:
|
||||
static JSBool
|
||||
ChangeCase(JSContext* cx, JSString* src, jsval* rval,
|
||||
ChangeCase(JSContext* cx, JSHandleString src, JSMutableHandleValue rval,
|
||||
void(*changeCaseFnc)(const nsAString&, nsAString&))
|
||||
{
|
||||
nsDependentJSString depStr;
|
||||
|
@ -114,12 +114,12 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
*rval = STRING_TO_JSVAL(ucstr);
|
||||
rval.set(STRING_TO_JSVAL(ucstr));
|
||||
return true;
|
||||
}
|
||||
|
||||
JSBool
|
||||
Compare(JSContext *cx, JSString *src1, JSString *src2, jsval *rval)
|
||||
Compare(JSContext *cx, JSHandleString src1, JSHandleString src2, JSMutableHandleValue rval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -161,12 +161,12 @@ private:
|
|||
return false;
|
||||
}
|
||||
|
||||
*rval = INT_TO_JSVAL(result);
|
||||
rval.set(INT_TO_JSVAL(result));
|
||||
return true;
|
||||
}
|
||||
|
||||
JSBool
|
||||
ToUnicode(JSContext* cx, const char* src, jsval* rval)
|
||||
ToUnicode(JSContext* cx, const char* src, JSMutableHandleValue rval)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -201,7 +201,6 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
JSString *str = nullptr;
|
||||
int32_t srcLength = PL_strlen(src);
|
||||
|
||||
if (mDecoder) {
|
||||
|
@ -222,24 +221,20 @@ private:
|
|||
if (shrunkUnichars)
|
||||
unichars = shrunkUnichars;
|
||||
}
|
||||
str = JS_NewUCString(cx,
|
||||
reinterpret_cast<jschar*>(unichars),
|
||||
unicharLength);
|
||||
JSString *str = JS_NewUCString(cx, reinterpret_cast<jschar*>(unichars), unicharLength);
|
||||
if (str) {
|
||||
rval.setString(str);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!str)
|
||||
JS_free(cx, unichars);
|
||||
}
|
||||
}
|
||||
|
||||
if (!str) {
|
||||
xpc::Throw(cx, NS_ERROR_OUT_OF_MEMORY);
|
||||
return false;
|
||||
}
|
||||
|
||||
*rval = STRING_TO_JSVAL(str);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssertThreadSafety()
|
||||
{
|
||||
MOZ_ASSERT(mThread == PR_GetCurrentThread(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче