From: Shane Carr Date: Mon, 23 Oct 2017 07:12:39 +0000 (+0000) Subject: ICU-13415 Refactoring shadowed virtual method in IFixedDecimal. X-Git-Tag: release-61-rc~211 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=de3c990b0b19d61e6a548500dbecf32940015727;p=icu ICU-13415 Refactoring shadowed virtual method in IFixedDecimal. X-SVN-Rev: 40626 --- diff --git a/icu4c/source/i18n/plurrule.cpp b/icu4c/source/i18n/plurrule.cpp index 48b7976baf3..dcf28b2bc1a 100644 --- a/icu4c/source/i18n/plurrule.cpp +++ b/icu4c/source/i18n/plurrule.cpp @@ -789,7 +789,9 @@ AndConstraint::isFulfilled(const IFixedDecimal &number) { // An empty AndConstraint, created by a rule with a keyword but no following expression. return TRUE; } - double n = number.getPluralOperand(digitsType); // pulls n | i | v | f value for the number. + + PluralOperand operand = tokenTypeToPluralOperand(digitsType); + double n = number.getPluralOperand(operand); // pulls n | i | v | f value for the number. // Will always be positive. // May be non-integer (n option only) do { @@ -1405,6 +1407,24 @@ PluralKeywordEnumeration::count(UErrorCode& /*status*/) const { PluralKeywordEnumeration::~PluralKeywordEnumeration() { } +PluralOperand tokenTypeToPluralOperand(tokenType tt) { + switch(tt) { + case tVariableN: + return PLURAL_OPERAND_N; + case tVariableI: + return PLURAL_OPERAND_I; + case tVariableF: + return PLURAL_OPERAND_F; + case tVariableV: + return PLURAL_OPERAND_V; + case tVariableT: + return PLURAL_OPERAND_T; + default: + U_ASSERT(FALSE); // unexpected. + return PLURAL_OPERAND_N; + } +} + IFixedDecimal::~IFixedDecimal() = default; FixedDecimal::FixedDecimal(const VisibleDigits &digits) { diff --git a/icu4c/source/i18n/plurrule_impl.h b/icu4c/source/i18n/plurrule_impl.h index e4f3f3f6eae..b93fc501bac 100644 --- a/icu4c/source/i18n/plurrule_impl.h +++ b/icu4c/source/i18n/plurrule_impl.h @@ -221,6 +221,12 @@ enum PluralOperand { PLURAL_OPERAND_J }; +/** + * Converts from the tokenType enum to PluralOperand. Asserts that the given + * tokenType can be mapped to a PluralOperand. + */ +PluralOperand tokenTypeToPluralOperand(tokenType tt); + /** * An interface to FixedDecimal, allowing for other implementations. * @internal @@ -235,25 +241,6 @@ class U_I18N_API IFixedDecimal { */ virtual double getPluralOperand(PluralOperand operand) const = 0; - /** Converts from the tokenType enum to PluralOperand. */ - virtual double getPluralOperand(tokenType tt) const { - switch(tt) { - case tVariableN: - return getPluralOperand(PLURAL_OPERAND_N); - case tVariableI: - return getPluralOperand(PLURAL_OPERAND_I); - case tVariableF: - return getPluralOperand(PLURAL_OPERAND_F); - case tVariableV: - return getPluralOperand(PLURAL_OPERAND_V); - case tVariableT: - return getPluralOperand(PLURAL_OPERAND_T); - default: - U_ASSERT(FALSE); // unexpected. - return 0.0; - } - } - virtual bool isNaN() const = 0; virtual bool isInfinite() const = 0;