summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Intl
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-09-13 18:05:23 +0100
committerLinus Groh <mail@linusgroh.de>2021-09-13 19:07:26 +0100
commitc277658ca6a8827e543eea621578887c9f0a9229 (patch)
tree0c9ea0cbef013dfb000e180305d3842870653167 /Userland/Libraries/LibJS/Runtime/Intl
parentb256b50476f97697c111d646d7e0a70845c3e2f2 (diff)
downloadserenity-c277658ca6a8827e543eea621578887c9f0a9229.zip
LibJS: Convert Intl.ListFormat.prototype to be a PrototypeObject
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Intl')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp24
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h7
2 files changed, 8 insertions, 23 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
index bf209ac624..3be67ae1f9 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp
@@ -12,25 +12,9 @@
namespace JS::Intl {
-static ListFormat* 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<ListFormat>(this_object)) {
- vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Intl.ListFormat");
- return nullptr;
- }
-
- return static_cast<ListFormat*>(this_object);
-}
-
// 13.4 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object
ListFormatPrototype::ListFormatPrototype(GlobalObject& global_object)
- : Object(*global_object.object_prototype())
+ : PrototypeObject(*global_object.object_prototype())
{
}
@@ -56,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
// 1. Let lf be the this value.
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
- auto* list_format = typed_this(global_object);
+ auto* list_format = typed_this_object(global_object);
if (vm.exception())
return {};
@@ -77,7 +61,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
// 1. Let lf be the this value.
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
- auto* list_format = typed_this(global_object);
+ auto* list_format = typed_this_object(global_object);
if (vm.exception())
return {};
@@ -95,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
{
// 1. Let lf be the this value.
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
- auto* list_format = typed_this(global_object);
+ auto* list_format = typed_this_object(global_object);
if (vm.exception())
return {};
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h
index bfa1c61340..1761b7c129 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.h
@@ -6,12 +6,13 @@
#pragma once
-#include <LibJS/Runtime/Object.h>
+#include <LibJS/Runtime/Intl/ListFormat.h>
+#include <LibJS/Runtime/PrototypeObject.h>
namespace JS::Intl {
-class ListFormatPrototype final : public Object {
- JS_OBJECT(ListFormatPrototype, Object);
+class ListFormatPrototype final : public PrototypeObject<ListFormatPrototype, ListFormat> {
+ JS_PROTOTYPE_OBJECT(ListFormatPrototype, ListFormat, Intl.ListFormat);
public:
explicit ListFormatPrototype(GlobalObject&);