mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibWeb: Port WebAssembly.Table to IDL
This commit is contained in:
parent
ca96f8e364
commit
2cfcbccdb5
17 changed files with 230 additions and 357 deletions
50
Userland/Libraries/LibWeb/WebAssembly/Table.h
Normal file
50
Userland/Libraries/LibWeb/WebAssembly/Table.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Optional.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
||||
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Bindings/TablePrototype.h>
|
||||
|
||||
namespace Web::WebAssembly {
|
||||
|
||||
struct TableDescriptor {
|
||||
Bindings::TableKind element;
|
||||
u32 initial { 0 };
|
||||
Optional<u32> maximum;
|
||||
};
|
||||
|
||||
class Table : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(Table, Bindings::PlatformObject);
|
||||
|
||||
public:
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Table>> construct_impl(JS::Realm&, TableDescriptor& descriptor, JS::Value value);
|
||||
|
||||
WebIDL::ExceptionOr<u32> grow(u32 delta, JS::Value value);
|
||||
|
||||
WebIDL::ExceptionOr<JS::Value> get(u32 index) const;
|
||||
WebIDL::ExceptionOr<void> set(u32 index, JS::Value value);
|
||||
|
||||
WebIDL::ExceptionOr<u32> length() const;
|
||||
|
||||
Wasm::TableAddress address() const { return m_address; }
|
||||
|
||||
private:
|
||||
Table(JS::Realm&, Wasm::TableAddress);
|
||||
|
||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||
|
||||
Wasm::TableAddress m_address;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue