summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-02-15 14:51:48 -0500
committerTim Flynn <trflynn89@pm.me>2022-02-16 07:23:07 -0500
commit63c34372744f9f47c09ff9f92db1ba388451e6dd (patch)
tree5e7b678049e670c0300cf27aa18c19ab9387380a /Meta/Lagom
parent89ead8c00a7c25aca8ab0022f09babcea9485bc2 (diff)
downloadserenity-63c34372744f9f47c09ff9f92db1ba388451e6dd.zip
LibUnicode: Use BCP 47 data to generate available calendars and numbers
BCP 47 will be the single source of truth for known calendar and number system keywords, and their aliases (e.g. "gregory" is an alias for "gregorian"). Move the generation of available keywords to where we parse the BCP 47 data, so that hard-coded aliases may be removed from other generators.
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp2
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp2
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp2
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h4
4 files changed, 4 insertions, 6 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp
index f6aa97759a..b6f3124d60 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp
@@ -1855,8 +1855,6 @@ struct DayPeriodData {
};
)~~~");
- generate_available_values(generator, "get_available_calendars"sv, locale_data.calendars, locale_data.calendar_aliases);
-
locale_data.unique_formats.generate(generator, "CalendarFormatImpl"sv, "s_calendar_formats"sv, 10);
locale_data.unique_symbol_lists.generate(generator, s_string_index_type, "s_symbol_lists"sv);
locale_data.unique_calendar_symbols.generate(generator, "CalendarSymbols"sv, "s_calendar_symbols"sv, 10);
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp
index 82e24ff7be..80dd3b0e2c 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp
@@ -1054,6 +1054,8 @@ struct Patterns {
};
)~~~");
+ generate_available_values(generator, "get_available_calendars"sv, locale_data.keywords.find("ca"sv)->value, locale_data.keyword_aliases.find("ca"sv)->value);
+ generate_available_values(generator, "get_available_number_systems"sv, locale_data.keywords.find("nu"sv)->value, locale_data.keyword_aliases.find("nu"sv)->value);
generate_available_values(generator, "get_available_currencies"sv, locale_data.currencies);
locale_data.unique_display_patterns.generate(generator, "DisplayPatternImpl"sv, "s_display_patterns"sv, 30);
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp
index 66648210e0..f9d0d4f537 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp
@@ -865,8 +865,6 @@ struct Unit {
};
)~~~");
- generate_available_values(generator, "get_available_number_systems"sv, locale_data.number_systems);
-
locale_data.unique_formats.generate(generator, "NumberFormatImpl"sv, "s_number_formats"sv, 10);
locale_data.unique_format_lists.generate(generator, s_number_format_index_type, "s_number_format_lists"sv);
locale_data.unique_symbols.generate(generator, s_string_index_type, "s_numeric_symbol_lists"sv);
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h
index 69a06a08d6..a3329f60e6 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h
@@ -533,8 +533,8 @@ Span<StringView const> @name@()
generator.append(first ? " " : ", ");
first = false;
- if (auto it = aliases.find_if([&](auto const& alias) { return alias.name == value; }); it != aliases.end())
- generator.append(String::formatted("\"{}\"sv", it->alias));
+ if (auto it = aliases.find_if([&](auto const& alias) { return alias.alias == value; }); it != aliases.end())
+ generator.append(String::formatted("\"{}\"sv", it->name));
else
generator.append(String::formatted("\"{}\"sv", value));
}