Wasmtime: C++
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
wasmtime::Global Class Reference

A WebAssembly global. More...

#include <wasmtime.hh>

Public Member Functions

 Global (wasmtime_global_t global)
 Creates as global from the raw underlying C API representation.
 
GlobalType type (Store::Context cx) const
 Returns the type of this global.
 
Val get (Store::Context cx) const
 Returns the current value of this global.
 
Result< std::monostate > set (Store::Context cx, const Val &val) const
 

Static Public Member Functions

static Result< Globalcreate (Store::Context cx, const GlobalType &ty, const Val &init)
 Create a new WebAssembly global. More...
 

Detailed Description

A WebAssembly global.

This class represents a WebAssembly global, either created through instantiating a module or a host global. Globals contain a WebAssembly value and can be read and optionally written to.

Note that this type does not itself own any resources. It points to resources owned within a Store and the Store must be passed in as the first argument to the functions defined on Global. Note that if the wrong Store is passed in then the process will be aborted.

Examples
externref.cc.

Member Function Documentation

◆ create()

static Result< Global > wasmtime::Global::create ( Store::Context  cx,
const GlobalType ty,
const Val init 
)
inlinestatic

Create a new WebAssembly global.

Parameters
cxthe store in which to create the global
tythe type that this global will have
initthe initial value of the global

This function can fail if init does not have a value that matches ty.

◆ set()

Result< std::monostate > wasmtime::Global::set ( Store::Context  cx,
const Val val 
) const
inline

Sets this global to a new value.

This can fail if val has the wrong type or if this global isn't mutable.

Examples
externref.cc.

The documentation for this class was generated from the following file: