Skip to content

Commit

Permalink
add array accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Jan 17, 2025
1 parent aedb9fb commit 86965e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
18 changes: 18 additions & 0 deletions debezium.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ func Get(proxyPtr uint32, fieldName string) uint32 {
return envGet(proxyPtr, uint32(uintptr(fieldNamePtr)))
}

// access the elemnt at index of the array
func GetArrayElem(proxyPtr uint32, elementIdx uint32) uint32 {
return envGetArrayElem(proxyPtr, uint32(elementIdx))
}

// returns the dimension of the array
func GetArraySize(proxyPtr uint32) uint32 {
return envGetArraySize(proxyPtr)
}

// materialize the String content referenced
func GetString(proxyPtr uint32) string {
var resultPtr = envGetString(proxyPtr)
Expand Down Expand Up @@ -121,6 +131,14 @@ func envSetBool(valuePtr uint32) uint32
//export get
func envGet(proxyPtr, fieldNamePtr uint32) uint32

//go:wasm-module env
//export get_array_elem
func envGetArrayElem(proxyPtr, elemIdx uint32) uint32

//go:wasm-module env
//export get_array_size
func envGetArraySize(proxyPtr uint32) uint32

//go:wasm-module env
//export get_bool
func envGetBool(proxyPtr uint32) uint32
Expand Down
10 changes: 10 additions & 0 deletions it/debezium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ func wazeroStub(ctx context.Context) wazero.Runtime {
return 14
}).
Export("is_null").
NewFunctionBuilder().
WithFunc(func(v1, v2 uint32) uint32 {
return 15
}).
Export("get_array_elem").
NewFunctionBuilder().
WithFunc(func(v uint32) uint32 {
return 16
}).
Export("get_array_size").
Instantiate(ctx)

if err != nil {
Expand Down

0 comments on commit 86965e5

Please sign in to comment.