Skip to content

Commit 51dad8c

Browse files
committed
deps: V8: cherry-pick 035c305ce776
Original commit message: [Intl] call new ListFormatter::createInstance The one we currently using is now marked as internal and to be removed for 68. Migrating to the style which already avaiable in ICU 67-1. Bug: v8:11031 Change-Id: I668382a2e1b8602ddca02bf231c5008a6c92bf2d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2477751 Reviewed-by: Jakob Kummerow <[email protected]> Commit-Queue: Frank Tang <[email protected]> Cr-Commit-Position: refs/heads/master@{#70638} Refs: v8/v8@035c305 PR-URL: #38497 Reviewed-By: Jiawen Geng <[email protected]>
1 parent 4fdcbae commit 51dad8c

File tree

2 files changed

+19
-38
lines changed

2 files changed

+19
-38
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# Reset this number to 0 on major V8 upgrades.
3838
# Increment by one for each non-official patch applied to deps/v8.
39-
'v8_embedder_string': '-node.66',
39+
'v8_embedder_string': '-node.67',
4040

4141
##### V8 defaults for Node.js #####
4242

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

+18-37
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,27 @@ namespace v8 {
2929
namespace internal {
3030

3131
namespace {
32-
const char* kStandard = "standard";
33-
const char* kOr = "or";
34-
const char* kUnit = "unit";
35-
const char* kStandardShort = "standard-short";
36-
const char* kOrShort = "or-short";
37-
const char* kUnitShort = "unit-short";
38-
const char* kStandardNarrow = "standard-narrow";
39-
const char* kOrNarrow = "or-narrow";
40-
const char* kUnitNarrow = "unit-narrow";
41-
42-
const char* GetIcuStyleString(JSListFormat::Style style,
43-
JSListFormat::Type type) {
32+
33+
UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
34+
switch (style) {
35+
case JSListFormat::Style::LONG:
36+
return ULISTFMT_WIDTH_WIDE;
37+
case JSListFormat::Style::SHORT:
38+
return ULISTFMT_WIDTH_SHORT;
39+
case JSListFormat::Style::NARROW:
40+
return ULISTFMT_WIDTH_NARROW;
41+
}
42+
UNREACHABLE();
43+
}
44+
45+
UListFormatterType GetIcuType(JSListFormat::Type type) {
4446
switch (type) {
4547
case JSListFormat::Type::CONJUNCTION:
46-
switch (style) {
47-
case JSListFormat::Style::LONG:
48-
return kStandard;
49-
case JSListFormat::Style::SHORT:
50-
return kStandardShort;
51-
case JSListFormat::Style::NARROW:
52-
return kStandardNarrow;
53-
}
48+
return ULISTFMT_TYPE_AND;
5449
case JSListFormat::Type::DISJUNCTION:
55-
switch (style) {
56-
case JSListFormat::Style::LONG:
57-
return kOr;
58-
case JSListFormat::Style::SHORT:
59-
return kOrShort;
60-
case JSListFormat::Style::NARROW:
61-
return kOrNarrow;
62-
}
50+
return ULISTFMT_TYPE_OR;
6351
case JSListFormat::Type::UNIT:
64-
switch (style) {
65-
case JSListFormat::Style::LONG:
66-
return kUnit;
67-
case JSListFormat::Style::SHORT:
68-
return kUnitShort;
69-
case JSListFormat::Style::NARROW:
70-
return kUnitNarrow;
71-
}
52+
return ULISTFMT_TYPE_UNITS;
7253
}
7354
UNREACHABLE();
7455
}
@@ -143,7 +124,7 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
143124
icu::Locale icu_locale = r.icu_locale;
144125
UErrorCode status = U_ZERO_ERROR;
145126
icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
146-
icu_locale, GetIcuStyleString(style_enum, type_enum), status);
127+
icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
147128
if (U_FAILURE(status) || formatter == nullptr) {
148129
delete formatter;
149130
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),

0 commit comments

Comments
 (0)