/* * Copyright (c) 2021-2023, Luke Wilde * Copyright (c) 2021-2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace Web::WebIDL { ErrorOr get_buffer_source_copy(JS::Object const& buffer_source); JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, DeprecatedString const& operation_name, Optional this_argument, JS::MarkedVector args); // https://webidl.spec.whatwg.org/#call-a-user-objects-operation template JS::Completion call_user_object_operation(WebIDL::CallbackType& callback, DeprecatedString const& operation_name, Optional this_argument, Args&&... args) { auto& function_object = callback.callback; JS::MarkedVector arguments_list { function_object->heap() }; (arguments_list.append(forward(args)), ...); return call_user_object_operation(callback, operation_name, move(this_argument), move(arguments_list)); } JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional this_argument, JS::MarkedVector args); // https://webidl.spec.whatwg.org/#invoke-a-callback-function template JS::Completion invoke_callback(WebIDL::CallbackType& callback, Optional this_argument, Args&&... args) { auto& function_object = callback.callback; JS::MarkedVector arguments_list { function_object->heap() }; (arguments_list.append(forward(args)), ...); return invoke_callback(callback, move(this_argument), move(arguments_list)); } JS::Completion construct(WebIDL::CallbackType& callback, JS::MarkedVector args); // https://webidl.spec.whatwg.org/#construct-a-callback-function template JS::Completion construct(WebIDL::CallbackType& callback, Args&&... args) { auto& function_object = callback.callback; JS::MarkedVector arguments_list { function_object->heap() }; (arguments_list.append(forward(args)), ...); return construct(callback, move(arguments_list)); } }