mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
IDLGenerators: Allow returning nullable dictionaries from IDL methods
This commit is contained in:
parent
5e534f4d83
commit
a8c282a30e
Notes:
github-actions[bot]
2024-12-05 08:58:02 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: a8c282a30e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2776
1 changed files with 2 additions and 2 deletions
|
@ -1760,7 +1760,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
@result_expression@ JS::js_null();
|
||||
} else {
|
||||
)~~~");
|
||||
} else if (type.is_primitive() || interface.enumerations.contains(type.name())) {
|
||||
} else if (type.is_primitive() || interface.enumerations.contains(type.name()) || interface.dictionaries.contains(type.name())) {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@value@.has_value()) {
|
||||
@result_expression@ JS::js_null();
|
||||
|
@ -1946,7 +1946,7 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
dictionary_generator.append(R"~~~(
|
||||
JS::Value @wrapped_value_name@;
|
||||
)~~~");
|
||||
generate_wrap_statement(dictionary_generator, ByteString::formatted("{}.{}", value, member.name.to_snakecase()), member.type, interface, ByteString::formatted("{} =", wrapped_value_name), WrappingReference::No, recursion_depth + 1);
|
||||
generate_wrap_statement(dictionary_generator, ByteString::formatted("{}{}{}", value, type.is_nullable() ? "->" : ".", member.name.to_snakecase()), member.type, interface, ByteString::formatted("{} =", wrapped_value_name), WrappingReference::No, recursion_depth + 1);
|
||||
|
||||
dictionary_generator.append(R"~~~(
|
||||
MUST(dictionary_object@recursion_depth@->create_data_property("@member_key@", @wrapped_value_name@));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue