ladybird/Userland/Libraries/LibJS/Runtime/WeakSet.cpp
Idan Horowitz 1a8ee5d8d7 LibJS: Generify the garbage collector's weak container notifications
This will allow us to use the same interface for other JS weak
containers like the WeakMap & WeakRef.
2021-06-12 10:44:28 +01:00

32 lines
589 B
C++

/*
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/WeakSet.h>
namespace JS {
WeakSet* WeakSet::create(GlobalObject& global_object)
{
return global_object.heap().allocate<WeakSet>(global_object, *global_object.weak_set_prototype());
}
WeakSet::WeakSet(Object& prototype)
: Object(prototype)
, WeakContainer(heap())
{
}
WeakSet::~WeakSet()
{
}
void WeakSet::remove_sweeped_cells(Badge<Heap>, Vector<Cell*>& cells)
{
for (auto* cell : cells)
m_values.remove(cell);
}
}