Skip to content

Commit 8aa9afe

Browse files
pkedyPhil Kedy
and
Phil Kedy
authored
Adding value scalar type and bringing apex config current (#16)
Co-authored-by: Phil Kedy <pkedy@gmail.com>
1 parent a55f514 commit 8aa9afe

File tree

12 files changed

+278
-162
lines changed

12 files changed

+278
-162
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ jobs:
2020

2121
- uses: actions/setup-go@v3
2222
with:
23-
go-version: '1.21'
23+
go-version: '1.24'
2424

2525
- uses: acifani/setup-tinygo@v1
2626
with:
27-
tinygo-version: 0.30.0
27+
tinygo-version: 0.37.0
2828

2929
- name: Install wasm-opt
3030
run: |
@@ -36,12 +36,12 @@ jobs:
3636
3737
- name: Build WebAssembly parser
3838
run: |
39-
tinygo build -o apex-parser.wasm -scheduler=none -target=wasi -no-debug cmd/apex-api/main.go
39+
tinygo build -o apex-parser.wasm -scheduler=none -target=wasip1 -buildmode=c-shared -no-debug cmd/apex-api/main.go
4040
wasm-opt -O apex-parser.wasm -o apex-parser.wasm
4141
4242
- name: Build waPC module
4343
run: |
44-
tinygo build -o apex-wapc.wasm -scheduler=none -target=wasi -no-debug cmd/wapc/main.go
44+
tinygo build -o apex-wapc.wasm -scheduler=none -target=wasip1 -buildmode=c-shared -no-debug cmd/wapc/main.go
4545
wasm-opt -O apex-wapc.wasm -o apex-wapc.wasm
4646
4747
- name: Release

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
all: codegen wasm-cli wasm-api wasm-wapc wasm-host
44

55
wasm-cli:
6-
tinygo build -o apex-cli.wasm -scheduler=none -target=wasi -no-debug cmd/apex-cli/main.go
6+
tinygo build -o apex-cli.wasm -scheduler=none -target=wasip1 -no-debug cmd/apex-cli/main.go
77
wasm-opt -O apex-cli.wasm -o apex-cli.wasm
88

99
wasm-api:
10-
tinygo build -o apex-api.wasm -scheduler=none -target=wasi -no-debug cmd/apex-api/main.go
10+
tinygo build -o apex-api.wasm -scheduler=none -target=wasip1 -buildmode=c-shared -no-debug cmd/apex-api/main.go
1111
wasm-opt -O apex-api.wasm -o apex-api.wasm
1212
cp apex-api.wasm cmd/host/apex-api.wasm
1313

1414
wasm-wapc:
15-
tinygo build -o apex-wapc.wasm -scheduler=none -target=wasi -no-debug cmd/wapc/main.go
15+
tinygo build -o apex-wapc.wasm -scheduler=none -target=wasip1 -buildmode=c-shared -no-debug cmd/wapc/main.go
1616
wasm-opt -O apex-wapc.wasm -o apex-wapc.wasm
1717

1818
wasm-host:

apex.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ config:
44
module: github.com/apexlang/apex-go
55
generates:
66
model/model.go:
7-
module: 'https://deno.land/x/apex_codegen@v0.1.10/go/mod.ts'
7+
module: 'jsr:@apexlang/codegen@^0.2.9/go'
88
visitorClass: InterfacesVisitor
99
config:
1010
writeTypeInfo: false
1111
runAfter:
1212
- command: tinyjson -all model/model.go
1313
model/msgpack.go:
14-
module: 'https://deno.land/x/apex_codegen@v0.1.10/go/mod.ts'
14+
module: 'jsr:@apexlang/codegen@^0.2.9/go'
1515
visitorClass: MsgPackVisitor
1616
model/wapc.go:
17-
module: 'https://deno.land/x/wapc_codegen@v0.0.6/tinygo/mod.ts'
17+
module: 'jsr:@wapc/codegen@^0.1.1/tinygo'
1818
visitorClass: ExportVisitor
1919
cmd/wapc/main.go:
20-
module: 'https://deno.land/x/wapc_codegen@v0.0.6/tinygo/mod.ts'
20+
module: 'jsr:@wapc/codegen@^0.1.1/tinygo'
2121
visitorClass: MainVisitor
2222
config:
2323
import: github.com/apexlang/apex-go/model

cmd/apex-api/main.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,13 @@ import (
2727
"github.com/apexlang/apex-go/rules"
2828
)
2929

30-
// main is required for TinyGo to compile to Wasm.
31-
func main() {}
32-
3330
//go:wasm-module apex
3431
//go:export resolve
35-
func resolve(
32+
func Resolve(
3633
locationPtr uintptr, locationSize uint32,
3734
fromPtr uintptr, fromSize uint32) uint64
3835

39-
//export parse
36+
//go:wasmexport parse
4037
func Parse(ptr uintptr, size uint32) (ptrSize uint64) {
4138
source := tinymem.PtrToString(ptr, size)
4239

@@ -47,7 +44,7 @@ func Parse(ptr uintptr, size uint32) (ptrSize uint64) {
4744
Resolver: func(location, from string) (string, error) {
4845
locationPtr, locationSize := tinymem.StringToPtr(location)
4946
fromPtr, fromSize := tinymem.StringToPtr(from)
50-
ptrsize := resolve(
47+
ptrsize := Resolve(
5148
locationPtr, locationSize,
5249
fromPtr, fromSize)
5350
if ptrsize == 0 {

cmd/wapc/main.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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.3.0
88
github.com/tetratelabs/tinymem v0.1.0
9-
github.com/wapc/tinygo-msgpack v0.1.6
9+
github.com/wapc/tinygo-msgpack v0.1.8
1010
github.com/wapc/wapc-guest-tinygo v0.3.3
1111
)
1212

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ github.com/tetratelabs/tinymem v0.1.0 h1:Qza1JAg9lquPPJ/CIei5qQYx7t18KLie83O2WR6
1414
github.com/tetratelabs/tinymem v0.1.0/go.mod h1:WFFTZFhLod6lTL+UetFAopVbGaB+KFsVcIY+RUv7NeY=
1515
github.com/wapc/tinygo-msgpack v0.1.6 h1:geW3N0MAVehJBZp1ITnK2J1R2woI/S1APJB+tFShO6Y=
1616
github.com/wapc/tinygo-msgpack v0.1.6/go.mod h1:2P4rQimy/6oQAkytwC2LdtVjLJ2D1dYkQHejfCtZXZQ=
17+
github.com/wapc/tinygo-msgpack v0.1.8 h1:KUKeWQ2G/SBVU7EOolTAjFaVWg6oDhAqlD/o1weeyBo=
18+
github.com/wapc/tinygo-msgpack v0.1.8/go.mod h1:u5RU3BuXpvLgefF1DT33saNDgkE9qYeu0PeoE3aGRCs=
1719
github.com/wapc/wapc-guest-tinygo v0.3.3 h1:jLebiwjVSHLGnS+BRabQ6+XOV7oihVWAc05Hf1SbeR0=
1820
github.com/wapc/wapc-guest-tinygo v0.3.3/go.mod h1:mzM3CnsdSYktfPkaBdZ8v88ZlfUDEy5Jh5XBOV3fYcw=
1921
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

model.axdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ enum Scalar {
195195
DATETIME = 14
196196
ANY = 15
197197
RAW = 16
198+
VALUE = 17
198199
}
199200

200201
type Named {

model/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var scalars = map[string]Scalar{
4444
"datetime": ScalarDatetime,
4545
"any": ScalarAny,
4646
"raw": ScalarRaw,
47+
"value": ScalarValue,
4748
}
4849

4950
type Converter struct {

model/model.go

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)