mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibWeb: Add a custom extended attribute for namespace-level finalization
This change adds the `WithFinalizer` extended attribute, which allows namespaces to call a custom function at the point they are finalized.
This commit is contained in:
parent
6d4b8bde55
commit
ddd1ac1e36
Notes:
sideshowbarker
2024-07-17 01:13:25 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/ddd1ac1e36 Pull-request: https://github.com/SerenityOS/serenity/pull/24051 Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 15 additions and 0 deletions
|
@ -3703,6 +3703,12 @@ private:
|
|||
)~~~");
|
||||
}
|
||||
|
||||
if (interface.extended_attributes.contains("WithFinalizer"sv)) {
|
||||
generator.append(R"~~~(
|
||||
virtual void finalize() 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()));
|
||||
|
@ -3835,6 +3841,15 @@ void @namespace_class@::visit_edges(JS::Cell::Visitor& visitor)
|
|||
)~~~");
|
||||
}
|
||||
|
||||
if (interface.extended_attributes.contains("WithFinalizer"sv)) {
|
||||
generator.append(R"~~~(
|
||||
void @namespace_class@::finalize()
|
||||
{
|
||||
@name@::finalize(*this);
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue