summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-12-13 22:06:33 +0000
committerAndreas Kling <kling@serenityos.org>2021-12-14 09:01:06 +0100
commit976ab23b9c075647bc32d0b7453c30d481d7a661 (patch)
tree59c0ce89bbc8cf6ea595843c3f71507fb5b47c30 /Meta/Lagom
parent841bd680faa1cd79f0f0c41effdfe4819aff41ed (diff)
downloadserenity-976ab23b9c075647bc32d0b7453c30d481d7a661.zip
LibWeb: Add support for the BufferSource IDL parameter type
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
index 8b9f70f1b7..9861f8215d 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp
@@ -1139,6 +1139,14 @@ 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 == "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) {
scoped_generator.append(R"~~~(
@@ -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>