mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
LibWeb/Bindings: Invert logic for nullability check in wrap statements
This is less code, and also makes a future bugfix much simpler to implement :^)
This commit is contained in:
parent
ffb65d76d6
commit
603a60f5cb
1 changed files with 6 additions and 12 deletions
|
@ -1796,27 +1796,19 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
||||||
if ((is_optional || type.is_nullable()) && !is<UnionType>(type)) {
|
if ((is_optional || type.is_nullable()) && !is<UnionType>(type)) {
|
||||||
if (type.is_string()) {
|
if (type.is_string()) {
|
||||||
scoped_generator.append(R"~~~(
|
scoped_generator.append(R"~~~(
|
||||||
if (!@value@.has_value()) {
|
if (@value@.has_value()) {
|
||||||
@result_expression@ JS::js_null();
|
|
||||||
} else {
|
|
||||||
)~~~");
|
)~~~");
|
||||||
} else if (type.name() == "sequence") {
|
} else if (type.name() == "sequence") {
|
||||||
scoped_generator.append(R"~~~(
|
scoped_generator.append(R"~~~(
|
||||||
if (!@value@.has_value()) {
|
if (@value@.has_value()) {
|
||||||
@result_expression@ JS::js_null();
|
|
||||||
} else {
|
|
||||||
)~~~");
|
)~~~");
|
||||||
} else if (type.is_primitive() || interface.enumerations.contains(type.name()) || interface.dictionaries.contains(type.name())) {
|
} else if (type.is_primitive() || interface.enumerations.contains(type.name()) || interface.dictionaries.contains(type.name())) {
|
||||||
scoped_generator.append(R"~~~(
|
scoped_generator.append(R"~~~(
|
||||||
if (!@value@.has_value()) {
|
if (@value@.has_value()) {
|
||||||
@result_expression@ JS::js_null();
|
|
||||||
} else {
|
|
||||||
)~~~");
|
)~~~");
|
||||||
} else {
|
} else {
|
||||||
scoped_generator.append(R"~~~(
|
scoped_generator.append(R"~~~(
|
||||||
if (!@value@) {
|
if (@value@) {
|
||||||
@result_expression@ JS::js_null();
|
|
||||||
} else {
|
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2071,6 +2063,8 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
||||||
|
|
||||||
if ((type.is_nullable() || is_optional) && !is<UnionType>(type)) {
|
if ((type.is_nullable() || is_optional) && !is<UnionType>(type)) {
|
||||||
scoped_generator.append(R"~~~(
|
scoped_generator.append(R"~~~(
|
||||||
|
} else {
|
||||||
|
@result_expression@ JS::js_null();
|
||||||
}
|
}
|
||||||
)~~~");
|
)~~~");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue