-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposed extism module and added methods to get exported functions (#79)
- Loading branch information
Showing
3 changed files
with
40 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters