Skip to content

Commit e67c7b4

Browse files
ChiitooAllan Sandfeld Jensen
authored andcommitted
Fix build with system ICU 69
- https://bugs.gentoo.org/781236 - https://chromium-review.googlesource.com/c/v8/v8/+/2477751 Change-Id: I8ea93bfe0acb87da9233fced73ff5ae7c5f4cb3e Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent 3f594ea commit e67c7b4

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

chromium/v8/src/objects/js-list-format.cc

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,35 @@
2828
namespace v8 {
2929
namespace internal {
3030

31+
#if U_ICU_VERSION_MAJOR_NUM >= 67
32+
namespace {
33+
34+
UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
35+
switch (style) {
36+
case JSListFormat::Style::LONG:
37+
return ULISTFMT_WIDTH_WIDE;
38+
case JSListFormat::Style::SHORT:
39+
return ULISTFMT_WIDTH_SHORT;
40+
case JSListFormat::Style::NARROW:
41+
return ULISTFMT_WIDTH_NARROW;
42+
}
43+
UNREACHABLE();
44+
}
45+
46+
UListFormatterType GetIcuType(JSListFormat::Type type) {
47+
switch (type) {
48+
case JSListFormat::Type::CONJUNCTION:
49+
return ULISTFMT_TYPE_AND;
50+
case JSListFormat::Type::DISJUNCTION:
51+
return ULISTFMT_TYPE_OR;
52+
case JSListFormat::Type::UNIT:
53+
return ULISTFMT_TYPE_UNITS;
54+
}
55+
UNREACHABLE();
56+
}
57+
58+
} // namespace
59+
#else
3160
namespace {
3261
const char* kStandard = "standard";
3362
const char* kOr = "or";
@@ -74,7 +103,7 @@ const char* GetIcuStyleString(JSListFormat::Style style,
74103
}
75104

76105
} // namespace
77-
106+
#endif
78107
MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
79108
Handle<Object> locales,
80109
Handle<Object> input_options) {
@@ -143,7 +172,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
143172
icu::Locale icu_locale = r.icu_locale;
144173
UErrorCode status = U_ZERO_ERROR;
145174
icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
175+
#if U_ICU_VERSION_MAJOR_NUM >= 67
176+
icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
177+
#else
146178
icu_locale, GetIcuStyleString(style_enum, type_enum), status);
179+
#endif
147180
if (U_FAILURE(status) || formatter == nullptr) {
148181
delete formatter;
149182
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),

0 commit comments

Comments
 (0)