Struct wit_parser::Interface
source · pub struct Interface {
pub name: String,
pub url: Option<String>,
pub docs: Docs,
pub types: Arena<TypeDef>,
pub type_lookup: HashMap<String, TypeId>,
pub functions: Vec<Function>,
pub globals: Vec<Global>,
}
Fields
name: String
url: Option<String>
docs: Docs
types: Arena<TypeDef>
type_lookup: HashMap<String, TypeId>
functions: Vec<Function>
globals: Vec<Global>
Implementations
sourceimpl Interface
impl Interface
sourcepub fn wasm_signature(
&self,
variant: AbiVariant,
func: &Function
) -> WasmSignature
pub fn wasm_signature(
&self,
variant: AbiVariant,
func: &Function
) -> WasmSignature
Get the WebAssembly type signature for this interface function
The first entry returned is the list of parameters and the second entry is the list of results for the wasm function signature.
sourcepub fn call(
&self,
variant: AbiVariant,
lift_lower: LiftLower,
func: &Function,
bindgen: &mut impl Bindgen
)
pub fn call(
&self,
variant: AbiVariant,
lift_lower: LiftLower,
func: &Function,
bindgen: &mut impl Bindgen
)
Generates an abstract sequence of instructions which represents this function being adapted as an imported function.
The instructions here, when executed, will emulate a language with
interface types calling the concrete wasm implementation. The parameters
for the returned instruction sequence are the language’s own
interface-types parameters. One instruction in the instruction stream
will be a Call
which represents calling the actual raw wasm function
signature.
This function is useful, for example, if you’re building a language generator for WASI bindings. This will document how to translate language-specific values into the wasm types to call a WASI function, and it will also automatically convert the results of the WASI function back to a language-specific value.
sourcepub fn guest_export_needs_post_return(&self, func: &Function) -> bool
pub fn guest_export_needs_post_return(&self, func: &Function) -> bool
Returns whether the Function
specified needs a post-return function to
be generated in guest code.
This is used when the return value contains a memory allocation such as a list or a string primarily.
sourcepub fn post_return(&self, func: &Function, bindgen: &mut impl Bindgen)
pub fn post_return(&self, func: &Function, bindgen: &mut impl Bindgen)
Used in a similar manner as the Interface::call
function except is
used to generate the post-return
callback for func
.
This is only intended to be used in guest generators for exported
functions and will primarily generate GuestDeallocate*
instructions,
plus others used as input to those instructions.