mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
LibJS: Convert WeakSet.prototype to be a PrototypeObject
This commit is contained in:
parent
777ae53615
commit
696967d7b6
2 changed files with 7 additions and 18 deletions
|
@ -11,7 +11,7 @@
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
WeakSetPrototype::WeakSetPrototype(GlobalObject& global_object)
|
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
|
// 24.4.3.1 WeakSet.prototype.add ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.add
|
||||||
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::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)
|
if (!weak_set)
|
||||||
return {};
|
return {};
|
||||||
auto value = vm.argument(0);
|
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
|
// 24.4.3.3 WeakSet.prototype.delete ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.delete
|
||||||
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::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)
|
if (!weak_set)
|
||||||
return {};
|
return {};
|
||||||
auto value = vm.argument(0);
|
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
|
// 24.4.3.4 WeakSet.prototype.has ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.has
|
||||||
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::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)
|
if (!weak_set)
|
||||||
return {};
|
return {};
|
||||||
auto value = vm.argument(0);
|
auto value = vm.argument(0);
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibJS/Runtime/PrototypeObject.h>
|
||||||
#include <LibJS/Runtime/WeakSet.h>
|
#include <LibJS/Runtime/WeakSet.h>
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
class WeakSetPrototype final : public Object {
|
class WeakSetPrototype final : public PrototypeObject<WeakSetPrototype, WeakSet> {
|
||||||
JS_OBJECT(WeakSetPrototype, Object);
|
JS_PROTOTYPE_OBJECT(WeakSetPrototype, WeakSet, WeakSet);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WeakSetPrototype(GlobalObject&);
|
WeakSetPrototype(GlobalObject&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue