mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibWeb/IDL/Codegen: Handle BufferSource in union types
This commit is contained in:
parent
423e77d5c3
commit
be8489fb04
Notes:
sideshowbarker
2024-07-17 05:13:53 +09:00
Author: https://github.com/stelar7 Commit: https://github.com/SerenityOS/serenity/commit/be8489fb04 Pull-request: https://github.com/SerenityOS/serenity/pull/22346 Reviewed-by: https://github.com/ADKaster
1 changed files with 11 additions and 0 deletions
|
@ -1205,6 +1205,17 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
)~~~");
|
||||
}
|
||||
|
||||
// Note: This covers steps 6-8 for when Buffersource is in a union with a type other than "object".
|
||||
// Since in that case, the return type would be Handle<BufferSource>, and not Handle<Object>.
|
||||
if (any_of(types, [](auto const& type) { return type->name() == "BufferSource"; }) && !includes_object) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<JS::ArrayBuffer>(@js_name@@js_suffix@_object) || is<JS::DataView>(@js_name@@js_suffix@_object) || is<JS::TypedArrayBase>(@js_name@@js_suffix@_object)) {
|
||||
JS::NonnullGCPtr<WebIDL::BufferSource> source_object = vm.heap().allocate<WebIDL::BufferSource>(realm, @js_name@@js_suffix@_object);
|
||||
return JS::make_handle(source_object);
|
||||
}
|
||||
)~~~");
|
||||
}
|
||||
|
||||
// 6. If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then
|
||||
// 1. If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
|
||||
// 2. If types includes object, then return the IDL value that is a reference to the object V.
|
||||
|
|
Loading…
Reference in a new issue