LibWeb: Allow creating "any" types in IDL with integral default values

This enables defining "any" types in IDL files such as:

    any threshold = 0;

This isn't able to parse decimal values yet.
This commit is contained in:
Timothy Flynn 2021-10-13 13:58:28 -04:00 committed by Andreas Kling
parent b7404015aa
commit ff66218631
Notes: sideshowbarker 2024-07-18 02:45:02 +09:00

View file

@ -1124,6 +1124,11 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
scoped_generator.append(R"~~~(
else
@cpp_name@ = JS::js_null();
)~~~");
} else if (optional_default_value->to_int().has_value() || optional_default_value->to_uint().has_value()) {
scoped_generator.append(R"~~~(
else
@cpp_name@ = JS::Value(@parameter.optional_default_value@);
)~~~");
} else {
TODO();