Skip to content

Commit

Permalink
ICU-22261 Add UCONFIG_NO_MF2 flag that can be used to disable Message…
Browse files Browse the repository at this point in the history
…Format 2 functionality
  • Loading branch information
catamorphism committed Mar 27, 2024
1 parent f7d641d commit 3b9c0b4
Show file tree
Hide file tree
Showing 37 changed files with 162 additions and 10 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/icu4c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,21 @@ jobs:
- "-DUCONFIG_NO_IDNA=1"
- "-DUCONFIG_NO_COLLATION=1"
- "-DUCONFIG_NO_FORMATTING=1"
- "-DUCONFIG_NO_MF2=1"
- "-DUCONFIG_NO_TRANSLITERATION=1"
- "-DUCONFIG_NO_REGULAR_EXPRESSIONS=1"
- "-DUCONFIG_NO_SERVICE=1"
- "-DUCONFIG_NO_FILTERED_BREAK_ITERATION=1"
# Turn on all the options in one test.
- "-DUCONFIG_NO_LEGACY_CONVERSION=1 -DUCONFIG_NO_NORMALIZATION=1 -DUCONFIG_NO_BREAK_ITERATION=1 -DUCONFIG_NO_IDNA=1 -DUCONFIG_NO_COLLATION=1 -DUCONFIG_NO_FORMATTING=1 -DUCONFIG_NO_TRANSLITERATION=1 -DUCONFIG_NO_REGULAR_EXPRESSIONS=1 -DUCONFIG_NO_SERVICE=1 -DUCONFIG_NO_FILTERED_BREAK_ITERATION=1"
- "-DUCONFIG_NO_LEGACY_CONVERSION=1 -DUCONFIG_NO_NORMALIZATION=1 -DUCONFIG_NO_BREAK_ITERATION=1 -DUCONFIG_NO_IDNA=1 -DUCONFIG_NO_COLLATION=1 -DUCONFIG_NO_FORMATTING=1 -DUCONFIG_NO_MF2=1 -DUCONFIG_NO_TRANSLITERATION=1 -DUCONFIG_NO_REGULAR_EXPRESSIONS=1 -DUCONFIG_NO_SERVICE=1 -DUCONFIG_NO_FILTERED_BREAK_ITERATION=1"
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Verify no additional new UCONFIG_NO_xxx added
run: |
# Test that we have exactly 12 "#ifndef UCONFIG_NO_" in uconfig.h. If the number changes, we need to also
# adjust the uconfig_cppflags above to include the new one and update the "12" below.
expected_count="12";
# Test that we have exactly 13 "#ifndef UCONFIG_NO_" in uconfig.h. If the number changes, we need to also
# adjust the uconfig_cppflags above to include the new one and update the "13" below.
expected_count="13";
count=`egrep "#ifndef UCONFIG_NO_" icu4c/source/common/unicode/uconfig.h| wc -l`;
if [ $expected_count != $count ]; then
echo "More than %s UCONFIG_NO_* defined in uconfig.h, please adjust uconfig_cppflags above to include any newly added flag" % $expected_count;
Expand Down Expand Up @@ -413,21 +414,22 @@ jobs:
- "-DUCONFIG_NO_IDNA=1"
- "-DUCONFIG_NO_COLLATION=1"
- "-DUCONFIG_NO_FORMATTING=1"
- "-DUCONFIG_NO_MF2=1"
- "-DUCONFIG_NO_TRANSLITERATION=1"
- "-DUCONFIG_NO_REGULAR_EXPRESSIONS=1"
- "-DUCONFIG_NO_SERVICE=1"
- "-DUCONFIG_NO_FILTERED_BREAK_ITERATION=1"
# Turn on all the options in one test.
- "-DUCONFIG_NO_LEGACY_CONVERSION=1 -DUCONFIG_NO_NORMALIZATION=1 -DUCONFIG_NO_BREAK_ITERATION=1 -DUCONFIG_NO_IDNA=1 -DUCONFIG_NO_COLLATION=1 -DUCONFIG_NO_FORMATTING=1 -DUCONFIG_NO_TRANSLITERATION=1 -DUCONFIG_NO_REGULAR_EXPRESSIONS=1 -DUCONFIG_NO_SERVICE=1 -DUCONFIG_NO_FILTERED_BREAK_ITERATION=1"
- "-DUCONFIG_NO_LEGACY_CONVERSION=1 -DUCONFIG_NO_NORMALIZATION=1 -DUCONFIG_NO_BREAK_ITERATION=1 -DUCONFIG_NO_IDNA=1 -DUCONFIG_NO_COLLATION=1 -DUCONFIG_NO_FORMATTING=1 -DUCONFIG_NO_MF2=1 -DUCONFIG_NO_TRANSLITERATION=1 -DUCONFIG_NO_REGULAR_EXPRESSIONS=1 -DUCONFIG_NO_SERVICE=1 -DUCONFIG_NO_FILTERED_BREAK_ITERATION=1"
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Verify no additional new UCONFIG_NO_xxx added
run: |
# Test that we have exactly 12 "#ifndef UCONFIG_NO_" in uconfig.h. If the number changes, we need to also
# adjust the uconfig_cppflags above to include the new one and update the "12" below.
# Test that we have exactly 13 "#ifndef UCONFIG_NO_" in uconfig.h. If the number changes, we need to also
# adjust the uconfig_cppflags above to include the new one and update the "13" below.
count=`egrep "#ifndef UCONFIG_NO_" icu4c/source/common/unicode/uconfig.h| wc -l`;
if [ "12" != $count ]; then
if [ "13" != $count ]; then
echo "More than %s UCONFIG_NO_* defined in uconfig.h, please adjust uconfig_cppflags above to include any newly added flag" % $count;
echo "Currently UCONFIG_NO_* defined in uconfig.h:";
egrep "#ifndef UCONFIG_NO_" icu4c/source/common/unicode/uconfig.h;
Expand Down
11 changes: 11 additions & 0 deletions icu4c/source/common/unicode/uconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,17 @@
# define UCONFIG_NO_FORMATTING 0
#endif

