/* * Copyright (c) 2021, Ali Mohammad Pur * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Web::WebAssembly { struct TableDescriptor { Bindings::TableKind element; u32 initial { 0 }; Optional maximum; }; class Table : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(Table, Bindings::PlatformObject); public: static WebIDL::ExceptionOr> construct_impl(JS::Realm&, TableDescriptor& descriptor, JS::Value value); WebIDL::ExceptionOr grow(u32 delta, JS::Value value); WebIDL::ExceptionOr get(u32 index) const; WebIDL::ExceptionOr set(u32 index, JS::Value value); WebIDL::ExceptionOr length() const; Wasm::TableAddress address() const { return m_address; } private: Table(JS::Realm&, Wasm::TableAddress); virtual JS::ThrowCompletionOr initialize(JS::Realm&) override; Wasm::TableAddress m_address; }; }