mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Add support for the BufferSource IDL parameter type
This commit is contained in:
parent
841bd680fa
commit
976ab23b9c
Notes:
sideshowbarker
2024-07-17 22:47:59 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/976ab23b9c0 Pull-request: https://github.com/SerenityOS/serenity/pull/11249
1 changed files with 9 additions and 0 deletions
|
@ -1138,6 +1138,14 @@ 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 == "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())))
|
||||
return vm.throw_completion<JS::TypeError>(global_object, JS::ErrorType::NotAnObjectOfType, "@parameter.type.name@");
|
||||
|
||||
// TODO: Should we make this a Variant?
|
||||
auto @cpp_name@ = JS::make_handle(&@js_name@@js_suffix@.as_object());
|
||||
)~~~");
|
||||
} else if (parameter.type->name == "any") {
|
||||
if (!optional) {
|
||||
|
@ -2756,6 +2764,7 @@ void generate_prototype_implementation(IDL::Interface const& interface)
|
|||
generator.append(R"~~~(
|
||||
#include <AK/Function.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/DataView.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/FunctionObject.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
|
Loading…
Reference in a new issue