summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2023-03-28 19:43:44 -0700
committerLinus Groh <mail@linusgroh.de>2023-04-01 23:43:07 +0100
commitf99d6e177f564064eef42a93e832ade22e7c3a99 (patch)
tree0ed20341cbfd6027f3738d89c5af6a7e625b0044
parent222e3c32cdd7e1d58146d2cea5e7cb93c672a780 (diff)
downloadserenity-f99d6e177f564064eef42a93e832ade22e7c3a99.zip
IDLGenerators: Support nullable double values
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
index 664bda2c73..82374d62f8 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
@@ -1584,6 +1584,12 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
@result_expression@ JS::js_null();
} else {
)~~~");
+ } else if (type.is_primitive()) {
+ scoped_generator.append(R"~~~(
+ if (!@value@.has_value()) {
+ @result_expression@ JS::js_null();
+ } else {
+)~~~");
} else {
scoped_generator.append(R"~~~(
if (!@value@) {
@@ -1643,9 +1649,15 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
@result_expression@ new_array@recursion_depth@;
)~~~");
} else if (type.name() == "boolean" || type.name() == "double" || type.name() == "float") {
- scoped_generator.append(R"~~~(
+ if (type.is_nullable()) {
+ scoped_generator.append(R"~~~(
+ @result_expression@ JS::Value(@value@.release_value());
+)~~~");
+ } else {
+ scoped_generator.append(R"~~~(
@result_expression@ JS::Value(@value@);
)~~~");
+ }
} else if (type.name() == "short" || type.name() == "long" || type.name() == "unsigned short") {
scoped_generator.append(R"~~~(
@result_expression@ JS::Value((i32)@value@);