/**
* \def UCONFIG_NO_MF2
* This switch turns off the experimental MessageFormat 2.0 API.
*
* @internal ICU 75.0 technology preview
* @deprecated This API is for technology preview only.
*/
#ifndef UCONFIG_NO_MF2
# define UCONFIG_NO_MF2 0
#endif

/**
* \def UCONFIG_NO_TRANSLITERATION
* This switch turns off transliteration.
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_arguments.h"
#include "unicode/messageformat2_data_model.h"
#include "unicode/messageformat2_formattable.h"
Expand Down Expand Up @@ -871,4 +873,6 @@ void MessageFormatter::checkDeclarations(MessageContext& context, Environment*&

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_allocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/unistr.h"
#include "uvector.h"

Expand Down Expand Up @@ -129,6 +131,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_arguments.h"
#include "unicode/messageformat2_data_model_names.h"
#include "uvector.h" // U_ASSERT
Expand Down Expand Up @@ -52,4 +54,6 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_cached_formatters.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_data_model_names.h"
#include "unicode/messageformat2_function_registry.h"
#include "hash.h"
Expand Down Expand Up @@ -52,6 +54,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "messageformat2_allocation.h"
#include "messageformat2_checker.h"
#include "messageformat2_macros.h"
Expand Down Expand Up @@ -292,4 +294,6 @@ void Checker::check(UErrorCode& status) {
} // namespace message2
U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_data_model.h"
#include "messageformat2_errors.h"

Expand Down Expand Up @@ -80,6 +82,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_data_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_data_model.h"
#include "messageformat2_allocation.h"
#include "messageformat2_macros.h"
Expand Down Expand Up @@ -1095,4 +1097,6 @@ MFDataModel::Builder::~Builder() {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "messageformat2_allocation.h"
#include "messageformat2_errors.h"
#include "messageformat2_macros.h"
Expand Down Expand Up @@ -283,4 +285,6 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_data_model_names.h"
#include "unicode/utypes.h"
#include "unicode/unistr.h"
Expand Down Expand Up @@ -145,6 +147,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_evaluation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "messageformat2_allocation.h"
#include "messageformat2_cached_formatters.h"
#include "messageformat2_evaluation.h"
Expand Down Expand Up @@ -205,4 +207,6 @@ PrioritizedVariant::~PrioritizedVariant() {}
} // namespace message2
U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_evaluation.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_arguments.h"
#include "unicode/messageformat2_data_model.h"
#include "unicode/messageformat2_function_registry.h"
Expand Down Expand Up @@ -193,6 +195,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_formattable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_formattable.h"
#include "unicode/smpdtfmt.h"
#include "messageformat2_macros.h"
Expand Down Expand Up @@ -331,4 +333,6 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2.h"
#include "messageformat2_allocation.h"
#include "messageformat2_cached_formatters.h"
Expand Down Expand Up @@ -350,4 +352,6 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_function_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/dtptngen.h"
#include "unicode/messageformat2_data_model_names.h"
#include "unicode/messageformat2_function_registry.h"
Expand Down Expand Up @@ -1178,5 +1180,7 @@ StandardFunctions::TextSelector::~TextSelector() {}
} // namespace message2
U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_function_registry_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/datefmt.h"
#include "unicode/messageformat2_function_registry.h"

Expand Down Expand Up @@ -217,6 +219,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/format.h"
#include "unicode/unistr.h"
#include "plurrule_impl.h"
Expand Down Expand Up @@ -99,6 +101,8 @@ static constexpr UChar32 ID_MATCH[] = {
} // namespace message2
U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "messageformat2_errors.h"
#include "messageformat2_macros.h"
#include "messageformat2_parser.h"
Expand Down Expand Up @@ -2429,5 +2431,7 @@ Parser::~Parser() {}
} // namespace message2
U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

U_NAMESPACE_BEGIN

namespace message2 {
Expand Down Expand Up @@ -138,6 +140,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
4 changes: 4 additions & 0 deletions icu4c/source/i18n/messageformat2_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_data_model.h"
#include "messageformat2_macros.h"
#include "messageformat2_serializer.h"
Expand Down Expand Up @@ -332,5 +334,7 @@ void Serializer::serialize() {
} // namespace message2
U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

Loading

0 comments on commit 3b9c0b4

Please sign in to comment.