1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:07:45 +00:00

LibWeb: Add new String support for parameters with empty string defaults

This adds new string support for parameters with an optional default
value of empty string ("").
This commit is contained in:
Kenneth Myhra 2023-02-28 21:29:52 +01:00 committed by Linus Groh
parent 7f717b8414
commit 98705ecf71

View file

@ -1314,9 +1314,15 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
} else {
if (optional_default_value == "\"\"") {
union_generator.append(R"~~~(
if (!interface.extended_attributes.contains("UseNewAKString")) {
union_generator.append(R"~~~(
@union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? DeprecatedString::empty() : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
)~~~");
} else {
union_generator.append(R"~~~(
@union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? String {} : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
)~~~");
}
} else if (optional_default_value == "{}") {
VERIFY(dictionary_type);
union_generator.append(R"~~~(