summaryrefslogtreecommitdiff
path: root/Meta
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-02-28 21:32:52 +0100
committerLinus Groh <mail@linusgroh.de>2023-03-01 22:44:20 +0000
commitc0559e8a10b6f0e0adc6ac37999580edead54d2e (patch)
tree722917895166f888074ca4a1a0b91478353e5408 /Meta
parent98705ecf71e22413b21ea4099399cf7d30ce6791 (diff)
downloadserenity-c0559e8a10b6f0e0adc6ac37999580edead54d2e.zip
LibWeb: Handle optional return values for getters returning new String
Diffstat (limited to 'Meta')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
index f10710578d..698cd4ac4a 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
@@ -1487,11 +1487,19 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
if (type.is_nullable() && !is<UnionType>(type)) {
if (type.is_string()) {
- scoped_generator.append(R"~~~(
+ if (!interface.extended_attributes.contains("UseNewAKString")) {
+ scoped_generator.append(R"~~~(
if (@value@.is_null()) {
@result_expression@ JS::js_null();
} else {
)~~~");
+ } else {
+ scoped_generator.append(R"~~~(
+ if (!@value@.has_value()) {
+ @result_expression@ JS::js_null();
+ } else {
+)~~~");
+ }
} else if (type.name() == "sequence") {
scoped_generator.append(R"~~~(
if (!@value@.has_value()) {
@@ -1508,9 +1516,15 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
}
if (type.is_string()) {
- scoped_generator.append(R"~~~(
+ if (type.is_nullable() && interface.extended_attributes.contains("UseNewAKString")) {
+ scoped_generator.append(R"~~~(
+ @result_expression@ JS::PrimitiveString::create(vm, @value@.release_value());
+)~~~");
+ } else {
+ scoped_generator.append(R"~~~(
@result_expression@ JS::PrimitiveString::create(vm, @value@);
)~~~");
+ }
} else if (type.name() == "sequence") {
// https://webidl.spec.whatwg.org/#es-sequence
auto& sequence_generic_type = verify_cast<IDL::ParameterizedType>(type);