mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-26 04:02:27 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
48
Libraries/LibWeb/WebAssembly/Module.cpp
Normal file
48
Libraries/LibWeb/WebAssembly/Module.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/ModulePrototype.h>
|
||||
#include <LibWeb/WebAssembly/Module.h>
|
||||
#include <LibWeb/WebAssembly/WebAssembly.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
#include <LibWeb/WebIDL/Buffers.h>
|
||||
|
||||
namespace Web::WebAssembly {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(Module);
|
||||
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Module>> Module::construct_impl(JS::Realm& realm, JS::Handle<WebIDL::BufferSource>& bytes)
|
||||
{
|
||||
auto& vm = realm.vm();
|
||||
|
||||
auto stable_bytes_or_error = WebIDL::get_buffer_source_copy(bytes->raw_object());
|
||||
if (stable_bytes_or_error.is_error()) {
|
||||
VERIFY(stable_bytes_or_error.error().code() == ENOMEM);
|
||||
return vm.throw_completion<JS::InternalError>(vm.error_message(JS::VM::ErrorMessage::OutOfMemory));
|
||||
}
|
||||
auto stable_bytes = stable_bytes_or_error.release_value();
|
||||
|
||||
auto compiled_module = TRY(Detail::compile_a_webassembly_module(vm, move(stable_bytes)));
|
||||
return vm.heap().allocate<Module>(realm, realm, move(compiled_module));
|
||||
}
|
||||
|
||||
Module::Module(JS::Realm& realm, NonnullRefPtr<Detail::CompiledWebAssemblyModule> compiled_module)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_compiled_module(move(compiled_module))
|
||||
{
|
||||
}
|
||||
|
||||
void Module::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE_WITH_CUSTOM_NAME(Module, WebAssembly.Module);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue