diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2f0f2d3..df1fbab 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,7 +21,7 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '1.19' - + - uses: acifani/setup-tinygo@v1 with: tinygo-version: 0.25.0 @@ -29,7 +29,7 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '1.19' - + - name: Install wasm-opt run: | wget https://github.com/WebAssembly/binaryen/releases/download/version_110/binaryen-version_110-x86_64-linux.tar.gz @@ -37,25 +37,34 @@ jobs: rm -rf binaryen-version_110-x86_64-linux.tar.gz cp binaryen-version_110/bin/wasm-opt /usr/local/bin rm -Rf binaryen-version_110 - + - name: Install tinyjson run: go install github.com/CosmWasm/tinyjson/...@latest - name: Install Apex CLI - run: wget -q https://apexlang.io/install.sh -O - | /bin/bash + run: | + wget -q https://apexlang.io/install.sh -O - | /bin/bash + apex install @wapc/codegen - name: Apex code generation run: apex generate - + - name: Build WebAssembly parser run: | tinygo build -o apex-parser.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/apex-api/main.go wasm-opt -O apex-parser.wasm -o apex-parser.wasm + - name: Build waPC module + run: | + tinygo build -o apex-wapc.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/wapc/main.go + wasm-opt -O apex-wapc.wasm -o apex-wapc.wasm + - name: Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | apex-parser.wasm + apex-wapc.wasm + model.apexlang LICENSE.txt diff --git a/Makefile b/Makefile index ee4a9e0..0046293 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -.PHONY: all wasm-cli wasm-api codegen +.PHONY: all wasm-cli wasm-api wasm-wapc wasm-host codegen -all: codegen wasm-cli wasm-api wasm-host +all: codegen wasm-cli wasm-api wasm-wapc wasm-host wasm-cli: tinygo build -o apex-cli.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/apex-cli/main.go @@ -11,6 +11,10 @@ wasm-api: wasm-opt -O apex-api.wasm -o apex-api.wasm cp apex-api.wasm cmd/host/apex-api.wasm +wasm-wapc: + tinygo build -o apex-wapc.wasm -scheduler=none -target=wasi -wasm-abi=generic -no-debug cmd/wapc/main.go + wasm-opt -O apex-wapc.wasm -o apex-wapc.wasm + wasm-host: go build -o apex-host cmd/host/main.go diff --git a/apex.yaml b/apex.yaml index 3b39c97..cbf9411 100644 --- a/apex.yaml +++ b/apex.yaml @@ -1,7 +1,7 @@ spec: model.apexlang config: package: model - module: github.com/apexlang/apex-wasm + module: github.com/apexlang/apex-go generates: model/model.go: module: '@apexlang/codegen/go' @@ -10,3 +10,15 @@ generates: writeTypeInfo: false runAfter: - command: tinyjson -all model/model.go + model/msgpack.go: + module: '@apexlang/codegen/go' + 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 diff --git a/cmd/wapc/main.go b/cmd/wapc/main.go new file mode 100644 index 0000000..307fea6 --- /dev/null +++ b/cmd/wapc/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "github.com/apexlang/apex-go/model" +) + +func main() { + // Create providers + resolverProvider := model.NewResolver() + + // Create services + parserService := model.NewParser(resolverProvider) + + // Register services + model.RegisterParser(parserService) +} diff --git a/go.mod b/go.mod index 5c878f5..c239f9a 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,8 @@ 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/wapc-guest-tinygo v0.3.3 ) require github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index ebca925..9db748e 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,16 @@ github.com/apexlang/tinyjson v0.9.1-0.20220929010544-92ef7a6da107 h1:GljFiJysL3S8SBhXWU47Emj34D3pVZgJ+Amj+jhM4fQ= github.com/apexlang/tinyjson v0.9.1-0.20220929010544-92ef7a6da107/go.mod h1:5+7QnSKrkIWnpIdhUT2t2EYzXnII3/3MlM0oDsBSbc8= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +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/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= diff --git a/model.apexlang b/model.apexlang index 0637a37..7c0db5a 100644 --- a/model.apexlang +++ b/model.apexlang @@ -1,5 +1,29 @@ namespace "apexlang.v1" +interface Parser @service @uses([Resolver]) { + parse(source: string): ParserResult +} + +interface Resolver @dependency { + resolve(location: string, from: string): string +} + +type ParserResult { + namespace: Namespace? + errors: [Error]? +} + +type Error { + message: string + positions: [u32] + locations: [Location] +} + +type Location { + line: u32 + column: u32 +} + "Namespace encapsulates is used to identify and refer to elements contained in the Apex specification." type Namespace { name: string @quoted diff --git a/model/model.go b/model/model.go index 9acce3b..9478147 100644 --- a/model/model.go +++ b/model/model.go @@ -3,6 +3,7 @@ package model import ( + "context" "encoding/json" "fmt" ) @@ -13,6 +14,33 @@ func (n *ns) Namespace() string { return "apexlang.v1" } +type Parser interface { + Parse(ctx context.Context, source string) (*ParserResult, error) +} + +type Resolver interface { + Resolve(ctx context.Context, location string, from string) (string, error) +} + +type ParserResult struct { + ns + Namespace *Namespace `json:"namespace,omitempty" yaml:"namespace,omitempty" msgpack:"namespace,omitempty"` + Errors []Error `json:"errors,omitempty" yaml:"errors,omitempty" msgpack:"errors,omitempty"` +} + +type Error struct { + ns + Message string `json:"message" yaml:"message" msgpack:"message"` + Positions []uint32 `json:"positions" yaml:"positions" msgpack:"positions"` + Locations []Location `json:"locations" yaml:"locations" msgpack:"locations"` +} + +type Location struct { + ns + Line uint32 `json:"line" yaml:"line" msgpack:"line"` + Column uint32 `json:"column" yaml:"column" msgpack:"column"` +} + // Namespace encapsulates is used to identify and refer to elements contained in // the Apex specification. type Namespace struct { diff --git a/model/model_tinyjson.go b/model/model_tinyjson.go index 6a6e18a..85ec3a3 100644 --- a/model/model_tinyjson.go +++ b/model/model_tinyjson.go @@ -892,7 +892,124 @@ func (v *Reference) UnmarshalJSON(data []byte) error { func (v *Reference) UnmarshalTinyJSON(l *jlexer.Lexer) { tinyjson85aaecc5DecodeGithubComApexlangApexGoModel6(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(in *jlexer.Lexer, out *Parameter) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(in *jlexer.Lexer, out *ParserResult) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "namespace": + if in.IsNull() { + in.Skip() + out.Namespace = nil + } else { + if out.Namespace == nil { + out.Namespace = new(Namespace) + } + (*out.Namespace).UnmarshalTinyJSON(in) + } + case "errors": + if in.IsNull() { + in.Skip() + out.Errors = nil + } else { + in.Delim('[') + if out.Errors == nil { + if !in.IsDelim(']') { + out.Errors = make([]Error, 0, 1) + } else { + out.Errors = []Error{} + } + } else { + out.Errors = (out.Errors)[:0] + } + for !in.IsDelim(']') { + var v13 Error + (v13).UnmarshalTinyJSON(in) + out.Errors = append(out.Errors, v13) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(out *jwriter.Writer, in ParserResult) { + out.RawByte('{') + first := true + _ = first + if in.Namespace != nil { + const prefix string = ",\"namespace\":" + first = false + out.RawString(prefix[1:]) + (*in.Namespace).MarshalTinyJSON(out) + } + if len(in.Errors) != 0 { + const prefix string = ",\"errors\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + { + out.RawByte('[') + for v14, v15 := range in.Errors { + if v14 > 0 { + out.RawByte(',') + } + (v15).MarshalTinyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v ParserResult) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalTinyJSON supports tinyjson.Marshaler interface +func (v ParserResult) MarshalTinyJSON(w *jwriter.Writer) { + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *ParserResult) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(&r, v) + return r.Error() +} + +// UnmarshalTinyJSON supports tinyjson.Unmarshaler interface +func (v *ParserResult) UnmarshalTinyJSON(l *jlexer.Lexer) { + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(l, v) +} +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(in *jlexer.Lexer, out *Parameter) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -951,9 +1068,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(in *jlexer.Lexer, out * out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v13 Annotation - (v13).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v13) + var v16 Annotation + (v16).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v16) in.WantComma() } in.Delim(']') @@ -968,7 +1085,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(in *jlexer.Lexer, out * in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(out *jwriter.Writer, in Parameter) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(out *jwriter.Writer, in Parameter) { out.RawByte('{') first := true _ = first @@ -997,11 +1114,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(out *jwriter.Writer, in out.RawString(prefix) { out.RawByte('[') - for v14, v15 := range in.Annotations { - if v14 > 0 { + for v17, v18 := range in.Annotations { + if v17 > 0 { out.RawByte(',') } - (v15).MarshalTinyJSON(out) + (v18).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1012,27 +1129,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v Parameter) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Parameter) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel7(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Parameter) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Parameter) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel7(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(in *jlexer.Lexer, out *Optional) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(in *jlexer.Lexer, out *Optional) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1063,7 +1180,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(in *jlexer.Lexer, out * in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(out *jwriter.Writer, in Optional) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(out *jwriter.Writer, in Optional) { out.RawByte('{') first := true _ = first @@ -1078,27 +1195,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v Optional) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Optional) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel8(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Optional) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Optional) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel8(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(in *jlexer.Lexer, out *Operation) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(in *jlexer.Lexer, out *Operation) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1145,9 +1262,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(in *jlexer.Lexer, out * out.Parameters = (out.Parameters)[:0] } for !in.IsDelim(']') { - var v16 Parameter - (v16).UnmarshalTinyJSON(in) - out.Parameters = append(out.Parameters, v16) + var v19 Parameter + (v19).UnmarshalTinyJSON(in) + out.Parameters = append(out.Parameters, v19) in.WantComma() } in.Delim(']') @@ -1188,9 +1305,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(in *jlexer.Lexer, out * out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v17 Annotation - (v17).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v17) + var v20 Annotation + (v20).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v20) in.WantComma() } in.Delim(']') @@ -1205,7 +1322,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(in *jlexer.Lexer, out * in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(out *jwriter.Writer, in Operation) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(out *jwriter.Writer, in Operation) { out.RawByte('{') first := true _ = first @@ -1224,11 +1341,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(out *jwriter.Writer, in out.RawString(prefix) { out.RawByte('[') - for v18, v19 := range in.Parameters { - if v18 > 0 { + for v21, v22 := range in.Parameters { + if v21 > 0 { out.RawByte(',') } - (v19).MarshalTinyJSON(out) + (v22).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1248,11 +1365,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(out *jwriter.Writer, in out.RawString(prefix) { out.RawByte('[') - for v20, v21 := range in.Annotations { - if v20 > 0 { + for v23, v24 := range in.Annotations { + if v23 > 0 { out.RawByte(',') } - (v21).MarshalTinyJSON(out) + (v24).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1263,27 +1380,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(out *jwriter.Writer, in // MarshalJSON supports json.Marshaler interface func (v Operation) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Operation) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel9(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Operation) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Operation) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel9(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(in *jlexer.Lexer, out *ObjectValue) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(in *jlexer.Lexer, out *ObjectValue) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1318,9 +1435,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(in *jlexer.Lexer, out out.Fields = (out.Fields)[:0] } for !in.IsDelim(']') { - var v22 ObjectField - (v22).UnmarshalTinyJSON(in) - out.Fields = append(out.Fields, v22) + var v25 ObjectField + (v25).UnmarshalTinyJSON(in) + out.Fields = append(out.Fields, v25) in.WantComma() } in.Delim(']') @@ -1335,7 +1452,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(out *jwriter.Writer, in ObjectValue) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(out *jwriter.Writer, in ObjectValue) { out.RawByte('{') first := true _ = first @@ -1346,11 +1463,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v23, v24 := range in.Fields { - if v23 > 0 { + for v26, v27 := range in.Fields { + if v26 > 0 { out.RawByte(',') } - (v24).MarshalTinyJSON(out) + (v27).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1361,27 +1478,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v ObjectValue) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v ObjectValue) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel10(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ObjectValue) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *ObjectValue) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel10(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(in *jlexer.Lexer, out *ObjectField) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out *ObjectField) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1414,7 +1531,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(out *jwriter.Writer, in ObjectField) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, in ObjectField) { out.RawByte('{') first := true _ = first @@ -1434,27 +1551,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v ObjectField) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v ObjectField) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel11(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ObjectField) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *ObjectField) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel11(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out *Namespace) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(in *jlexer.Lexer, out *Namespace) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1501,9 +1618,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v25 Annotation - (v25).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v25) + var v28 Annotation + (v28).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v28) in.WantComma() } in.Delim(']') @@ -1524,9 +1641,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Imports = (out.Imports)[:0] } for !in.IsDelim(']') { - var v26 Import - (v26).UnmarshalTinyJSON(in) - out.Imports = append(out.Imports, v26) + var v29 Import + (v29).UnmarshalTinyJSON(in) + out.Imports = append(out.Imports, v29) in.WantComma() } in.Delim(']') @@ -1547,9 +1664,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Directives = (out.Directives)[:0] } for !in.IsDelim(']') { - var v27 Directive - (v27).UnmarshalTinyJSON(in) - out.Directives = append(out.Directives, v27) + var v30 Directive + (v30).UnmarshalTinyJSON(in) + out.Directives = append(out.Directives, v30) in.WantComma() } in.Delim(']') @@ -1570,9 +1687,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Aliases = (out.Aliases)[:0] } for !in.IsDelim(']') { - var v28 Alias - (v28).UnmarshalTinyJSON(in) - out.Aliases = append(out.Aliases, v28) + var v31 Alias + (v31).UnmarshalTinyJSON(in) + out.Aliases = append(out.Aliases, v31) in.WantComma() } in.Delim(']') @@ -1593,9 +1710,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Functions = (out.Functions)[:0] } for !in.IsDelim(']') { - var v29 Operation - (v29).UnmarshalTinyJSON(in) - out.Functions = append(out.Functions, v29) + var v32 Operation + (v32).UnmarshalTinyJSON(in) + out.Functions = append(out.Functions, v32) in.WantComma() } in.Delim(']') @@ -1616,9 +1733,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Interfaces = (out.Interfaces)[:0] } for !in.IsDelim(']') { - var v30 Interface - (v30).UnmarshalTinyJSON(in) - out.Interfaces = append(out.Interfaces, v30) + var v33 Interface + (v33).UnmarshalTinyJSON(in) + out.Interfaces = append(out.Interfaces, v33) in.WantComma() } in.Delim(']') @@ -1639,9 +1756,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Types = (out.Types)[:0] } for !in.IsDelim(']') { - var v31 Type - (v31).UnmarshalTinyJSON(in) - out.Types = append(out.Types, v31) + var v34 Type + (v34).UnmarshalTinyJSON(in) + out.Types = append(out.Types, v34) in.WantComma() } in.Delim(']') @@ -1662,9 +1779,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out out.Unions = (out.Unions)[:0] } for !in.IsDelim(']') { - var v32 Union - (v32).UnmarshalTinyJSON(in) - out.Unions = append(out.Unions, v32) + var v35 Union + (v35).UnmarshalTinyJSON(in) + out.Unions = append(out.Unions, v35) in.WantComma() } in.Delim(']') @@ -1679,7 +1796,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, in Namespace) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(out *jwriter.Writer, in Namespace) { out.RawByte('{') first := true _ = first @@ -1698,11 +1815,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v33, v34 := range in.Annotations { - if v33 > 0 { + for v36, v37 := range in.Annotations { + if v36 > 0 { out.RawByte(',') } - (v34).MarshalTinyJSON(out) + (v37).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1712,11 +1829,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v35, v36 := range in.Imports { - if v35 > 0 { + for v38, v39 := range in.Imports { + if v38 > 0 { out.RawByte(',') } - (v36).MarshalTinyJSON(out) + (v39).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1726,11 +1843,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v37, v38 := range in.Directives { - if v37 > 0 { + for v40, v41 := range in.Directives { + if v40 > 0 { out.RawByte(',') } - (v38).MarshalTinyJSON(out) + (v41).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1740,11 +1857,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v39, v40 := range in.Aliases { - if v39 > 0 { + for v42, v43 := range in.Aliases { + if v42 > 0 { out.RawByte(',') } - (v40).MarshalTinyJSON(out) + (v43).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1754,11 +1871,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v41, v42 := range in.Functions { - if v41 > 0 { + for v44, v45 := range in.Functions { + if v44 > 0 { out.RawByte(',') } - (v42).MarshalTinyJSON(out) + (v45).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1768,11 +1885,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v43, v44 := range in.Interfaces { - if v43 > 0 { + for v46, v47 := range in.Interfaces { + if v46 > 0 { out.RawByte(',') } - (v44).MarshalTinyJSON(out) + (v47).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1782,11 +1899,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v45, v46 := range in.Types { - if v45 > 0 { + for v48, v49 := range in.Types { + if v48 > 0 { out.RawByte(',') } - (v46).MarshalTinyJSON(out) + (v49).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1796,11 +1913,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v47, v48 := range in.Unions { - if v47 > 0 { + for v50, v51 := range in.Unions { + if v50 > 0 { out.RawByte(',') } - (v48).MarshalTinyJSON(out) + (v51).MarshalTinyJSON(out) } out.RawByte(']') } @@ -1811,27 +1928,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Namespace) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Namespace) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel12(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Namespace) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Namespace) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel12(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(in *jlexer.Lexer, out *Named) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(in *jlexer.Lexer, out *Named) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1866,7 +1983,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(out *jwriter.Writer, in Named) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(out *jwriter.Writer, in Named) { out.RawByte('{') first := true _ = first @@ -1886,27 +2003,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Named) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Named) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel13(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Named) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Named) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel13(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(in *jlexer.Lexer, out *Map) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(in *jlexer.Lexer, out *Map) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -1939,7 +2056,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(out *jwriter.Writer, in Map) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(out *jwriter.Writer, in Map) { out.RawByte('{') first := true _ = first @@ -1959,27 +2076,100 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Map) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Map) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel14(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Map) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Map) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel14(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(l, v) +} +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(in *jlexer.Lexer, out *Location) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "line": + out.Line = uint32(in.Uint32()) + case "column": + out.Column = uint32(in.Uint32()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(out *jwriter.Writer, in Location) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"line\":" + out.RawString(prefix[1:]) + out.Uint32(uint32(in.Line)) + } + { + const prefix string = ",\"column\":" + out.RawString(prefix) + out.Uint32(uint32(in.Column)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Location) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalTinyJSON supports tinyjson.Marshaler interface +func (v Location) MarshalTinyJSON(w *jwriter.Writer) { + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(w, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(in *jlexer.Lexer, out *ListValue) { + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Location) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(&r, v) + return r.Error() +} + +// UnmarshalTinyJSON supports tinyjson.Unmarshaler interface +func (v *Location) UnmarshalTinyJSON(l *jlexer.Lexer) { + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(l, v) +} +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(in *jlexer.Lexer, out *ListValue) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2014,9 +2204,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(in *jlexer.Lexer, out out.Values = (out.Values)[:0] } for !in.IsDelim(']') { - var v49 Value - (v49).UnmarshalTinyJSON(in) - out.Values = append(out.Values, v49) + var v52 Value + (v52).UnmarshalTinyJSON(in) + out.Values = append(out.Values, v52) in.WantComma() } in.Delim(']') @@ -2031,7 +2221,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(out *jwriter.Writer, in ListValue) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(out *jwriter.Writer, in ListValue) { out.RawByte('{') first := true _ = first @@ -2042,11 +2232,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v50, v51 := range in.Values { - if v50 > 0 { + for v53, v54 := range in.Values { + if v53 > 0 { out.RawByte(',') } - (v51).MarshalTinyJSON(out) + (v54).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2057,27 +2247,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v ListValue) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v ListValue) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel15(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ListValue) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *ListValue) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel15(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(in *jlexer.Lexer, out *List) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(in *jlexer.Lexer, out *List) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2108,7 +2298,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(out *jwriter.Writer, in List) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(out *jwriter.Writer, in List) { out.RawByte('{') first := true _ = first @@ -2123,27 +2313,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v List) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v List) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel16(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *List) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *List) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel16(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(in *jlexer.Lexer, out *Interface) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(in *jlexer.Lexer, out *Interface) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2190,9 +2380,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(in *jlexer.Lexer, out out.Operations = (out.Operations)[:0] } for !in.IsDelim(']') { - var v52 Operation - (v52).UnmarshalTinyJSON(in) - out.Operations = append(out.Operations, v52) + var v55 Operation + (v55).UnmarshalTinyJSON(in) + out.Operations = append(out.Operations, v55) in.WantComma() } in.Delim(']') @@ -2213,9 +2403,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v53 Annotation - (v53).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v53) + var v56 Annotation + (v56).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v56) in.WantComma() } in.Delim(']') @@ -2230,7 +2420,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(out *jwriter.Writer, in Interface) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(out *jwriter.Writer, in Interface) { out.RawByte('{') first := true _ = first @@ -2251,11 +2441,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v54, v55 := range in.Operations { - if v54 > 0 { + for v57, v58 := range in.Operations { + if v57 > 0 { out.RawByte(',') } - (v55).MarshalTinyJSON(out) + (v58).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2265,11 +2455,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v56, v57 := range in.Annotations { - if v56 > 0 { + for v59, v60 := range in.Annotations { + if v59 > 0 { out.RawByte(',') } - (v57).MarshalTinyJSON(out) + (v60).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2280,27 +2470,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Interface) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Interface) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel17(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Interface) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Interface) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel17(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(in *jlexer.Lexer, out *ImportRef) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(in *jlexer.Lexer, out *ImportRef) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2341,7 +2531,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(out *jwriter.Writer, in ImportRef) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(out *jwriter.Writer, in ImportRef) { out.RawByte('{') first := true _ = first @@ -2361,27 +2551,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v ImportRef) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v ImportRef) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel18(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *ImportRef) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *ImportRef) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel18(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(in *jlexer.Lexer, out *Import) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(in *jlexer.Lexer, out *Import) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2428,9 +2618,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(in *jlexer.Lexer, out out.Names = (out.Names)[:0] } for !in.IsDelim(']') { - var v58 ImportRef - (v58).UnmarshalTinyJSON(in) - out.Names = append(out.Names, v58) + var v61 ImportRef + (v61).UnmarshalTinyJSON(in) + out.Names = append(out.Names, v61) in.WantComma() } in.Delim(']') @@ -2453,9 +2643,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v59 Annotation - (v59).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v59) + var v62 Annotation + (v62).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v62) in.WantComma() } in.Delim(']') @@ -2470,7 +2660,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(out *jwriter.Writer, in Import) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(out *jwriter.Writer, in Import) { out.RawByte('{') first := true _ = first @@ -2495,11 +2685,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v60, v61 := range in.Names { - if v60 > 0 { + for v63, v64 := range in.Names { + if v63 > 0 { out.RawByte(',') } - (v61).MarshalTinyJSON(out) + (v64).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2514,11 +2704,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v62, v63 := range in.Annotations { - if v62 > 0 { + for v65, v66 := range in.Annotations { + if v65 > 0 { out.RawByte(',') } - (v63).MarshalTinyJSON(out) + (v66).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2529,27 +2719,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Import) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Import) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel19(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Import) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Import) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel19(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(in *jlexer.Lexer, out *Field) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(in *jlexer.Lexer, out *Field) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2608,9 +2798,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v64 Annotation - (v64).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v64) + var v67 Annotation + (v67).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v67) in.WantComma() } in.Delim(']') @@ -2625,7 +2815,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(out *jwriter.Writer, in Field) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(out *jwriter.Writer, in Field) { out.RawByte('{') first := true _ = first @@ -2654,11 +2844,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v65, v66 := range in.Annotations { - if v65 > 0 { + for v68, v69 := range in.Annotations { + if v68 > 0 { out.RawByte(',') } - (v66).MarshalTinyJSON(out) + (v69).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2669,27 +2859,171 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Field) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Field) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel20(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Field) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Field) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel20(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(l, v) +} +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(in *jlexer.Lexer, out *Error) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "message": + out.Message = string(in.String()) + case "positions": + if in.IsNull() { + in.Skip() + out.Positions = nil + } else { + in.Delim('[') + if out.Positions == nil { + if !in.IsDelim(']') { + out.Positions = make([]uint32, 0, 16) + } else { + out.Positions = []uint32{} + } + } else { + out.Positions = (out.Positions)[:0] + } + for !in.IsDelim(']') { + var v70 uint32 + v70 = uint32(in.Uint32()) + out.Positions = append(out.Positions, v70) + in.WantComma() + } + in.Delim(']') + } + case "locations": + if in.IsNull() { + in.Skip() + out.Locations = nil + } else { + in.Delim('[') + if out.Locations == nil { + if !in.IsDelim(']') { + out.Locations = make([]Location, 0, 8) + } else { + out.Locations = []Location{} + } + } else { + out.Locations = (out.Locations)[:0] + } + for !in.IsDelim(']') { + var v71 Location + (v71).UnmarshalTinyJSON(in) + out.Locations = append(out.Locations, v71) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(out *jwriter.Writer, in Error) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"message\":" + out.RawString(prefix[1:]) + out.String(string(in.Message)) + } + { + const prefix string = ",\"positions\":" + out.RawString(prefix) + if in.Positions == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v72, v73 := range in.Positions { + if v72 > 0 { + out.RawByte(',') + } + out.Uint32(uint32(v73)) + } + out.RawByte(']') + } + } + { + const prefix string = ",\"locations\":" + out.RawString(prefix) + if in.Locations == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v74, v75 := range in.Locations { + if v74 > 0 { + out.RawByte(',') + } + (v75).MarshalTinyJSON(out) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v Error) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalTinyJSON supports tinyjson.Marshaler interface +func (v Error) MarshalTinyJSON(w *jwriter.Writer) { + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(w, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(in *jlexer.Lexer, out *EnumValue) { + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *Error) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(&r, v) + return r.Error() +} + +// UnmarshalTinyJSON supports tinyjson.Unmarshaler interface +func (v *Error) UnmarshalTinyJSON(l *jlexer.Lexer) { + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(l, v) +} +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(in *jlexer.Lexer, out *EnumValue) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2748,9 +3082,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v67 Annotation - (v67).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v67) + var v76 Annotation + (v76).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v76) in.WantComma() } in.Delim(']') @@ -2765,7 +3099,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(out *jwriter.Writer, in EnumValue) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(out *jwriter.Writer, in EnumValue) { out.RawByte('{') first := true _ = first @@ -2794,11 +3128,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v68, v69 := range in.Annotations { - if v68 > 0 { + for v77, v78 := range in.Annotations { + if v77 > 0 { out.RawByte(',') } - (v69).MarshalTinyJSON(out) + (v78).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2809,27 +3143,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v EnumValue) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v EnumValue) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel21(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *EnumValue) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *EnumValue) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel21(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(in *jlexer.Lexer, out *Enum) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(in *jlexer.Lexer, out *Enum) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -2876,9 +3210,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(in *jlexer.Lexer, out out.Values = (out.Values)[:0] } for !in.IsDelim(']') { - var v70 EnumValue - (v70).UnmarshalTinyJSON(in) - out.Values = append(out.Values, v70) + var v79 EnumValue + (v79).UnmarshalTinyJSON(in) + out.Values = append(out.Values, v79) in.WantComma() } in.Delim(']') @@ -2899,9 +3233,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v71 Annotation - (v71).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v71) + var v80 Annotation + (v80).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v80) in.WantComma() } in.Delim(']') @@ -2916,7 +3250,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(out *jwriter.Writer, in Enum) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(out *jwriter.Writer, in Enum) { out.RawByte('{') first := true _ = first @@ -2937,11 +3271,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v72, v73 := range in.Values { - if v72 > 0 { + for v81, v82 := range in.Values { + if v81 > 0 { out.RawByte(',') } - (v73).MarshalTinyJSON(out) + (v82).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2951,11 +3285,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v74, v75 := range in.Annotations { - if v74 > 0 { + for v83, v84 := range in.Annotations { + if v83 > 0 { out.RawByte(',') } - (v75).MarshalTinyJSON(out) + (v84).MarshalTinyJSON(out) } out.RawByte(']') } @@ -2966,27 +3300,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Enum) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Enum) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel22(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Enum) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Enum) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel22(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(in *jlexer.Lexer, out *DirectiveRequire) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(in *jlexer.Lexer, out *DirectiveRequire) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3023,11 +3357,11 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(in *jlexer.Lexer, out out.Locations = (out.Locations)[:0] } for !in.IsDelim(']') { - var v76 DirectiveLocation + var v85 DirectiveLocation if data := in.Raw(); in.Ok() { - in.AddError((v76).UnmarshalJSON(data)) + in.AddError((v85).UnmarshalJSON(data)) } - out.Locations = append(out.Locations, v76) + out.Locations = append(out.Locations, v85) in.WantComma() } in.Delim(']') @@ -3042,7 +3376,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(out *jwriter.Writer, in DirectiveRequire) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(out *jwriter.Writer, in DirectiveRequire) { out.RawByte('{') first := true _ = first @@ -3058,11 +3392,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v77, v78 := range in.Locations { - if v77 > 0 { + for v86, v87 := range in.Locations { + if v86 > 0 { out.RawByte(',') } - out.Raw((v78).MarshalJSON()) + out.Raw((v87).MarshalJSON()) } out.RawByte(']') } @@ -3073,27 +3407,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v DirectiveRequire) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v DirectiveRequire) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel23(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DirectiveRequire) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *DirectiveRequire) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel23(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(in *jlexer.Lexer, out *Directive) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(in *jlexer.Lexer, out *Directive) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3140,9 +3474,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(in *jlexer.Lexer, out out.Parameters = (out.Parameters)[:0] } for !in.IsDelim(']') { - var v79 Parameter - (v79).UnmarshalTinyJSON(in) - out.Parameters = append(out.Parameters, v79) + var v88 Parameter + (v88).UnmarshalTinyJSON(in) + out.Parameters = append(out.Parameters, v88) in.WantComma() } in.Delim(']') @@ -3163,11 +3497,11 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(in *jlexer.Lexer, out out.Locations = (out.Locations)[:0] } for !in.IsDelim(']') { - var v80 DirectiveLocation + var v89 DirectiveLocation if data := in.Raw(); in.Ok() { - in.AddError((v80).UnmarshalJSON(data)) + in.AddError((v89).UnmarshalJSON(data)) } - out.Locations = append(out.Locations, v80) + out.Locations = append(out.Locations, v89) in.WantComma() } in.Delim(']') @@ -3188,9 +3522,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(in *jlexer.Lexer, out out.Require = (out.Require)[:0] } for !in.IsDelim(']') { - var v81 DirectiveRequire - (v81).UnmarshalTinyJSON(in) - out.Require = append(out.Require, v81) + var v90 DirectiveRequire + (v90).UnmarshalTinyJSON(in) + out.Require = append(out.Require, v90) in.WantComma() } in.Delim(']') @@ -3205,7 +3539,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(out *jwriter.Writer, in Directive) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(out *jwriter.Writer, in Directive) { out.RawByte('{') first := true _ = first @@ -3224,11 +3558,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v82, v83 := range in.Parameters { - if v82 > 0 { + for v91, v92 := range in.Parameters { + if v91 > 0 { out.RawByte(',') } - (v83).MarshalTinyJSON(out) + (v92).MarshalTinyJSON(out) } out.RawByte(']') } @@ -3240,11 +3574,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v84, v85 := range in.Locations { - if v84 > 0 { + for v93, v94 := range in.Locations { + if v93 > 0 { out.RawByte(',') } - out.Raw((v85).MarshalJSON()) + out.Raw((v94).MarshalJSON()) } out.RawByte(']') } @@ -3256,11 +3590,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(out *jwriter.Writer, i out.RawString("null") } else { out.RawByte('[') - for v86, v87 := range in.Require { - if v86 > 0 { + for v95, v96 := range in.Require { + if v95 > 0 { out.RawByte(',') } - (v87).MarshalTinyJSON(out) + (v96).MarshalTinyJSON(out) } out.RawByte(']') } @@ -3271,27 +3605,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Directive) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Directive) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel24(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Directive) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Directive) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel24(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(in *jlexer.Lexer, out *Argument) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel28(in *jlexer.Lexer, out *Argument) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3324,7 +3658,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(out *jwriter.Writer, in Argument) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel28(out *jwriter.Writer, in Argument) { out.RawByte('{') first := true _ = first @@ -3344,27 +3678,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Argument) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel28(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Argument) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel25(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel28(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Argument) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel28(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Argument) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel25(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel28(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(in *jlexer.Lexer, out *Annotation) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel29(in *jlexer.Lexer, out *Annotation) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3401,9 +3735,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(in *jlexer.Lexer, out out.Arguments = (out.Arguments)[:0] } for !in.IsDelim(']') { - var v88 Argument - (v88).UnmarshalTinyJSON(in) - out.Arguments = append(out.Arguments, v88) + var v97 Argument + (v97).UnmarshalTinyJSON(in) + out.Arguments = append(out.Arguments, v97) in.WantComma() } in.Delim(']') @@ -3418,7 +3752,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(out *jwriter.Writer, in Annotation) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel29(out *jwriter.Writer, in Annotation) { out.RawByte('{') first := true _ = first @@ -3432,11 +3766,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v89, v90 := range in.Arguments { - if v89 > 0 { + for v98, v99 := range in.Arguments { + if v98 > 0 { out.RawByte(',') } - (v90).MarshalTinyJSON(out) + (v99).MarshalTinyJSON(out) } out.RawByte(']') } @@ -3447,27 +3781,27 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Annotation) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel29(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Annotation) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel26(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel29(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Annotation) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel29(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Annotation) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel26(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel29(l, v) } -func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(in *jlexer.Lexer, out *Alias) { +func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel30(in *jlexer.Lexer, out *Alias) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -3516,9 +3850,9 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(in *jlexer.Lexer, out out.Annotations = (out.Annotations)[:0] } for !in.IsDelim(']') { - var v91 Annotation - (v91).UnmarshalTinyJSON(in) - out.Annotations = append(out.Annotations, v91) + var v100 Annotation + (v100).UnmarshalTinyJSON(in) + out.Annotations = append(out.Annotations, v100) in.WantComma() } in.Delim(']') @@ -3533,7 +3867,7 @@ func tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(in *jlexer.Lexer, out in.Consumed() } } -func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(out *jwriter.Writer, in Alias) { +func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel30(out *jwriter.Writer, in Alias) { out.RawByte('{') first := true _ = first @@ -3557,11 +3891,11 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(out *jwriter.Writer, i out.RawString(prefix) { out.RawByte('[') - for v92, v93 := range in.Annotations { - if v92 > 0 { + for v101, v102 := range in.Annotations { + if v101 > 0 { out.RawByte(',') } - (v93).MarshalTinyJSON(out) + (v102).MarshalTinyJSON(out) } out.RawByte(']') } @@ -3572,23 +3906,23 @@ func tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(out *jwriter.Writer, i // MarshalJSON supports json.Marshaler interface func (v Alias) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(&w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel30(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalTinyJSON supports tinyjson.Marshaler interface func (v Alias) MarshalTinyJSON(w *jwriter.Writer) { - tinyjson85aaecc5EncodeGithubComApexlangApexGoModel27(w, v) + tinyjson85aaecc5EncodeGithubComApexlangApexGoModel30(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Alias) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(&r, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel30(&r, v) return r.Error() } // UnmarshalTinyJSON supports tinyjson.Unmarshaler interface func (v *Alias) UnmarshalTinyJSON(l *jlexer.Lexer) { - tinyjson85aaecc5DecodeGithubComApexlangApexGoModel27(l, v) + tinyjson85aaecc5DecodeGithubComApexlangApexGoModel30(l, v) } diff --git a/model/msgpack.go b/model/msgpack.go new file mode 100644 index 0000000..0a5b984 --- /dev/null +++ b/model/msgpack.go @@ -0,0 +1,2131 @@ +// Code generated by @apexlang/codegen. DO NOT EDIT. + +package model + +import ( + "github.com/wapc/tinygo-msgpack" + "github.com/wapc/tinygo-msgpack/convert" +) + +var _ = convert.Package + +type parserParseArgs struct { + Source string `json:"source" yaml:"source" msgpack:"source"` +} + +func (o *parserParseArgs) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "source": + o.Source, err = decoder.ReadString() + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *parserParseArgs) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("source") + encoder.WriteString(o.Source) + + return nil +} + +type resolverResolveArgs struct { + Location string `json:"location" yaml:"location" msgpack:"location"` + From string `json:"from" yaml:"from" msgpack:"from"` +} + +func (o *resolverResolveArgs) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "location": + o.Location, err = decoder.ReadString() + case "from": + o.From, err = decoder.ReadString() + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *resolverResolveArgs) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("location") + encoder.WriteString(o.Location) + encoder.WriteString("from") + encoder.WriteString(o.From) + + return nil +} + +func (o *ParserResult) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "namespace": + o.Namespace, err = msgpack.DecodeNillable[Namespace](decoder) + case "errors": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Errors = make([]Error, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Error + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Errors = append(o.Errors, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *ParserResult) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("namespace") + o.Namespace.Encode(encoder) + encoder.WriteString("errors") + encoder.WriteArraySize(uint32(len(o.Errors))) + for _, v := range o.Errors { + v.Encode(encoder) + } + + return nil +} + +func (o *Error) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "message": + o.Message, err = decoder.ReadString() + case "positions": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Positions = make([]uint32, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem uint32 + nonNilItem, err = decoder.ReadUint32() + if err != nil { + return err + } + o.Positions = append(o.Positions, nonNilItem) + } + case "locations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Locations = make([]Location, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Location + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Locations = append(o.Locations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Error) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(3) + encoder.WriteString("message") + encoder.WriteString(o.Message) + encoder.WriteString("positions") + encoder.WriteArraySize(uint32(len(o.Positions))) + for _, v := range o.Positions { + encoder.WriteUint32(v) + } + encoder.WriteString("locations") + encoder.WriteArraySize(uint32(len(o.Locations))) + for _, v := range o.Locations { + v.Encode(encoder) + } + + return nil +} + +func (o *Location) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "line": + o.Line, err = decoder.ReadUint32() + case "column": + o.Column, err = decoder.ReadUint32() + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Location) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("line") + encoder.WriteUint32(o.Line) + encoder.WriteString("column") + encoder.WriteUint32(o.Column) + + return nil +} + +func (o *Namespace) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + case "imports": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Imports = make([]Import, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Import + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Imports = append(o.Imports, nonNilItem) + } + case "directives": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Directives = make([]Directive, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Directive + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Directives = append(o.Directives, nonNilItem) + } + case "aliases": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Aliases = make([]Alias, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Alias + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Aliases = append(o.Aliases, nonNilItem) + } + case "functions": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Functions = make([]Operation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Operation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Functions = append(o.Functions, nonNilItem) + } + case "interfaces": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Interfaces = make([]Interface, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Interface + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Interfaces = append(o.Interfaces, nonNilItem) + } + case "types": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Types = make([]Type, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Type + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Types = append(o.Types, nonNilItem) + } + case "unions": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Unions = make([]Union, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Union + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Unions = append(o.Unions, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Namespace) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(10) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + encoder.WriteString("imports") + encoder.WriteArraySize(uint32(len(o.Imports))) + for _, v := range o.Imports { + v.Encode(encoder) + } + encoder.WriteString("directives") + encoder.WriteArraySize(uint32(len(o.Directives))) + for _, v := range o.Directives { + v.Encode(encoder) + } + encoder.WriteString("aliases") + encoder.WriteArraySize(uint32(len(o.Aliases))) + for _, v := range o.Aliases { + v.Encode(encoder) + } + encoder.WriteString("functions") + encoder.WriteArraySize(uint32(len(o.Functions))) + for _, v := range o.Functions { + v.Encode(encoder) + } + encoder.WriteString("interfaces") + encoder.WriteArraySize(uint32(len(o.Interfaces))) + for _, v := range o.Interfaces { + v.Encode(encoder) + } + encoder.WriteString("types") + encoder.WriteArraySize(uint32(len(o.Types))) + for _, v := range o.Types { + v.Encode(encoder) + } + encoder.WriteString("unions") + encoder.WriteArraySize(uint32(len(o.Unions))) + for _, v := range o.Unions { + v.Encode(encoder) + } + + return nil +} + +func (o *Import) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "description": + o.Description, err = decoder.ReadNillableString() + case "all": + o.All, err = decoder.ReadBool() + case "names": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Names = make([]ImportRef, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem ImportRef + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Names = append(o.Names, nonNilItem) + } + case "from": + o.From, err = decoder.ReadString() + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Import) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(5) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("all") + encoder.WriteBool(o.All) + encoder.WriteString("names") + encoder.WriteArraySize(uint32(len(o.Names))) + for _, v := range o.Names { + v.Encode(encoder) + } + encoder.WriteString("from") + encoder.WriteString(o.From) + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *ImportRef) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "as": + o.As, err = decoder.ReadNillableString() + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *ImportRef) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("as") + encoder.WriteNillableString(o.As) + + return nil +} + +func (o *Type) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "fields": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Fields = make([]Field, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Field + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Fields = append(o.Fields, nonNilItem) + } + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Type) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(4) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("fields") + encoder.WriteArraySize(uint32(len(o.Fields))) + for _, v := range o.Fields { + v.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Interface) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "operations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Operations = make([]Operation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Operation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Operations = append(o.Operations, nonNilItem) + } + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Interface) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(4) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("operations") + encoder.WriteArraySize(uint32(len(o.Operations))) + for _, v := range o.Operations { + v.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Alias) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "type": + o.Type, err = msgpack.Decode[TypeRef](decoder) + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Alias) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(4) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("type") + o.Type.Encode(encoder) + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Operation) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "parameters": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Parameters = make([]Parameter, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Parameter + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Parameters = append(o.Parameters, nonNilItem) + } + case "unary": + o.Unary, err = msgpack.DecodeNillable[Parameter](decoder) + case "returns": + o.Returns, err = msgpack.DecodeNillable[TypeRef](decoder) + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Operation) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(6) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("parameters") + encoder.WriteArraySize(uint32(len(o.Parameters))) + for _, v := range o.Parameters { + v.Encode(encoder) + } + encoder.WriteString("unary") + o.Unary.Encode(encoder) + encoder.WriteString("returns") + if o.Returns == nil { + encoder.WriteNil() + } else { + o.Returns.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Parameter) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "type": + o.Type, err = msgpack.Decode[TypeRef](decoder) + case "defaultValue": + o.DefaultValue, err = msgpack.DecodeNillable[Value](decoder) + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Parameter) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(5) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("type") + o.Type.Encode(encoder) + encoder.WriteString("defaultValue") + if o.DefaultValue == nil { + encoder.WriteNil() + } else { + o.DefaultValue.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Field) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "type": + o.Type, err = msgpack.Decode[TypeRef](decoder) + case "defaultValue": + o.DefaultValue, err = msgpack.DecodeNillable[Value](decoder) + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Field) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(5) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("type") + o.Type.Encode(encoder) + encoder.WriteString("defaultValue") + if o.DefaultValue == nil { + encoder.WriteNil() + } else { + o.DefaultValue.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Union) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "types": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Types = make([]TypeRef, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem TypeRef + nonNilItem, err = msgpack.Decode[TypeRef](decoder) + if err != nil { + return err + } + o.Types = append(o.Types, nonNilItem) + } + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Union) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(4) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("types") + encoder.WriteArraySize(uint32(len(o.Types))) + for _, v := range o.Types { + v.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Enum) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "values": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Values = make([]EnumValue, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem EnumValue + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Values = append(o.Values, nonNilItem) + } + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Enum) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(4) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("values") + encoder.WriteArraySize(uint32(len(o.Values))) + for _, v := range o.Values { + v.Encode(encoder) + } + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *EnumValue) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "index": + o.Index, err = decoder.ReadUint64() + case "display": + o.Display, err = decoder.ReadNillableString() + case "annotations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Annotations = make([]Annotation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Annotation + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Annotations = append(o.Annotations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *EnumValue) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(5) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("index") + encoder.WriteUint64(o.Index) + encoder.WriteString("display") + encoder.WriteNillableString(o.Display) + encoder.WriteString("annotations") + encoder.WriteArraySize(uint32(len(o.Annotations))) + for _, v := range o.Annotations { + v.Encode(encoder) + } + + return nil +} + +func (o *Directive) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "description": + o.Description, err = decoder.ReadNillableString() + case "parameters": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Parameters = make([]Parameter, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Parameter + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Parameters = append(o.Parameters, nonNilItem) + } + case "locations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Locations = make([]DirectiveLocation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem DirectiveLocation + nonNilItem, err = convert.Numeric[DirectiveLocation](decoder.ReadInt32()) + if err != nil { + return err + } + o.Locations = append(o.Locations, nonNilItem) + } + case "require": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Require = make([]DirectiveRequire, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem DirectiveRequire + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Require = append(o.Require, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Directive) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(5) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("description") + encoder.WriteNillableString(o.Description) + encoder.WriteString("parameters") + encoder.WriteArraySize(uint32(len(o.Parameters))) + for _, v := range o.Parameters { + v.Encode(encoder) + } + encoder.WriteString("locations") + encoder.WriteArraySize(uint32(len(o.Locations))) + for _, v := range o.Locations { + encoder.WriteInt32(int32(v)) + } + encoder.WriteString("require") + encoder.WriteArraySize(uint32(len(o.Require))) + for _, v := range o.Require { + v.Encode(encoder) + } + + return nil +} + +func (o *DirectiveRequire) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "directive": + o.Directive, err = decoder.ReadString() + case "locations": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Locations = make([]DirectiveLocation, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem DirectiveLocation + nonNilItem, err = convert.Numeric[DirectiveLocation](decoder.ReadInt32()) + if err != nil { + return err + } + o.Locations = append(o.Locations, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *DirectiveRequire) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("directive") + encoder.WriteString(o.Directive) + encoder.WriteString("locations") + encoder.WriteArraySize(uint32(len(o.Locations))) + for _, v := range o.Locations { + encoder.WriteInt32(int32(v)) + } + + return nil +} + +func (o *Annotation) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "arguments": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Arguments = make([]Argument, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Argument + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Arguments = append(o.Arguments, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Annotation) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("arguments") + encoder.WriteArraySize(uint32(len(o.Arguments))) + for _, v := range o.Arguments { + v.Encode(encoder) + } + + return nil +} + +func (o *Argument) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "value": + o.Value, err = msgpack.Decode[Value](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Argument) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("value") + o.Value.Encode(encoder) + + return nil +} + +func (o *Named) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "kind": + o.Kind, err = convert.Numeric[Kind](decoder.ReadInt32()) + case "name": + o.Name, err = decoder.ReadString() + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Named) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("kind") + encoder.WriteInt32(int32(o.Kind)) + encoder.WriteString("name") + encoder.WriteString(o.Name) + + return nil +} + +func (o *List) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "type": + o.Type, err = msgpack.Decode[TypeRef](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *List) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("type") + o.Type.Encode(encoder) + + return nil +} + +func (o *Map) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "keyType": + o.KeyType, err = msgpack.Decode[TypeRef](decoder) + case "valueType": + o.ValueType, err = msgpack.Decode[TypeRef](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Map) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("keyType") + o.KeyType.Encode(encoder) + encoder.WriteString("valueType") + o.ValueType.Encode(encoder) + + return nil +} + +func (o *Stream) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "type": + o.Type, err = msgpack.Decode[TypeRef](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Stream) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("type") + o.Type.Encode(encoder) + + return nil +} + +func (o *Optional) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "type": + o.Type, err = msgpack.Decode[TypeRef](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Optional) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("type") + o.Type.Encode(encoder) + + return nil +} + +func (o *Reference) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Reference) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("name") + encoder.WriteString(o.Name) + + return nil +} + +func (o *ListValue) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "values": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Values = make([]Value, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem Value + nonNilItem, err = msgpack.Decode[Value](decoder) + if err != nil { + return err + } + o.Values = append(o.Values, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *ListValue) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("values") + encoder.WriteArraySize(uint32(len(o.Values))) + for _, v := range o.Values { + v.Encode(encoder) + } + + return nil +} + +func (o *ObjectValue) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "fields": + listSize, err := decoder.ReadArraySize() + if err != nil { + return err + } + o.Fields = make([]ObjectField, 0, listSize) + for listSize > 0 { + listSize-- + var nonNilItem ObjectField + err = nonNilItem.Decode(decoder) + if err != nil { + return err + } + o.Fields = append(o.Fields, nonNilItem) + } + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *ObjectValue) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(1) + encoder.WriteString("fields") + encoder.WriteArraySize(uint32(len(o.Fields))) + for _, v := range o.Fields { + v.Encode(encoder) + } + + return nil +} + +func (o *ObjectField) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "name": + o.Name, err = decoder.ReadString() + case "value": + o.Value, err = msgpack.Decode[Value](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *ObjectField) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + encoder.WriteMapSize(2) + encoder.WriteString("name") + encoder.WriteString(o.Name) + encoder.WriteString("value") + o.Value.Encode(encoder) + + return nil +} + +func (o *TypeRef) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "Scalar": + o.Scalar, err = convert.NillableNumeric[Scalar](decoder.ReadNillableInt32()) + case "Named": + o.Named, err = msgpack.DecodeNillable[Named](decoder) + case "List": + o.List, err = msgpack.DecodeNillable[List](decoder) + case "Map": + o.Map, err = msgpack.DecodeNillable[Map](decoder) + case "Stream": + o.Stream, err = msgpack.DecodeNillable[Stream](decoder) + case "Optional": + o.Optional, err = msgpack.DecodeNillable[Optional](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *TypeRef) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + if o.Scalar != nil { + encoder.WriteMapSize(1) + encoder.WriteString("Scalar") + encoder.WriteNillableInt32((*int32)(o.Scalar)) + return nil + } + if o.Named != nil { + encoder.WriteMapSize(1) + encoder.WriteString("Named") + o.Named.Encode(encoder) + return nil + } + if o.List != nil { + encoder.WriteMapSize(1) + encoder.WriteString("List") + o.List.Encode(encoder) + return nil + } + if o.Map != nil { + encoder.WriteMapSize(1) + encoder.WriteString("Map") + o.Map.Encode(encoder) + return nil + } + if o.Stream != nil { + encoder.WriteMapSize(1) + encoder.WriteString("Stream") + o.Stream.Encode(encoder) + return nil + } + if o.Optional != nil { + encoder.WriteMapSize(1) + encoder.WriteString("Optional") + o.Optional.Encode(encoder) + return nil + } + + encoder.WriteNil() + return nil +} + +func (o *Value) Decode(decoder msgpack.Reader) error { + numFields, err := decoder.ReadMapSize() + if err != nil { + return err + } + + for numFields > 0 { + numFields-- + field, err := decoder.ReadString() + if err != nil { + return err + } + switch field { + case "bool": + o.Bool, err = decoder.ReadNillableBool() + case "string": + o.String, err = decoder.ReadNillableString() + case "i64": + o.I64, err = decoder.ReadNillableInt64() + case "f64": + o.F64, err = decoder.ReadNillableFloat64() + case "Reference": + o.Reference, err = msgpack.DecodeNillable[Reference](decoder) + case "ListValue": + o.ListValue, err = msgpack.DecodeNillable[ListValue](decoder) + case "ObjectValue": + o.ObjectValue, err = msgpack.DecodeNillable[ObjectValue](decoder) + default: + err = decoder.Skip() + } + if err != nil { + return err + } + } + + return nil +} + +func (o *Value) Encode(encoder msgpack.Writer) error { + if o == nil { + encoder.WriteNil() + return nil + } + if o.Bool != nil { + encoder.WriteMapSize(1) + encoder.WriteString("bool") + encoder.WriteNillableBool(o.Bool) + return nil + } + if o.String != nil { + encoder.WriteMapSize(1) + encoder.WriteString("string") + encoder.WriteNillableString(o.String) + return nil + } + if o.I64 != nil { + encoder.WriteMapSize(1) + encoder.WriteString("i64") + encoder.WriteNillableInt64(o.I64) + return nil + } + if o.F64 != nil { + encoder.WriteMapSize(1) + encoder.WriteString("f64") + encoder.WriteNillableFloat64(o.F64) + return nil + } + if o.Reference != nil { + encoder.WriteMapSize(1) + encoder.WriteString("Reference") + o.Reference.Encode(encoder) + return nil + } + if o.ListValue != nil { + encoder.WriteMapSize(1) + encoder.WriteString("ListValue") + o.ListValue.Encode(encoder) + return nil + } + if o.ObjectValue != nil { + encoder.WriteMapSize(1) + encoder.WriteString("ObjectValue") + o.ObjectValue.Encode(encoder) + return nil + } + + encoder.WriteNil() + return nil +} diff --git a/model/service.go b/model/service.go new file mode 100644 index 0000000..1364f52 --- /dev/null +++ b/model/service.go @@ -0,0 +1,86 @@ +package model + +import ( + "context" + + "github.com/apexlang/apex-go/errors" + "github.com/apexlang/apex-go/location" + "github.com/apexlang/apex-go/parser" + "github.com/apexlang/apex-go/rules" +) + +type parserImpl struct { + resolver Resolver +} + +func NewParser(resolver Resolver) Parser { + return &parserImpl{ + resolver: resolver, + } +} + +func (p *parserImpl) Parse(ctx context.Context, source string) (*ParserResult, error) { + doc, err := parser.Parse(parser.ParseParams{ + Source: source, + Options: parser.ParseOptions{ + NoSource: true, + Resolver: func(location, from string) (string, error) { + return p.resolver.Resolve(ctx, location, from) + }, + }, + }) + if err != nil { + return nil, err + } + + errs := rules.Validate(doc, rules.Rules...) + if len(errs) > 0 { + return &ParserResult{ + Errors: convertErrors(errs), + }, nil + } + + ns, errs := Convert(doc) + if len(errs) > 0 { + return &ParserResult{ + Errors: convertErrors(errs), + }, nil + } + + return &ParserResult{ + Namespace: ns, + }, nil +} + +func convertErrors(errs []error) []Error { + e := make([]Error, len(errs)) + for i, err := range errs { + switch v := err.(type) { + case *errors.Error: + e[i] = Error{ + Message: v.Message, + Positions: convertAny(v.Positions, func(p uint) uint32 { return uint32(p) }), + Locations: convertAny(v.Locations, func(l location.SourceLocation) Location { + return Location{ + Line: uint32(l.Line), + Column: uint32(l.Column), + } + }), + } + default: + e[i] = Error{ + Message: err.Error(), + } + } + + } + return e +} + +func convertAny[S, D any](source []S, fn func(S) D) []D { + dest := make([]D, len(source)) + for i, value := range source { + dest[i] = fn(value) + } + return dest +} diff --git a/model/wapc.go b/model/wapc.go new file mode 100644 index 0000000..0352ccb --- /dev/null +++ b/model/wapc.go @@ -0,0 +1,67 @@ +// Code generated by @apexlang/codegen. DO NOT EDIT. + +package model + +import ( + "context" + + "github.com/wapc/tinygo-msgpack" + "github.com/wapc/tinygo-msgpack/convert" + "github.com/wapc/wapc-guest-tinygo" +) + +var _ = convert.Package + +type ResolverImpl struct { + binding string +} + +func NewResolver(binding ...string) *ResolverImpl { + var bindingName string + if len(binding) > 0 { + bindingName = binding[0] + } + return &ResolverImpl{ + binding: bindingName, + } +} + +func (h *ResolverImpl) Resolve(ctx context.Context, location string, from string) (string, error) { + inputArgs := resolverResolveArgs{ + Location: location, + From: from, + } + inputBytes, err := msgpack.ToBytes(&inputArgs) + if err != nil { + return "", err + } + payload, err := wapc.HostCall( + h.binding, + "apexlang.v1.Resolver", + "resolve", + inputBytes, + ) + if err != nil { + return "", err + } + decoder := msgpack.NewDecoder(payload) + return decoder.ReadString() +} + +func RegisterParser(svc Parser) { + wapc.RegisterFunction("apexlang.v1.Parser/parse", parserParseWrapper(svc)) +} + +func parserParseWrapper(svc Parser) wapc.Function { + return func(payload []byte) ([]byte, error) { + ctx := context.Background() + decoder := msgpack.NewDecoder(payload) + var inputArgs parserParseArgs + inputArgs.Decode(&decoder) + response, err := svc.Parse(ctx, inputArgs.Source) + if err != nil { + return nil, err + } + return msgpack.ToBytes(response) + } +}