From 7c490d4da3d3a209636b20c838d1dc8f1b0b6475 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 20 Jul 2022 13:57:04 -0400 Subject: [PATCH] LibJS: Move PatternPartitionWithSource structure to AbstractOperations.h This struct will be needed by more than just the DateTimeFormat object. Also add an equality operator, which will be needed by NumberFormat. --- .../LibJS/Runtime/Intl/AbstractOperations.h | 24 +++++++++++++++++++ .../LibJS/Runtime/Intl/DateTimeFormat.h | 19 --------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h index 93122774b2..1cb3919d92 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.h @@ -53,6 +53,30 @@ struct PatternPartition { String value; }; +struct PatternPartitionWithSource : public PatternPartition { + static Vector create_from_parent_list(Vector partitions) + { + Vector result; + result.ensure_capacity(partitions.size()); + + for (auto& partition : partitions) { + PatternPartitionWithSource partition_with_source {}; + partition_with_source.type = partition.type; + partition_with_source.value = move(partition.value); + result.append(move(partition_with_source)); + } + + return result; + } + + bool operator==(PatternPartitionWithSource const& other) const + { + return (type == other.type) && (value == other.value) && (source == other.source); + } + + StringView source; +}; + // Table 2: Single units sanctioned for use in ECMAScript, https://tc39.es/ecma402/#table-sanctioned-single-unit-identifiers constexpr auto sanctioned_single_unit_identifiers() { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h index eb17b0ea69..47f26071b6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h @@ -180,25 +180,6 @@ struct LocalTime { u16 millisecond { 0 }; // [[Millisecond]] }; -struct PatternPartitionWithSource : public PatternPartition { - static Vector create_from_parent_list(Vector partitions) - { - Vector result; - result.ensure_capacity(partitions.size()); - - for (auto& partition : partitions) { - PatternPartitionWithSource partition_with_source {}; - partition_with_source.type = partition.type; - partition_with_source.value = move(partition.value); - result.append(move(partition_with_source)); - } - - return result; - } - - StringView source; -}; - ThrowCompletionOr to_date_time_options(GlobalObject& global_object, Value options_value, OptionRequired, OptionDefaults); Optional date_time_style_format(StringView data_locale, DateTimeFormat& date_time_format); Optional basic_format_matcher(Unicode::CalendarPattern const& options, Vector formats);