1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:17:45 +00:00

LibJS: Add JS_CELL macro and use it in all JS::Cell subclasses

This is similar to what we already had with JS_OBJECT (and also
JS_ENVIRONMENT) but sits at the top of the Cell inheritance hierarchy.
This commit is contained in:
Andreas Kling 2022-08-28 22:11:20 +02:00
parent 94f016b363
commit 6e973ce69b
16 changed files with 37 additions and 23 deletions

View file

@ -14,6 +14,14 @@
namespace JS {
#define JS_CELL(class_, base_class) \
public: \
using Base = base_class; \
virtual StringView class_name() const override \
{ \
return #class_##sv; \
}
class Cell {
AK_MAKE_NONCOPYABLE(Cell);
AK_MAKE_NONMOVABLE(Cell);

View file

@ -97,9 +97,9 @@ private:
bool has_lazy_freelist() const { return m_next_lazy_freelist_index < cell_count(); }
struct FreelistEntry final : public Cell {
FreelistEntry* next { nullptr };
JS_CELL(FreelistEntry, Cell);
virtual StringView class_name() const override { return "FreelistEntry"sv; }
FreelistEntry* next { nullptr };
};
Cell* cell(size_t index)