| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7557e74 commit ccecea5
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,12 +24,58 @@ | |||
| 24 | 24 | #include "unicode/fpositer.h" | |
| 25 | 25 | #include "unicode/listformatter.h" | |
| 26 | 26 | #include "unicode/ulistformatter.h" | |
| 27 | + #include "unicode/uvernum.h" | ||
| 27 | 28 | ||
| 28 | 29 | namespace v8 { | |
| 29 | 30 | namespace internal { | |
| 30 | 31 | ||
| 31 | 32 | namespace { | |
| 32 | 33 | ||
| 34 | + #if U_ICU_VERSION_MAJOR_NUM < 67 | ||
| 35 | + const char* kStandard = "standard"; | ||
| 36 | + const char* kOr = "or"; | ||
| 37 | + const char* kUnit = "unit"; | ||
| 38 | + const char* kStandardShort = "standard-short"; | ||
| 39 | + const char* kOrShort = "or-short"; | ||
| 40 | + const char* kUnitShort = "unit-short"; | ||
| 41 | + const char* kStandardNarrow = "standard-narrow"; | ||
| 42 | + const char* kOrNarrow = "or-narrow"; | ||
| 43 | + const char* kUnitNarrow = "unit-narrow"; | ||
| 44 | + | ||
| 45 | + const char* GetIcuStyleString(JSListFormat::Style style, | ||
| 46 | + JSListFormat::Type type) { | ||
| 47 | + switch (type) { | ||
| 48 | + case JSListFormat::Type::CONJUNCTION: | ||
| 49 | + switch (style) { | ||
| 50 | + case JSListFormat::Style::LONG: | ||
| 51 | + return kStandard; | ||
| 52 | + case JSListFormat::Style::SHORT: | ||
| 53 | + return kStandardShort; | ||
| 54 | + case JSListFormat::Style::NARROW: | ||
| 55 | + return kStandardNarrow; | ||
| 56 | + } | ||
| 57 | + case JSListFormat::Type::DISJUNCTION: | ||
| 58 | + switch (style) { | ||
| 59 | + case JSListFormat::Style::LONG: | ||
| 60 | + return kOr; | ||
| 61 | + case JSListFormat::Style::SHORT: | ||
| 62 | + return kOrShort; | ||
| 63 | + case JSListFormat::Style::NARROW: | ||
| 64 | + return kOrNarrow; | ||
| 65 | + } | ||
| 66 | + case JSListFormat::Type::UNIT: | ||
| 67 | + switch (style) { | ||
| 68 | + case JSListFormat::Style::LONG: | ||
| 69 | + return kUnit; | ||
| 70 | + case JSListFormat::Style::SHORT: | ||
| 71 | + return kUnitShort; | ||
| 72 | + case JSListFormat::Style::NARROW: | ||
| 73 | + return kUnitNarrow; | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + UNREACHABLE(); | ||
| 77 | + } | ||
| 78 | + #else | ||
| 33 | 79 | UListFormatterWidth GetIcuWidth(JSListFormat::Style style) { | |
| 34 | 80 | switch (style) { | |
| 35 | 81 | case JSListFormat::Style::LONG: | |
@@ -53,6 +99,7 @@ UListFormatterType GetIcuType(JSListFormat::Type type) { | |||
| 53 | 99 | } | |
| 54 | 100 | UNREACHABLE(); | |
| 55 | 101 | } | |
| 102 | + #endif | ||
| 56 | 103 | ||
| 57 | 104 | } // namespace | |
| 58 | 105 | ||
@@ -124,7 +171,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map, | |||
| 124 | 171 | icu::Locale icu_locale = r.icu_locale; | |
| 125 | 172 | UErrorCode status = U_ZERO_ERROR; | |
| 126 | 173 | icu::ListFormatter* formatter = icu::ListFormatter::createInstance( | |
| 174 | + #if U_ICU_VERSION_MAJOR_NUM < 67 | ||
| 175 | + icu_locale, GetIcuStyleString(style_enum, type_enum), status); | ||
| 176 | + #else | ||
| 127 | 177 | icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status); | |
| 178 | + #endif | ||
| 128 | 179 | if (U_FAILURE(status) || formatter == nullptr) { | |
| 129 | 180 | delete formatter; | |
| 130 | 181 | THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,3 @@ | |||
| 1 | 1 | { | |
| 2 | - "minimum_icu": 67 | ||
| 2 | + "minimum_icu": 65 | ||
| 3 | 3 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments