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:
Timothy Flynn 2025-04-07 15:56:31 -04:00 committed by Tim Flynn
commit 62793b1bd8
Notes: github-actions[bot] 2025-04-08 10:53:24 +00:00
29 changed files with 284 additions and 116 deletions

View file

@ -10,15 +10,14 @@
#include <AK/Array.h>
#include <AK/String.h>
#include <LibCrypto/BigFraction/BigFraction.h>
#include <LibJS/Runtime/Intl/AbstractOperations.h>
#include <LibJS/Runtime/Object.h>
#include <LibJS/Runtime/Intl/IntlObject.h>
#include <LibJS/Runtime/Temporal/Duration.h>
#include <LibUnicode/Locale.h>
namespace JS::Intl {
class DurationFormat final : public Object {
JS_OBJECT(DurationFormat, Object);
class DurationFormat final : public IntlObject {
JS_OBJECT(DurationFormat, IntlObject);
GC_DECLARE_ALLOCATOR(DurationFormat);
public:
@ -72,15 +71,11 @@ public:
Display display { Display::Auto };
};
static constexpr auto relevant_extension_keys()
{
// 13.2.3 Internal slots, https://tc39.es/ecma402/#sec-Intl.DurationFormat-internal-slots
// The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ».
return AK::Array { "nu"sv };
}
virtual ~DurationFormat() override = default;
virtual ReadonlySpan<StringView> relevant_extension_keys() const override;
virtual ReadonlySpan<ResolutionOptionDescriptor> resolution_option_descriptors(VM&) const override;
void set_locale(String locale) { m_locale = move(locale); }
String const& locale() const { return m_locale; }