Bug 1037613 - rm js_GetLocalizedErrorMessage, localeGetErrorMessage callback. r=jorendorff

This commit is contained in:
Jan de Mooij 2014-07-15 15:14:38 +02:00
Родитель d268839202
Коммит cfcce18b5a
11 изменённых файлов: 21 добавлений и 55 удалений

Просмотреть файл

@ -54,8 +54,7 @@ JSErrorFormatString ErrorFormatString[] = {
};
const JSErrorFormatString*
GetErrorMessage(void* aUserRef, const char* aLocale,
const unsigned aErrorNumber)
GetErrorMessage(void* aUserRef, const unsigned aErrorNumber)
{
MOZ_ASSERT(aErrorNumber < ArrayLength(ErrorFormatString));
return &ErrorFormatString[aErrorNumber];
@ -139,8 +138,7 @@ ErrorResult::ThrowTypeError(const dom::ErrNum errorNumber, ...)
mResult = NS_ERROR_TYPE_ERR;
Message* message = new Message();
message->mErrorNumber = errorNumber;
uint16_t argCount =
dom::GetErrorMessage(nullptr, nullptr, errorNumber)->argCount;
uint16_t argCount = dom::GetErrorMessage(nullptr, errorNumber)->argCount;
MOZ_ASSERT(argCount <= 10);
argCount = std::min<uint16_t>(argCount, 10);
while (argCount--) {

Просмотреть файл

@ -877,7 +877,7 @@ static const JSErrorFormatString ErrorFormatString[CTYPESERR_LIMIT] = {
};
static const JSErrorFormatString*
GetErrorMessage(void* userRef, const char* locale, const unsigned errorNumber)
GetErrorMessage(void* userRef, const unsigned errorNumber)
{
if (0 < errorNumber && errorNumber < CTYPESERR_LIMIT)
return &ErrorFormatString[errorNumber];

Просмотреть файл

@ -733,8 +733,7 @@ typedef struct JSErrorFormatString {
} JSErrorFormatString;
typedef const JSErrorFormatString *
(* JSErrorCallback)(void *userRef, const char *locale,
const unsigned errorNumber);
(* JSErrorCallback)(void *userRef, const unsigned errorNumber);
typedef bool
(* JSLocaleToUpperCase)(JSContext *cx, JS::HandleString src, JS::MutableHandleValue rval);
@ -4536,7 +4535,6 @@ struct JSLocaleCallbacks {
JSLocaleToLowerCase localeToLowerCase;
JSLocaleCompare localeCompare; // not used #if EXPOSE_INTL_API
JSLocaleToUnicode localeToUnicode;
JSErrorCallback localeGetErrorMessage;
};
/*

Просмотреть файл

@ -391,8 +391,7 @@ js_ReportOutOfMemory(ThreadSafeContext *cxArg)
}
/* Get the message for this error, but we don't expand any arguments. */
const JSErrorFormatString *efs =
js_GetLocalizedErrorMessage(cx, nullptr, nullptr, JSMSG_OUT_OF_MEMORY);
const JSErrorFormatString *efs = js_GetErrorMessage(nullptr, JSMSG_OUT_OF_MEMORY);
const char *msg = efs ? efs->format : "Out of memory";
/* Fill out the report, but don't do anything that requires allocation. */
@ -671,13 +670,14 @@ js_ExpandErrorArguments(ExclusiveContext *cx, JSErrorCallback callback,
*messagep = nullptr;
/* Most calls supply js_GetErrorMessage; if this is so, assume nullptr. */
if (!callback || callback == js_GetErrorMessage) {
efs = js_GetLocalizedErrorMessage(cx, userRef, nullptr, errorNumber);
} else {
if (!callback)
callback = js_GetErrorMessage;
{
AutoSuppressGC suppressGC(cx);
efs = callback(userRef, nullptr, errorNumber);
efs = callback(userRef, errorNumber);
}
if (efs) {
reportp->exnType = efs->exnType;
@ -1004,9 +1004,9 @@ const JSErrorFormatString js_ErrorFormatString[JSErr_Limit] = {
};
JS_FRIEND_API(const JSErrorFormatString *)
js_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber)
js_GetErrorMessage(void *userRef, const unsigned errorNumber)
{
if ((errorNumber > 0) && (errorNumber < JSErr_Limit))
if (errorNumber > 0 && errorNumber < JSErr_Limit)
return &js_ErrorFormatString[errorNumber];
return nullptr;
}

Просмотреть файл

@ -579,28 +579,6 @@ ErrorObject::createConstructor(JSContext *cx, JSProtoKey key)
return ctor;
}
const JSErrorFormatString*
js_GetLocalizedErrorMessage(ExclusiveContext *cx, void *userRef, const char *locale,
const unsigned errorNumber)
{
const JSErrorFormatString *errorString = nullptr;
// The locale callbacks might not be thread safe, so don't call them if
// we're not on the main thread. When used with XPConnect,
// |localeGetErrorMessage| will be nullptr anyways.
if (cx->isJSContext() &&
cx->asJSContext()->runtime()->localeCallbacks &&
cx->asJSContext()->runtime()->localeCallbacks->localeGetErrorMessage)
{
JSLocaleCallbacks *callbacks = cx->asJSContext()->runtime()->localeCallbacks;
errorString = callbacks->localeGetErrorMessage(userRef, locale, errorNumber);
}
if (!errorString)
errorString = js_GetErrorMessage(userRef, locale, errorNumber);
return errorString;
}
JS_FRIEND_API(JSFlatString *)
js::GetErrorTypeName(JSRuntime *rt, int16_t exnType)
{
@ -628,11 +606,9 @@ js_ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
// Find the exception index associated with this error.
JSErrNum errorNumber = static_cast<JSErrNum>(reportp->errorNumber);
const JSErrorFormatString *errorString;
if (!callback || callback == js_GetErrorMessage)
errorString = js_GetLocalizedErrorMessage(cx, nullptr, nullptr, errorNumber);
else
errorString = callback(userRef, nullptr, errorNumber);
if (!callback)
callback = js_GetErrorMessage;
const JSErrorFormatString *errorString = callback(userRef, errorNumber);
JSExnType exnType = errorString ? static_cast<JSExnType>(errorString->exnType) : JSEXN_NONE;
MOZ_ASSERT(exnType < JSEXN_LIMIT);

Просмотреть файл

@ -76,10 +76,6 @@ js_ReportUncaughtException(JSContext *cx);
extern JSErrorReport *
js_ErrorFromException(JSContext *cx, js::HandleObject obj);
extern const JSErrorFormatString *
js_GetLocalizedErrorMessage(js::ExclusiveContext *cx, void *userRef, const char *locale,
const unsigned errorNumber);
/*
* Make a copy of errobj parented to cx's compartment's global.
*

Просмотреть файл

@ -1242,7 +1242,7 @@ typedef enum JSErrNum {
} JSErrNum;
extern JS_FRIEND_API(const JSErrorFormatString *)
js_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber);
js_GetErrorMessage(void *userRef, const unsigned errorNumber);
namespace js {

Просмотреть файл

@ -198,7 +198,7 @@ NewGlobalObject(JSContext *cx, JS::CompartmentOptions &options,
JSPrincipals *principals);
static const JSErrorFormatString *
my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber);
my_GetErrorMessage(void *userRef, const unsigned errorNumber);
/*
@ -5115,7 +5115,7 @@ static const JSErrorFormatString jsShell_ErrorFormatString[JSShellErr_Limit] = {
};
static const JSErrorFormatString *
my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber)
my_GetErrorMessage(void *userRef, const unsigned errorNumber)
{
if (errorNumber == 0 || errorNumber >= JSShellErr_Limit)
return nullptr;

Просмотреть файл

@ -120,8 +120,7 @@ js::intrinsic_ThrowError(JSContext *cx, unsigned argc, Value *vp)
uint32_t errorNumber = args[0].toInt32();
#ifdef DEBUG
const JSErrorFormatString *efs =
js_GetLocalizedErrorMessage(cx, nullptr, nullptr, errorNumber);
const JSErrorFormatString *efs = js_GetErrorMessage(nullptr, errorNumber);
JS_ASSERT(efs->argCount == args.length() - 1);
#endif

Просмотреть файл

@ -43,7 +43,6 @@ struct XPCLocaleCallbacks : public JSLocaleCallbacks
localeToLowerCase = LocaleToLowerCase;
localeCompare = LocaleCompare;
localeToUnicode = LocaleToUnicode;
localeGetErrorMessage = nullptr;
}
~XPCLocaleCallbacks()

Просмотреть файл

@ -881,7 +881,7 @@ static const JSErrorFormatString jsShell_ErrorFormatString[JSShellErr_Limit] = {
};
static const JSErrorFormatString *
my_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber)
my_GetErrorMessage(void *userRef, const unsigned errorNumber)
{
if (errorNumber == 0 || errorNumber >= JSShellErr_Limit)
return nullptr;