LibJS+LibWeb: Let WrapperGenerator deal with legacy_null_to_empty_string

This concept is not present in ECMAScript, and it bothers me every time
I see it.
It's only used by WrapperGenerator, and even there only relevant in two
places, so let's fully remove it from LibJS and use a simple ternary
expression instead:

    cpp_name = js_name.is_null() && legacy_null_to_empty_string
        ? String::empty()
        : js_name.to_string(global_object);
This commit is contained in:
Linus Groh 2021-10-11 23:23:52 +01:00
parent 8ea79c05db
commit 44e70d1bc0
Notes: sideshowbarker 2024-07-18 02:48:43 +09:00
3 changed files with 10 additions and 6 deletions

View file

@ -906,7 +906,9 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (!optional) {
if (!parameter.type.nullable) {
scoped_generator.append(R"~~~(
auto @cpp_name@ = @js_name@@js_suffix@.to_string(global_object, @legacy_null_to_empty_string@);
auto @cpp_name@ = @js_name@@js_suffix@.is_null() && @legacy_null_to_empty_string@
? String::empty()
: @js_name@@js_suffix@.to_string(global_object);
if (vm.exception())
@return_statement@
)~~~");
@ -914,7 +916,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
scoped_generator.append(R"~~~(
String @cpp_name@;
if (!@js_name@@js_suffix@.is_nullish()) {
@cpp_name@ = @js_name@@js_suffix@.to_string(global_object, @legacy_null_to_empty_string@);
@cpp_name@ = @js_name@@js_suffix@.to_string(global_object);
if (vm.exception())
@return_statement@
}
@ -924,7 +926,9 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
scoped_generator.append(R"~~~(
String @cpp_name@;
if (!@js_name@@js_suffix@.is_undefined()) {
@cpp_name@ = @js_name@@js_suffix@.to_string(global_object, @legacy_null_to_empty_string@);
@cpp_name@ = @js_name@@js_suffix@.is_null() && @legacy_null_to_empty_string@
? String::empty()
: @js_name@@js_suffix@.to_string(global_object);
if (vm.exception())
@return_statement@
})~~~");