summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-09-11 15:55:33 -0400
committerAndreas Kling <kling@serenityos.org>2021-09-12 01:40:56 +0200
commit696967d7b690e6501e7cfa6bab41beecb3e5ca42 (patch)
tree3137379eb73d85ce103825e93a84b0ac43ad542b /Userland
parent777ae53615e4ed77980c3ad792a0602d24719bd3 (diff)
downloadserenity-696967d7b690e6501e7cfa6bab41beecb3e5ca42.zip
LibJS: Convert WeakSet.prototype to be a PrototypeObject
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp20
-rw-r--r--Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h5
2 files changed, 7 insertions, 18 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
index 2592686746..21ac9db81d 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp
@@ -11,7 +11,7 @@
namespace JS {
WeakSetPrototype::WeakSetPrototype(GlobalObject& global_object)
- : Object(*global_object.object_prototype())
+ : PrototypeObject(*global_object.object_prototype())
{
}
@@ -33,22 +33,10 @@ WeakSetPrototype::~WeakSetPrototype()
{
}
-WeakSet* WeakSetPrototype::typed_this(VM& vm, GlobalObject& global_object)
-{
- auto* this_object = vm.this_value(global_object).to_object(global_object);
- if (!this_object)
- return {};
- if (!is<WeakSet>(this_object)) {
- vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, "WeakSet");
- return nullptr;
- }
- return static_cast<WeakSet*>(this_object);
-}
-
// 24.4.3.1 WeakSet.prototype.add ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.add
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add)
{
- auto* weak_set = typed_this(vm, global_object);
+ auto* weak_set = typed_this_object(global_object);
if (!weak_set)
return {};
auto value = vm.argument(0);
@@ -63,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add)
// 24.4.3.3 WeakSet.prototype.delete ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.delete
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::delete_)
{
- auto* weak_set = typed_this(vm, global_object);
+ auto* weak_set = typed_this_object(global_object);
if (!weak_set)
return {};
auto value = vm.argument(0);
@@ -75,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::delete_)
// 24.4.3.4 WeakSet.prototype.has ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.has
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::has)
{
- auto* weak_set = typed_this(vm, global_object);
+ auto* weak_set = typed_this_object(global_object);
if (!weak_set)
return {};
auto value = vm.argument(0);
diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h
index 5aee2fb630..120f4c01c4 100644
--- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h
+++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.h
@@ -6,12 +6,13 @@
#pragma once
+#include <LibJS/Runtime/PrototypeObject.h>
#include <LibJS/Runtime/WeakSet.h>
namespace JS {
-class WeakSetPrototype final : public Object {
- JS_OBJECT(WeakSetPrototype, Object);
+class WeakSetPrototype final : public PrototypeObject<WeakSetPrototype, WeakSet> {
+ JS_PROTOTYPE_OBJECT(WeakSetPrototype, WeakSet, WeakSet);
public:
WeakSetPrototype(GlobalObject&);