mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 20:42:11 +02:00
LibJS: Define constructor slots for describing how to read options
This is an editorial change in the ECMA-402 spec. See: https://github.com/tc39/ecma402/commit/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:
Notes:
github-actions[bot]
2025-04-08 10:53:24 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/62793b1bd88 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4275
36
Libraries/LibJS/Runtime/Intl/IntlObject.h
Normal file
36
Libraries/LibJS/Runtime/Intl/IntlObject.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Span.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
||||
// https://tc39.es/ecma402/#resolution-option-descriptor
|
||||
struct ResolutionOptionDescriptor {
|
||||
StringView key;
|
||||
PropertyKey property;
|
||||
OptionType type { OptionType::String };
|
||||
ReadonlySpan<StringView> values {};
|
||||
};
|
||||
|
||||
class IntlObject : public Object {
|
||||
JS_OBJECT(IntlObject, Object);
|
||||
|
||||
public:
|
||||
virtual ReadonlySpan<StringView> relevant_extension_keys() const = 0;
|
||||
virtual ReadonlySpan<ResolutionOptionDescriptor> resolution_option_descriptors(VM&) const = 0;
|
||||
|
||||
protected:
|
||||
using Object::Object;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user