mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
LibJS: Define constructor slots for describing how to read options
This is an editorial change in the ECMA-402 spec. See:
a2beb66
We implement this change by introducing a virtual interface that all
Intl "service" objects must implement. A future patch will make use of
the virtualized RelevantExtensionKeys and ResolutionOptionDescriptors
accessors, and we will need to be able to use those slots from a generic
instance type.
This commit is contained in:
parent
19ce186f97
commit
62793b1bd8
Notes:
github-actions[bot]
2025-04-08 10:53:24 +00:00
Author: https://github.com/trflynn89
Commit: 62793b1bd8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4275
29 changed files with 284 additions and 116 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@ GC_DEFINE_ALLOCATOR(Collator);
|
|||
|
||||
// 10 Collator Objects, https://tc39.es/ecma402/#collator-objects
|
||||
Collator::Collator(Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
: IntlObject(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -22,4 +22,27 @@ void Collator::visit_edges(Visitor& visitor)
|
|||
visitor.visit(m_bound_compare);
|
||||
}
|
||||
|
||||
// 10.2.3 Internal slots, https://tc39.es/ecma402/#sec-intl-collator-internal-slots
|
||||
ReadonlySpan<StringView> Collator::relevant_extension_keys() const
|
||||
{
|
||||
// The value of the [[RelevantExtensionKeys]] internal slot is a List that must include the element "co", may include any or all of the elements "kf" and "kn", and must not include any other elements.
|
||||
static constexpr AK::Array keys { "co"sv, "kf"sv, "kn"sv };
|
||||
return keys;
|
||||
}
|
||||
|
||||
// 10.2.3 Internal slots, https://tc39.es/ecma402/#sec-intl-collator-internal-slots
|
||||
ReadonlySpan<ResolutionOptionDescriptor> Collator::resolution_option_descriptors(VM& vm) const
|
||||
{
|
||||
// The value of the [[ResolutionOptionDescriptors]] internal slot is « { [[Key]]: "co", [[Property]]: "collation" }, { [[Key]]: "kn", [[Property]]: "numeric", [[Type]]: boolean }, { [[Key]]: "kf", [[Property]]: "caseFirst", [[Values]]: « "upper", "lower", "false" » } ».
|
||||
static constexpr AK::Array case_first_values { "upper"sv, "lower"sv, "false"sv };
|
||||
|
||||
static auto descriptors = to_array<ResolutionOptionDescriptor>({
|
||||
{ .key = "co"sv, .property = vm.names.collation },
|
||||
{ .key = "kn"sv, .property = vm.names.numeric, .type = OptionType::Boolean },
|
||||
{ .key = "kf"sv, .property = vm.names.caseFirst, .values = case_first_values },
|
||||
});
|
||||
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue