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 <jkummerow@chromium.org>
    Commit-Queue: Frank Tang <ftang@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#70638}

Refs: https://github.com/v8/v8/commit/035c305ce7761f51328b45f1bd83e26aef267c9d

PR-URL: https://github.com/nodejs/node/pull/38497
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
This commit is contained in:
Michaël Zasso committed 2021-05-18 08:32:30 +02:00
1 parent c260d98d9a
commit 40df0dcb59
2 files changed
+18 -37

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@
# Reset this number to 0 on major V8 upgrades. # Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8. # Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.66', 'v8_embedder_string': '-node.67',
##### V8 defaults for Node.js ##### ##### V8 defaults for Node.js #####
+17 -36
View File
@@ -29,46 +29,27 @@ namespace v8 {
namespace internal { namespace internal {
namespace { namespace {
const char* kStandard = "standard";
const char* kOr = "or";
const char* kUnit = "unit";
const char* kStandardShort = "standard-short";
const char* kOrShort = "or-short";
const char* kUnitShort = "unit-short";
const char* kStandardNarrow = "standard-narrow";
const char* kOrNarrow = "or-narrow";
const char* kUnitNarrow = "unit-narrow";
const char* GetIcuStyleString(JSListFormat::Style style, UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
JSListFormat::Type type) { switch (style) {
case JSListFormat::Style::LONG:
return ULISTFMT_WIDTH_WIDE;
case JSListFormat::Style::SHORT:
return ULISTFMT_WIDTH_SHORT;
case JSListFormat::Style::NARROW:
return ULISTFMT_WIDTH_NARROW;
}
UNREACHABLE();
}
UListFormatterType GetIcuType(JSListFormat::Type type) {
switch (type) { switch (type) {
case JSListFormat::Type::CONJUNCTION: case JSListFormat::Type::CONJUNCTION:
switch (style) { return ULISTFMT_TYPE_AND;
case JSListFormat::Style::LONG:
return kStandard;
case JSListFormat::Style::SHORT:
return kStandardShort;
case JSListFormat::Style::NARROW:
return kStandardNarrow;
}
case JSListFormat::Type::DISJUNCTION: case JSListFormat::Type::DISJUNCTION:
switch (style) { return ULISTFMT_TYPE_OR;
case JSListFormat::Style::LONG:
return kOr;
case JSListFormat::Style::SHORT:
return kOrShort;
case JSListFormat::Style::NARROW:
return kOrNarrow;
}
case JSListFormat::Type::UNIT: case JSListFormat::Type::UNIT:
switch (style) { return ULISTFMT_TYPE_UNITS;
case JSListFormat::Style::LONG:
return kUnit;
case JSListFormat::Style::SHORT:
return kUnitShort;
case JSListFormat::Style::NARROW:
return kUnitNarrow;
}
} }
UNREACHABLE(); UNREACHABLE();
} }
@@ -143,7 +124,7 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
icu::Locale icu_locale = r.icu_locale; icu::Locale icu_locale = r.icu_locale;
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
icu::ListFormatter* formatter = icu::ListFormatter::createInstance( icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
icu_locale, GetIcuStyleString(style_enum, type_enum), status); icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
if (U_FAILURE(status) || formatter == nullptr) { if (U_FAILURE(status) || formatter == nullptr) {
delete formatter; delete formatter;
THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),