Represent WebIDL C++ types with a single CppType model that tracks nullability, optional presence, and contained storage. GC-like values now use GC::Ref/GC::Ptr directly, while containers choose "plain", "Root", or "Conservative" container types depending on what they contain. For example, sequence<Element> becomes a RootVector of GC::Ref values, while sequence<SomeDictionary> becomes a ConservativeVector only when the dictionary contains GC-like values. This moves the generated bindings away from wrapping GC values in GC::Root by default. This has broad fallout as the types passed to interfaces for GC objects changes almost fully across the board.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
/*
|
|
* 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 <LibGC/Ptr.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibJS/Runtime/Value.h>
|
|
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
|
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/Bindings/Table.h>
|
|
|
|
namespace Web::WebAssembly {
|
|
|
|
class Table : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(Table, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(Table);
|
|
|
|
public:
|
|
static WebIDL::ExceptionOr<GC::Ref<Table>> construct_impl(JS::Realm&, Bindings::TableDescriptor& descriptor, Optional<JS::Value> value);
|
|
|
|
WebIDL::ExceptionOr<u32> grow(u32 delta, Optional<JS::Value> value);
|
|
|
|
WebIDL::ExceptionOr<JS::Value> get(u32 index) const;
|
|
WebIDL::ExceptionOr<void> set(u32 index, Optional<JS::Value> value);
|
|
|
|
WebIDL::ExceptionOr<u32> length() const;
|
|
|
|
Wasm::TableAddress address() const { return m_address; }
|
|
|
|
private:
|
|
Table(JS::Realm&, Wasm::TableAddress);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
Wasm::TableAddress m_address;
|
|
};
|
|
|
|
}
|