зеркало из https://github.com/mozilla/gecko-dev.git
Bug 966559 - Use public C API for NumberingSystem. r=Waldo
MozReview-Commit-ID: CBICCJQXI7R --HG-- extra : rebase_source : b74b9d6038580ab970565bb56c09d5330be92407
This commit is contained in:
Родитель
448fa1ae73
Коммит
89b4923282
|
@ -80,8 +80,6 @@ included_inclnames_to_ignore = set([
|
|||
'prtypes.h', # NSPR
|
||||
'selfhosted.out.h', # generated in $OBJDIR
|
||||
'shellmoduleloader.out.h', # generated in $OBJDIR
|
||||
'unicode/locid.h', # ICU
|
||||
'unicode/numsys.h', # ICU
|
||||
'unicode/timezone.h', # ICU
|
||||
'unicode/ucal.h', # ICU
|
||||
'unicode/uclean.h', # ICU
|
||||
|
@ -91,6 +89,7 @@ included_inclnames_to_ignore = set([
|
|||
'unicode/uenum.h', # ICU
|
||||
'unicode/unorm.h', # ICU
|
||||
'unicode/unum.h', # ICU
|
||||
'unicode/unumsys.h', # ICU
|
||||
'unicode/ustring.h', # ICU
|
||||
'unicode/utypes.h', # ICU
|
||||
'vtune/VTuneWrapper.h' # VTune
|
||||
|
|
|
@ -23,14 +23,13 @@
|
|||
#include "jsobj.h"
|
||||
|
||||
#if ENABLE_INTL_API
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/numsys.h"
|
||||
#include "unicode/ucal.h"
|
||||
#include "unicode/ucol.h"
|
||||
#include "unicode/udat.h"
|
||||
#include "unicode/udatpg.h"
|
||||
#include "unicode/uenum.h"
|
||||
#include "unicode/unum.h"
|
||||
#include "unicode/unumsys.h"
|
||||
#include "unicode/ustring.h"
|
||||
#endif
|
||||
#include "vm/DateTime.h"
|
||||
|
@ -51,11 +50,6 @@ using mozilla::IsNegativeZero;
|
|||
using mozilla::MakeScopeExit;
|
||||
using mozilla::PodCopy;
|
||||
|
||||
#if ENABLE_INTL_API
|
||||
using icu::Locale;
|
||||
using icu::NumberingSystem;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Pervasive note: ICU functions taking a UErrorCode in/out parameter always
|
||||
|
@ -283,34 +277,24 @@ unum_setTextAttribute(UNumberFormat* fmt, UNumberFormatTextAttribute tag, const
|
|||
MOZ_CRASH("unum_setTextAttribute: Intl API disabled");
|
||||
}
|
||||
|
||||
class Locale {
|
||||
public:
|
||||
explicit Locale(const char* language, const char* country = 0, const char* variant = 0,
|
||||
const char* keywordsAndValues = 0);
|
||||
};
|
||||
typedef void* UNumberingSystem;
|
||||
|
||||
Locale::Locale(const char* language, const char* country, const char* variant,
|
||||
const char* keywordsAndValues)
|
||||
static UNumberingSystem*
|
||||
unumsys_open(const char* locale, UErrorCode* status)
|
||||
{
|
||||
MOZ_CRASH("Locale::Locale: Intl API disabled");
|
||||
MOZ_CRASH("unumsys_open: Intl API disabled");
|
||||
}
|
||||
|
||||
class NumberingSystem {
|
||||
public:
|
||||
static NumberingSystem* createInstance(const Locale& inLocale, UErrorCode& status);
|
||||
const char* getName();
|
||||
};
|
||||
|
||||
NumberingSystem*
|
||||
NumberingSystem::createInstance(const Locale& inLocale, UErrorCode& status)
|
||||
static const char*
|
||||
unumsys_getName(const UNumberingSystem* unumsys)
|
||||
{
|
||||
MOZ_CRASH("NumberingSystem::createInstance: Intl API disabled");
|
||||
MOZ_CRASH("unumsys_getName: Intl API disabled");
|
||||
}
|
||||
|
||||
const char*
|
||||
NumberingSystem::getName()
|
||||
static void
|
||||
unumsys_close(UNumberingSystem* unumsys)
|
||||
{
|
||||
MOZ_CRASH("NumberingSystem::getName: Intl API disabled");
|
||||
MOZ_CRASH("unumsys_close: Intl API disabled");
|
||||
}
|
||||
|
||||
typedef void* UCalendar;
|
||||
|
@ -1445,20 +1429,20 @@ js::intl_numberingSystem(JSContext* cx, unsigned argc, Value* vp)
|
|||
if (!locale)
|
||||
return false;
|
||||
|
||||
// There's no C API for numbering system, so use the C++ API and hope it
|
||||
// won't break. http://bugs.icu-project.org/trac/ticket/10039
|
||||
Locale ulocale(locale.ptr());
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
NumberingSystem* numbers = NumberingSystem::createInstance(ulocale, status);
|
||||
UNumberingSystem* numbers = unumsys_open(icuLocale(locale.ptr()), &status);
|
||||
if (U_FAILURE(status)) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_INTERNAL_INTL_ERROR);
|
||||
return false;
|
||||
}
|
||||
const char* name = numbers->getName();
|
||||
|
||||
ScopedICUObject<UNumberingSystem, unumsys_close> toClose(numbers);
|
||||
|
||||
const char* name = unumsys_getName(numbers);
|
||||
RootedString jsname(cx, JS_NewStringCopyZ(cx, name));
|
||||
delete numbers;
|
||||
if (!jsname)
|
||||
return false;
|
||||
|
||||
args.rval().setString(jsname);
|
||||
return true;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче