mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00
LibWeb: Support interfaces with the [Global] extended attribute
These are treated differently as the interface members are placed on the object itself, not its prototype. As the object itself still needs to be hand-written code, and we can no longer fully hide the gnarly generated code in the prototype object, these now generate a 'mixin' class that is added to the actual object through inheritance. https://webidl.spec.whatwg.org/#Global
This commit is contained in:
parent
de83f5422d
commit
3316d247bf
Notes:
sideshowbarker
2024-07-17 22:09:47 +09:00
Author: https://github.com/linusg
Commit: 3316d247bf
Pull-request: https://github.com/SerenityOS/serenity/pull/17752
Reviewed-by: https://github.com/awesomekling
5 changed files with 639 additions and 443 deletions
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
* Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
*
|
||||
|
@ -24,6 +24,8 @@ void generate_prototype_header(IDL::Interface const&, StringBuilder&);
|
|||
void generate_prototype_implementation(IDL::Interface const&, StringBuilder&);
|
||||
void generate_iterator_prototype_header(IDL::Interface const&, StringBuilder&);
|
||||
void generate_iterator_prototype_implementation(IDL::Interface const&, StringBuilder&);
|
||||
void generate_global_mixin_header(IDL::Interface const&, StringBuilder&);
|
||||
void generate_global_mixin_implementation(IDL::Interface const&, StringBuilder&);
|
||||
}
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
@ -40,12 +42,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool prototype_implementation_mode = false;
|
||||
bool iterator_prototype_header_mode = false;
|
||||
bool iterator_prototype_implementation_mode = false;
|
||||
bool global_mixin_header_mode = false;
|
||||
bool global_mixin_implementation_mode = false;
|
||||
args_parser.add_option(constructor_header_mode, "Generate the constructor .h file", "constructor-header", 'C');
|
||||
args_parser.add_option(constructor_implementation_mode, "Generate the constructor .cpp file", "constructor-implementation", 'O');
|
||||
args_parser.add_option(prototype_header_mode, "Generate the prototype .h file", "prototype-header", 'P');
|
||||
args_parser.add_option(prototype_implementation_mode, "Generate the prototype .cpp file", "prototype-implementation", 'R');
|
||||
args_parser.add_option(iterator_prototype_header_mode, "Generate the iterator prototype .h file", "iterator-prototype-header", 0);
|
||||
args_parser.add_option(iterator_prototype_implementation_mode, "Generate the iterator prototype .cpp file", "iterator-prototype-implementation", 0);
|
||||
args_parser.add_option(global_mixin_header_mode, "Generate the global object mixin .h file", "global-mixin-header", 0);
|
||||
args_parser.add_option(global_mixin_implementation_mode, "Generate the global object mixin .cpp file", "global-mixin-implementation", 0);
|
||||
args_parser.add_option(Core::ArgsParser::Option {
|
||||
.argument_mode = Core::ArgsParser::OptionArgumentMode::Required,
|
||||
.help_string = "Add a header search path passed to the compiler",
|
||||
|
@ -148,6 +154,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (iterator_prototype_implementation_mode)
|
||||
IDL::generate_iterator_prototype_implementation(interface, output_builder);
|
||||
|
||||
if (global_mixin_header_mode)
|
||||
IDL::generate_global_mixin_header(interface, output_builder);
|
||||
|
||||
if (global_mixin_implementation_mode)
|
||||
IDL::generate_global_mixin_implementation(interface, output_builder);
|
||||
|
||||
TRY(output_file->write(output_builder.string_view().bytes()));
|
||||
|
||||
if (!depfile_path.is_null()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue