1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:28:11 +00:00

LibWeb/HTML: Port Window.structuredClone() to IDL

This commit is contained in:
Linus Groh 2023-03-07 18:21:49 +00:00
parent a31c561a5a
commit 129ab02470
8 changed files with 42 additions and 25 deletions

View file

@ -136,6 +136,9 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
if (type.name() == "any" || type.name() == "undefined")
return { .name = "JS::Value", .sequence_storage_type = SequenceStorageType::MarkedVector };
if (type.name() == "object")
return { .name = "JS::Handle<JS::Object>", .sequence_storage_type = SequenceStorageType::Vector };
if (type.name() == "BufferSource")
return { .name = "JS::Handle<JS::Object>", .sequence_storage_type = SequenceStorageType::MarkedVector };
@ -591,6 +594,10 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
@js_name@@js_suffix@ = new_promise;
}
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"~~~(
auto @cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
)~~~");
} else if (parameter.type->name() == "BufferSource") {
scoped_generator.append(R"~~~(