LibUnicode: Generate a method to lookup available keyword values

This commit is contained in:
Timothy Flynn 2022-07-14 14:06:17 -04:00 committed by Andreas Kling
parent c2e5b20eb6
commit 80568d5776
Notes: sideshowbarker 2024-07-17 10:54:57 +09:00
3 changed files with 28 additions and 0 deletions

View file

@ -1157,6 +1157,32 @@ struct TextLayout {
generate_available_values(generator, "get_available_number_systems"sv, locale_data.keywords.find("nu"sv)->value);
generate_available_values(generator, "get_available_currencies"sv, locale_data.currencies);
generator.append(R"~~~(
Span<StringView const> get_available_keyword_values(StringView key)
{
auto key_value = key_from_string(key);
if (!key_value.has_value())
return {};
switch (*key_value) {
case Key::Ca:
return get_available_calendars();
case Key::Co:
return get_available_collation_types();
case Key::Hc:
return get_available_hour_cycles();
case Key::Kf:
return get_available_collation_case_orderings();
case Key::Kn:
return get_available_collation_numeric_orderings();
case Key::Nu:
return get_available_number_systems();
}
VERIFY_NOT_REACHED();
}
)~~~");
locale_data.unique_display_patterns.generate(generator, "DisplayPatternImpl"sv, "s_display_patterns"sv, 30);
locale_data.unique_language_lists.generate(generator, s_string_index_type, "s_language_lists"sv);
locale_data.unique_territory_lists.generate(generator, s_string_index_type, "s_territory_lists"sv);

View file

@ -766,6 +766,7 @@ StringView style_to_string(Style style)
}
}
Span<StringView const> __attribute__((weak)) get_available_keyword_values(StringView) { return {}; }
Span<StringView const> __attribute__((weak)) get_available_calendars() { return {}; }
Span<StringView const> __attribute__((weak)) get_available_collation_case_orderings() { return {}; }
Span<StringView const> __attribute__((weak)) get_available_collation_numeric_orderings() { return {}; }

View file

@ -145,6 +145,7 @@ Optional<String> canonicalize_unicode_locale_id(LocaleID&);
String const& default_locale();
bool is_locale_available(StringView locale);
Span<StringView const> get_available_keyword_values(StringView key);
Span<StringView const> get_available_calendars();
Span<StringView const> get_available_collation_case_orderings();
Span<StringView const> get_available_collation_numeric_orderings();