mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb: Support generating optional object IDL parameters
These are used by WebAssembly IDL.
This commit is contained in:
parent
49e6cb7c3d
commit
0d921720b4
Notes:
sideshowbarker
2024-07-17 09:49:33 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0d921720b4 Pull-request: https://github.com/SerenityOS/serenity/pull/17878 Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 9 additions and 1 deletions
|
@ -605,9 +605,17 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
auto @cpp_name@ = JS::make_handle(&static_cast<JS::Promise&>(@js_name@@js_suffix@.as_object()));
|
||||
)~~~");
|
||||
} else if (parameter.type->name() == "object") {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<JS::Handle<JS::Object>> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_undefined())
|
||||
@cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
auto @cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
|
||||
)~~~");
|
||||
}
|
||||
} else if (parameter.type->name() == "BufferSource") {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_object() || !(is<JS::TypedArrayBase>(@js_name@@js_suffix@.as_object()) || is<JS::ArrayBuffer>(@js_name@@js_suffix@.as_object()) || is<JS::DataView>(@js_name@@js_suffix@.as_object())))
|
||||
|
|
Loading…
Add table
Reference in a new issue