From ca9123f66f2ea19a79cb27d73e1f6814c1e57205 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 7 Jan 2022 08:40:04 -0500 Subject: [PATCH] LibUnicode: Rename DateTimeFormat's generator's TimeZone struct Before using LibTimeZone within LibUnicode, rename this structure to avoid naming conflicts with the TimeZone namespace. --- .../GenerateUnicodeDateTimeFormat.cpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp index 102dddd920..9c98d2e6d5 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp @@ -55,10 +55,10 @@ constexpr auto s_calendar_symbols_list_index_type = "u8"sv; using CalendarIndexType = u8; constexpr auto s_calendar_index_type = "u8"sv; -using TimeZoneIndexType = u16; +using TimeZoneNamesIndexType = u16; constexpr auto s_time_zone_index_type = "u16"sv; -using TimeZoneListIndexType = u8; +using TimeZoneNamesListIndexType = u8; constexpr auto s_time_zone_list_index_type = "u8"sv; using TimeZoneFormatIndexType = u8; @@ -379,13 +379,13 @@ struct AK::Traits : public GenericTraits { static unsigned hash(Calendar const& c) { return c.hash(); } }; -struct TimeZone { +struct TimeZoneNames { unsigned hash() const { return pair_int_hash(long_name, short_name); } - bool operator==(TimeZone const& other) const + bool operator==(TimeZoneNames const& other) const { return (long_name == other.long_name) && (short_name == other.short_name); } @@ -395,8 +395,8 @@ struct TimeZone { }; template<> -struct AK::Formatter : Formatter { - ErrorOr format(FormatBuilder& builder, TimeZone const& time_zone) +struct AK::Formatter : Formatter { + ErrorOr format(FormatBuilder& builder, TimeZoneNames const& time_zone) { return Formatter::format(builder, "{{ {}, {} }}", @@ -406,8 +406,8 @@ struct AK::Formatter : Formatter { }; template<> -struct AK::Traits : public GenericTraits { - static unsigned hash(TimeZone const& t) { return t.hash(); } +struct AK::Traits : public GenericTraits { + static unsigned hash(TimeZoneNames const& t) { return t.hash(); } }; struct TimeZoneFormat { @@ -475,7 +475,7 @@ struct AK::Traits : public GenericTraits { static unsigned hash(DayPeriod const& d) { return d.hash(); } }; -using TimeZoneList = Vector; +using TimeZoneNamesList = Vector; using DayPeriodList = Vector; using HourCycleList = Vector; @@ -490,7 +490,7 @@ struct AK::Formatter : Formatter { struct Locale { HashMap calendars; - TimeZoneListIndexType time_zones { 0 }; + TimeZoneNamesListIndexType time_zones { 0 }; TimeZoneFormatIndexType time_zone_formats { 0 }; DayPeriodListIndexType day_periods { 0 }; @@ -507,8 +507,8 @@ struct UnicodeLocaleData { UniqueStorage unique_calendar_symbols; UniqueStorage unique_calendar_symbols_lists; UniqueStorage unique_calendars; - UniqueStorage unique_time_zones; - UniqueStorage unique_time_zone_lists; + UniqueStorage unique_time_zones; + UniqueStorage unique_time_zone_lists; UniqueStorage unique_time_zone_formats; UniqueStorage unique_day_periods; UniqueStorage unique_day_period_lists; @@ -1397,23 +1397,23 @@ static ErrorOr parse_time_zone_names(String locale_time_zone_names_path, U return {}; }; - TimeZoneList time_zones; + TimeZoneNamesList time_zones; TimeZoneFormat time_zone_formats {}; time_zone_formats.gmt_zero_format = locale_data.unique_strings.ensure(gmt_zero_format_string.as_string()); auto parse_time_zone = [&](StringView meta_zone, JsonObject const& meta_zone_object) { auto const& golden_zones = locale_data.meta_zones.find(meta_zone)->value; - TimeZone time_zone {}; + TimeZoneNames time_zone_names {}; if (auto long_name = parse_name("long"sv, meta_zone_object); long_name.has_value()) - time_zone.long_name = long_name.value(); + time_zone_names.long_name = long_name.value(); if (auto short_name = parse_name("short"sv, meta_zone_object); short_name.has_value()) - time_zone.short_name = short_name.value(); + time_zone_names.short_name = short_name.value(); for (auto const& golden_zone : golden_zones) { auto time_zone_index = locale_data.time_zones.find_first_index(golden_zone).value(); - time_zones[time_zone_index] = locale_data.unique_time_zones.ensure(move(time_zone)); + time_zones[time_zone_index] = locale_data.unique_time_zones.ensure(move(time_zone_names)); } }; @@ -1743,7 +1743,7 @@ struct CalendarData { @calendar_symbols_list_index_type@ symbols { 0 }; }; -struct TimeZoneData { +struct TimeZoneNames { @string_index_type@ long_name { 0 }; @string_index_type@ short_name { 0 }; }; @@ -1764,7 +1764,7 @@ struct DayPeriodData { locale_data.unique_calendar_symbols.generate(generator, "CalendarSymbols"sv, "s_calendar_symbols"sv, 10); locale_data.unique_calendar_symbols_lists.generate(generator, s_calendar_symbols_index_type, "s_calendar_symbol_lists"sv); locale_data.unique_calendars.generate(generator, "CalendarData"sv, "s_calendars"sv, 10); - locale_data.unique_time_zones.generate(generator, "TimeZoneData"sv, "s_time_zones"sv, 30); + locale_data.unique_time_zones.generate(generator, "TimeZoneNames"sv, "s_time_zones"sv, 30); locale_data.unique_time_zone_lists.generate(generator, s_time_zone_index_type, "s_time_zone_lists"sv); locale_data.unique_time_zone_formats.generate(generator, "TimeZoneFormat"sv, "s_time_zone_formats"sv, 30); locale_data.unique_day_periods.generate(generator, "DayPeriodData"sv, "s_day_periods"sv, 30); @@ -2081,7 +2081,7 @@ static TimeZoneFormat const* find_time_zone_formats(StringView locale) return &s_time_zone_formats.at(time_zone_format_index); } -static TimeZoneData const* find_time_zone_data(StringView locale, StringView time_zone) +static TimeZoneNames const* find_time_zone_names(StringView locale, StringView time_zone) { auto locale_value = locale_from_string(locale); if (!locale_value.has_value()) @@ -2104,7 +2104,7 @@ static TimeZoneData const* find_time_zone_data(StringView locale, StringView tim Optional get_time_zone_name(StringView locale, StringView time_zone, CalendarPatternStyle style) { if ((style == CalendarPatternStyle::Long) || (style == CalendarPatternStyle::Short)) { - if (auto const* data = find_time_zone_data(locale, time_zone); data != nullptr) { + if (auto const* data = find_time_zone_names(locale, time_zone); data != nullptr) { auto time_zone_index = style == CalendarPatternStyle::Long ? data->long_name : data->short_name; if (time_zone_index != 0) return s_string_list[time_zone_index];