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

@@ -1,7 +1,6 @@
package wasm
import (
"context"
"testing"
"github.com/tetratelabs/wazero/api"
@@ -10,7 +9,7 @@ import (
func TestModule_BuildFunctionDefinitions(t *testing.T) {
nopCode := &Code{Body: []byte{OpcodeEnd}}
fn := func(context.Context) {}
fn := func() {}
tests := []struct {
name string
m *Module