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/val.h>
12#include <wasmtime/store.h>
13#include <wasmtime/extern.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
34
57typedef wasm_trap_t* (*wasmtime_func_callback_t)(
58 void *env,
59 wasmtime_caller_t* caller,
60 const wasmtime_val_t *args,
61 size_t nargs,
62 wasmtime_val_t *results,
63 size_t nresults);
64
81WASM_API_EXTERN void wasmtime_func_new(
82 wasmtime_context_t *store,
83 const wasm_functype_t* type,
85 void *env,
86 void (*finalizer)(void*),
88);
89
123typedef wasm_trap_t* (*wasmtime_func_unchecked_callback_t)(
124 void *env,
125 wasmtime_caller_t* caller,
126 wasmtime_val_raw_t *args_and_results,
127 size_t num_args_and_results);
128
153WASM_API_EXTERN void wasmtime_func_new_unchecked(
154 wasmtime_context_t *store,
155 const wasm_functype_t* type,
157 void *env,
158 void (*finalizer)(void*),
159 wasmtime_func_t *ret
160);
161
168 const wasmtime_context_t *store,
169 const wasmtime_func_t *func
170);
171
208 wasmtime_context_t *store,
209 const wasmtime_func_t *func,
210 const wasmtime_val_t *args,
211 size_t nargs,
212 wasmtime_val_t *results,
213 size_t nresults,
214 wasm_trap_t **trap
215);
216
245 wasmtime_context_t *store,
246 const wasmtime_func_t *func,
247 wasmtime_val_raw_t *args_and_results
248);
249
268WASM_API_EXTERN bool wasmtime_caller_export_get(
269 wasmtime_caller_t *caller,
270 const char *name,
271 size_t name_len,
273);
274
279
293WASM_API_EXTERN void wasmtime_func_from_raw(
294 wasmtime_context_t* context,
295 size_t raw,
296 wasmtime_func_t *ret);
297
302WASM_API_EXTERN size_t wasmtime_func_to_raw(
303 wasmtime_context_t* context,
304 const wasmtime_func_t *func);
305
306#ifdef __cplusplus
307} // extern "C"
308#endif
309
310#endif // WASMTIME_FUNC_H
Definition of wasmtime_extern_t and external items.
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.
size_t 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...
void wasmtime_func_from_raw(wasmtime_context_t *context, size_t raw, wasmtime_func_t *ret)
Converts a raw nonzero funcref value from wasmtime_val_raw_t into a wasmtime_func_t.
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:123
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_trap_t * wasmtime_func_call_unchecked(wasmtime_context_t *store, const wasmtime_func_t *func, wasmtime_val_raw_t *args_and_results)
Call a WebAssembly function in an "unchecked" fashion.
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:123
Representation of a function in Wasmtime.
Definition: extern.h:24
Container for different kinds of wasm values.
Definition: val.h:207
Container for possible wasm values.
Definition: val.h:170