1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:48:11 +00:00

LibWeb: Add a custom extended attribute for namespace-level GC visitors

Currently, the WebAssemblyObject implements a visitor to keep its static
objects alive. This custom attribute will be used to hook the generated
namespace object's visitor to one that we define in non-generated code.
This commit is contained in:
Timothy Flynn 2023-03-16 12:57:02 -04:00 committed by Linus Groh
parent aa06dd7f21
commit 2cd7159694

View file

@ -2706,6 +2706,12 @@ public:
private:
)~~~");
if (interface.extended_attributes.contains("WithGCVistor"sv)) {
generator.append(R"~~~(
virtual void visit_edges(JS::Cell::Visitor&) override;
)~~~");
}
for (auto const& overload_set : interface.overload_sets) {
auto function_generator = generator.fork();
function_generator.set("function.name:snakecase", make_input_acceptable_cpp(overload_set.key.to_snakecase()));
@ -2818,6 +2824,16 @@ JS::ThrowCompletionOr<void> @namespace_class@::initialize(JS::Realm& realm)
}
)~~~");
if (interface.extended_attributes.contains("WithGCVistor"sv)) {
generator.append(R"~~~(
void @namespace_class@::visit_edges(JS::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
@name@::visit_edges(visitor);
}
)~~~");
}
for (auto const& function : interface.functions)
generate_function(generator, function, StaticFunction::Yes, interface.namespace_class, interface.name, interface);
for (auto const& overload_set : interface.overload_sets) {