Skip to content

Commit 86ab7d5

Browse files
authored
Upgrading to the latest Apex CLI (#8)
1 parent 59f6f8d commit 86ab7d5

File tree

14 files changed

+233
-347
lines changed

14 files changed

+233
-347
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.wasm
22
test.*
33
/apex-host
4+
go.work.sum

apex.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
spec: model.apexlang
1+
spec: model.axdl
22
config:
33
package: model
44
module: github.com/apexlang/apex-go
55
generates:
66
model/model.go:
7-
module: '@apexlang/codegen/go'
7+
module: https://deno.land/x/apex_codegen@v0.1.6/go/mod.ts
88
visitorClass: InterfacesVisitor
99
config:
1010
writeTypeInfo: false
1111
runAfter:
1212
- command: tinyjson -all model/model.go
1313
model/msgpack.go:
14-
module: '@apexlang/codegen/go'
14+
module: https://deno.land/x/apex_codegen@v0.1.6/go/mod.ts
1515
visitorClass: MsgPackVisitor
16-
model/wapc.go:
17-
module: '@wapc/codegen/tinygo'
18-
visitorClass: ExportVisitor
19-
cmd/wapc/main.go:
20-
module: '@wapc/codegen/tinygo'
21-
visitorClass: MainVisitor
22-
config:
23-
import: github.com/apexlang/apex-go/model
24-
package: model

cmd/host/go.mod

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

55
require (
66
github.com/mitchellh/go-homedir v1.1.0
7-
github.com/tetratelabs/wazero v1.0.0-pre.4
7+
github.com/tetratelabs/wazero v1.0.0-pre.6
88
)

cmd/host/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
22
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
3-
github.com/tetratelabs/wazero v1.0.0-pre.4 h1:RBJQT5OzmORkSp6MmZDWoFEr0zXjk4pmvMKAdeUnsaI=
4-
github.com/tetratelabs/wazero v1.0.0-pre.4/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
3+
github.com/tetratelabs/wazero v1.0.0-pre.6 h1:3DRqjuHazHyZmgWCgqu7nKgYIYNEi2+2RQpCwTqbVHs=
4+
github.com/tetratelabs/wazero v1.0.0-pre.6/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=

cmd/host/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func main() {
8989
bufferPtr := results[0]
9090
defer free.Call(ctx, bufferPtr)
9191

92-
g.Memory().Write(ctx, uint32(bufferPtr), specBytes)
92+
g.Memory().Write(uint32(bufferPtr), specBytes)
9393
results, err = parse.Call(ctx, bufferPtr, specSize)
9494
if err != nil {
9595
panic(err)
@@ -103,7 +103,7 @@ func main() {
103103
size := uint32(ret & 0xFFFFFFFF)
104104
ptr := uint32(ret >> uint64(32))
105105

106-
docBytes, _ := g.Memory().Read(ctx, ptr, size)
106+
docBytes, _ := g.Memory().Read(ptr, size)
107107

108108
fmt.Println(string(docBytes))
109109
}
@@ -112,7 +112,7 @@ type definitions string
112112

113113
// resolve is defined as a reflective func because it isn't used frequently.
114114
func (d definitions) resolve(ctx context.Context, m api.Module, locationPtr, locationLen, fromPtr, fromLen uint32) uint64 {
115-
locationBuf, ok := m.Memory().Read(ctx, locationPtr, locationLen)
115+
locationBuf, ok := m.Memory().Read(locationPtr, locationLen)
116116
if !ok {
117117
returnString(ctx, m, "out of memory")
118118
}
@@ -159,7 +159,7 @@ func returnString(ctx context.Context, m api.Module, value string) uint64 {
159159

160160
ptr := uintptr(results[0])
161161

162-
m.Memory().Write(ctx, uint32(ptr), []byte(value))
162+
m.Memory().Write(uint32(ptr), []byte(value))
163163
ptrSize := (uint64(ptr) << uint64(32)) | uint64(size)
164164
return ptrSize
165165
}

cmd/wapc/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package main
22

33
import (
44
"github.com/apexlang/apex-go/model"
5+
"github.com/apexlang/apex-go/wapc"
56
)
67

78
func main() {
89
// Create providers
9-
resolverProvider := model.NewResolver()
10+
resolverProvider := wapc.NewResolver()
1011

1112
// Create services
1213
parserService := model.NewParser(resolverProvider)
1314

1415
// Register services
15-
model.RegisterParser(parserService)
16+
wapc.RegisterParser(parserService)
1617
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/CosmWasm/tinyjson v0.9.0
77
github.com/iancoleman/strcase v0.2.0
88
github.com/tetratelabs/tinymem v0.1.0
9-
github.com/wapc/tinygo-msgpack v0.1.4
9+
github.com/wapc/tinygo-msgpack v0.1.6
1010
github.com/wapc/wapc-guest-tinygo v0.3.3
1111
)
1212

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
99
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
1010
github.com/tetratelabs/tinymem v0.1.0 h1:Qza1JAg9lquPPJ/CIei5qQYx7t18KLie83O2WR6CM58=
1111
github.com/tetratelabs/tinymem v0.1.0/go.mod h1:WFFTZFhLod6lTL+UetFAopVbGaB+KFsVcIY+RUv7NeY=
12-
github.com/wapc/tinygo-msgpack v0.1.4 h1:oiwtclAGh/A+x024gCFXxey/iNtRmGaE+nvtyAw2vvo=
13-
github.com/wapc/tinygo-msgpack v0.1.4/go.mod h1:2P4rQimy/6oQAkytwC2LdtVjLJ2D1dYkQHejfCtZXZQ=
12+
github.com/wapc/tinygo-msgpack v0.1.6 h1:geW3N0MAVehJBZp1ITnK2J1R2woI/S1APJB+tFShO6Y=
13+
github.com/wapc/tinygo-msgpack v0.1.6/go.mod h1:2P4rQimy/6oQAkytwC2LdtVjLJ2D1dYkQHejfCtZXZQ=
1414
github.com/wapc/wapc-guest-tinygo v0.3.3 h1:jLebiwjVSHLGnS+BRabQ6+XOV7oihVWAc05Hf1SbeR0=
1515
github.com/wapc/wapc-guest-tinygo v0.3.3/go.mod h1:mzM3CnsdSYktfPkaBdZ8v88ZlfUDEy5Jh5XBOV3fYcw=
1616
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
File renamed without changes.

0 commit comments

Comments
 (0)