mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +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
|
@ -5,14 +5,9 @@
|
|||
*/
|
||||
|
||||
#include <AK/Enumerate.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Intl/NumberFormat.h>
|
||||
#include <LibJS/Runtime/Intl/NumberFormatConstructor.h>
|
||||
#include <LibJS/Runtime/Intl/PluralRules.h>
|
||||
#include <LibJS/Runtime/Intl/RelativeTimeFormat.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
||||
|
@ -20,10 +15,29 @@ GC_DEFINE_ALLOCATOR(RelativeTimeFormat);
|
|||
|
||||
// 18 RelativeTimeFormat Objects, https://tc39.es/ecma402/#relativetimeformat-objects
|
||||
RelativeTimeFormat::RelativeTimeFormat(Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
: IntlObject(ConstructWithPrototypeTag::Tag, prototype)
|
||||
{
|
||||
}
|
||||
|
||||
// 18.2.3 Internal slots, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat-internal-slots
|
||||
ReadonlySpan<StringView> RelativeTimeFormat::relevant_extension_keys() const
|
||||
{
|
||||
// The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ».
|
||||
static constexpr AK::Array keys { "nu"sv };
|
||||
return keys;
|
||||
}
|
||||
|
||||
// 18.2.3 Internal slots, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat-internal-slots
|
||||
ReadonlySpan<ResolutionOptionDescriptor> RelativeTimeFormat::resolution_option_descriptors(VM& vm) const
|
||||
{
|
||||
// The value of the [[ResolutionOptionDescriptors]] internal slot is « { [[Key]]: "nu", [[Property]]: "numberingSystem" } ».
|
||||
static auto descriptors = to_array<ResolutionOptionDescriptor>({
|
||||
{ .key = "nu"sv, .property = vm.names.numberingSystem },
|
||||
});
|
||||
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
// 18.5.1 SingularRelativeTimeUnit ( unit ), https://tc39.es/ecma402/#sec-singularrelativetimeunit
|
||||
ThrowCompletionOr<Unicode::TimeUnit> singular_relative_time_unit(VM& vm, StringView unit)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue