From 72adfe7239e6a0370fcdd5cd0bdf1cb761875318 Mon Sep 17 00:00:00 2001 From: Dan Minor Date: Tue, 11 May 2021 11:37:37 +0000 Subject: [PATCH] Bug 1701695 - Rename NumberFormatOptions::CurrencyDisplayStyle; r=gregtatum This should be CurrencyDisplay to be consistent with ecma-402. Differential Revision: https://phabricator.services.mozilla.com/D113557 --- intl/components/gtest/TestNumberFormat.cpp | 4 ++-- intl/components/src/NumberFormat.h | 4 ++-- intl/components/src/NumberFormatterSkeleton.cpp | 10 +++++----- intl/components/src/NumberFormatterSkeleton.h | 2 +- intl/l10n/FluentBundle.cpp | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/intl/components/gtest/TestNumberFormat.cpp b/intl/components/gtest/TestNumberFormat.cpp index cb057c45e327..661da409e58e 100644 --- a/intl/components/gtest/TestNumberFormat.cpp +++ b/intl/components/gtest/TestNumberFormat.cpp @@ -96,8 +96,8 @@ TEST(IntlNumberFormat, SignificantDigits) TEST(IntlNumberFormat, Currency) { NumberFormatOptions options; - options.mCurrency = Some( - std::make_pair("MXN", NumberFormatOptions::CurrencyDisplayStyle::Symbol)); + options.mCurrency = + Some(std::make_pair("MXN", NumberFormatOptions::CurrencyDisplay::Symbol)); NumberFormat nf("es-MX", options); Buffer buf8; ASSERT_TRUE(nf.format(123456.789, buf8).isOk()); diff --git a/intl/components/src/NumberFormat.h b/intl/components/src/NumberFormat.h index 1e71426ebc24..31dc31d1a60e 100644 --- a/intl/components/src/NumberFormat.h +++ b/intl/components/src/NumberFormat.h @@ -42,13 +42,13 @@ struct MOZ_STACK_CLASS NumberFormatOptions { * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit-width */ - enum class CurrencyDisplayStyle { + enum class CurrencyDisplay { Symbol, Code, Name, NarrowSymbol, }; - Maybe> mCurrency; + Maybe> mCurrency; /** * Set the fraction digits settings. |min| can be zero, |max| must be diff --git a/intl/components/src/NumberFormatterSkeleton.cpp b/intl/components/src/NumberFormatterSkeleton.cpp index cb78d462953e..37be858f1f63 100644 --- a/intl/components/src/NumberFormatterSkeleton.cpp +++ b/intl/components/src/NumberFormatterSkeleton.cpp @@ -82,19 +82,19 @@ bool NumberFormatterSkeleton::currency(std::string_view currency) { } bool NumberFormatterSkeleton::currencyDisplay( - NumberFormatOptions::CurrencyDisplayStyle display) { + NumberFormatOptions::CurrencyDisplay display) { switch (display) { - case NumberFormatOptions::CurrencyDisplayStyle::Code: + case NumberFormatOptions::CurrencyDisplay::Code: return appendToken(u"unit-width-iso-code"); break; - case NumberFormatOptions::CurrencyDisplayStyle::Name: + case NumberFormatOptions::CurrencyDisplay::Name: return appendToken(u"unit-width-full-name"); break; - case NumberFormatOptions::CurrencyDisplayStyle::Symbol: + case NumberFormatOptions::CurrencyDisplay::Symbol: // Default, no additional tokens needed. return true; break; - case NumberFormatOptions::CurrencyDisplayStyle::NarrowSymbol: + case NumberFormatOptions::CurrencyDisplay::NarrowSymbol: return appendToken(u"unit-width-narrow"); break; default: diff --git a/intl/components/src/NumberFormatterSkeleton.h b/intl/components/src/NumberFormatterSkeleton.h index a71c227345aa..643acaf16b10 100644 --- a/intl/components/src/NumberFormatterSkeleton.h +++ b/intl/components/src/NumberFormatterSkeleton.h @@ -59,7 +59,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final { bool currency(std::string_view currency); - bool currencyDisplay(NumberFormatOptions::CurrencyDisplayStyle display); + bool currencyDisplay(NumberFormatOptions::CurrencyDisplay display); bool unit(std::string_view unit); diff --git a/intl/l10n/FluentBundle.cpp b/intl/l10n/FluentBundle.cpp index ea599e115a1d..ccf04f672200 100644 --- a/intl/l10n/FluentBundle.cpp +++ b/intl/l10n/FluentBundle.cpp @@ -218,15 +218,15 @@ ffi::RawNumberFormatter* FluentBuiltInNumberFormatterCreate( switch (aOptions->currency_display) { case ffi::FluentNumberCurrencyDisplayStyleRaw::Symbol: options.mCurrency = Some(std::make_pair( - currency, NumberFormatOptions::CurrencyDisplayStyle::Symbol)); + currency, NumberFormatOptions::CurrencyDisplay::Symbol)); break; case ffi::FluentNumberCurrencyDisplayStyleRaw::Code: options.mCurrency = Some(std::make_pair( - currency, NumberFormatOptions::CurrencyDisplayStyle::Code)); + currency, NumberFormatOptions::CurrencyDisplay::Code)); break; case ffi::FluentNumberCurrencyDisplayStyleRaw::Name: options.mCurrency = Some(std::make_pair( - currency, NumberFormatOptions::CurrencyDisplayStyle::Name)); + currency, NumberFormatOptions::CurrencyDisplay::Name)); break; default: MOZ_ASSERT_UNREACHABLE();