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 authored and markusicu committed Mar 28, 2024
1 parent cce642a commit aff1bba
Show file tree
Hide file tree
Showing 37 changed files with 182 additions and 13 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 */
6 changes: 6 additions & 0 deletions icu4c/source/i18n/messageformat2_allocation.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html

#include "unicode/utypes.h"

#ifndef U_HIDE_DEPRECATED_API

#ifndef MESSAGEFORMAT2_UTILS_H
Expand All @@ -10,6 +12,8 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

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

Expand Down Expand Up @@ -129,6 +133,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 */
6 changes: 6 additions & 0 deletions icu4c/source/i18n/messageformat2_cached_formatters.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html

#include "unicode/utypes.h"

#ifndef U_HIDE_DEPRECATED_API

#ifndef MESSAGEFORMAT2_CACHED_FORMATTERS_H
Expand All @@ -10,6 +12,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 +56,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 */
6 changes: 6 additions & 0 deletions icu4c/source/i18n/messageformat2_checker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html

#include "unicode/utypes.h"

#ifndef U_HIDE_DEPRECATED_API

#ifndef MESSAGEFORMAT_CHECKER_H
Expand All @@ -10,6 +12,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 +84,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 */
7 changes: 6 additions & 1 deletion icu4c/source/i18n/messageformat2_errors.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html

#include "unicode/utypes.h"

#ifndef U_HIDE_DEPRECATED_API

#ifndef MESSAGEFORMAT2_ERRORS_H
Expand All @@ -15,8 +17,9 @@

#if !UCONFIG_NO_FORMATTING

#if !UCONFIG_NO_MF2

#include "unicode/messageformat2_data_model_names.h"
#include "unicode/utypes.h"
#include "unicode/unistr.h"

#include "uvector.h"
Expand Down Expand Up @@ -145,6 +148,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 */
6 changes: 6 additions & 0 deletions icu4c/source/i18n/messageformat2_evaluation.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html

#include "unicode/utypes.h"

#ifndef U_HIDE_DEPRECATED_API

#ifndef MESSAGEFORMAT2_EVALUATION_H
Expand All @@ -15,6 +17,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 +197,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 */

6 changes: 6 additions & 0 deletions icu4c/source/i18n/messageformat2_function_registry_internal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2024 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html

#include "unicode/utypes.h"

#ifndef U_HIDE_DEPRECATED_API

#ifndef MESSAGEFORMAT2_FUNCTION_REGISTRY_INTERNAL_H
Expand All @@ -10,6 +12,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 +221,8 @@ namespace message2 {

U_NAMESPACE_END

#endif /* #if !UCONFIG_NO_MF2 */

#endif /* #if !UCONFIG_NO_FORMATTING */

#endif /* U_SHOW_CPLUSPLUS_API */
Expand Down
Loading

0 comments on commit aff1bba

Please sign in to comment.