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
commit 98705ecf71
Notes: sideshowbarker 2024-07-17 16:23:06 +09:00

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"~~~(