Submitted By: Ken Moffat Date: 2021-05-04 Initial Package Version: 14.16.1 Upstream Status: Unknown Origin: Gentoo Description: Allows node.js-v14.16.1 to build with ICU_69.1. Port of the Chromium commit 035c305ce7761f51328b45f1bd83e26aef267c9d to node-v14. Original commit message follows. Author: Frank Tang AuthorDate: 2020-10-15 22:44:27 -0700 Commit: Commit Bot CommitDate: 2020-10-20 02:08:13 +0000 [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. --- a/deps/v8/src/objects/js-list-format.cc +++ b/deps/v8/src/objects/js-list-format.cc @@ -29,46 +29,26 @@ namespace internal { 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"; +UListFormatterWidth GetIcuWidth(JSListFormat::Style style) { + 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(); +} -const char* GetIcuStyleString(JSListFormat::Style style, - JSListFormat::Type type) { +UListFormatterType GetIcuType(JSListFormat::Type type) { switch (type) { case JSListFormat::Type::CONJUNCTION: - switch (style) { - case JSListFormat::Style::LONG: - return kStandard; - case JSListFormat::Style::SHORT: - return kStandardShort; - case JSListFormat::Style::NARROW: - return kStandardNarrow; - } + return ULISTFMT_TYPE_AND; case JSListFormat::Type::DISJUNCTION: - switch (style) { - case JSListFormat::Style::LONG: - return kOr; - case JSListFormat::Style::SHORT: - return kOrShort; - case JSListFormat::Style::NARROW: - return kOrNarrow; - } + return ULISTFMT_TYPE_OR; case JSListFormat::Type::UNIT: - switch (style) { - case JSListFormat::Style::LONG: - return kUnit; - case JSListFormat::Style::SHORT: - return kUnitShort; - case JSListFormat::Style::NARROW: - return kUnitNarrow; - } + return ULISTFMT_TYPE_UNITS; } UNREACHABLE(); } @@ -143,7 +123,7 @@ icu::Locale icu_locale = r.icu_locale; UErrorCode status = U_ZERO_ERROR; 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) { delete formatter; THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError),