-
Notifications
You must be signed in to change notification settings - Fork 10
/
module.go
30 lines (25 loc) · 882 Bytes
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package extism
import "github.com/tetratelabs/wazero/api"
// Module is a wrapper around a wazero module. It allows us to provide
// our own API and stability guarantees despite any changes that wazero
// may choose to make.
type Module struct {
inner api.Module
}
// ExportedFunctions returns a map of functions exported from the module
// keyed by the function name.
func (m *Module) ExportedFunctions() map[string]FunctionDefinition {
v := make(map[string]FunctionDefinition)
for name, def := range m.inner.ExportedFunctionDefinitions() {
v[name] = FunctionDefinition{inner: def}
}
return v
}
// FunctionDefinition represents a function defined in a module. It provides
// a wrapper around the underlying wazero function definition.
type FunctionDefinition struct {
inner api.FunctionDefinition
}
func (f *FunctionDefinition) Name() string {
return f.inner.Name()
}