From 4ae2390554bdbfa01152ae894dc830be4f602cf6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 6 Aug 2022 14:53:39 +0200 Subject: [PATCH] LibWeb: Support NoInstanceWrapper extended attribute on interfaces This tells the wrapper generator that there is no separate wrapper class for this interface, and it should refer directly to the C++ "Foo" object instead of "FooWrapper". --- .../LibWeb/WrapperGenerator/IDLGenerators.cpp | 8 ++++++++ .../CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index f138bc92dd..db4282b912 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -1979,7 +1979,9 @@ void generate_implementation(IDL::Interface const& interface) #include #include #include +#if __has_include() #include +#endif #include #include #include @@ -2858,7 +2860,9 @@ void generate_constructor_implementation(IDL::Interface const& interface) #include #include #include +#if __has_include() #include +#endif #include #include #include @@ -3162,7 +3166,9 @@ void generate_prototype_implementation(IDL::Interface const& interface) #include #include #include +#if __has_include() #include +#endif #include #include #include @@ -3640,7 +3646,9 @@ void generate_iterator_implementation(IDL::Interface const& interface) #include #include #include +#if __has_include() #include +#endif #include #include diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp index 9e3427bfba..c8470390e8 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp @@ -570,7 +570,11 @@ void Parser::parse_interface(Interface& interface) parse_function(extended_attributes, interface); } - interface.wrapper_class = String::formatted("{}Wrapper", interface.name); + if (interface.extended_attributes.contains("NoInstanceWrapper")) { + interface.wrapper_class = interface.name; + } else { + interface.wrapper_class = String::formatted("{}Wrapper", interface.name); + } interface.wrapper_base_class = String::formatted("{}Wrapper", interface.parent_name.is_empty() ? String::empty() : interface.parent_name); interface.constructor_class = String::formatted("{}Constructor", interface.name); interface.prototype_class = String::formatted("{}Prototype", interface.name);