Wasmtime
func.h
Go to the documentation of this file.
1
7#ifndef WASMTIME_FUNC_H
8#define WASMTIME_FUNC_H
9
10#include <wasm.h>
11#include <wasmtime/extern.h>
12#include <wasmtime/store.h>
13#include <wasmtime/val.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
34
57typedef wasm_trap_t *(*wasmtime_func_callback_t)(
58 void *env, wasmtime_caller_t *caller, const wasmtime_val_t *args,
59 size_t nargs, wasmtime_val_t *results, size_t nresults);
60
77WASM_API_EXTERN void wasmtime_func_new(wasmtime_context_t *store,
78 const wasm_functype_t *type,
80 void *env, void (*finalizer)(void *),
81 wasmtime_func_t *ret);
82
116typedef wasm_trap_t *(*wasmtime_func_unchecked_callback_t)(
117 void *env, wasmtime_caller_t *caller, wasmtime_val_raw_t *args_and_results,
118 size_t num_args_and_results);
119
144WASM_API_EXTERN void wasmtime_func_new_unchecked(
145 wasmtime_context_t *store, const wasm_functype_t *type,
146 wasmtime_func_unchecked_callback_t callback, void *env,
147 void (*finalizer)(void *), wasmtime_func_t *ret);
148
154WASM_API_EXTERN wasm_functype_t *
156 const wasmtime_func_t *func);
157
193WASM_API_EXTERN wasmtime_error_t *
195 const wasmtime_val_t *args, size_t nargs,
196 wasmtime_val_t *results, size_t nresults,
197 wasm_trap_t **trap);
198
228WASM_API_EXTERN wasmtime_error_t *
230 const wasmtime_func_t *func,
231 wasmtime_val_raw_t *args_and_results,
232 size_t args_and_results_len, wasm_trap_t **trap);
233
253 const char *name,
254 size_t name_len,
255 wasmtime_extern_t *item);
256
260WASM_API_EXTERN wasmtime_context_t *
262
276WASM_API_EXTERN void wasmtime_func_from_raw(wasmtime_context_t *context,
277 void *raw, wasmtime_func_t *ret);
278
283WASM_API_EXTERN void *wasmtime_func_to_raw(wasmtime_context_t *context,
284 const wasmtime_func_t *func);
285
286#ifdef __cplusplus
287} // extern "C"
288#endif
289
290#endif // WASMTIME_FUNC_H
Definition of wasmtime_extern_t and external items.
void wasmtime_func_from_raw(wasmtime_context_t *context, void *raw, wasmtime_func_t *ret)
Converts a raw nonzero funcref value from wasmtime_val_raw_t into a wasmtime_func_t.
wasmtime_error_t * wasmtime_func_call(wasmtime_context_t *store, const wasmtime_func_t *func, const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results, size_t nresults, wasm_trap_t **trap)
Call a WebAssembly function.
void * wasmtime_func_to_raw(wasmtime_context_t *context, const wasmtime_func_t *func)
Converts a func which belongs to context into a usize parameter that is suitable for insertion into a...
wasmtime_error_t * wasmtime_func_call_unchecked(wasmtime_context_t *store, const wasmtime_func_t *func, wasmtime_val_raw_t *args_and_results, size_t args_and_results_len, wasm_trap_t **trap)
Call a WebAssembly function in an "unchecked" fashion.
void wasmtime_func_new(wasmtime_context_t *store, const wasm_functype_t *type, wasmtime_func_callback_t callback, void *env, void(*finalizer)(void *), wasmtime_func_t *ret)
Creates a new host-defined function.
wasmtime_context_t * wasmtime_caller_context(wasmtime_caller_t *caller)
Returns the store context of the caller object.
wasm_trap_t *(* wasmtime_func_unchecked_callback_t)(void *env, wasmtime_caller_t *caller, wasmtime_val_raw_t *args_and_results, size_t num_args_and_results)
Callback signature for wasmtime_func_new_unchecked.
Definition: func.h:116
bool wasmtime_caller_export_get(wasmtime_caller_t *caller, const char *name, size_t name_len, wasmtime_extern_t *item)
Loads a wasmtime_extern_t from the caller's context.
void wasmtime_func_new_unchecked(wasmtime_context_t *store, const wasm_functype_t *type, wasmtime_func_unchecked_callback_t callback, void *env, void(*finalizer)(void *), wasmtime_func_t *ret)
Creates a new host function in the same manner of wasmtime_func_new, but the function-to-call has no ...
wasm_trap_t *(* wasmtime_func_callback_t)(void *env, wasmtime_caller_t *caller, const wasmtime_val_t *args, size_t nargs, wasmtime_val_t *results, size_t nresults)
Callback signature for wasmtime_func_new.
Definition: func.h:57
wasm_functype_t * wasmtime_func_type(const wasmtime_context_t *store, const wasmtime_func_t *func)
Returns the type of the function specified.
An opaque object representing the type of a function.
Opaque struct representing a wasm trap.
An interior pointer into a wasmtime_store_t which is used as "context" for many functions.
Errors generated by Wasmtime.
Container for different kinds of extern items.
Definition: extern.h:133
Representation of a function in Wasmtime.
Definition: extern.h:25
Container for different kinds of wasm values.
Definition: val.h:441
Container for possible wasm values.
Definition: val.h:372