MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / Define

Method Define

linker.go:59–80  ·  view source on GitHub ↗

Define defines a new item in this linker with the given module/name pair. Returns an error if shadowing is disallowed and the module/name is already defined.

(store Storelike, module, name string, item AsExtern)

Source from the content-addressed store, hash-verified

57// Define defines a new item in this linker with the given module/name pair. Returns
58// an error if shadowing is disallowed and the module/name is already defined.
59func (l *Linker) Define(store Storelike, module, name string, item AsExtern) error {
60 extern := item.AsExtern()
61 err := C.wasmtime_linker_define(
62 l.ptr(),
63 store.Context(),
64 C._GoStringPtr(module),
65 C._GoStringLen(module),
66 C._GoStringPtr(name),
67 C._GoStringLen(name),
68 &extern,
69 )
70 runtime.KeepAlive(l)
71 runtime.KeepAlive(module)
72 runtime.KeepAlive(name)
73 runtime.KeepAlive(item)
74 runtime.KeepAlive(store)
75 if err == nil {
76 return nil
77 }
78
79 return mkError(err)
80}
81
82// DefineFunc acts as a convenience wrapper to calling Define and WrapFunc.
83//

Callers 3

TestLinkerFunction · 0.95
TestLinkerShadowingFunction · 0.95
DefineFuncMethod · 0.95

Calls 4

ptrMethod · 0.95
mkErrorFunction · 0.85
AsExternMethod · 0.65
ContextMethod · 0.65

Tested by 2

TestLinkerFunction · 0.76
TestLinkerShadowingFunction · 0.76