ICU 4.6 NumberFormat::EStyle enum is gone in ICU 4.8. Adding #if #else to make it work across versions.

There was an ICU cleanup (removing all C++ style enums and replacing them with plain C enums). NumberFormat::EStyle had a draft status (from ICU 4.2) and it was cut. Confusion came up because DateFormat::EStyle is stable and won't be removed.

TEST=Compile Chromium with ICU 4.6 and ICU 4.8
BUG=1561
Review URL: http://codereview.chromium.org/7421003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8701 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
cira@chromium.org 2011-07-20 17:46:56 +00:00
parent 013baa4164
commit d0ee5982a8

View File

@ -36,6 +36,8 @@
#include "unicode/numfmt.h"
#include "unicode/uchar.h"
#include "unicode/ucurr.h"
#include "unicode/unum.h"
#include "unicode/uversion.h"
namespace v8 {
namespace internal {
@ -231,6 +233,8 @@ static icu::DecimalFormat* CreateNumberFormat(v8::Handle<v8::String> locale,
}
// Generates ICU number format pattern from given skeleton.
// TODO(cira): Remove once ICU includes equivalent method
// (see http://bugs.icu-project.org/trac/ticket/8610).
static icu::DecimalFormat* CreateFormatterFromSkeleton(
const icu::Locale& icu_locale,
const icu::UnicodeString& skeleton,
@ -251,6 +255,7 @@ static icu::DecimalFormat* CreateFormatterFromSkeleton(
// Case of non-consecutive U+00A4 is taken care of in i18n.js.
int32_t end_index = skeleton.lastIndexOf(currency_symbol, index);
#if (U_ICU_VERSION_MAJOR_NUM == 4) && (U_ICU_VERSION_MINOR_NUM <= 6)
icu::NumberFormat::EStyles style;
switch (end_index - index) {
case 0:
@ -262,6 +267,19 @@ static icu::DecimalFormat* CreateFormatterFromSkeleton(
default:
style = icu::NumberFormat::kPluralCurrencyStyle;
}
#else // ICU version is 4.8 or above (we ignore versions below 4.0).
UNumberFormatStyle style;
switch (end_index - index) {
case 0:
style = UNUM_CURRENCY;
break;
case 1:
style = UNUM_CURRENCY_ISO;
break;
default:
style = UNUM_CURRENCY_PLURAL;
}
#endif
base_format = static_cast<icu::DecimalFormat*>(
icu::NumberFormat::createInstance(icu_locale, style, *status));