Restores ability to define host functions w/o context via reflection (#832)

This restores the ability to leave out the initial context parameter
when defining functions with reflection. This is important because some
projects are porting from a different library to wazero, and all the
alternatives are not contextualized.

For example, this project is porting envoy host functions, and the
original definitions (in mosn) don't have a context parameter. By being
lenient, they can migrate easier.

See 6b813482b6/pkg/proxywasm/wazero/imports_v1.go

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-10-28 12:44:12 -07:00
committed by GitHub
parent 1ac6c06acb
commit d108ce4c43
25 changed files with 115 additions and 69 deletions

View File

@@ -405,7 +405,7 @@ func TestRuntime_InstantiateModuleFromBinary_ErrorOnStart(t *testing.T) {
r := NewRuntime(testCtx)
defer r.Close(testCtx)
start := func(context.Context) {
start := func() {
panic(errors.New("ice cream"))
}