summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-09-11 16:16:36 -0400
committerAndreas Kling <kling@serenityos.org>2021-09-12 01:40:56 +0200
commit43e4cec3e228043413a6c06f7cc26c8a997ed338 (patch)
tree4a14b6dcb04192144334d4b0d3d4d3c1cf479b6e /Userland
parent94f076a7746b09971be611407b832082152fc645 (diff)
downloadserenity-43e4cec3e228043413a6c06f7cc26c8a997ed338.zip
LibJS: Convert FinalizationRegistry.prototype to be a PrototypeObject
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp20
-rw-r--r--Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h7
2 files changed, 7 insertions, 20 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
index a0047c8b0c..a74227491a 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp
@@ -10,7 +10,7 @@
namespace JS {
FinalizationRegistryPrototype::FinalizationRegistryPrototype(GlobalObject& global_object)
- : Object(*global_object.object_prototype())
+ : PrototypeObject(*global_object.object_prototype())
{
}
@@ -32,22 +32,10 @@ FinalizationRegistryPrototype::~FinalizationRegistryPrototype()
{
}
-FinalizationRegistry* FinalizationRegistryPrototype::typed_this(VM& vm, GlobalObject& global_object)
-{
- auto* this_object = vm.this_value(global_object).to_object(global_object);
- if (!this_object)
- return nullptr;
- if (!is<FinalizationRegistry>(this_object)) {
- vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "FinalizationRegistry");
- return nullptr;
- }
- return static_cast<FinalizationRegistry*>(this_object);
-}
-
// @STAGE 2@ FinalizationRegistry.prototype.cleanupSome ( [ callback ] ), https://github.com/tc39/proposal-cleanup-some/blob/master/spec/finalization-registry.html
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some)
{
- auto* finalization_registry = typed_this(vm, global_object);
+ auto* finalization_registry = typed_this_object(global_object);
if (!finalization_registry)
return {};
@@ -65,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some)
// 26.2.3.2 FinalizationRegistry.prototype.register ( target, heldValue [ , unregisterToken ] ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.register
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
{
- auto* finalization_registry = typed_this(vm, global_object);
+ auto* finalization_registry = typed_this_object(global_object);
if (!finalization_registry)
return {};
@@ -95,7 +83,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
// 26.2.3.3 FinalizationRegistry.prototype.unregister ( unregisterToken ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::unregister)
{
- auto* finalization_registry = typed_this(vm, global_object);
+ auto* finalization_registry = typed_this_object(global_object);
if (!finalization_registry)
return {};
diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h
index 963489cad0..f78f782645 100644
--- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.h
@@ -7,11 +7,12 @@
#pragma once
#include <LibJS/Runtime/FinalizationRegistry.h>
+#include <LibJS/Runtime/PrototypeObject.h>
namespace JS {
-class FinalizationRegistryPrototype final : public Object {
- JS_OBJECT(FinalizationRegistryPrototype, Object);
+class FinalizationRegistryPrototype final : public PrototypeObject<FinalizationRegistryPrototype, FinalizationRegistry> {
+ JS_PROTOTYPE_OBJECT(FinalizationRegistryPrototype, FinalizationRegistry, FinalizationRegistry);
public:
FinalizationRegistryPrototype(GlobalObject&);
@@ -19,8 +20,6 @@ public:
virtual ~FinalizationRegistryPrototype() override;
private:
- static FinalizationRegistry* typed_this(VM&, GlobalObject&);
-
JS_DECLARE_NATIVE_FUNCTION(cleanup_some);
JS_DECLARE_NATIVE_FUNCTION(register_);
JS_DECLARE_NATIVE_FUNCTION(unregister);