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.
38 lines
986 B
C++
38 lines
986 B
C++
/*
|
|
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWasm/AbstractMachine/AbstractMachine.h>
|
|
#include <LibWeb/Bindings/ExceptionOrUtils.h>
|
|
#include <LibWeb/Bindings/Global.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
|
|
namespace Web::WebAssembly {
|
|
|
|
class Global : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(Global, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(Global);
|
|
|
|
public:
|
|
static WebIDL::ExceptionOr<GC::Ref<Global>> construct_impl(JS::Realm&, Bindings::GlobalDescriptor const&, Optional<JS::Value>);
|
|
|
|
WebIDL::ExceptionOr<JS::Value> value_of() const;
|
|
|
|
WebIDL::ExceptionOr<void> set_value(JS::Value);
|
|
WebIDL::ExceptionOr<JS::Value> value() const;
|
|
|
|
Wasm::GlobalAddress address() const { return m_address; }
|
|
|
|
private:
|
|
Global(JS::Realm&, Wasm::GlobalAddress);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
Wasm::GlobalAddress m_address;
|
|
};
|
|
|
|
}
|