Skip to content

Commit

Permalink
Upgrading to the latest Apex CLI (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkedy committed Jan 21, 2023
1 parent 59f6f8d commit 86ab7d5
Show file tree
Hide file tree
Showing 14 changed files with 233 additions and 347 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.wasm
test.*
/apex-host
go.work.sum
15 changes: 3 additions & 12 deletions apex.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
spec: model.apexlang
spec: model.axdl
config:
package: model
module: github.com/apexlang/apex-go
generates:
model/model.go:
module: '@apexlang/codegen/go'
module: https://deno.land/x/[email protected]/go/mod.ts
visitorClass: InterfacesVisitor
config:
writeTypeInfo: false
runAfter:
- command: tinyjson -all model/model.go
model/msgpack.go:
module: '@apexlang/codegen/go'
module: https://deno.land/x/[email protected]/go/mod.ts
visitorClass: MsgPackVisitor
model/wapc.go:
module: '@wapc/codegen/tinygo'
visitorClass: ExportVisitor
cmd/wapc/main.go:
module: '@wapc/codegen/tinygo'
visitorClass: MainVisitor
config:
import: github.com/apexlang/apex-go/model
package: model
2 changes: 1 addition & 1 deletion cmd/host/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.19

require (
github.com/mitchellh/go-homedir v1.1.0
github.com/tetratelabs/wazero v1.0.0-pre.4
github.com/tetratelabs/wazero v1.0.0-pre.6
)
4 changes: 2 additions & 2 deletions cmd/host/go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/tetratelabs/wazero v1.0.0-pre.4 h1:RBJQT5OzmORkSp6MmZDWoFEr0zXjk4pmvMKAdeUnsaI=
github.com/tetratelabs/wazero v1.0.0-pre.4/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
github.com/tetratelabs/wazero v1.0.0-pre.6 h1:3DRqjuHazHyZmgWCgqu7nKgYIYNEi2+2RQpCwTqbVHs=
github.com/tetratelabs/wazero v1.0.0-pre.6/go.mod h1:u8wrFmpdrykiFK0DFPiFm5a4+0RzsdmXYVtijBKqUVo=
8 changes: 4 additions & 4 deletions cmd/host/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func main() {
bufferPtr := results[0]
defer free.Call(ctx, bufferPtr)

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

docBytes, _ := g.Memory().Read(ctx, ptr, size)
docBytes, _ := g.Memory().Read(ptr, size)

fmt.Println(string(docBytes))
}
Expand All @@ -112,7 +112,7 @@ type definitions string

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

ptr := uintptr(results[0])

m.Memory().Write(ctx, uint32(ptr), []byte(value))
m.Memory().Write(uint32(ptr), []byte(value))
ptrSize := (uint64(ptr) << uint64(32)) | uint64(size)
return ptrSize
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/wapc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package main

import (
"github.com/apexlang/apex-go/model"
"github.com/apexlang/apex-go/wapc"
)

func main() {
// Create providers
resolverProvider := model.NewResolver()
resolverProvider := wapc.NewResolver()

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

// Register services
model.RegisterParser(parserService)
wapc.RegisterParser(parserService)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/CosmWasm/tinyjson v0.9.0
github.com/iancoleman/strcase v0.2.0
github.com/tetratelabs/tinymem v0.1.0
github.com/wapc/tinygo-msgpack v0.1.4
github.com/wapc/tinygo-msgpack v0.1.6
github.com/wapc/wapc-guest-tinygo v0.3.3
)

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

0 comments on commit 86ab7d5

Please sign in to comment.