Skip to content

ICU-22939 Function composition and default bidi strategy #3536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
847 changes: 591 additions & 256 deletions icu4c/source/i18n/messageformat2.cpp

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions icu4c/source/i18n/messageformat2_allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ namespace message2 {
return result;
}

template<typename T>
inline T* create(const T& node, UErrorCode& status) {
if (U_FAILURE(status)) {
return nullptr;
}
T* result = new T(node);
if (result == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR;
}
return result;
}

Comment on lines +136 to +147
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these should go into common - perhaps cmemory.h , errorcode.h or uobject.h

} // namespace message2

U_NAMESPACE_END
Expand Down
11 changes: 1 addition & 10 deletions icu4c/source/i18n/messageformat2_errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ namespace message2 {
addError(DynamicError(DynamicErrorType::BadOptionError, formatterName), status);
}

void DynamicErrors::setRecoverableBadOption(const FunctionName& formatterName, UErrorCode& status) {
addError(DynamicError(DynamicErrorType::RecoverableBadOptionError, formatterName), status);
}

void DynamicErrors::setOperandMismatchError(const FunctionName& formatterName, UErrorCode& status) {
addError(DynamicError(DynamicErrorType::OperandMismatchError, formatterName), status);
}
Expand Down Expand Up @@ -145,8 +141,7 @@ namespace message2 {
status = U_MF_FORMATTING_ERROR;
break;
}
case DynamicErrorType::BadOptionError:
case DynamicErrorType::RecoverableBadOptionError: {
case DynamicErrorType::BadOptionError: {
status = U_MF_BAD_OPTION;
break;
}
Expand Down Expand Up @@ -246,10 +241,6 @@ namespace message2 {
resolutionAndFormattingErrors->adoptElement(errorP, status);
break;
}
case DynamicErrorType::RecoverableBadOptionError: {
resolutionAndFormattingErrors->adoptElement(errorP, status);
break;
}
}
}

Expand Down
11 changes: 0 additions & 11 deletions icu4c/source/i18n/messageformat2_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ namespace message2 {
UnresolvedVariable,
FormattingError,
BadOptionError,
/**
This is used to signal errors from :number and :integer when a
bad `select` option is passed. In this case, fallback output
is not used, so it must be distinguished from a regular bad
option error (but it maps to a bad option error in the final
error code).
See https://github.com/unicode-org/message-format-wg/blob/main/spec/functions/number.md#number-selection
"The formatting of the _resolved value_ is not affected by the `select` option.")
*/
RecoverableBadOptionError,
OperandMismatchError,
SelectorError,
UnknownFunction,
Expand Down Expand Up @@ -141,7 +131,6 @@ namespace message2 {
// Used when the name of the offending formatter is unknown
void setFormattingError(UErrorCode&);
void setBadOption(const FunctionName&, UErrorCode&);
void setRecoverableBadOption(const FunctionName&, UErrorCode&);
void setOperandMismatchError(const FunctionName&, UErrorCode&);
bool hasDataModelError() const { return staticErrors.hasDataModelError(); }
bool hasFormattingError() const { return formattingError; }
Expand Down
Loading