Wasmtime
wasmtime::ExternRef Class Reference

Representation of a WebAssembly externref value. More...

#include <val.hh>

Public Member Functions

 ExternRef (wasmtime_externref_t val)
 Creates a new ExternRef directly from its C-API representation.
 
 ExternRef (const ExternRef &other)
 Copy constructor to clone other.
 
ExternRefoperator= (const ExternRef &other)
 Copy assignment to clone from other.
 
 ExternRef (ExternRef &&other)
 Move constructor to move the contents of other.
 
ExternRefoperator= (ExternRef &&other)
 Move assignment to move the contents of other.
 
 ExternRef (Store::Context cx, std::any val)
 
std::any & data (Store::Context cx)
 Returns the underlying host data associated with this ExternRef.
 
uint32_t take_raw (Store::Context cx)
 
uint32_t borrow_raw (Store::Context cx) const
 Returns wasmtime_externref_to_raw.
 

Friends

class Val
 

Detailed Description

Representation of a WebAssembly externref value.

This class represents an value that cannot be forged by WebAssembly itself. All ExternRef values are guaranteed to be created by the host and its embedding. It's suitable to place private data structures in here which WebAssembly will not have access to, only other host functions will have access to them.

Note that ExternRef values are rooted within a Store and must be manually unrooted via the unroot function. If this is not used then values will never be candidates for garbage collection.

Constructor & Destructor Documentation

◆ ExternRef()

wasmtime::ExternRef::ExternRef ( Store::Context  cx,
std::any  val 
)
inlineexplicit

Creates a new externref value from the provided argument.

Note that val should be safe to send across threads and should own any memory that it points to. Also note that ExternRef is similar to a std::shared_ptr in that there can be many references to the same value.

Member Function Documentation

◆ take_raw()

uint32_t wasmtime::ExternRef::take_raw ( Store::Context  cx)
inline

Consumes ownership of the underlying wasmtime_externref_t and returns the result of wasmtime_externref_to_raw.


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