diff options
author | Luke Wilde <lukew@serenityos.org> | 2021-09-27 16:02:22 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-27 18:45:45 +0200 |
commit | 067d83961551e916f7a7098cd0c39edc67b25bda (patch) | |
tree | 416b2b10be846471209d025bb9b96415fc2e1417 | |
parent | d30ec4d790026845944412be31c4c1528d0b6bcf (diff) | |
download | serenity-067d83961551e916f7a7098cd0c39edc67b25bda.zip |
LibWeb: Add support for the any type in returning and parameters
Required for CustomEvent.
-rw-r--r-- | Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp index 39b66c1d9a..060f3ab960 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp @@ -897,9 +897,27 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter } )~~~"); } else if (parameter.type.name == "any") { - scoped_generator.append(R"~~~( + if (!optional) { + scoped_generator.append(R"~~~( auto @cpp_name@ = @js_name@@js_suffix@; )~~~"); + } else { + scoped_generator.append(R"~~~( + JS::Value @cpp_name@; + if (!@js_name@@js_suffix@.is_undefined()) + @cpp_name@ = @js_name@@js_suffix@; +)~~~"); + if (optional_default_value.has_value()) { + if (optional_default_value == "null") { + scoped_generator.append(R"~~~( + else + @cpp_name@ = JS::js_null(); +)~~~"); + } else { + TODO(); + } + } + } } else { dbgln("Unimplemented JS-to-C++ conversion: {}", parameter.type.name); VERIFY_NOT_REACHED(); @@ -1000,7 +1018,7 @@ static void generate_return_statement(SourceGenerator& generator, IDL::Type cons scoped_generator.append(R"~~~( return JS::Value((i32)retval); )~~~"); - } else if (return_type.name == "Uint8ClampedArray") { + } else if (return_type.name == "Uint8ClampedArray" || return_type.name == "any") { scoped_generator.append(R"~~~( return retval; )~~~"); |