Skip to content

Commit 24c64c9

Browse files
committed
ICU-22939 MF2: Re-implement resolved values and implement bidi default strategy
Implement the changes to resolved values necessary to implement function composition. Implement lazy/call-by-need evaluation (instead of lazy-call-by-name evaluation). Implement the default bidi strategy and APIs for controlling it. Update spec tests to those from the current version of the message-format-wg repo, except for currency and math tests (these functions are not yet implemented).
1 parent fd27c48 commit 24c64c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3757
-2850
lines changed

icu4c/source/i18n/messageformat2.cpp

Lines changed: 591 additions & 256 deletions
Large diffs are not rendered by default.

icu4c/source/i18n/messageformat2_allocation.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ namespace message2 {
133133
return result;
134134
}
135135

136+
template<typename T>
137+
inline T* create(const T& node, UErrorCode& status) {
138+
if (U_FAILURE(status)) {
139+
return nullptr;
140+
}
141+
T* result = new T(node);
142+
if (result == nullptr) {
143+
status = U_MEMORY_ALLOCATION_ERROR;
144+
}
145+
return result;
146+
}
147+
136148
} // namespace message2
137149

138150
U_NAMESPACE_END

icu4c/source/i18n/messageformat2_errors.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ namespace message2 {
3333
addError(DynamicError(DynamicErrorType::BadOptionError, formatterName), status);
3434
}
3535

36-
void DynamicErrors::setRecoverableBadOption(const FunctionName& formatterName, UErrorCode& status) {
37-
addError(DynamicError(DynamicErrorType::RecoverableBadOptionError, formatterName), status);
38-
}
39-
4036
void DynamicErrors::setOperandMismatchError(const FunctionName& formatterName, UErrorCode& status) {
4137
addError(DynamicError(DynamicErrorType::OperandMismatchError, formatterName), status);
4238
}
@@ -145,8 +141,7 @@ namespace message2 {
145141
status = U_MF_FORMATTING_ERROR;
146142
break;
147143
}
148-
case DynamicErrorType::BadOptionError:
149-
case DynamicErrorType::RecoverableBadOptionError: {
144+
case DynamicErrorType::BadOptionError: {
150145
status = U_MF_BAD_OPTION;
151146
break;
152147
}
@@ -246,10 +241,6 @@ namespace message2 {
246241
resolutionAndFormattingErrors->adoptElement(errorP, status);
247242
break;
248243
}
249-
case DynamicErrorType::RecoverableBadOptionError: {
250-
resolutionAndFormattingErrors->adoptElement(errorP, status);
251-
break;
252-
}
253244
}
254245
}
255246

icu4c/source/i18n/messageformat2_errors.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ namespace message2 {
6767
UnresolvedVariable,
6868
FormattingError,
6969
BadOptionError,
70-
/**
71-
This is used to signal errors from :number and :integer when a
72-
bad `select` option is passed. In this case, fallback output
73-
is not used, so it must be distinguished from a regular bad
74-
option error (but it maps to a bad option error in the final
75-
error code).
76-
See https://github.com/unicode-org/message-format-wg/blob/main/spec/functions/number.md#number-selection
77-
"The formatting of the _resolved value_ is not affected by the `select` option.")
78-
*/
79-
RecoverableBadOptionError,
8070
OperandMismatchError,
8171
SelectorError,
8272
UnknownFunction,
@@ -141,7 +131,6 @@ namespace message2 {
141131
// Used when the name of the offending formatter is unknown
142132
void setFormattingError(UErrorCode&);
143133
void setBadOption(const FunctionName&, UErrorCode&);
144-
void setRecoverableBadOption(const FunctionName&, UErrorCode&);
145134
void setOperandMismatchError(const FunctionName&, UErrorCode&);
146135
bool hasDataModelError() const { return staticErrors.hasDataModelError(); }
147136
bool hasFormattingError() const { return formattingError; }

0 commit comments

Comments
 (0)