summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-04-02 00:42:15 +0300
committerIdan Horowitz <idan.horowitz@gmail.com>2022-04-02 13:13:37 +0300
commita7f2d46b4926987effbdb9a067b13a1ff476c37f (patch)
tree1aac02ee604b9a92135d75f2307a76271a407545
parent32d142b06cceb8817c4e1a316d3aee282cc7d3a3 (diff)
downloadserenity-a7f2d46b4926987effbdb9a067b13a1ff476c37f.zip
LibWeb: Support integral default values for IDL unions
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
index 4c5c8d4989..9de6d960ac 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp
@@ -1146,6 +1146,10 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
union_generator.append(R"~~~(
@union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? TRY(@js_name@@js_suffix@_to_dictionary(@js_name@@js_suffix@)) : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
)~~~");
+ } else if (optional_default_value->to_int().has_value() || optional_default_value->to_uint().has_value()) {
+ union_generator.append(R"~~~(
+ @union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? @parameter.optional_default_value@ : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
+)~~~");
} else {
TODO();
}