mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 837957 - Implement ICU dependent functions of Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat (cleanup). r=jwalden
--HG-- extra : rebase_source : 8adc5d1feb27ccd24eef30c1a7b6b4a2e7f6e91a
This commit is contained in:
parent
7c83e480e3
commit
e9faffd1de
@ -69,13 +69,7 @@ using icu::NumberingSystem;
|
||||
* directory for license.
|
||||
*/
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define SUPPRESS_UNUSED_WARNING __attribute__ ((unused))
|
||||
#else
|
||||
# define SUPPRESS_UNUSED_WARNING
|
||||
#endif
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static int32_t
|
||||
static int32_t
|
||||
u_strlen(const UChar *s)
|
||||
{
|
||||
MOZ_NOT_REACHED("u_strlen: Intl API disabled");
|
||||
@ -213,21 +207,21 @@ enum UNumberFormatTextAttribute {
|
||||
UNUM_CURRENCY_CODE,
|
||||
};
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static int32_t
|
||||
static int32_t
|
||||
unum_countAvailable(void)
|
||||
{
|
||||
MOZ_NOT_REACHED("unum_countAvailable: Intl API disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static const char *
|
||||
static const char *
|
||||
unum_getAvailable(int32_t localeIndex)
|
||||
{
|
||||
MOZ_NOT_REACHED("unum_getAvailable: Intl API disabled");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static UNumberFormat *
|
||||
static UNumberFormat *
|
||||
unum_open(UNumberFormatStyle style, const UChar *pattern, int32_t patternLength,
|
||||
const char *locale, UParseError *parseErr, UErrorCode *status)
|
||||
{
|
||||
@ -236,13 +230,13 @@ unum_open(UNumberFormatStyle style, const UChar *pattern, int32_t patternLength,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
unum_setAttribute(UNumberFormat *fmt, UNumberFormatAttribute attr, int32_t newValue)
|
||||
{
|
||||
MOZ_NOT_REACHED("unum_setAttribute: Intl API disabled");
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static int32_t
|
||||
static int32_t
|
||||
unum_formatDouble(const UNumberFormat *fmt, double number, UChar *result,
|
||||
int32_t resultLength, UFieldPosition *pos, UErrorCode *status)
|
||||
{
|
||||
@ -251,13 +245,13 @@ unum_formatDouble(const UNumberFormat *fmt, double number, UChar *result,
|
||||
return 0;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
unum_close(UNumberFormat *fmt)
|
||||
{
|
||||
MOZ_NOT_REACHED("unum_close: Intl API disabled");
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
unum_setTextAttribute(UNumberFormat *fmt, UNumberFormatTextAttribute tag, const UChar *newValue,
|
||||
int32_t newValueLength, UErrorCode *status)
|
||||
{
|
||||
@ -306,7 +300,7 @@ enum UCalendarType {
|
||||
UCAL_GREGORIAN
|
||||
};
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static UCalendar *
|
||||
static UCalendar *
|
||||
ucal_open(const UChar *zoneID, int32_t len, const char *locale,
|
||||
UCalendarType type, UErrorCode *status)
|
||||
{
|
||||
@ -315,7 +309,7 @@ ucal_open(const UChar *zoneID, int32_t len, const char *locale,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static const char *
|
||||
static const char *
|
||||
ucal_getType(const UCalendar *cal, UErrorCode *status)
|
||||
{
|
||||
MOZ_NOT_REACHED("ucal_getType: Intl API disabled");
|
||||
@ -323,7 +317,7 @@ ucal_getType(const UCalendar *cal, UErrorCode *status)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static UEnumeration *
|
||||
static UEnumeration *
|
||||
ucal_getKeywordValuesForLocale(const char *key, const char *locale,
|
||||
UBool commonlyUsed, UErrorCode *status)
|
||||
{
|
||||
@ -332,7 +326,7 @@ ucal_getKeywordValuesForLocale(const char *key, const char *locale,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
ucal_close(UCalendar *cal)
|
||||
{
|
||||
MOZ_NOT_REACHED("ucal_close: Intl API disabled");
|
||||
@ -340,7 +334,7 @@ ucal_close(UCalendar *cal)
|
||||
|
||||
typedef void *UDateTimePatternGenerator;
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static UDateTimePatternGenerator *
|
||||
static UDateTimePatternGenerator *
|
||||
udatpg_open(const char *locale, UErrorCode *pErrorCode)
|
||||
{
|
||||
MOZ_NOT_REACHED("udatpg_open: Intl API disabled");
|
||||
@ -348,7 +342,7 @@ udatpg_open(const char *locale, UErrorCode *pErrorCode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static int32_t
|
||||
static int32_t
|
||||
udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, const UChar *skeleton,
|
||||
int32_t length, UChar *bestPattern, int32_t capacity,
|
||||
UErrorCode *pErrorCode)
|
||||
@ -358,7 +352,7 @@ udatpg_getBestPattern(UDateTimePatternGenerator *dtpg, const UChar *skeleton,
|
||||
return 0;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
udatpg_close(UDateTimePatternGenerator *dtpg)
|
||||
{
|
||||
MOZ_NOT_REACHED("udatpg_close: Intl API disabled");
|
||||
@ -372,21 +366,21 @@ enum UDateFormatStyle {
|
||||
UDAT_IGNORE = UDAT_PATTERN
|
||||
};
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static int32_t
|
||||
static int32_t
|
||||
udat_countAvailable(void)
|
||||
{
|
||||
MOZ_NOT_REACHED("udat_countAvailable: Intl API disabled");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static const char *
|
||||
static const char *
|
||||
udat_getAvailable(int32_t localeIndex)
|
||||
{
|
||||
MOZ_NOT_REACHED("udat_getAvailable: Intl API disabled");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static UDateFormat *
|
||||
static UDateFormat *
|
||||
udat_open(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle, const char *locale,
|
||||
const UChar *tzID, int32_t tzIDLength, const UChar *pattern,
|
||||
int32_t patternLength, UErrorCode *status)
|
||||
@ -396,21 +390,21 @@ udat_open(UDateFormatStyle timeStyle, UDateFormatStyle dateStyle, const char *lo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static const UCalendar *
|
||||
static const UCalendar *
|
||||
udat_getCalendar(const UDateFormat *fmt)
|
||||
{
|
||||
MOZ_NOT_REACHED("udat_getCalendar: Intl API disabled");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode)
|
||||
{
|
||||
MOZ_NOT_REACHED("ucal_setGregorianChange: Intl API disabled");
|
||||
*pErrorCode = U_UNSUPPORTED_ERROR;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static int32_t
|
||||
static int32_t
|
||||
udat_format(const UDateFormat *format, UDate dateToFormat, UChar *result,
|
||||
int32_t resultLength, UFieldPosition *position, UErrorCode *status)
|
||||
{
|
||||
@ -419,7 +413,7 @@ udat_format(const UDateFormat *format, UDate dateToFormat, UChar *result,
|
||||
return 0;
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static void
|
||||
static void
|
||||
udat_close(UDateFormat *format)
|
||||
{
|
||||
MOZ_NOT_REACHED("udat_close: Intl API disabled");
|
||||
@ -461,7 +455,7 @@ typedef int32_t
|
||||
typedef const char *
|
||||
(* GetAvailable)(int32_t localeIndex);
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static bool
|
||||
static bool
|
||||
intl_availableLocales(JSContext *cx, CountAvailable countAvailable,
|
||||
GetAvailable getAvailable, MutableHandleValue result)
|
||||
{
|
||||
@ -497,7 +491,7 @@ intl_availableLocales(JSContext *cx, CountAvailable countAvailable,
|
||||
/**
|
||||
* Returns the object holding the internal properties for obj.
|
||||
*/
|
||||
SUPPRESS_UNUSED_WARNING static bool
|
||||
static bool
|
||||
GetInternals(JSContext *cx, HandleObject obj, MutableHandleObject internals)
|
||||
{
|
||||
RootedValue getInternalsValue(cx);
|
||||
@ -526,13 +520,13 @@ equal(const char *s1, const char *s2)
|
||||
return !strcmp(s1, s2);
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static bool
|
||||
static bool
|
||||
equal(JSAutoByteString &s1, const char *s2)
|
||||
{
|
||||
return !strcmp(s1.ptr(), s2);
|
||||
}
|
||||
|
||||
SUPPRESS_UNUSED_WARNING static const char *
|
||||
static const char *
|
||||
icuLocale(const char *locale)
|
||||
{
|
||||
if (equal(locale, "und"))
|
||||
@ -1448,6 +1442,10 @@ intl_FormatNumber(JSContext *cx, UNumberFormat *nf, double x, MutableHandleValue
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trim any unused characters.
|
||||
if (!chars.resize(size))
|
||||
return false;
|
||||
|
||||
RootedString str(cx, chars.finishString());
|
||||
if (!str)
|
||||
return false;
|
||||
@ -1925,6 +1923,10 @@ intl_FormatDateTime(JSContext *cx, UDateFormat *df, double x, MutableHandleValue
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trim any unused characters.
|
||||
if (!chars.resize(size))
|
||||
return false;
|
||||
|
||||
RootedString str(cx, chars.finishString());
|
||||
if (!str)
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user