From b03feb6338737c6bbab61e64c224f275e6059d87 Mon Sep 17 00:00:00 2001 From: "Shane F. Carr" Date: Wed, 25 Mar 2020 14:21:07 -0500 Subject: [PATCH] ICU-20920 Changing "Sequence" to "Mixed" in ICU4C MeasureUnit --- icu4c/source/i18n/measunit_extra.cpp | 12 ++++---- icu4c/source/i18n/measunit_impl.h | 4 +-- icu4c/source/i18n/unicode/measunit.h | 32 +++++++++++----------- icu4c/source/test/intltest/measfmttest.cpp | 12 ++++---- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/icu4c/source/i18n/measunit_extra.cpp b/icu4c/source/i18n/measunit_extra.cpp index d848965ff43..c9785652317 100644 --- a/icu4c/source/i18n/measunit_extra.cpp +++ b/icu4c/source/i18n/measunit_extra.cpp @@ -496,19 +496,19 @@ private: } bool added = result.append(singleUnit, status); if (sawPlus && !added) { - // Two similar units are not allowed in a sequence unit + // Two similar units are not allowed in a mixed unit status = kUnitIdentifierSyntaxError; return; } if ((++unitNum) >= 2) { UMeasureUnitComplexity complexity = sawPlus - ? UMEASURE_UNIT_SEQUENCE + ? UMEASURE_UNIT_MIXED : UMEASURE_UNIT_COMPOUND; if (unitNum == 2) { U_ASSERT(result.complexity == UMEASURE_UNIT_SINGLE); result.complexity = complexity; } else if (result.complexity != complexity) { - // Mixed sequence and compound units + // Can't have mixed compound units status = kUnitIdentifierSyntaxError; return; } @@ -589,7 +589,7 @@ void serialize(MeasureUnitImpl& impl, UErrorCode& status) { return; } if (impl.complexity == UMEASURE_UNIT_COMPOUND) { - // Note: don't sort a SEQUENCE unit + // Note: don't sort a MIXED unit uprv_sortArray( impl.units.getAlias(), impl.units.length(), @@ -609,7 +609,7 @@ void serialize(MeasureUnitImpl& impl, UErrorCode& status) { for (int32_t i = 1; i < impl.units.length(); i++) { const SingleUnitImpl& prev = *impl.units[i-1]; const SingleUnitImpl& curr = *impl.units[i]; - if (impl.complexity == UMEASURE_UNIT_SEQUENCE) { + if (impl.complexity == UMEASURE_UNIT_MIXED) { impl.identifier.append("-and-", status); serializeSingle(curr, true, impl.identifier, status); } else { @@ -753,7 +753,7 @@ MeasureUnit MeasureUnit::product(const MeasureUnit& other, UErrorCode& status) c MeasureUnitImpl impl = MeasureUnitImpl::forMeasureUnitMaybeCopy(*this, status); MeasureUnitImpl temp; const MeasureUnitImpl& otherImpl = MeasureUnitImpl::forMeasureUnit(other, temp, status); - if (impl.complexity == UMEASURE_UNIT_SEQUENCE || otherImpl.complexity == UMEASURE_UNIT_SEQUENCE) { + if (impl.complexity == UMEASURE_UNIT_MIXED || otherImpl.complexity == UMEASURE_UNIT_MIXED) { status = U_ILLEGAL_ARGUMENT_ERROR; return {}; } diff --git a/icu4c/source/i18n/measunit_impl.h b/icu4c/source/i18n/measunit_impl.h index 5d2e6b1fe57..cf0ea63d2af 100644 --- a/icu4c/source/i18n/measunit_impl.h +++ b/icu4c/source/i18n/measunit_impl.h @@ -82,7 +82,7 @@ struct SingleUnitImpl : public UMemory { /** * Internal representation of measurement units. Capable of representing all complexities of units, - * including sequence and compound units. + * including mixed and compound units. */ struct MeasureUnitImpl : public UMemory { /** Extract the MeasureUnitImpl from a MeasureUnit. */ @@ -151,7 +151,7 @@ struct MeasureUnitImpl : public UMemory { /** Mutates this MeasureUnitImpl to append a single unit. */ bool append(const SingleUnitImpl& singleUnit, UErrorCode& status); - /** The complexity, either SINGLE, COMPOUND, or SEQUENCE. */ + /** The complexity, either SINGLE, COMPOUND, or MIXED. */ UMeasureUnitComplexity complexity = UMEASURE_UNIT_SINGLE; /** diff --git a/icu4c/source/i18n/unicode/measunit.h b/icu4c/source/i18n/unicode/measunit.h index 9353159c92a..9aacfedb978 100644 --- a/icu4c/source/i18n/unicode/measunit.h +++ b/icu4c/source/i18n/unicode/measunit.h @@ -40,8 +40,8 @@ struct MeasureUnitImpl; * square-kilometer, kilojoule, one-per-second. * - COMPOUND: A unit composed of the product of multiple single units. Examples: * meter-per-second, kilowatt-hour, kilogram-meter-per-square-second. - * - SEQUENCE: A unit composed of the sum of multiple single units. Examples: foot+inch, - * hour+minute+second, degree+arcminute+arcsecond. + * - MIXED: A unit composed of the sum of multiple single units. Examples: foot+inch, + * hour+minute+second, degree+arcminute+arcsecond. * * The complexity determines which operations are available. For example, you cannot set the power * or SI prefix of a compound unit. @@ -64,11 +64,11 @@ enum UMeasureUnitComplexity { UMEASURE_UNIT_COMPOUND, /** - * A sequence unit, like hour+minute. + * A mixed unit, like hour+minute. * * @draft ICU 67 */ - UMEASURE_UNIT_SEQUENCE + UMEASURE_UNIT_MIXED }; /** @@ -258,14 +258,14 @@ class U_I18N_API MeasureUnit: public UObject { MeasureUnit(MeasureUnit &&other) noexcept; /** - * Construct a MeasureUnit from a CLDR Sequence Unit Identifier, defined in UTS 35. + * Construct a MeasureUnit from a CLDR Unit Identifier, defined in UTS 35. * Validates and canonicalizes the identifier. * *
      * MeasureUnit example = MeasureUnit::forIdentifier("furlong-per-nanosecond")
      * 
* - * @param identifier The CLDR Sequence Unit Identifier + * @param identifier The CLDR Unit Identifier * @param status Set if the identifier is invalid. * @draft ICU 67 */ @@ -335,7 +335,7 @@ class U_I18N_API MeasureUnit: public UObject { #ifndef U_HIDE_DRAFT_API /** - * Get the CLDR Sequence Unit Identifier for this MeasureUnit, as defined in UTS 35. + * Get the CLDR Unit Identifier for this MeasureUnit, as defined in UTS 35. * * @return The string form of this unit, owned by this MeasureUnit. * @draft ICU 67 @@ -357,7 +357,7 @@ class U_I18N_API MeasureUnit: public UObject { * * There is sufficient locale data to format all standard SI prefixes. * - * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will + * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will * occur. For more information, see UMeasureUnitComplexity. * * @param prefix The SI prefix, from UMeasureSIPrefix. @@ -371,7 +371,7 @@ class U_I18N_API MeasureUnit: public UObject { * Gets the current SI prefix of this SINGLE unit. For example, if the unit has the SI prefix * "kilo", then UMEASURE_SI_PREFIX_KILO is returned. * - * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will + * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will * occur. For more information, see UMeasureUnitComplexity. * * @param status Set if this is not a SINGLE unit or if another error occurs. @@ -384,7 +384,7 @@ class U_I18N_API MeasureUnit: public UObject { * Creates a MeasureUnit which is this SINGLE unit augmented with the specified dimensionality * (power). For example, if dimensionality is 2, the unit will be squared. * - * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will + * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will * occur. For more information, see UMeasureUnitComplexity. * * @param dimensionality The dimensionality (power). @@ -398,7 +398,7 @@ class U_I18N_API MeasureUnit: public UObject { * Gets the dimensionality (power) of this MeasureUnit. For example, if the unit is square, * then 2 is returned. * - * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will + * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will * occur. For more information, see UMeasureUnitComplexity. * * @param status Set if this is not a SINGLE unit or if another error occurs. @@ -412,10 +412,10 @@ class U_I18N_API MeasureUnit: public UObject { * * For example, if the receiver is "meter-per-second", the unit "second-per-meter" is returned. * - * NOTE: Only works on SINGLE and COMPOUND units. If this is a SEQUENCE unit, an error will + * NOTE: Only works on SINGLE and COMPOUND units. If this is a MIXED unit, an error will * occur. For more information, see UMeasureUnitComplexity. * - * @param status Set if this is a SEQUENCE unit or if another error occurs. + * @param status Set if this is a MIXED unit or if another error occurs. * @return The reciprocal of the target unit. * @draft ICU 67 */ @@ -431,10 +431,10 @@ class U_I18N_API MeasureUnit: public UObject { * unit "kilowatt-hour-per-day" is returned. * * NOTE: Only works on SINGLE and COMPOUND units. If either unit (receivee and argument) is a - * SEQUENCE unit, an error will occur. For more information, see UMeasureUnitComplexity. + * MIXED unit, an error will occur. For more information, see UMeasureUnitComplexity. * * @param other The MeasureUnit to multiply with the target. - * @param status Set if this or other is a SEQUENCE unit or if another error occurs. + * @param status Set if this or other is a MIXED unit or if another error occurs. * @return The product of the target unit with the provided unit. * @draft ICU 67 */ @@ -443,7 +443,7 @@ class U_I18N_API MeasureUnit: public UObject { #ifndef U_HIDE_INTERNAL_API /** - * Gets the list of SINGLE units contained within a SEQUENCE of COMPOUND unit. + * Gets the list of SINGLE units contained within a MIXED of COMPOUND unit. * * Examples: * - Given "meter-kilogram-per-second", three units will be returned: "meter", diff --git a/icu4c/source/test/intltest/measfmttest.cpp b/icu4c/source/test/intltest/measfmttest.cpp index 4846540dbdb..6f6c14cc8df 100644 --- a/icu4c/source/test/intltest/measfmttest.cpp +++ b/icu4c/source/test/intltest/measfmttest.cpp @@ -152,7 +152,7 @@ private: const char* identifier, const char** subIdentifiers, int32_t subIdentifierCount); - void verifySequenceUnit( + void verifyMixedUnit( const MeasureUnit& unit, const char* identifier, const char** subIdentifiers, @@ -3368,10 +3368,10 @@ void MeasureFormatTest::TestCompoundUnitOperations() { MeasureUnit inchFoot = MeasureUnit::forIdentifier("inch-and-foot", status); const char* footInchSub[] = {"foot", "inch"}; - verifySequenceUnit(footInch, "foot-and-inch", + verifyMixedUnit(footInch, "foot-and-inch", footInchSub, UPRV_LENGTHOF(footInchSub)); const char* inchFootSub[] = {"inch", "foot"}; - verifySequenceUnit(inchFoot, "inch-and-foot", + verifyMixedUnit(inchFoot, "inch-and-foot", inchFootSub, UPRV_LENGTHOF(inchFootSub)); assertTrue("order matters inequality", footInch != inchFoot); @@ -3575,12 +3575,12 @@ void MeasureFormatTest::verifyCompoundUnit( } } -void MeasureFormatTest::verifySequenceUnit( +void MeasureFormatTest::verifyMixedUnit( const MeasureUnit& unit, const char* identifier, const char** subIdentifiers, int32_t subIdentifierCount) { - IcuTestErrorCode status(*this, "verifySequenceUnit"); + IcuTestErrorCode status(*this, "verifyMixedUnit"); UnicodeString uid(identifier, -1, US_INV); assertEquals(uid + ": Identifier", identifier, @@ -3590,7 +3590,7 @@ void MeasureFormatTest::verifySequenceUnit( unit == MeasureUnit::forIdentifier(identifier, status)); status.errIfFailureAndReset("%s: Constructor", identifier); assertEquals(uid + ": Complexity", - UMEASURE_UNIT_SEQUENCE, + UMEASURE_UNIT_MIXED, unit.getComplexity(status)); status.errIfFailureAndReset("%s: Complexity", identifier); -- 2.40.0