mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibJS: Convert Intl.DisplayNames.prototype to be a PrototypeObject
This commit is contained in:
parent
a9c33b5bbd
commit
b256b50476
2 changed files with 7 additions and 22 deletions
|
@ -12,25 +12,9 @@
|
||||||
|
|
||||||
namespace JS::Intl {
|
namespace JS::Intl {
|
||||||
|
|
||||||
static DisplayNames* typed_this(GlobalObject& global_object)
|
|
||||||
{
|
|
||||||
auto& vm = global_object.vm();
|
|
||||||
|
|
||||||
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
|
||||||
if (!this_object)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if (!is<DisplayNames>(this_object)) {
|
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Intl.DisplayNames");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return static_cast<DisplayNames*>(this_object);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 12.4 Properties of the Intl.DisplayNames Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object
|
// 12.4 Properties of the Intl.DisplayNames Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-displaynames-prototype-object
|
||||||
DisplayNamesPrototype::DisplayNamesPrototype(GlobalObject& global_object)
|
DisplayNamesPrototype::DisplayNamesPrototype(GlobalObject& global_object)
|
||||||
: Object(*global_object.object_prototype())
|
: PrototypeObject(*global_object.object_prototype())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +39,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
||||||
|
|
||||||
// 1. Let displayNames be this value.
|
// 1. Let displayNames be this value.
|
||||||
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
||||||
auto* display_names = typed_this(global_object);
|
auto* display_names = typed_this_object(global_object);
|
||||||
if (!display_names)
|
if (!display_names)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -107,7 +91,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
|
||||||
{
|
{
|
||||||
// 1. Let displayNames be this value.
|
// 1. Let displayNames be this value.
|
||||||
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
||||||
auto* display_names = typed_this(global_object);
|
auto* display_names = typed_this_object(global_object);
|
||||||
if (!display_names)
|
if (!display_names)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibJS/Runtime/Object.h>
|
#include <LibJS/Runtime/Intl/DisplayNames.h>
|
||||||
|
#include <LibJS/Runtime/PrototypeObject.h>
|
||||||
|
|
||||||
namespace JS::Intl {
|
namespace JS::Intl {
|
||||||
|
|
||||||
class DisplayNamesPrototype final : public Object {
|
class DisplayNamesPrototype final : public PrototypeObject<DisplayNamesPrototype, DisplayNames> {
|
||||||
JS_OBJECT(DisplayNamesPrototype, Object);
|
JS_PROTOTYPE_OBJECT(DisplayNamesPrototype, DisplayNames, Intl.DisplayNames);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DisplayNamesPrototype(GlobalObject&);
|
explicit DisplayNamesPrototype(GlobalObject&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue