summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-10-11 23:23:52 +0100
committerLinus Groh <mail@linusgroh.de>2021-10-11 23:36:03 +0100
commit44e70d1bc0508f8c65ae83fa21f1642654364f4c (patch)
tree1b4f82fd8b3ce0ece364fe7a25e244793cf43409 /Meta
parent8ea79c05dbb2d2e3e9d775737bc608dc3dd976a9 (diff)
downloadserenity-44e70d1bc0508f8c65ae83fa21f1642654364f4c.zip
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);
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
index 248731c1b4..c9e27c81b5 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
@@ -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@
})~~~");