mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb/Bindings: Generate dictionary in bindings in a C++ scope
This fixes a compile error of multiple variables of the same name within the same scope for the URLPattern IDL, which has a dictionary return type that contains multiple dictionaries of the same type. Conveniently, this also makes the complicated generated code of the URLPattern interface easier to read by adding some more structure :^)
This commit is contained in:
parent
69f0120833
commit
64a2c156bb
Notes:
github-actions[bot]
2025-02-10 17:06:29 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/64a2c156bb9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3237 Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 6 additions and 4 deletions
|
@ -2005,7 +2005,8 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
auto dictionary_generator = scoped_generator.fork();
|
||||
|
||||
dictionary_generator.append(R"~~~(
|
||||
auto dictionary_object@recursion_depth@ = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||
{
|
||||
auto dictionary_object@recursion_depth@ = JS::Object::create(realm, realm.intrinsics().object_prototype());
|
||||
)~~~");
|
||||
|
||||
auto* current_dictionary = &interface.dictionaries.find(type.name())->value;
|
||||
|
@ -2021,12 +2022,12 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
dictionary_generator.set("wrapped_value_name", wrapped_value_name);
|
||||
|
||||
dictionary_generator.append(R"~~~(
|
||||
JS::Value @wrapped_value_name@;
|
||||
JS::Value @wrapped_value_name@;
|
||||
)~~~");
|
||||
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@));
|
||||
MUST(dictionary_object@recursion_depth@->create_data_property("@member_key@", @wrapped_value_name@));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
|
@ -2037,7 +2038,8 @@ static void generate_wrap_statement(SourceGenerator& generator, ByteString const
|
|||
}
|
||||
|
||||
dictionary_generator.append(R"~~~(
|
||||
@result_expression@ dictionary_object@recursion_depth@;
|
||||
@result_expression@ dictionary_object@recursion_depth@;
|
||||
}
|
||||
)~~~");
|
||||
} else if (type.name() == "object") {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
|
Loading…
Add table
Reference in a new issue