Skip to content

Commit a55f514

Browse files
authored
Union members & version bumps (#15)
1 parent ac88d3b commit a55f514

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+747
-466
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 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.20'
23+
go-version: '1.21'
2424

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

2929
- name: Install wasm-opt
3030
run: |

apex.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ config:
44
module: github.com/apexlang/apex-go
55
generates:
66
model/model.go:
7-
module: 'https://deno.land/x/apex_codegen@v0.1.9/go/mod.ts'
7+
module: 'https://deno.land/x/apex_codegen@v0.1.10/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: 'https://deno.land/x/apex_codegen@v0.1.9/go/mod.ts'
14+
module: 'https://deno.land/x/apex_codegen@v0.1.10/go/mod.ts'
1515
visitorClass: MsgPackVisitor
1616
model/wapc.go:
1717
module: 'https://deno.land/x/wapc_codegen@v0.0.6/tinygo/mod.ts'

ast/definitions.go

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -317,16 +317,16 @@ type UnionDefinition struct {
317317
Name *Name `json:"name"`
318318
Description *StringValue `json:"description,omitempty"` // Optional
319319
AnnotatedNode
320-
Types []Type `json:"types"`
320+
Members []*UnionMemberDefinition `json:"types"`
321321
}
322322

323-
func NewUnionDefinition(loc *Location, name *Name, description *StringValue, annotations []*Annotation, types []Type) *UnionDefinition {
323+
func NewUnionDefinition(loc *Location, name *Name, description *StringValue, annotations []*Annotation, members []*UnionMemberDefinition) *UnionDefinition {
324324
return &UnionDefinition{
325325
BaseNode: BaseNode{kinds.UnionDefinition, loc},
326326
Name: name,
327327
Description: description,
328328
AnnotatedNode: AnnotatedNode{annotations},
329-
Types: types,
329+
Members: members,
330330
}
331331
}
332332

@@ -335,6 +335,30 @@ func (d *UnionDefinition) Accept(context Context, visitor Visitor) {
335335
VisitAnnotations(context, visitor, d.Annotations)
336336
}
337337

338+
// UnionMemberDefinition implements Node, Definition
339+
var _ Definition = (*UnionMemberDefinition)(nil)
340+
341+
type UnionMemberDefinition struct {
342+
BaseNode
343+
Description *StringValue `json:"description,omitempty"` // Optional
344+
Type Type `json:"type"`
345+
AnnotatedNode
346+
}
347+
348+
func NewUnionMemberDefinition(loc *Location, description *StringValue, t Type, annotations []*Annotation) *UnionMemberDefinition {
349+
return &UnionMemberDefinition{
350+
BaseNode: BaseNode{kinds.EnumValueDefinition, loc},
351+
Description: description,
352+
Type: t,
353+
AnnotatedNode: AnnotatedNode{annotations},
354+
}
355+
}
356+
357+
func (d *UnionMemberDefinition) Accept(context Context, visitor Visitor) {
358+
visitor.VisitUnionMember(context)
359+
VisitAnnotations(context, visitor, d.Annotations)
360+
}
361+
338362
// EnumDefinition implements Node, Definition
339363
var _ Definition = (*EnumDefinition)(nil)
340364

ast/document.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

ast/location.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

ast/nodes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

ast/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

ast/values.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

ast/visitor.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -164,6 +164,9 @@ type Visitor interface {
164164

165165
VisitUnionsBefore(context Context)
166166
VisitUnion(context Context)
167+
VisitUnionMembersBefore(context Context)
168+
VisitUnionMember(context Context)
169+
VisitUnionMembersAfter(context Context)
167170
VisitUnionsAfter(context Context)
168171

169172
VisitAnnotationsBefore(context Context)
@@ -243,9 +246,12 @@ func (b *BaseVisitor) VisitEnumValuesAfter(context Context) {}
243246
func (b *BaseVisitor) VisitEnumAfter(context Context) {}
244247
func (b *BaseVisitor) VisitEnumsAfter(context Context) {}
245248

246-
func (b *BaseVisitor) VisitUnionsBefore(context Context) {}
247-
func (b *BaseVisitor) VisitUnion(context Context) {}
248-
func (b *BaseVisitor) VisitUnionsAfter(context Context) {}
249+
func (b *BaseVisitor) VisitUnionsBefore(context Context) {}
250+
func (b *BaseVisitor) VisitUnion(context Context) {}
251+
func (b *BaseVisitor) VisitUnionMembersBefore(context Context) {}
252+
func (b *BaseVisitor) VisitUnionMember(context Context) {}
253+
func (b *BaseVisitor) VisitUnionMembersAfter(context Context) {}
254+
func (b *BaseVisitor) VisitUnionsAfter(context Context) {}
249255

250256
func (b *BaseVisitor) VisitAnnotationsBefore(context Context) {}
251257
func (b *BaseVisitor) VisitAnnotationBefore(context Context) {}
@@ -451,6 +457,15 @@ func (m *MultiVisitor) VisitUnionsBefore(context Context) {
451457
func (m *MultiVisitor) VisitUnion(context Context) {
452458
m.visit(func(v Visitor) { v.VisitUnionsBefore(context) })
453459
}
460+
func (m *MultiVisitor) VisitUnionMembersBefore(context Context) {
461+
m.visit(func(v Visitor) { v.VisitUnionMembersBefore(context) })
462+
}
463+
func (m *MultiVisitor) VisitUnionMember(context Context) {
464+
m.visit(func(v Visitor) { v.VisitUnionMember(context) })
465+
}
466+
func (m *MultiVisitor) VisitUnionMembersAfter(context Context) {
467+
m.visit(func(v Visitor) { v.VisitUnionMembersAfter(context) })
468+
}
454469
func (m *MultiVisitor) VisitUnionsAfter(context Context) {
455470
m.visit(func(v Visitor) { v.VisitUnionsAfter(context) })
456471
}

cmd/apex-api/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2022 The Apex Authors.
2+
Copyright 2024 The Apex Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)