Skip to content

Commit cdb1906

Browse files
authored
deps: updates wazero to 1.0.1
Merge pull request #7 from codefromthecrypt/wazero-1.0.1
2 parents a6000b7 + b207a5b commit cdb1906

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/alecthomas/assert/v2 v2.0.2
7-
github.com/tetratelabs/wazero v1.0.0-pre.4
7+
github.com/tetratelabs/wazero v1.0.1
88
github.com/yeqown/go-qrcode/v2 v2.2.1
99
github.com/yeqown/go-qrcode/writer/standard v1.2.1
1010
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
1414
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
1515
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1616
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
17-
github.com/tetratelabs/wazero v1.0.0-pre.4 h1:RBJQT5OzmORkSp6MmZDWoFEr0zXjk4pmvMKAdeUnsaI=
18-
github.com/tetratelabs/wazero v1.0.0-pre.4/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
17+
github.com/tetratelabs/wazero v1.0.1 h1:xyWBoGyMjYekG3mEQ/W7xm9E05S89kJ/at696d/9yuc=
18+
github.com/tetratelabs/wazero v1.0.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ=
1919
github.com/yeqown/go-qrcode/v2 v2.2.1 h1:Jc1Q916fwC05R8C7mpWDbrT9tyLPaLLKDABoC5XBCe8=
2020
github.com/yeqown/go-qrcode/v2 v2.2.1/go.mod h1:2Qsk2APUCPne0TsRo40DIkI5MYnbzYKCnKGEFWrxd24=
2121
github.com/yeqown/go-qrcode/writer/standard v1.2.1 h1:FMRZiur5yApUIe4fqtqmcdl/XQTZAZWt2DhkPx4VIW0=

scanner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s *Scanner) ReadAll(img image.Image) ([][]byte, error) {
9090
return nil, err
9191
}
9292

93-
data := [][]byte{}
93+
var data [][]byte
9494
symbol, next := s.getSymbols(zbarImg)
9595

9696
for next {
@@ -149,9 +149,9 @@ func (s *Scanner) createImage(i image.Image) img {
149149

150150
switch i := i.(type) {
151151
case *image.Gray:
152-
s.mod.Memory().Write(ctx, buf, i.Pix)
152+
s.mod.Memory().Write(buf, i.Pix)
153153
default:
154-
s.mod.Memory().Write(ctx, buf, toGray(i).Pix)
154+
s.mod.Memory().Write(buf, toGray(i).Pix)
155155
}
156156

157157
var zbarImg img
@@ -224,7 +224,7 @@ type Reader struct {
224224
// Read reads a symbol into b
225225
//
226226
// Make sure not to Call (*Reader).Next() before
227-
// receiving io.EOF. Otherwise, the remaning data
227+
// receiving io.EOF. Otherwise, the remaining data
228228
// will be skipped.
229229
// The reader may return
230230
//

zbar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func newZbarInstance() (wazero.Runtime, api.Module) {
2525
wasi_snapshot_preview1.MustInstantiate(ctx, r)
2626
emscripten.MustInstantiate(ctx, r)
2727

28-
zbar := must(r.InstantiateModuleFromBinary(ctx, zbarWasm))
28+
zbar := must(r.Instantiate(ctx, zbarWasm))
2929
return r, zbar
3030
}
3131

zbar_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func Test_E2E(t *testing.T) {
5151

5252
res, err := zbar.ReadAll(img)
5353
assert.NoError(t, err)
54-
assert.Equal(t, []byte(random), res[0])
54+
assert.Equal(t, random, res[0])
5555

5656
res = [][]byte{{}}
5757
r, err := zbar.Read(img)
@@ -63,6 +63,6 @@ func Test_E2E(t *testing.T) {
6363
}
6464

6565
assert.NoError(t, err)
66-
assert.Equal(t, [][]byte{[]byte(random)}, res)
66+
assert.Equal(t, [][]byte{random}, res)
6767

6868
}

zbar_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ func newSymbol(ptr uint32, zbar api.Module) symbol {
2828

2929
func (s *symbol) read(b []byte, offset uint32) (uint32, bool) {
3030
if offset+uint32(len(b)) < s.len {
31-
b2, _ := s.mod.Memory().Read(ctx, s.data+offset, uint32(len(b)))
31+
b2, _ := s.mod.Memory().Read(s.data+offset, uint32(len(b)))
3232
copy(b, b2)
3333
return uint32(len(b)), true
3434
}
3535

36-
b2, _ := s.mod.Memory().Read(ctx, s.data+offset, s.len-offset)
36+
b2, _ := s.mod.Memory().Read(s.data+offset, s.len-offset)
3737
copy(b, b2)
3838
return s.len - offset, false
3939
}
4040

4141
func (s *symbol) readAll() []byte {
42-
b, ok := s.mod.Memory().Read(ctx, s.data, s.len)
42+
b, ok := s.mod.Memory().Read(s.data, s.len)
4343
if !ok {
4444
return nil
4545
}

0 commit comments

Comments
 (0)