ICU-20378 Changing APIs for UFieldCategory to int32_t.

This commit is contained in:
Shane F. Carr 2019-01-27 21:29:12 -08:00
parent 64f4dd64e2
commit 30396f4dd0
3 changed files with 22 additions and 16 deletions

View File

@ -25,12 +25,12 @@ void ConstrainedFieldPosition::reset() {
fCategory = UFIELD_CATEGORY_UNDEFINED;
}
void ConstrainedFieldPosition::constrainCategory(UFieldCategory category) {
void ConstrainedFieldPosition::constrainCategory(int32_t category) {
fConstraint = UCFPOS_CONSTRAINT_CATEGORY;
fCategory = category;
}
void ConstrainedFieldPosition::constrainField(UFieldCategory category, int32_t field) {
void ConstrainedFieldPosition::constrainField(int32_t category, int32_t field) {
fConstraint = UCFPOS_CONSTRAINT_FIELD;
fCategory = category;
fField = field;
@ -41,7 +41,7 @@ void ConstrainedFieldPosition::setInt64IterationContext(int64_t context) {
}
void ConstrainedFieldPosition::setState(
UFieldCategory category,
int32_t category,
int32_t field,
int32_t start,
int32_t limit) {
@ -98,7 +98,7 @@ ucfpos_reset(UConstrainedFieldPosition* ptr, UErrorCode* ec) {
}
U_CAPI void U_EXPORT2
ucfpos_constrainCategory(UConstrainedFieldPosition* ptr, UFieldCategory category, UErrorCode* ec) {
ucfpos_constrainCategory(UConstrainedFieldPosition* ptr, int32_t category, UErrorCode* ec) {
auto* impl = UConstrainedFieldPositionImpl::validate(ptr, *ec);
if (U_FAILURE(*ec)) {
return;
@ -107,7 +107,7 @@ ucfpos_constrainCategory(UConstrainedFieldPosition* ptr, UFieldCategory category
}
U_CAPI void U_EXPORT2
ucfpos_constrainField(UConstrainedFieldPosition* ptr, UFieldCategory category, int32_t field, UErrorCode* ec) {
ucfpos_constrainField(UConstrainedFieldPosition* ptr, int32_t category, int32_t field, UErrorCode* ec) {
auto* impl = UConstrainedFieldPositionImpl::validate(ptr, *ec);
if (U_FAILURE(*ec)) {
return;
@ -124,7 +124,7 @@ ucfpos_getConstraintType(const UConstrainedFieldPosition* ptr, UErrorCode* ec) {
return impl->fImpl.getConstraintType();
}
U_CAPI UFieldCategory U_EXPORT2
U_CAPI int32_t U_EXPORT2
ucfpos_getCategory(const UConstrainedFieldPosition* ptr, UErrorCode* ec) {
const auto* impl = UConstrainedFieldPositionImpl::validate(ptr, *ec);
if (U_FAILURE(*ec)) {
@ -173,7 +173,7 @@ ucfpos_setInt64IterationContext(UConstrainedFieldPosition* ptr, int64_t context,
U_CAPI void U_EXPORT2
ucfpos_setState(
UConstrainedFieldPosition* ptr,
UFieldCategory category,
int32_t category,
int32_t field,
int32_t start,
int32_t limit,

View File

@ -83,7 +83,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
* @param category The field category to fix when iterating.
* @draft ICU 64
*/
void constrainCategory(UFieldCategory category);
void constrainCategory(int32_t category);
/**
* Sets a constraint on the category and field.
@ -108,7 +108,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
* @param field The field to fix when iterating.
* @draft ICU 64
*/
void constrainField(UFieldCategory category, int32_t field);
void constrainField(int32_t category, int32_t field);
/**
* Gets the currently active constraint.
@ -130,7 +130,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
* @return The field category saved in the instance.
* @draft ICU 64
*/
inline UFieldCategory getCategory() const {
inline int32_t getCategory() const {
return fCategory;
};
@ -216,7 +216,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
* @draft ICU 64
*/
void setState(
UFieldCategory category,
int32_t category,
int32_t field,
int32_t start,
int32_t limit);
@ -230,7 +230,7 @@ class U_I18N_API ConstrainedFieldPosition : public UMemory {
int32_t fStart = 0;
int32_t fLimit = 0;
UCFPosConstraintType fConstraint = UCFPOS_CONSTRAINT_NONE;
UFieldCategory fCategory = UFIELD_CATEGORY_UNDEFINED;
int32_t fCategory = UFIELD_CATEGORY_UNDEFINED;
};

View File

@ -23,6 +23,12 @@
* All possible field categories in ICU. Every entry in this enum corresponds
* to another enum that exists in ICU.
*
* In the APIs that take a UFieldCategory, an int32_t type is used. Field
* categories having any of the top four bits turned on are reserved as
* private-use for external APIs implementing FormattedValue. This means that
* categories 2^28 and higher or below zero (with the highest bit turned on)
* are private-use and will not be used by ICU in the future.
*
* @draft ICU 64
*/
typedef enum UFieldCategory {
@ -192,7 +198,7 @@ ucfpos_close(UConstrainedFieldPosition* ucfpos);
U_DRAFT void U_EXPORT2
ucfpos_constrainCategory(
UConstrainedFieldPosition* ucfpos,
UFieldCategory category,
int32_t category,
UErrorCode* ec);
@ -225,7 +231,7 @@ ucfpos_constrainCategory(
U_DRAFT void U_EXPORT2
ucfpos_constrainField(
UConstrainedFieldPosition* ucfpos,
UFieldCategory category,
int32_t category,
int32_t field,
UErrorCode* ec);
@ -256,7 +262,7 @@ ucfpos_getConstraintType(
* @return The field category saved in the instance.
* @draft ICU 64
*/
U_DRAFT UFieldCategory U_EXPORT2
U_DRAFT int32_t U_EXPORT2
ucfpos_getCategory(
const UConstrainedFieldPosition* ucfpos,
UErrorCode* ec);
@ -353,7 +359,7 @@ ucfpos_setInt64IterationContext(
U_DRAFT void U_EXPORT2
ucfpos_setState(
UConstrainedFieldPosition* ucfpos,
UFieldCategory category,
int32_t category,
int32_t field,
int32_t start,
int32_t limit,