Skip to content

Commit

Permalink
fix: add input_offset
Browse files Browse the repository at this point in the history
  • Loading branch information
G4Vi committed Dec 22, 2023
1 parent fd1af11 commit 7b84046
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions extism_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,21 @@ func TestJsonManifest(t *testing.T) {
}
}

func TestInputOffset(t *testing.T) {
manifest := manifest("input_offset.wasm")

if plugin, ok := plugin(t, manifest); ok {
defer plugin.Close()

input_data := []byte("hello world")
exit, output, err := plugin.Call("input_offset_length", input_data)

if assertCall(t, err, exit) {
assert.Equal(t, len(input_data), int(output[0]))
}
}
}

func BenchmarkInitialize(b *testing.B) {
ctx := context.Background()
cache := wazero.NewCompilationCache()
Expand Down
1 change: 1 addition & 0 deletions host.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ func buildEnvModule(ctx context.Context, rt wazero.Runtime, extism api.Module) (
wrap("input_set", []ValueType{ValueTypeI64, ValueTypeI64}, []ValueType{})
wrap("output_set", []ValueType{ValueTypeI64, ValueTypeI64}, []ValueType{})
wrap("input_length", []ValueType{}, []ValueType{ValueTypeI64})
wrap("input_offset", []ValueType{}, []ValueType{ValueTypeI64})
wrap("output_length", []ValueType{}, []ValueType{ValueTypeI64})
wrap("output_offset", []ValueType{}, []ValueType{ValueTypeI64})
wrap("length", []ValueType{ValueTypeI64}, []ValueType{ValueTypeI64})
Expand Down
Binary file added wasm/input_offset.wasm
Binary file not shown.

0 comments on commit 7b84046

Please sign in to comment.