diff --git a/cmd/accumulated/run/encoding.go b/cmd/accumulated/run/encoding.go index a321fca2e..2d4d5f8d3 100644 --- a/cmd/accumulated/run/encoding.go +++ b/cmd/accumulated/run/encoding.go @@ -11,10 +11,11 @@ import ( "github.com/multiformats/go-multiaddr" "gitlab.com/accumulatenetwork/core/schema/pkg/binary" "gitlab.com/accumulatenetwork/core/schema/pkg/json" + "gitlab.com/accumulatenetwork/core/schema/pkg/widget" ) -var wMultiaddr = multiaddrWidget{} -var wPeerID = peerIdWidget{} +func wMultiaddr() widget.Widget[*multiaddr.Multiaddr] { return multiaddrWidget{} } +func wPeerID() widget.Widget[*peer.ID] { return peerIdWidget{} } type multiaddrWidget struct{} diff --git a/cmd/accumulated/run/schema_gen.go b/cmd/accumulated/run/schema_gen.go index 5801593a3..b211fd017 100644 --- a/cmd/accumulated/run/schema_gen.go +++ b/cmd/accumulated/run/schema_gen.go @@ -882,7 +882,7 @@ func init() { }, }, Underlying: schema.TypeReferenceFor[multiaddr.Multiaddr](), - Encoder: schema.WidgetExternalEncoder[Multiaddr]{W: wMultiaddr}, + Encoder: schema.WidgetExternalEncoder(wMultiaddr), }).SetGoType() sNetworkService = schema.WithMethods[*NetworkService, *NetworkService](&schema.CompositeType{ @@ -982,7 +982,7 @@ func init() { }, }, Underlying: schema.TypeReferenceFor[peer.ID](), - Encoder: schema.WidgetExternalEncoder[PeerID]{W: wPeerID}, + Encoder: schema.WidgetExternalEncoder(wPeerID), }).SetGoType() sPrivateKey = schema.WithUnionMethods[PrivateKey, PrivateKeyType]( diff --git a/exp/ioutil/mapped_file.go b/exp/ioutil/mapped_file.go index 95d04f266..a7b20dfa9 100644 --- a/exp/ioutil/mapped_file.go +++ b/exp/ioutil/mapped_file.go @@ -15,20 +15,20 @@ import ( "sync/atomic" "github.com/edsrzf/mmap-go" - "gitlab.com/accumulatenetwork/core/schema/pkg/binary" + "gitlab.com/accumulatenetwork/accumulate/internal/util/pool" ) type MappedFile struct { mu *sync.RWMutex file *os.File data mmap.MMap - pool *binary.Pool[*MappedFileRange] + pool *pool.Pool[*MappedFileRange] } func OpenMappedFile(name string, flags int, perm fs.FileMode) (_ *MappedFile, err error) { f := new(MappedFile) f.mu = new(sync.RWMutex) - f.pool = binary.NewPointerPool[MappedFileRange]() + f.pool = pool.New[MappedFileRange]() defer func() { if err != nil { _ = f.Close() diff --git a/go.mod b/go.mod index 1df0229f5..ceb03dd9e 100644 --- a/go.mod +++ b/go.mod @@ -72,7 +72,7 @@ require ( github.com/sergi/go-diff v1.2.0 github.com/ulikunitz/xz v0.5.11 github.com/vektra/mockery/v2 v2.42.3 - gitlab.com/accumulatenetwork/core/schema v0.2.1-0.20240713035306-1121dbc75e5d + gitlab.com/accumulatenetwork/core/schema v0.2.1-0.20241002211257-5a76a2dad5eb gitlab.com/firelizzard/go-script v0.0.0-20240404234115-d5f0a716003d go.opentelemetry.io/otel v1.27.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 @@ -377,7 +377,7 @@ require ( github.com/uudashr/gocognit v1.1.2 // indirect github.com/yagipy/maintidx v1.0.0 // indirect github.com/yeya24/promlinter v0.2.0 // indirect - gitlab.com/accumulatenetwork/utils/jsonrpc v0.1.0 + gitlab.com/accumulatenetwork/utils/jsonrpc v0.1.1-0.20240904211734-7057029b6ad1 gitlab.com/bosi/decorder v0.4.1 // indirect go.etcd.io/bbolt v1.3.6 go.uber.org/multierr v1.11.0 // indirect diff --git a/go.sum b/go.sum index 57abf7e76..47cfc7861 100644 --- a/go.sum +++ b/go.sum @@ -1170,10 +1170,10 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -gitlab.com/accumulatenetwork/core/schema v0.2.1-0.20240713035306-1121dbc75e5d h1:6crG3cl/LB7if3Lt3MbE3c8qgTzl/aLvdB+RmGpnDXE= -gitlab.com/accumulatenetwork/core/schema v0.2.1-0.20240713035306-1121dbc75e5d/go.mod h1:FTl7W44SWhDenzAtvKkLu30Cin8DAr249mH4eg7BNLY= -gitlab.com/accumulatenetwork/utils/jsonrpc v0.1.0 h1:t4Akt7LvcROop2bh++KRIhbv+NORJT1m5WWIsiEUIF8= -gitlab.com/accumulatenetwork/utils/jsonrpc v0.1.0/go.mod h1:Kopfqa//YI6CkXkVpHRMOZqODMNFwifB8IvKw+m52no= +gitlab.com/accumulatenetwork/core/schema v0.2.1-0.20241002211257-5a76a2dad5eb h1:AeG7HjYtyMj/3Xq736CwELkpplss4ieFW8fsSEf1dh8= +gitlab.com/accumulatenetwork/core/schema v0.2.1-0.20241002211257-5a76a2dad5eb/go.mod h1:ZEUsUF0Gr3daHqbDee9MnLB0IX3hdg7AYUogv+Xm2js= +gitlab.com/accumulatenetwork/utils/jsonrpc v0.1.1-0.20240904211734-7057029b6ad1 h1:w7bF8KV1SmNXwdA+MVxyL/u997CgvHggApyH4pa9mpQ= +gitlab.com/accumulatenetwork/utils/jsonrpc v0.1.1-0.20240904211734-7057029b6ad1/go.mod h1:/lKDPIe8tS8Tui1Qw7C0HajOwtljBfBXNkvmmfbYgTA= gitlab.com/bosi/decorder v0.4.1 h1:VdsdfxhstabyhZovHafFw+9eJ6eU0d2CkFNJcZz/NU4= gitlab.com/bosi/decorder v0.4.1/go.mod h1:jecSqWUew6Yle1pCr2eLWTensJMmsxHsBwt+PVbkAqA= gitlab.com/ethan.reesor/vscode-notebooks/go-playbooks v0.0.0-20220417214602-1121b9fae118 h1:UnyYFTz6dWVMBzLUyqHPIQwMrdpiuE+CE7p/5kUfvmk= diff --git a/internal/util/pool/pool.go b/internal/util/pool/pool.go new file mode 100644 index 000000000..b16f36c07 --- /dev/null +++ b/internal/util/pool/pool.go @@ -0,0 +1,23 @@ +// Copyright 2024 The Accumulate Authors +// +// Use of this source code is governed by an MIT-style +// license that can be found in the LICENSE file or at +// https://opensource.org/licenses/MIT. + +package pool + +import "sync" + +func New[T any]() *Pool[*T] { + return (*Pool[*T])(&sync.Pool{New: func() any { return new(T) }}) +} + +type Pool[T any] sync.Pool + +func (p *Pool[T]) Get() T { + return (*sync.Pool)(p).Get().(T) +} + +func (p *Pool[T]) Put(v T) { + (*sync.Pool)(p).Put(v) +} diff --git a/pkg/database/bpt/types_gen.go b/pkg/database/bpt/types_gen.go index ae3a37bab..ea21409ed 100644 --- a/pkg/database/bpt/types_gen.go +++ b/pkg/database/bpt/types_gen.go @@ -21,6 +21,9 @@ var wParameters = widget.ForComposite(widget.Fields[Parameters]{ // Copy returns a copy of the Parameters. func (v *Parameters) Copy() *Parameters { + if v == nil { + return nil + } var u = new(Parameters) wParameters.CopyTo(u, v) return u @@ -53,6 +56,9 @@ func (branch) Type() nodeType { return nodeTypeBranch } // Copy returns a copy of the branch. func (v *branch) Copy() *branch { + if v == nil { + return nil + } var u = new(branch) wbranch.CopyTo(u, v) return u @@ -75,6 +81,9 @@ func (emptyNode) Type() nodeType { return nodeTypeEmpty } // Copy returns a copy of the emptyNode. func (v *emptyNode) Copy() *emptyNode { + if v == nil { + return nil + } var u = new(emptyNode) wemptyNode.CopyTo(u, v) return u @@ -99,6 +108,9 @@ var wleaf = widget.ForComposite(widget.Fields[leaf]{ // Copy returns a copy of the leaf. func (v *leaf) Copy() *leaf { + if v == nil { + return nil + } var u = new(leaf) wleaf.CopyTo(u, v) return u @@ -182,6 +194,9 @@ var wstateData = widget.ForComposite(widget.Fields[stateData]{ // Copy returns a copy of the stateData. func (v *stateData) Copy() *stateData { + if v == nil { + return nil + } var u = new(stateData) wstateData.CopyTo(u, v) return u diff --git a/pkg/database/keyvalue/block/database.go b/pkg/database/keyvalue/block/database.go index 53fb4313f..5116caf1d 100644 --- a/pkg/database/keyvalue/block/database.go +++ b/pkg/database/keyvalue/block/database.go @@ -13,16 +13,17 @@ import ( "sync" "sync/atomic" + "gitlab.com/accumulatenetwork/accumulate/internal/util/pool" "gitlab.com/accumulatenetwork/accumulate/pkg/database/keyvalue" "gitlab.com/accumulatenetwork/accumulate/pkg/database/keyvalue/memory" "gitlab.com/accumulatenetwork/accumulate/pkg/types/record" "gitlab.com/accumulatenetwork/core/schema/pkg/binary" ) -var poolEncoder = binary.NewPointerPool[binary.Encoder]() -var poolDecoder = binary.NewPointerPool[binary.Decoder]() -var poolLocation = binary.NewPointerPool[recordLocation]() -var poolBuffer = binary.NewPointerPool[bytes.Buffer]() +var poolEncoder = pool.New[binary.Encoder]() +var poolDecoder = pool.New[binary.Decoder]() +var poolLocation = pool.New[recordLocation]() +var poolBuffer = binary.NewBufferPool() type Database struct { config diff --git a/pkg/database/keyvalue/block/types_gen.go b/pkg/database/keyvalue/block/types_gen.go index 2998b1b82..f9b2c4f3d 100644 --- a/pkg/database/keyvalue/block/types_gen.go +++ b/pkg/database/keyvalue/block/types_gen.go @@ -20,6 +20,9 @@ var wblockID = widget.ForComposite(widget.Fields[blockID]{ // Copy returns a copy of the blockID. func (v *blockID) Copy() *blockID { + if v == nil { + return nil + } var u = new(blockID) wblockID.CopyTo(u, v) return u @@ -61,6 +64,9 @@ func (endBlockEntry) Type() entryType { return entryTypeEndBlock } // Copy returns a copy of the endBlockEntry. func (v *endBlockEntry) Copy() *endBlockEntry { + if v == nil { + return nil + } var u = new(endBlockEntry) wendBlockEntry.CopyTo(u, v) return u @@ -189,6 +195,9 @@ var wfileHeader = widget.ForComposite(widget.Fields[fileHeader]{}, widget.Identi // Copy returns a copy of the fileHeader. func (v *fileHeader) Copy() *fileHeader { + if v == nil { + return nil + } var u = new(fileHeader) wfileHeader.CopyTo(u, v) return u @@ -236,6 +245,9 @@ func (recordEntry) Type() entryType { return entryTypeRecord } // Copy returns a copy of the recordEntry. func (v *recordEntry) Copy() *recordEntry { + if v == nil { + return nil + } var u = new(recordEntry) wrecordEntry.CopyTo(u, v) return u @@ -282,6 +294,9 @@ var wrecordLocation = widget.ForComposite(widget.Fields[recordLocation]{ // Copy returns a copy of the recordLocation. func (v *recordLocation) Copy() *recordLocation { + if v == nil { + return nil + } var u = new(recordLocation) wrecordLocation.CopyTo(u, v) return u @@ -305,6 +320,9 @@ func (startBlockEntry) Type() entryType { return entryTypeStartBlock } // Copy returns a copy of the startBlockEntry. func (v *startBlockEntry) Copy() *startBlockEntry { + if v == nil { + return nil + } var u = new(startBlockEntry) wstartBlockEntry.CopyTo(u, v) return u diff --git a/pkg/types/encoding/reader.go b/pkg/types/encoding/reader.go index 364ba0f96..88a441cb9 100644 --- a/pkg/types/encoding/reader.go +++ b/pkg/types/encoding/reader.go @@ -18,9 +18,10 @@ import ( "time" "gitlab.com/accumulatenetwork/accumulate/pkg/url" + bin2 "gitlab.com/accumulatenetwork/core/schema/pkg/binary" ) -var ErrFieldsOutOfOrder = errors.New("fields are out of order") +var ErrFieldsOutOfOrder = bin2.ErrFieldsOutOfOrder const MaxValueSize = 1 << 24 diff --git a/pkg/types/encoding/time.go b/pkg/types/encoding/time.go index 873271bcd..585e49334 100644 --- a/pkg/types/encoding/time.go +++ b/pkg/types/encoding/time.go @@ -13,51 +13,30 @@ import ( "gitlab.com/accumulatenetwork/core/schema/pkg/binary" "gitlab.com/accumulatenetwork/core/schema/pkg/json" + "gitlab.com/accumulatenetwork/core/schema/pkg/widget" ) -type Time time.Time +func TimeWidget() widget.Widget[*time.Time] { return timeWidget{} } -func (u Time) Get() time.Time { return time.Time(u) } -func (u *Time) Set(v time.Time) { *u = Time(v) } +type timeWidget struct{} -func (u *Time) String() string { return u.Get().String() } -func (u *Time) Copy() *Time { return u } -func (u *Time) Equal(v *Time) bool { return strings.EqualFold(u.String(), v.String()) } +func (timeWidget) IsNil(v *time.Time) bool { return false } +func (timeWidget) Empty(v *time.Time) bool { return *v == time.Time{} } +func (timeWidget) CopyTo(dst, src *time.Time) { *dst = *src } +func (timeWidget) Equal(a, b *time.Time) bool { return (*a).Equal(*b) } +func (timeWidget) MarshalJSON(e *json.Encoder, v *time.Time) error { return e.Encode(v) } +func (timeWidget) UnmarshalJSON(d *json.Decoder, v *time.Time) error { return d.Decode(v) } -func (u *Time) MarshalJSON() ([]byte, error) { - return json.Marshal(u) -} - -func (u *Time) UnmarshalJSON(b []byte) error { - return json.Unmarshal(b, u) -} - -func (u *Time) MarshalJSONV2(e *json.Encoder) error { - return e.Encode(u.Get()) -} - -func (u *Time) UnmarshalJSONV2(d *json.Decoder) error { - return d.Decode((*time.Time)(u)) -} - -func (u *Time) MarshalBinary() ([]byte, error) { - return binary.Marshal(u) -} - -func (u *Time) UnmarshalBinary(b []byte) error { - return binary.Unmarshal(b, u) -} - -func (u *Time) MarshalBinaryV2(e *binary.Encoder) error { - return e.EncodeInt(u.Get().UTC().Unix()) +func (timeWidget) MarshalBinary(e *binary.Encoder, v *time.Time) error { + return e.EncodeInt(v.UTC().Unix()) } -func (u *Time) UnmarshalBinaryV2(d *binary.Decoder) error { - v, err := d.DecodeInt() +func (timeWidget) UnmarshalBinary(d *binary.Decoder, v *time.Time) error { + u, err := d.DecodeInt() if err != nil { return err } - u.Set(time.Unix(v, 0).UTC()) + *v = time.Unix(u, 0).UTC() return nil } diff --git a/tools/cmd/gen-model/go.go b/tools/cmd/gen-model/go.go index e790173aa..9a362234c 100644 --- a/tools/cmd/gen-model/go.go +++ b/tools/cmd/gen-model/go.go @@ -32,6 +32,7 @@ func (c *Counter) Next() int { var goFuncs = template.FuncMap{ "fullName": fullName, + "structName": structName, "hasChains": hasChains, "fieldType": fieldType, "recordType": recordType, @@ -75,15 +76,27 @@ func wrapped(r typegen.Record) bool { return typ.Code == typegen.TypeCodeUnknown && typ.Name == "raw" } -func fullName(r typegen.Record) string { +func structName(r typegen.Record) string { e, ok := r.(*typegen.EntityRecord) if !ok || !e.Interface { return r.FullName() } - name := e.FullName() + name := r.FullName() return strings.ToLower(name[:1]) + name[1:] } +func fullName(r typegen.Record) string { + name := structName(r) + if len(r.GetTypeParameters()) == 0 { + return name + } + var params []string + for _, p := range r.GetTypeParameters() { + params = append(params, p.Name) + } + return name + "[" + strings.Join(params, ", ") + "]" +} + func hasChains(r typegen.Record) bool { switch r := r.(type) { case *typegen.ChainRecord: diff --git a/tools/cmd/gen-model/go.go.tmpl b/tools/cmd/gen-model/go.go.tmpl index 4ade01eac..a0abe0a37 100644 --- a/tools/cmd/gen-model/go.go.tmpl +++ b/tools/cmd/gen-model/go.go.tmpl @@ -25,6 +25,27 @@ import ( "gitlab.com/accumulatenetwork/accumulate/internal/database/smt/storage" ) + +{{ define "typeParams"}} +{{- if .TypeParameters -}} +[ +{{- range .TypeParameters -}} +{{.Name}} {{.Constraint}}, +{{- end -}} +] +{{- end -}} +{{ end}} + +{{ define "typeArgs"}} +{{- if .TypeParameters -}} +[ +{{- range .TypeParameters -}} +{{.Name}}, +{{- end -}} +] +{{- end -}} +{{ end}} + {{ define "accessor"}} {{- if .Private}}get{{end}}{{.Name}} {{- end}} @@ -85,7 +106,7 @@ return values.NewCounted(c.logger.L, c.{{valueStore .}}, {{template "key" .}}, v {{$c := .}} {{if .Interface}} -type {{.FullName}} interface { +type {{.FullName}}{{template "typeParams" .}} interface { record.Record {{- range .Attributes}} {{template "accessor" .}}({{range .GetParameters}}{{lower .Name}} {{parameterType .}},{{end}}) {{recordType . false}} @@ -93,7 +114,7 @@ type {{.FullName}} interface { } {{end}} -type {{fullName .}} struct { +type {{structName .}}{{template "typeParams" .}} struct { logger {{logger}} store record.Store {{- if not .Root}} diff --git a/tools/internal/typegen/records.go b/tools/internal/typegen/records.go index cfc27baac..44457ef02 100644 --- a/tools/internal/typegen/records.go +++ b/tools/internal/typegen/records.go @@ -14,6 +14,7 @@ type Record interface { Type() RecordType GetParent() *EntityRecord GetParameters() []*Field + GetTypeParameters() []*TypeParameter FullName() string GetName() string } @@ -36,23 +37,10 @@ func (t RecordType) IsState() bool { return t == RecordTypeState } func (t RecordType) IsIndex() bool { return t == RecordTypeIndex } func (t RecordType) IsOther() bool { return t == RecordTypeOther } -func (r *EntityRecord) GetName() string { return r.Name } -func (r *ChainRecord) GetName() string { return r.Name } -func (r *StateRecord) GetName() string { return r.Name } -func (r *IndexRecord) GetName() string { return r.Name } -func (r *OtherRecord) GetName() string { return r.Name } - -func (r *EntityRecord) GetParameters() []*Field { return r.Parameters } -func (r *ChainRecord) GetParameters() []*Field { return r.Parameters } -func (r *StateRecord) GetParameters() []*Field { return r.Parameters } -func (r *IndexRecord) GetParameters() []*Field { return r.Parameters } -func (r *OtherRecord) GetParameters() []*Field { return r.Parameters } - -func (r *EntityRecord) GetParent() *EntityRecord { return r.Parent } -func (r *ChainRecord) GetParent() *EntityRecord { return r.Parent } -func (r *StateRecord) GetParent() *EntityRecord { return r.Parent } -func (r *IndexRecord) GetParent() *EntityRecord { return r.Parent } -func (r *OtherRecord) GetParent() *EntityRecord { return r.Parent } +func (r *RecordBase) GetName() string { return r.Name } +func (r *RecordBase) GetParameters() []*Field { return r.Parameters } +func (r *RecordBase) GetTypeParameters() []*TypeParameter { return r.TypeParameters } +func (r *RecordBase) GetParent() *EntityRecord { return r.Parent } func (r *EntityRecord) FullName() string { if r.Root { diff --git a/tools/internal/typegen/types.yml b/tools/internal/typegen/types.yml index 7d3974b50..0e6838e6a 100644 --- a/tools/internal/typegen/types.yml +++ b/tools/internal/typegen/types.yml @@ -19,6 +19,11 @@ RecordBase: type: bool - name: CustomValueConstructor type: bool + - name: TypeParameters + type: TypeParameter + pointer: true + marshal-as: reference + repeatable: true - name: Parameters type: Field pointer: true @@ -27,6 +32,13 @@ RecordBase: - name: Index type: string +TypeParameter: + fields: + - name: Name + type: string + - name: Constraint + type: string + EntityRecord: non-binary: true incomparable: true diff --git a/tools/internal/typegen/types_gen.go b/tools/internal/typegen/types_gen.go index c716646df..40798e275 100644 --- a/tools/internal/typegen/types_gen.go +++ b/tools/internal/typegen/types_gen.go @@ -11,8 +11,12 @@ package typegen //lint:file-ignore S1001,S1002,S1008,SA4013 generated code import ( + "bytes" "encoding/json" + "errors" "fmt" + "io" + "strings" "gitlab.com/accumulatenetwork/accumulate/pkg/types/encoding" ) @@ -58,16 +62,17 @@ type OtherRecord struct { } type RecordBase struct { - Name string `json:"name,omitempty" form:"name" query:"name" validate:"required"` - Key string `json:"key,omitempty" form:"key" query:"key" validate:"required"` - Description string `json:"description,omitempty" form:"description" query:"description" validate:"required"` - Parent *EntityRecord `json:"parent,omitempty" form:"parent" query:"parent" validate:"required"` - Private bool `json:"private,omitempty" form:"private" query:"private" validate:"required"` - OmitAccessor bool `json:"omitAccessor,omitempty" form:"omitAccessor" query:"omitAccessor" validate:"required"` - OmitConstructor bool `json:"omitConstructor,omitempty" form:"omitConstructor" query:"omitConstructor" validate:"required"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty" form:"customValueConstructor" query:"customValueConstructor" validate:"required"` - Parameters []*Field `json:"parameters,omitempty" form:"parameters" query:"parameters" validate:"required"` - Index string `json:"index,omitempty" form:"index" query:"index" validate:"required"` + Name string `json:"name,omitempty" form:"name" query:"name" validate:"required"` + Key string `json:"key,omitempty" form:"key" query:"key" validate:"required"` + Description string `json:"description,omitempty" form:"description" query:"description" validate:"required"` + Parent *EntityRecord `json:"parent,omitempty" form:"parent" query:"parent" validate:"required"` + Private bool `json:"private,omitempty" form:"private" query:"private" validate:"required"` + OmitAccessor bool `json:"omitAccessor,omitempty" form:"omitAccessor" query:"omitAccessor" validate:"required"` + OmitConstructor bool `json:"omitConstructor,omitempty" form:"omitConstructor" query:"omitConstructor" validate:"required"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty" form:"customValueConstructor" query:"customValueConstructor" validate:"required"` + TypeParameters []*TypeParameter `json:"typeParameters,omitempty" form:"typeParameters" query:"typeParameters" validate:"required"` + Parameters []*Field `json:"parameters,omitempty" form:"parameters" query:"parameters" validate:"required"` + Index string `json:"index,omitempty" form:"index" query:"index" validate:"required"` } type StateRecord struct { @@ -80,6 +85,13 @@ type StateRecord struct { Comparator string `json:"comparator,omitempty" form:"comparator" query:"comparator" validate:"required"` } +type TypeParameter struct { + fieldsSet []bool + Name string `json:"name,omitempty" form:"name" query:"name" validate:"required"` + Constraint string `json:"constraint,omitempty" form:"constraint" query:"constraint" validate:"required"` + extraData []byte +} + func (*ChainRecord) Type() RecordType { return RecordTypeChain } func (*EntityRecord) Type() RecordType { return RecordTypeEntity } @@ -90,6 +102,110 @@ func (*OtherRecord) Type() RecordType { return RecordTypeOther } func (*StateRecord) Type() RecordType { return RecordTypeState } +func (v *TypeParameter) Copy() *TypeParameter { + u := new(TypeParameter) + + u.Name = v.Name + u.Constraint = v.Constraint + if len(v.extraData) > 0 { + u.extraData = make([]byte, len(v.extraData)) + copy(u.extraData, v.extraData) + } + + return u +} + +func (v *TypeParameter) CopyAsInterface() interface{} { return v.Copy() } + +func (v *TypeParameter) Equal(u *TypeParameter) bool { + if !(v.Name == u.Name) { + return false + } + if !(v.Constraint == u.Constraint) { + return false + } + + return true +} + +var fieldNames_TypeParameter = []string{ + 1: "Name", + 2: "Constraint", +} + +func (v *TypeParameter) MarshalBinary() ([]byte, error) { + if v == nil { + return []byte{encoding.EmptyObject}, nil + } + + buffer := new(bytes.Buffer) + writer := encoding.NewWriter(buffer) + + if !(len(v.Name) == 0) { + writer.WriteString(1, v.Name) + } + if !(len(v.Constraint) == 0) { + writer.WriteString(2, v.Constraint) + } + + _, _, err := writer.Reset(fieldNames_TypeParameter) + if err != nil { + return nil, encoding.Error{E: err} + } + buffer.Write(v.extraData) + return buffer.Bytes(), nil +} + +func (v *TypeParameter) IsValid() error { + var errs []string + + if len(v.fieldsSet) > 0 && !v.fieldsSet[0] { + errs = append(errs, "field Name is missing") + } else if len(v.Name) == 0 { + errs = append(errs, "field Name is not set") + } + if len(v.fieldsSet) > 1 && !v.fieldsSet[1] { + errs = append(errs, "field Constraint is missing") + } else if len(v.Constraint) == 0 { + errs = append(errs, "field Constraint is not set") + } + + switch len(errs) { + case 0: + return nil + case 1: + return errors.New(errs[0]) + default: + return errors.New(strings.Join(errs, "; ")) + } +} + +func (v *TypeParameter) UnmarshalBinary(data []byte) error { + return v.UnmarshalBinaryFrom(bytes.NewReader(data)) +} + +func (v *TypeParameter) UnmarshalBinaryFrom(rd io.Reader) error { + reader := encoding.NewReader(rd) + + if x, ok := reader.ReadString(1); ok { + v.Name = x + } + if x, ok := reader.ReadString(2); ok { + v.Constraint = x + } + + seen, err := reader.Reset(fieldNames_TypeParameter) + if err != nil { + return encoding.Error{E: err} + } + v.fieldsSet = seen + v.extraData, err = reader.ReadAll() + if err != nil { + return encoding.Error{E: err} + } + return nil +} + func init() { encoding.RegisterTypeDefinition(&[]*encoding.TypeField{ @@ -102,6 +218,7 @@ func init() { encoding.NewTypeField("omitAccessor", "bool"), encoding.NewTypeField("omitConstructor", "bool"), encoding.NewTypeField("customValueConstructor", "bool"), + encoding.NewTypeField("typeParameters", "TypeParameter[]"), encoding.NewTypeField("parameters", "Field[]"), encoding.NewTypeField("index", "string"), encoding.NewTypeField("chainType", "string"), @@ -117,6 +234,7 @@ func init() { encoding.NewTypeField("omitAccessor", "bool"), encoding.NewTypeField("omitConstructor", "bool"), encoding.NewTypeField("customValueConstructor", "bool"), + encoding.NewTypeField("typeParameters", "TypeParameter[]"), encoding.NewTypeField("parameters", "Field[]"), encoding.NewTypeField("index", "string"), encoding.NewTypeField("fields", "Field[]"), @@ -144,6 +262,7 @@ func init() { encoding.NewTypeField("omitAccessor", "bool"), encoding.NewTypeField("omitConstructor", "bool"), encoding.NewTypeField("customValueConstructor", "bool"), + encoding.NewTypeField("typeParameters", "TypeParameter[]"), encoding.NewTypeField("parameters", "Field[]"), encoding.NewTypeField("index", "string"), encoding.NewTypeField("dataType", "FieldType"), @@ -164,6 +283,7 @@ func init() { encoding.NewTypeField("omitAccessor", "bool"), encoding.NewTypeField("omitConstructor", "bool"), encoding.NewTypeField("customValueConstructor", "bool"), + encoding.NewTypeField("typeParameters", "TypeParameter[]"), encoding.NewTypeField("parameters", "Field[]"), encoding.NewTypeField("index", "string"), encoding.NewTypeField("dataType", "string"), @@ -181,6 +301,7 @@ func init() { encoding.NewTypeField("omitAccessor", "bool"), encoding.NewTypeField("omitConstructor", "bool"), encoding.NewTypeField("customValueConstructor", "bool"), + encoding.NewTypeField("typeParameters", "TypeParameter[]"), encoding.NewTypeField("parameters", "Field[]"), encoding.NewTypeField("index", "string"), }, "RecordBase", "recordBase") @@ -195,6 +316,7 @@ func init() { encoding.NewTypeField("omitAccessor", "bool"), encoding.NewTypeField("omitConstructor", "bool"), encoding.NewTypeField("customValueConstructor", "bool"), + encoding.NewTypeField("typeParameters", "TypeParameter[]"), encoding.NewTypeField("parameters", "Field[]"), encoding.NewTypeField("index", "string"), encoding.NewTypeField("dataType", "FieldType"), @@ -205,22 +327,28 @@ func init() { encoding.NewTypeField("comparator", "string"), }, "StateRecord", "stateRecord") + encoding.RegisterTypeDefinition(&[]*encoding.TypeField{ + encoding.NewTypeField("name", "string"), + encoding.NewTypeField("constraint", "string"), + }, "TypeParameter", "typeParameter") + } func (v *ChainRecord) MarshalJSON() ([]byte, error) { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - ChainType string `json:"chainType,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + ChainType string `json:"chainType,omitempty"` }{} u.Type = v.Type() if !(len(v.RecordBase.Name) == 0) { @@ -247,6 +375,9 @@ func (v *ChainRecord) MarshalJSON() ([]byte, error) { if !(!v.RecordBase.CustomValueConstructor) { u.CustomValueConstructor = v.RecordBase.CustomValueConstructor } + if !(len(v.RecordBase.TypeParameters) == 0) { + u.TypeParameters = v.RecordBase.TypeParameters + } if !(len(v.RecordBase.Parameters) == 0) { u.Parameters = v.RecordBase.Parameters } @@ -270,6 +401,7 @@ func (v *EntityRecord) MarshalJSON() ([]byte, error) { OmitAccessor bool `json:"omitAccessor,omitempty"` OmitConstructor bool `json:"omitConstructor,omitempty"` CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` Index string `json:"index,omitempty"` Fields encoding.JsonList[*Field] `json:"fields,omitempty"` @@ -311,6 +443,9 @@ func (v *EntityRecord) MarshalJSON() ([]byte, error) { if !(!v.RecordBase.CustomValueConstructor) { u.CustomValueConstructor = v.RecordBase.CustomValueConstructor } + if !(len(v.RecordBase.TypeParameters) == 0) { + u.TypeParameters = v.RecordBase.TypeParameters + } if !(len(v.RecordBase.Parameters) == 0) { u.Parameters = v.RecordBase.Parameters } @@ -361,23 +496,24 @@ func (v *EntityRecord) MarshalJSON() ([]byte, error) { func (v *IndexRecord) MarshalJSON() ([]byte, error) { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - DataType FieldType `json:"dataType,omitempty"` - Pointer bool `json:"pointer,omitempty"` - EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` - Union bool `json:"union,omitempty"` - Collection CollectionType `json:"collection,omitempty"` - Comparator string `json:"comparator,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + DataType FieldType `json:"dataType,omitempty"` + Pointer bool `json:"pointer,omitempty"` + EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` + Union bool `json:"union,omitempty"` + Collection CollectionType `json:"collection,omitempty"` + Comparator string `json:"comparator,omitempty"` }{} u.Type = v.Type() if !(len(v.RecordBase.Name) == 0) { @@ -404,6 +540,9 @@ func (v *IndexRecord) MarshalJSON() ([]byte, error) { if !(!v.RecordBase.CustomValueConstructor) { u.CustomValueConstructor = v.RecordBase.CustomValueConstructor } + if !(len(v.RecordBase.TypeParameters) == 0) { + u.TypeParameters = v.RecordBase.TypeParameters + } if !(len(v.RecordBase.Parameters) == 0) { u.Parameters = v.RecordBase.Parameters } @@ -433,21 +572,22 @@ func (v *IndexRecord) MarshalJSON() ([]byte, error) { func (v *OtherRecord) MarshalJSON() ([]byte, error) { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - DataType string `json:"dataType,omitempty"` - Pointer bool `json:"pointer,omitempty"` - HasChains bool `json:"hasChains,omitempty"` - Constructor string `json:"constructor,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + DataType string `json:"dataType,omitempty"` + Pointer bool `json:"pointer,omitempty"` + HasChains bool `json:"hasChains,omitempty"` + Constructor string `json:"constructor,omitempty"` }{} u.Type = v.Type() if !(len(v.RecordBase.Name) == 0) { @@ -474,6 +614,9 @@ func (v *OtherRecord) MarshalJSON() ([]byte, error) { if !(!v.RecordBase.CustomValueConstructor) { u.CustomValueConstructor = v.RecordBase.CustomValueConstructor } + if !(len(v.RecordBase.TypeParameters) == 0) { + u.TypeParameters = v.RecordBase.TypeParameters + } if !(len(v.RecordBase.Parameters) == 0) { u.Parameters = v.RecordBase.Parameters } @@ -497,16 +640,17 @@ func (v *OtherRecord) MarshalJSON() ([]byte, error) { func (v *RecordBase) MarshalJSON() ([]byte, error) { u := struct { - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` }{} if !(len(v.Name) == 0) { u.Name = v.Name @@ -532,6 +676,9 @@ func (v *RecordBase) MarshalJSON() ([]byte, error) { if !(!v.CustomValueConstructor) { u.CustomValueConstructor = v.CustomValueConstructor } + if !(len(v.TypeParameters) == 0) { + u.TypeParameters = v.TypeParameters + } if !(len(v.Parameters) == 0) { u.Parameters = v.Parameters } @@ -543,23 +690,24 @@ func (v *RecordBase) MarshalJSON() ([]byte, error) { func (v *StateRecord) MarshalJSON() ([]byte, error) { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - DataType FieldType `json:"dataType,omitempty"` - Pointer bool `json:"pointer,omitempty"` - EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` - Union bool `json:"union,omitempty"` - Collection CollectionType `json:"collection,omitempty"` - Comparator string `json:"comparator,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + DataType FieldType `json:"dataType,omitempty"` + Pointer bool `json:"pointer,omitempty"` + EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` + Union bool `json:"union,omitempty"` + Collection CollectionType `json:"collection,omitempty"` + Comparator string `json:"comparator,omitempty"` }{} u.Type = v.Type() if !(len(v.RecordBase.Name) == 0) { @@ -586,6 +734,9 @@ func (v *StateRecord) MarshalJSON() ([]byte, error) { if !(!v.RecordBase.CustomValueConstructor) { u.CustomValueConstructor = v.RecordBase.CustomValueConstructor } + if !(len(v.RecordBase.TypeParameters) == 0) { + u.TypeParameters = v.RecordBase.TypeParameters + } if !(len(v.RecordBase.Parameters) == 0) { u.Parameters = v.RecordBase.Parameters } @@ -615,18 +766,19 @@ func (v *StateRecord) MarshalJSON() ([]byte, error) { func (v *ChainRecord) UnmarshalJSON(data []byte) error { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - ChainType string `json:"chainType,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + ChainType string `json:"chainType,omitempty"` }{} u.Type = v.Type() u.Name = v.RecordBase.Name @@ -637,6 +789,7 @@ func (v *ChainRecord) UnmarshalJSON(data []byte) error { u.OmitAccessor = v.RecordBase.OmitAccessor u.OmitConstructor = v.RecordBase.OmitConstructor u.CustomValueConstructor = v.RecordBase.CustomValueConstructor + u.TypeParameters = v.RecordBase.TypeParameters u.Parameters = v.RecordBase.Parameters u.Index = v.RecordBase.Index u.ChainType = v.ChainType @@ -655,6 +808,7 @@ func (v *ChainRecord) UnmarshalJSON(data []byte) error { v.RecordBase.OmitAccessor = u.OmitAccessor v.RecordBase.OmitConstructor = u.OmitConstructor v.RecordBase.CustomValueConstructor = u.CustomValueConstructor + v.RecordBase.TypeParameters = u.TypeParameters v.RecordBase.Parameters = u.Parameters v.RecordBase.Index = u.Index v.ChainType = u.ChainType @@ -672,6 +826,7 @@ func (v *EntityRecord) UnmarshalJSON(data []byte) error { OmitAccessor bool `json:"omitAccessor,omitempty"` OmitConstructor bool `json:"omitConstructor,omitempty"` CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` Index string `json:"index,omitempty"` Fields encoding.JsonList[*Field] `json:"fields,omitempty"` @@ -697,6 +852,7 @@ func (v *EntityRecord) UnmarshalJSON(data []byte) error { u.OmitAccessor = v.RecordBase.OmitAccessor u.OmitConstructor = v.RecordBase.OmitConstructor u.CustomValueConstructor = v.RecordBase.CustomValueConstructor + u.TypeParameters = v.RecordBase.TypeParameters u.Parameters = v.RecordBase.Parameters u.Index = v.RecordBase.Index u.Fields = v.Fields @@ -727,6 +883,7 @@ func (v *EntityRecord) UnmarshalJSON(data []byte) error { v.RecordBase.OmitAccessor = u.OmitAccessor v.RecordBase.OmitConstructor = u.OmitConstructor v.RecordBase.CustomValueConstructor = u.CustomValueConstructor + v.RecordBase.TypeParameters = u.TypeParameters v.RecordBase.Parameters = u.Parameters v.RecordBase.Index = u.Index v.Fields = u.Fields @@ -752,23 +909,24 @@ func (v *EntityRecord) UnmarshalJSON(data []byte) error { func (v *IndexRecord) UnmarshalJSON(data []byte) error { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - DataType FieldType `json:"dataType,omitempty"` - Pointer bool `json:"pointer,omitempty"` - EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` - Union bool `json:"union,omitempty"` - Collection CollectionType `json:"collection,omitempty"` - Comparator string `json:"comparator,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + DataType FieldType `json:"dataType,omitempty"` + Pointer bool `json:"pointer,omitempty"` + EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` + Union bool `json:"union,omitempty"` + Collection CollectionType `json:"collection,omitempty"` + Comparator string `json:"comparator,omitempty"` }{} u.Type = v.Type() u.Name = v.RecordBase.Name @@ -779,6 +937,7 @@ func (v *IndexRecord) UnmarshalJSON(data []byte) error { u.OmitAccessor = v.RecordBase.OmitAccessor u.OmitConstructor = v.RecordBase.OmitConstructor u.CustomValueConstructor = v.RecordBase.CustomValueConstructor + u.TypeParameters = v.RecordBase.TypeParameters u.Parameters = v.RecordBase.Parameters u.Index = v.RecordBase.Index u.DataType = v.DataType @@ -802,6 +961,7 @@ func (v *IndexRecord) UnmarshalJSON(data []byte) error { v.RecordBase.OmitAccessor = u.OmitAccessor v.RecordBase.OmitConstructor = u.OmitConstructor v.RecordBase.CustomValueConstructor = u.CustomValueConstructor + v.RecordBase.TypeParameters = u.TypeParameters v.RecordBase.Parameters = u.Parameters v.RecordBase.Index = u.Index v.DataType = u.DataType @@ -815,21 +975,22 @@ func (v *IndexRecord) UnmarshalJSON(data []byte) error { func (v *OtherRecord) UnmarshalJSON(data []byte) error { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - DataType string `json:"dataType,omitempty"` - Pointer bool `json:"pointer,omitempty"` - HasChains bool `json:"hasChains,omitempty"` - Constructor string `json:"constructor,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + DataType string `json:"dataType,omitempty"` + Pointer bool `json:"pointer,omitempty"` + HasChains bool `json:"hasChains,omitempty"` + Constructor string `json:"constructor,omitempty"` }{} u.Type = v.Type() u.Name = v.RecordBase.Name @@ -840,6 +1001,7 @@ func (v *OtherRecord) UnmarshalJSON(data []byte) error { u.OmitAccessor = v.RecordBase.OmitAccessor u.OmitConstructor = v.RecordBase.OmitConstructor u.CustomValueConstructor = v.RecordBase.CustomValueConstructor + u.TypeParameters = v.RecordBase.TypeParameters u.Parameters = v.RecordBase.Parameters u.Index = v.RecordBase.Index u.DataType = v.DataType @@ -861,6 +1023,7 @@ func (v *OtherRecord) UnmarshalJSON(data []byte) error { v.RecordBase.OmitAccessor = u.OmitAccessor v.RecordBase.OmitConstructor = u.OmitConstructor v.RecordBase.CustomValueConstructor = u.CustomValueConstructor + v.RecordBase.TypeParameters = u.TypeParameters v.RecordBase.Parameters = u.Parameters v.RecordBase.Index = u.Index v.DataType = u.DataType @@ -872,16 +1035,17 @@ func (v *OtherRecord) UnmarshalJSON(data []byte) error { func (v *RecordBase) UnmarshalJSON(data []byte) error { u := struct { - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` }{} u.Name = v.Name u.Key = v.Key @@ -891,6 +1055,7 @@ func (v *RecordBase) UnmarshalJSON(data []byte) error { u.OmitAccessor = v.OmitAccessor u.OmitConstructor = v.OmitConstructor u.CustomValueConstructor = v.CustomValueConstructor + u.TypeParameters = v.TypeParameters u.Parameters = v.Parameters u.Index = v.Index err := json.Unmarshal(data, &u) @@ -905,6 +1070,7 @@ func (v *RecordBase) UnmarshalJSON(data []byte) error { v.OmitAccessor = u.OmitAccessor v.OmitConstructor = u.OmitConstructor v.CustomValueConstructor = u.CustomValueConstructor + v.TypeParameters = u.TypeParameters v.Parameters = u.Parameters v.Index = u.Index return nil @@ -912,23 +1078,24 @@ func (v *RecordBase) UnmarshalJSON(data []byte) error { func (v *StateRecord) UnmarshalJSON(data []byte) error { u := struct { - Type RecordType `json:"type"` - Name string `json:"name,omitempty"` - Key string `json:"key,omitempty"` - Description string `json:"description,omitempty"` - Parent *EntityRecord `json:"parent,omitempty"` - Private bool `json:"private,omitempty"` - OmitAccessor bool `json:"omitAccessor,omitempty"` - OmitConstructor bool `json:"omitConstructor,omitempty"` - CustomValueConstructor bool `json:"customValueConstructor,omitempty"` - Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` - Index string `json:"index,omitempty"` - DataType FieldType `json:"dataType,omitempty"` - Pointer bool `json:"pointer,omitempty"` - EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` - Union bool `json:"union,omitempty"` - Collection CollectionType `json:"collection,omitempty"` - Comparator string `json:"comparator,omitempty"` + Type RecordType `json:"type"` + Name string `json:"name,omitempty"` + Key string `json:"key,omitempty"` + Description string `json:"description,omitempty"` + Parent *EntityRecord `json:"parent,omitempty"` + Private bool `json:"private,omitempty"` + OmitAccessor bool `json:"omitAccessor,omitempty"` + OmitConstructor bool `json:"omitConstructor,omitempty"` + CustomValueConstructor bool `json:"customValueConstructor,omitempty"` + TypeParameters encoding.JsonList[*TypeParameter] `json:"typeParameters,omitempty"` + Parameters encoding.JsonList[*Field] `json:"parameters,omitempty"` + Index string `json:"index,omitempty"` + DataType FieldType `json:"dataType,omitempty"` + Pointer bool `json:"pointer,omitempty"` + EmptyIfMissing bool `json:"emptyIfMissing,omitempty"` + Union bool `json:"union,omitempty"` + Collection CollectionType `json:"collection,omitempty"` + Comparator string `json:"comparator,omitempty"` }{} u.Type = v.Type() u.Name = v.RecordBase.Name @@ -939,6 +1106,7 @@ func (v *StateRecord) UnmarshalJSON(data []byte) error { u.OmitAccessor = v.RecordBase.OmitAccessor u.OmitConstructor = v.RecordBase.OmitConstructor u.CustomValueConstructor = v.RecordBase.CustomValueConstructor + u.TypeParameters = v.RecordBase.TypeParameters u.Parameters = v.RecordBase.Parameters u.Index = v.RecordBase.Index u.DataType = v.DataType @@ -962,6 +1130,7 @@ func (v *StateRecord) UnmarshalJSON(data []byte) error { v.RecordBase.OmitAccessor = u.OmitAccessor v.RecordBase.OmitConstructor = u.OmitConstructor v.RecordBase.CustomValueConstructor = u.CustomValueConstructor + v.RecordBase.TypeParameters = u.TypeParameters v.RecordBase.Parameters = u.Parameters v.RecordBase.Index = u.Index v.DataType = u.DataType