Meta: Reuse built-in JS types list for IDL to C++ generation

This opens up the code path for the `ArrayBuffer` type, which can now be
used as a method argument.
This commit is contained in:
Jelle Raaijmakers 2024-10-14 21:51:15 +02:00 committed by Andreas Kling
commit 0b9d55b676
Notes: github-actions[bot] 2024-10-15 08:03:48 +00:00

View file

@ -120,7 +120,8 @@ static bool is_javascript_builtin(Type const& type)
"ArrayBuffer"sv,
"Float32Array"sv,
"Float64Array"sv,
"Uint8Array"sv
"Uint8Array"sv,
"Uint8ClampedArray"sv,
};
return types.span().contains_slow(type.name());
@ -692,7 +693,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
auto @cpp_name@ = JS::make_handle(TRY(@js_name@@js_suffix@.to_object(vm)));
)~~~");
}
} else if (parameter.type->name().is_one_of("BufferSource", "Float32Array", "Float64Array", "Uint8Array", "Uint8ClampedArray")) {
} else if (is_javascript_builtin(parameter.type) || parameter.type->name() == "BufferSource"sv) {
if (optional) {
scoped_generator.append(R"~~~(
Optional<JS::Handle<WebIDL::BufferSource>> @cpp_name@;