mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-03 04:50:29 +00:00
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.
This commit is contained in:
parent
0a6363d3e9
commit
7c490d4da3
Notes:
sideshowbarker
2024-07-17 08:44:17 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/7c490d4da3 Pull-request: https://github.com/SerenityOS/serenity/pull/14631 Reviewed-by: https://github.com/linusg ✅
2 changed files with 24 additions and 19 deletions
|
@ -53,6 +53,30 @@ struct PatternPartition {
|
|||
String value;
|
||||
};
|
||||
|
||||
struct PatternPartitionWithSource : public PatternPartition {
|
||||
static Vector<PatternPartitionWithSource> create_from_parent_list(Vector<PatternPartition> partitions)
|
||||
{
|
||||
Vector<PatternPartitionWithSource> 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()
|
||||
{
|
||||
|
|
|
@ -180,25 +180,6 @@ struct LocalTime {
|
|||
u16 millisecond { 0 }; // [[Millisecond]]
|
||||
};
|
||||
|
||||
struct PatternPartitionWithSource : public PatternPartition {
|
||||
static Vector<PatternPartitionWithSource> create_from_parent_list(Vector<PatternPartition> partitions)
|
||||
{
|
||||
Vector<PatternPartitionWithSource> 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<Object*> to_date_time_options(GlobalObject& global_object, Value options_value, OptionRequired, OptionDefaults);
|
||||
Optional<Unicode::CalendarPattern> date_time_style_format(StringView data_locale, DateTimeFormat& date_time_format);
|
||||
Optional<Unicode::CalendarPattern> basic_format_matcher(Unicode::CalendarPattern const& options, Vector<Unicode::CalendarPattern> formats);
|
||||
|
|
Loading…
Reference in a new issue