NewFunc creates a new `Func` with the given `ty` which, when called, will call `f` The `ty` given is the wasm type signature of the `Func` to create. When called the `f` callback receives two arguments. The first is a `Caller` to learn information about the calling context and the second is a list
( store Storelike, ty *FuncType, f func(*Caller, []Val) ([]Val, *Trap), )
| 48 | // If the `f` callback panics then the panic will be propagated to the caller |
| 49 | // as well. |
| 50 | func NewFunc( |
| 51 | store Storelike, |
| 52 | ty *FuncType, |
| 53 | f func(*Caller, []Val) ([]Val, *Trap), |
| 54 | ) *Func { |
| 55 | idx := insertFuncNew(getDataInStore(store), ty, f) |
| 56 | |
| 57 | ret := C.wasmtime_func_t{} |
| 58 | C.go_func_new( |
| 59 | store.Context(), |
| 60 | ty.ptr(), |
| 61 | C.size_t(idx), |
| 62 | 0, |
| 63 | &ret, |
| 64 | ) |
| 65 | runtime.KeepAlive(store) |
| 66 | runtime.KeepAlive(ty) |
| 67 | |
| 68 | return mkFunc(ret) |
| 69 | } |
| 70 | |
| 71 | //export goTrampolineNew |
| 72 | func goTrampolineNew( |
searching dependent graphs…