mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
LibJS: Convert FinalizationRegistry.prototype to be a PrototypeObject
This commit is contained in:
parent
94f076a774
commit
43e4cec3e2
2 changed files with 7 additions and 20 deletions
|
@ -10,7 +10,7 @@
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
FinalizationRegistryPrototype::FinalizationRegistryPrototype(GlobalObject& global_object)
|
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
|
// @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)
|
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)
|
if (!finalization_registry)
|
||||||
return {};
|
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
|
// 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_)
|
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)
|
if (!finalization_registry)
|
||||||
return {};
|
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
|
// 26.2.3.3 FinalizationRegistry.prototype.unregister ( unregisterToken ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
|
||||||
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::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)
|
if (!finalization_registry)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <LibJS/Runtime/FinalizationRegistry.h>
|
#include <LibJS/Runtime/FinalizationRegistry.h>
|
||||||
|
#include <LibJS/Runtime/PrototypeObject.h>
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
class FinalizationRegistryPrototype final : public Object {
|
class FinalizationRegistryPrototype final : public PrototypeObject<FinalizationRegistryPrototype, FinalizationRegistry> {
|
||||||
JS_OBJECT(FinalizationRegistryPrototype, Object);
|
JS_PROTOTYPE_OBJECT(FinalizationRegistryPrototype, FinalizationRegistry, FinalizationRegistry);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FinalizationRegistryPrototype(GlobalObject&);
|
FinalizationRegistryPrototype(GlobalObject&);
|
||||||
|
@ -19,8 +20,6 @@ public:
|
||||||
virtual ~FinalizationRegistryPrototype() override;
|
virtual ~FinalizationRegistryPrototype() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static FinalizationRegistry* typed_this(VM&, GlobalObject&);
|
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(cleanup_some);
|
JS_DECLARE_NATIVE_FUNCTION(cleanup_some);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(register_);
|
JS_DECLARE_NATIVE_FUNCTION(register_);
|
||||||
JS_DECLARE_NATIVE_FUNCTION(unregister);
|
JS_DECLARE_NATIVE_FUNCTION(unregister);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue