| //////////////////////////////////////////////////////////////////////////////// |
| // Do not modify! |
| // Generated by codergen |
| //////////////////////////////////////////////////////////////////////////////// |
| |
| package test |
| |
| import ( |
| "android.googlesource.com/platform/tools/gpu/binary" |
| "android.googlesource.com/platform/tools/gpu/binary/registry" |
| "android.googlesource.com/platform/tools/gpu/binary/schema" |
| ) |
| |
| const ( |
| ixǁLeaf = iota |
| ixǁAnonymous |
| ixǁArray |
| ixǁArrayInMap |
| ixǁArrayOfArrays |
| ixǁContains |
| ixǁComplex |
| ixǁMapInArray |
| ixǁMapInSlice |
| ixǁMapKey |
| ixǁMapKeyValue |
| ixǁMapOfMaps |
| ixǁMapValue |
| ixǁSlice |
| ixǁSliceInMap |
| ixǁSliceOfSlices |
| ixǁTypeA |
| ixǁTypeB |
| ixǁTypeC |
| ixǁX |
| ixǁY |
| ) |
| |
| var entities [21]binary.Entity |
| |
| var Namespace = registry.NewNamespace() |
| |
| func init() { |
| registry.Global.AddFallbacks(Namespace) |
| Namespace.AddClassOf((*Leaf)(nil)) |
| Namespace.AddClassOf((*Anonymous)(nil)) |
| Namespace.AddClassOf((*Array)(nil)) |
| Namespace.AddClassOf((*ArrayInMap)(nil)) |
| Namespace.AddClassOf((*ArrayOfArrays)(nil)) |
| Namespace.AddClassOf((*Contains)(nil)) |
| Namespace.AddClassOf((*Complex)(nil)) |
| Namespace.AddClassOf((*MapInArray)(nil)) |
| Namespace.AddClassOf((*MapInSlice)(nil)) |
| Namespace.AddClassOf((*MapKey)(nil)) |
| Namespace.AddClassOf((*MapKeyValue)(nil)) |
| Namespace.AddClassOf((*MapOfMaps)(nil)) |
| Namespace.AddClassOf((*MapValue)(nil)) |
| Namespace.AddClassOf((*Slice)(nil)) |
| Namespace.AddClassOf((*SliceInMap)(nil)) |
| Namespace.AddClassOf((*SliceOfSlices)(nil)) |
| Namespace.AddClassOf((*TypeA)(nil)) |
| Namespace.AddClassOf((*TypeB)(nil)) |
| Namespace.AddClassOf((*TypeC)(nil)) |
| Namespace.AddClassOf((*X)(nil)) |
| Namespace.AddClassOf((*Y)(nil)) |
| Namespace.AddFrozenOf((*X_V1)(nil)) |
| } |
| |
| type binaryClassLeaf struct{} |
| |
| func (*Leaf) Class() binary.Class { |
| return (*binaryClassLeaf)(nil) |
| } |
| func doEncodeLeaf(e binary.Writer, o *Leaf) { |
| e.Uint32(o.A) |
| } |
| func doDecodeLeaf(d binary.Reader, o *Leaf) { |
| o.A = uint32(d.Uint32()) |
| } |
| func (*binaryClassLeaf) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeLeaf(e, obj.(*Leaf)) |
| } |
| func (*binaryClassLeaf) New() binary.Object { |
| return &Leaf{} |
| } |
| func (*binaryClassLeaf) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeLeaf(d, obj.(*Leaf)) |
| } |
| func (o *Leaf) WriteSimple(w binary.Writer) { |
| doEncodeLeaf(w, o) |
| } |
| func (o *Leaf) ReadSimple(r binary.Reader) { |
| doDecodeLeaf(r, o) |
| } |
| func (c *binaryClassLeaf) Schema() *binary.Entity { |
| return &entities[ixǁLeaf] |
| } |
| |
| type binaryClassAnonymous struct{} |
| |
| func (*Anonymous) Class() binary.Class { |
| return (*binaryClassAnonymous)(nil) |
| } |
| func doEncodeAnonymous(e binary.Writer, o *Anonymous) { |
| e.Simple(&o.Leaf) |
| } |
| func doDecodeAnonymous(d binary.Reader, o *Anonymous) { |
| d.Simple(&o.Leaf) |
| } |
| func (*binaryClassAnonymous) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeAnonymous(e, obj.(*Anonymous)) |
| } |
| func (*binaryClassAnonymous) New() binary.Object { |
| return &Anonymous{} |
| } |
| func (*binaryClassAnonymous) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeAnonymous(d, obj.(*Anonymous)) |
| } |
| func (o *Anonymous) WriteSimple(w binary.Writer) { |
| doEncodeAnonymous(w, o) |
| } |
| func (o *Anonymous) ReadSimple(r binary.Reader) { |
| doDecodeAnonymous(r, o) |
| } |
| func (c *binaryClassAnonymous) Schema() *binary.Entity { |
| return &entities[ixǁAnonymous] |
| } |
| |
| type binaryClassArray struct{} |
| |
| func (*Array) Class() binary.Class { |
| return (*binaryClassArray)(nil) |
| } |
| func doEncodeArray(e binary.Writer, o *Array) { |
| for i := range o.Leaves { |
| curr := &o.Leaves[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| func doDecodeArray(d binary.Reader, o *Array) { |
| for i := range o.Leaves { |
| curr := &o.Leaves[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| func (*binaryClassArray) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeArray(e, obj.(*Array)) |
| } |
| func (*binaryClassArray) New() binary.Object { |
| return &Array{} |
| } |
| func (*binaryClassArray) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeArray(d, obj.(*Array)) |
| } |
| func (o *Array) WriteSimple(w binary.Writer) { |
| doEncodeArray(w, o) |
| } |
| func (o *Array) ReadSimple(r binary.Reader) { |
| doDecodeArray(r, o) |
| } |
| func (c *binaryClassArray) Schema() *binary.Entity { |
| return &entities[ixǁArray] |
| } |
| |
| type binaryClassArrayInMap struct{} |
| |
| func (*ArrayInMap) Class() binary.Class { |
| return (*binaryClassArrayInMap)(nil) |
| } |
| func doEncodeArrayInMap(e binary.Writer, o *ArrayInMap) { |
| e.Uint32(uint32(len(o.M))) |
| for k, v := range o.M { |
| e.Uint32(k) |
| for i := range v { |
| curr := &v[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| func doDecodeArrayInMap(d binary.Reader, o *ArrayInMap) { |
| if count := d.Count(); count > 0 { |
| o.M = make(map[uint32][3]Leaf, count) |
| m := o.M |
| for i := uint32(0); i < count; i++ { |
| var k uint32 |
| var v [3]Leaf |
| k = uint32(d.Uint32()) |
| for i := range v { |
| curr := &v[i] |
| d.Simple(&(*curr)) |
| } |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassArrayInMap) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeArrayInMap(e, obj.(*ArrayInMap)) |
| } |
| func (*binaryClassArrayInMap) New() binary.Object { |
| return &ArrayInMap{} |
| } |
| func (*binaryClassArrayInMap) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeArrayInMap(d, obj.(*ArrayInMap)) |
| } |
| func (o *ArrayInMap) WriteSimple(w binary.Writer) { |
| doEncodeArrayInMap(w, o) |
| } |
| func (o *ArrayInMap) ReadSimple(r binary.Reader) { |
| doDecodeArrayInMap(r, o) |
| } |
| func (c *binaryClassArrayInMap) Schema() *binary.Entity { |
| return &entities[ixǁArrayInMap] |
| } |
| |
| type binaryClassArrayOfArrays struct{} |
| |
| func (*ArrayOfArrays) Class() binary.Class { |
| return (*binaryClassArrayOfArrays)(nil) |
| } |
| func doEncodeArrayOfArrays(e binary.Writer, o *ArrayOfArrays) { |
| for i := range o.Array { |
| curr := &o.Array[i] |
| for i := range *curr { |
| curr := &(*curr)[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| func doDecodeArrayOfArrays(d binary.Reader, o *ArrayOfArrays) { |
| for i := range o.Array { |
| curr := &o.Array[i] |
| for i := range *curr { |
| curr := &(*curr)[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| } |
| func (*binaryClassArrayOfArrays) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeArrayOfArrays(e, obj.(*ArrayOfArrays)) |
| } |
| func (*binaryClassArrayOfArrays) New() binary.Object { |
| return &ArrayOfArrays{} |
| } |
| func (*binaryClassArrayOfArrays) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeArrayOfArrays(d, obj.(*ArrayOfArrays)) |
| } |
| func (o *ArrayOfArrays) WriteSimple(w binary.Writer) { |
| doEncodeArrayOfArrays(w, o) |
| } |
| func (o *ArrayOfArrays) ReadSimple(r binary.Reader) { |
| doDecodeArrayOfArrays(r, o) |
| } |
| func (c *binaryClassArrayOfArrays) Schema() *binary.Entity { |
| return &entities[ixǁArrayOfArrays] |
| } |
| |
| type binaryClassContains struct{} |
| |
| func (*Contains) Class() binary.Class { |
| return (*binaryClassContains)(nil) |
| } |
| func doEncodeContains(e binary.Writer, o *Contains) { |
| e.Simple(&o.LeafField) |
| } |
| func doDecodeContains(d binary.Reader, o *Contains) { |
| d.Simple(&o.LeafField) |
| } |
| func (*binaryClassContains) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeContains(e, obj.(*Contains)) |
| } |
| func (*binaryClassContains) New() binary.Object { |
| return &Contains{} |
| } |
| func (*binaryClassContains) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeContains(d, obj.(*Contains)) |
| } |
| func (o *Contains) WriteSimple(w binary.Writer) { |
| doEncodeContains(w, o) |
| } |
| func (o *Contains) ReadSimple(r binary.Reader) { |
| doDecodeContains(r, o) |
| } |
| func (c *binaryClassContains) Schema() *binary.Entity { |
| return &entities[ixǁContains] |
| } |
| |
| type binaryClassComplex struct{} |
| |
| func (*Complex) Class() binary.Class { |
| return (*binaryClassComplex)(nil) |
| } |
| func doEncodeComplex(e binary.Encoder, o *Complex) { |
| e.Uint32(uint32(len(o.SliceMapArray))) |
| for i := range o.SliceMapArray { |
| curr := &o.SliceMapArray[i] |
| e.Uint32(uint32(len(*curr))) |
| for k, v := range *curr { |
| e.Simple(&k) |
| for i := range v { |
| curr := &v[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| e.Uint32(uint32(len(o.SliceArrayMap))) |
| for i := range o.SliceArrayMap { |
| curr := &o.SliceArrayMap[i] |
| for i := range *curr { |
| curr := &(*curr)[i] |
| e.Uint32(uint32(len(*curr))) |
| for k, v := range *curr { |
| e.Simple(&k) |
| e.Simple(&v) |
| } |
| } |
| } |
| for i := range o.ArraySliceMap { |
| curr := &o.ArraySliceMap[i] |
| e.Uint32(uint32(len(*curr))) |
| for i := range *curr { |
| curr := &(*curr)[i] |
| e.Uint32(uint32(len(*curr))) |
| for k, v := range *curr { |
| e.Simple(&k) |
| e.Simple(&v) |
| } |
| } |
| } |
| for i := range o.ArrayMapSlice { |
| curr := &o.ArrayMapSlice[i] |
| e.Uint32(uint32(len(*curr))) |
| for k, v := range *curr { |
| e.Simple(&k) |
| e.Uint32(uint32(len(v))) |
| for i := range v { |
| curr := &v[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| e.Uint32(uint32(len(o.MapArraySlice))) |
| for k, v := range o.MapArraySlice { |
| e.Simple(&k) |
| for i := range v { |
| curr := &v[i] |
| e.Uint32(uint32(len(*curr))) |
| for i := range *curr { |
| curr := &(*curr)[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| e.Uint32(uint32(len(o.MapSliceArray))) |
| for k, v := range o.MapSliceArray { |
| e.Simple(&k) |
| e.Uint32(uint32(len(v))) |
| for i := range v { |
| curr := &v[i] |
| for i := range *curr { |
| curr := &(*curr)[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| } |
| func doDecodeComplex(d binary.Decoder, o *Complex) { |
| if count := d.Count(); count > 0 { |
| o.SliceMapArray = make([]map[Contains][3]Contains, count) |
| for i := range o.SliceMapArray { |
| curr := &o.SliceMapArray[i] |
| if count := d.Count(); count > 0 { |
| *curr = make(map[Contains][3]Contains, count) |
| m := *curr |
| for i := uint32(0); i < count; i++ { |
| var k Contains |
| var v [3]Contains |
| d.Simple(&k) |
| for i := range v { |
| curr := &v[i] |
| d.Simple(&(*curr)) |
| } |
| m[k] = v |
| } |
| } |
| } |
| } |
| if count := d.Count(); count > 0 { |
| o.SliceArrayMap = make([][3]map[Contains]Contains, count) |
| for i := range o.SliceArrayMap { |
| curr := &o.SliceArrayMap[i] |
| for i := range *curr { |
| curr := &(*curr)[i] |
| if count := d.Count(); count > 0 { |
| *curr = make(map[Contains]Contains, count) |
| m := *curr |
| for i := uint32(0); i < count; i++ { |
| var k Contains |
| var v Contains |
| d.Simple(&k) |
| d.Simple(&v) |
| m[k] = v |
| } |
| } |
| } |
| } |
| } |
| for i := range o.ArraySliceMap { |
| curr := &o.ArraySliceMap[i] |
| if count := d.Count(); count > 0 { |
| *curr = make([]map[Contains]Contains, count) |
| for i := range *curr { |
| curr := &(*curr)[i] |
| if count := d.Count(); count > 0 { |
| *curr = make(map[Contains]Contains, count) |
| m := *curr |
| for i := uint32(0); i < count; i++ { |
| var k Contains |
| var v Contains |
| d.Simple(&k) |
| d.Simple(&v) |
| m[k] = v |
| } |
| } |
| } |
| } |
| } |
| for i := range o.ArrayMapSlice { |
| curr := &o.ArrayMapSlice[i] |
| if count := d.Count(); count > 0 { |
| *curr = make(map[Contains][]Contains, count) |
| m := *curr |
| for i := uint32(0); i < count; i++ { |
| var k Contains |
| var v []Contains |
| d.Simple(&k) |
| if count := d.Count(); count > 0 { |
| v = make([]Contains, count) |
| for i := range v { |
| curr := &v[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| m[k] = v |
| } |
| } |
| } |
| if count := d.Count(); count > 0 { |
| o.MapArraySlice = make(map[Contains][3][]Contains, count) |
| m := o.MapArraySlice |
| for i := uint32(0); i < count; i++ { |
| var k Contains |
| var v [3][]Contains |
| d.Simple(&k) |
| for i := range v { |
| curr := &v[i] |
| if count := d.Count(); count > 0 { |
| *curr = make([]Contains, count) |
| for i := range *curr { |
| curr := &(*curr)[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| } |
| m[k] = v |
| } |
| } |
| if count := d.Count(); count > 0 { |
| o.MapSliceArray = make(map[Contains][][3]Contains, count) |
| m := o.MapSliceArray |
| for i := uint32(0); i < count; i++ { |
| var k Contains |
| var v [][3]Contains |
| d.Simple(&k) |
| if count := d.Count(); count > 0 { |
| v = make([][3]Contains, count) |
| for i := range v { |
| curr := &v[i] |
| for i := range *curr { |
| curr := &(*curr)[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| } |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassComplex) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeComplex(e, obj.(*Complex)) |
| } |
| func (*binaryClassComplex) New() binary.Object { |
| return &Complex{} |
| } |
| func (*binaryClassComplex) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeComplex(d, obj.(*Complex)) |
| } |
| func (c *binaryClassComplex) Schema() *binary.Entity { |
| return &entities[ixǁComplex] |
| } |
| |
| type binaryClassMapInArray struct{} |
| |
| func (*MapInArray) Class() binary.Class { |
| return (*binaryClassMapInArray)(nil) |
| } |
| func doEncodeMapInArray(e binary.Writer, o *MapInArray) { |
| for i := range o.Array { |
| curr := &o.Array[i] |
| e.Uint32(uint32(len(*curr))) |
| for k, v := range *curr { |
| e.Uint32(k) |
| e.Uint32(v) |
| } |
| } |
| } |
| func doDecodeMapInArray(d binary.Reader, o *MapInArray) { |
| for i := range o.Array { |
| curr := &o.Array[i] |
| if count := d.Count(); count > 0 { |
| *curr = make(map[uint32]uint32, count) |
| m := *curr |
| for i := uint32(0); i < count; i++ { |
| var k uint32 |
| var v uint32 |
| k = uint32(d.Uint32()) |
| v = uint32(d.Uint32()) |
| m[k] = v |
| } |
| } |
| } |
| } |
| func (*binaryClassMapInArray) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeMapInArray(e, obj.(*MapInArray)) |
| } |
| func (*binaryClassMapInArray) New() binary.Object { |
| return &MapInArray{} |
| } |
| func (*binaryClassMapInArray) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeMapInArray(d, obj.(*MapInArray)) |
| } |
| func (o *MapInArray) WriteSimple(w binary.Writer) { |
| doEncodeMapInArray(w, o) |
| } |
| func (o *MapInArray) ReadSimple(r binary.Reader) { |
| doDecodeMapInArray(r, o) |
| } |
| func (c *binaryClassMapInArray) Schema() *binary.Entity { |
| return &entities[ixǁMapInArray] |
| } |
| |
| type binaryClassMapInSlice struct{} |
| |
| func (*MapInSlice) Class() binary.Class { |
| return (*binaryClassMapInSlice)(nil) |
| } |
| func doEncodeMapInSlice(e binary.Encoder, o *MapInSlice) { |
| e.Uint32(uint32(len(o.Slice))) |
| for i := range o.Slice { |
| curr := &o.Slice[i] |
| e.Uint32(uint32(len(*curr))) |
| for k, v := range *curr { |
| e.Uint32(k) |
| e.Uint32(v) |
| } |
| } |
| } |
| func doDecodeMapInSlice(d binary.Decoder, o *MapInSlice) { |
| if count := d.Count(); count > 0 { |
| o.Slice = make([]map[uint32]uint32, count) |
| for i := range o.Slice { |
| curr := &o.Slice[i] |
| if count := d.Count(); count > 0 { |
| *curr = make(map[uint32]uint32, count) |
| m := *curr |
| for i := uint32(0); i < count; i++ { |
| var k uint32 |
| var v uint32 |
| k = uint32(d.Uint32()) |
| v = uint32(d.Uint32()) |
| m[k] = v |
| } |
| } |
| } |
| } |
| } |
| func (*binaryClassMapInSlice) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeMapInSlice(e, obj.(*MapInSlice)) |
| } |
| func (*binaryClassMapInSlice) New() binary.Object { |
| return &MapInSlice{} |
| } |
| func (*binaryClassMapInSlice) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeMapInSlice(d, obj.(*MapInSlice)) |
| } |
| func (c *binaryClassMapInSlice) Schema() *binary.Entity { |
| return &entities[ixǁMapInSlice] |
| } |
| |
| type binaryClassMapKey struct{} |
| |
| func (*MapKey) Class() binary.Class { |
| return (*binaryClassMapKey)(nil) |
| } |
| func doEncodeMapKey(e binary.Writer, o *MapKey) { |
| e.Uint32(uint32(len(o.M))) |
| for k, v := range o.M { |
| e.Simple(&k) |
| e.Uint32(v) |
| } |
| } |
| func doDecodeMapKey(d binary.Reader, o *MapKey) { |
| if count := d.Count(); count > 0 { |
| o.M = make(map[Leaf]uint32, count) |
| m := o.M |
| for i := uint32(0); i < count; i++ { |
| var k Leaf |
| var v uint32 |
| d.Simple(&k) |
| v = uint32(d.Uint32()) |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassMapKey) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeMapKey(e, obj.(*MapKey)) |
| } |
| func (*binaryClassMapKey) New() binary.Object { |
| return &MapKey{} |
| } |
| func (*binaryClassMapKey) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeMapKey(d, obj.(*MapKey)) |
| } |
| func (o *MapKey) WriteSimple(w binary.Writer) { |
| doEncodeMapKey(w, o) |
| } |
| func (o *MapKey) ReadSimple(r binary.Reader) { |
| doDecodeMapKey(r, o) |
| } |
| func (c *binaryClassMapKey) Schema() *binary.Entity { |
| return &entities[ixǁMapKey] |
| } |
| |
| type binaryClassMapKeyValue struct{} |
| |
| func (*MapKeyValue) Class() binary.Class { |
| return (*binaryClassMapKeyValue)(nil) |
| } |
| func doEncodeMapKeyValue(e binary.Writer, o *MapKeyValue) { |
| e.Uint32(uint32(len(o.M))) |
| for k, v := range o.M { |
| e.Simple(&k) |
| e.Simple(&v) |
| } |
| } |
| func doDecodeMapKeyValue(d binary.Reader, o *MapKeyValue) { |
| if count := d.Count(); count > 0 { |
| o.M = make(map[Leaf]Leaf, count) |
| m := o.M |
| for i := uint32(0); i < count; i++ { |
| var k Leaf |
| var v Leaf |
| d.Simple(&k) |
| d.Simple(&v) |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassMapKeyValue) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeMapKeyValue(e, obj.(*MapKeyValue)) |
| } |
| func (*binaryClassMapKeyValue) New() binary.Object { |
| return &MapKeyValue{} |
| } |
| func (*binaryClassMapKeyValue) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeMapKeyValue(d, obj.(*MapKeyValue)) |
| } |
| func (o *MapKeyValue) WriteSimple(w binary.Writer) { |
| doEncodeMapKeyValue(w, o) |
| } |
| func (o *MapKeyValue) ReadSimple(r binary.Reader) { |
| doDecodeMapKeyValue(r, o) |
| } |
| func (c *binaryClassMapKeyValue) Schema() *binary.Entity { |
| return &entities[ixǁMapKeyValue] |
| } |
| |
| type binaryClassMapOfMaps struct{} |
| |
| func (*MapOfMaps) Class() binary.Class { |
| return (*binaryClassMapOfMaps)(nil) |
| } |
| func doEncodeMapOfMaps(e binary.Encoder, o *MapOfMaps) { |
| e.Uint32(uint32(len(o.M))) |
| for k, v := range o.M { |
| e.Uint32(k) |
| e.Uint32(uint32(len(v))) |
| for k, v := range v { |
| e.Simple(&k) |
| e.Simple(&v) |
| } |
| } |
| } |
| func doDecodeMapOfMaps(d binary.Decoder, o *MapOfMaps) { |
| if count := d.Count(); count > 0 { |
| o.M = make(map[uint32]map[Leaf]Leaf, count) |
| m := o.M |
| for i := uint32(0); i < count; i++ { |
| var k uint32 |
| var v map[Leaf]Leaf |
| k = uint32(d.Uint32()) |
| if count := d.Count(); count > 0 { |
| v = make(map[Leaf]Leaf, count) |
| m := v |
| for i := uint32(0); i < count; i++ { |
| var k Leaf |
| var v Leaf |
| d.Simple(&k) |
| d.Simple(&v) |
| m[k] = v |
| } |
| } |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassMapOfMaps) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeMapOfMaps(e, obj.(*MapOfMaps)) |
| } |
| func (*binaryClassMapOfMaps) New() binary.Object { |
| return &MapOfMaps{} |
| } |
| func (*binaryClassMapOfMaps) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeMapOfMaps(d, obj.(*MapOfMaps)) |
| } |
| func (c *binaryClassMapOfMaps) Schema() *binary.Entity { |
| return &entities[ixǁMapOfMaps] |
| } |
| |
| type binaryClassMapValue struct{} |
| |
| func (*MapValue) Class() binary.Class { |
| return (*binaryClassMapValue)(nil) |
| } |
| func doEncodeMapValue(e binary.Writer, o *MapValue) { |
| e.Uint32(uint32(len(o.M))) |
| for k, v := range o.M { |
| e.Uint32(k) |
| e.Simple(&v) |
| } |
| } |
| func doDecodeMapValue(d binary.Reader, o *MapValue) { |
| if count := d.Count(); count > 0 { |
| o.M = make(map[uint32]Leaf, count) |
| m := o.M |
| for i := uint32(0); i < count; i++ { |
| var k uint32 |
| var v Leaf |
| k = uint32(d.Uint32()) |
| d.Simple(&v) |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassMapValue) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeMapValue(e, obj.(*MapValue)) |
| } |
| func (*binaryClassMapValue) New() binary.Object { |
| return &MapValue{} |
| } |
| func (*binaryClassMapValue) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeMapValue(d, obj.(*MapValue)) |
| } |
| func (o *MapValue) WriteSimple(w binary.Writer) { |
| doEncodeMapValue(w, o) |
| } |
| func (o *MapValue) ReadSimple(r binary.Reader) { |
| doDecodeMapValue(r, o) |
| } |
| func (c *binaryClassMapValue) Schema() *binary.Entity { |
| return &entities[ixǁMapValue] |
| } |
| |
| type binaryClassSlice struct{} |
| |
| func (*Slice) Class() binary.Class { |
| return (*binaryClassSlice)(nil) |
| } |
| func doEncodeSlice(e binary.Writer, o *Slice) { |
| e.Uint32(uint32(len(o.Leaves))) |
| for i := range o.Leaves { |
| curr := &o.Leaves[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| func doDecodeSlice(d binary.Reader, o *Slice) { |
| if count := d.Count(); count > 0 { |
| o.Leaves = make([]Leaf, count) |
| for i := range o.Leaves { |
| curr := &o.Leaves[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| } |
| func (*binaryClassSlice) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeSlice(e, obj.(*Slice)) |
| } |
| func (*binaryClassSlice) New() binary.Object { |
| return &Slice{} |
| } |
| func (*binaryClassSlice) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeSlice(d, obj.(*Slice)) |
| } |
| func (o *Slice) WriteSimple(w binary.Writer) { |
| doEncodeSlice(w, o) |
| } |
| func (o *Slice) ReadSimple(r binary.Reader) { |
| doDecodeSlice(r, o) |
| } |
| func (c *binaryClassSlice) Schema() *binary.Entity { |
| return &entities[ixǁSlice] |
| } |
| |
| type binaryClassSliceInMap struct{} |
| |
| func (*SliceInMap) Class() binary.Class { |
| return (*binaryClassSliceInMap)(nil) |
| } |
| func doEncodeSliceInMap(e binary.Encoder, o *SliceInMap) { |
| e.Uint32(uint32(len(o.M))) |
| for k, v := range o.M { |
| e.Uint32(k) |
| e.Uint32(uint32(len(v))) |
| for i := range v { |
| curr := &v[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| func doDecodeSliceInMap(d binary.Decoder, o *SliceInMap) { |
| if count := d.Count(); count > 0 { |
| o.M = make(map[uint32][]Leaf, count) |
| m := o.M |
| for i := uint32(0); i < count; i++ { |
| var k uint32 |
| var v []Leaf |
| k = uint32(d.Uint32()) |
| if count := d.Count(); count > 0 { |
| v = make([]Leaf, count) |
| for i := range v { |
| curr := &v[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| m[k] = v |
| } |
| } |
| } |
| func (*binaryClassSliceInMap) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeSliceInMap(e, obj.(*SliceInMap)) |
| } |
| func (*binaryClassSliceInMap) New() binary.Object { |
| return &SliceInMap{} |
| } |
| func (*binaryClassSliceInMap) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeSliceInMap(d, obj.(*SliceInMap)) |
| } |
| func (c *binaryClassSliceInMap) Schema() *binary.Entity { |
| return &entities[ixǁSliceInMap] |
| } |
| |
| type binaryClassSliceOfSlices struct{} |
| |
| func (*SliceOfSlices) Class() binary.Class { |
| return (*binaryClassSliceOfSlices)(nil) |
| } |
| func doEncodeSliceOfSlices(e binary.Encoder, o *SliceOfSlices) { |
| e.Uint32(uint32(len(o.Slice))) |
| for i := range o.Slice { |
| curr := &o.Slice[i] |
| e.Uint32(uint32(len(*curr))) |
| for i := range *curr { |
| curr := &(*curr)[i] |
| e.Simple(&(*curr)) |
| } |
| } |
| } |
| func doDecodeSliceOfSlices(d binary.Decoder, o *SliceOfSlices) { |
| if count := d.Count(); count > 0 { |
| o.Slice = make([][]Leaf, count) |
| for i := range o.Slice { |
| curr := &o.Slice[i] |
| if count := d.Count(); count > 0 { |
| *curr = make([]Leaf, count) |
| for i := range *curr { |
| curr := &(*curr)[i] |
| d.Simple(&(*curr)) |
| } |
| } |
| } |
| } |
| } |
| func (*binaryClassSliceOfSlices) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeSliceOfSlices(e, obj.(*SliceOfSlices)) |
| } |
| func (*binaryClassSliceOfSlices) New() binary.Object { |
| return &SliceOfSlices{} |
| } |
| func (*binaryClassSliceOfSlices) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeSliceOfSlices(d, obj.(*SliceOfSlices)) |
| } |
| func (c *binaryClassSliceOfSlices) Schema() *binary.Entity { |
| return &entities[ixǁSliceOfSlices] |
| } |
| |
| type binaryClassTypeA struct{} |
| |
| func (*TypeA) Class() binary.Class { |
| return (*binaryClassTypeA)(nil) |
| } |
| func doEncodeTypeA(e binary.Writer, o *TypeA) { |
| e.String(o.Data) |
| } |
| func doDecodeTypeA(d binary.Reader, o *TypeA) { |
| o.Data = string(d.String()) |
| } |
| func (*binaryClassTypeA) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeTypeA(e, obj.(*TypeA)) |
| } |
| func (*binaryClassTypeA) New() binary.Object { |
| return &TypeA{} |
| } |
| func (*binaryClassTypeA) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeTypeA(d, obj.(*TypeA)) |
| } |
| func (o *TypeA) WriteSimple(w binary.Writer) { |
| doEncodeTypeA(w, o) |
| } |
| func (o *TypeA) ReadSimple(r binary.Reader) { |
| doDecodeTypeA(r, o) |
| } |
| func (c *binaryClassTypeA) Schema() *binary.Entity { |
| return &entities[ixǁTypeA] |
| } |
| |
| type binaryClassTypeB struct{} |
| |
| func (*TypeB) Class() binary.Class { |
| return (*binaryClassTypeB)(nil) |
| } |
| func doEncodeTypeB(e binary.Writer, o *TypeB) { |
| e.String(o.Data) |
| } |
| func doDecodeTypeB(d binary.Reader, o *TypeB) { |
| o.Data = string(d.String()) |
| } |
| func (*binaryClassTypeB) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeTypeB(e, obj.(*TypeB)) |
| } |
| func (*binaryClassTypeB) New() binary.Object { |
| return &TypeB{} |
| } |
| func (*binaryClassTypeB) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeTypeB(d, obj.(*TypeB)) |
| } |
| func (o *TypeB) WriteSimple(w binary.Writer) { |
| doEncodeTypeB(w, o) |
| } |
| func (o *TypeB) ReadSimple(r binary.Reader) { |
| doDecodeTypeB(r, o) |
| } |
| func (c *binaryClassTypeB) Schema() *binary.Entity { |
| return &entities[ixǁTypeB] |
| } |
| |
| type binaryClassTypeC struct{} |
| |
| func (*TypeC) Class() binary.Class { |
| return (*binaryClassTypeC)(nil) |
| } |
| func doEncodeTypeC(e binary.Writer, o *TypeC) { |
| e.Int8(int8(o.Data)) |
| } |
| func doDecodeTypeC(d binary.Reader, o *TypeC) { |
| o.Data = Simple(d.Int8()) |
| } |
| func (*binaryClassTypeC) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeTypeC(e, obj.(*TypeC)) |
| } |
| func (*binaryClassTypeC) New() binary.Object { |
| return &TypeC{} |
| } |
| func (*binaryClassTypeC) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeTypeC(d, obj.(*TypeC)) |
| } |
| func (o *TypeC) WriteSimple(w binary.Writer) { |
| doEncodeTypeC(w, o) |
| } |
| func (o *TypeC) ReadSimple(r binary.Reader) { |
| doDecodeTypeC(r, o) |
| } |
| func (c *binaryClassTypeC) Schema() *binary.Entity { |
| return &entities[ixǁTypeC] |
| } |
| |
| type binaryClassX struct{} |
| |
| func (*X) Class() binary.Class { |
| return (*binaryClassX)(nil) |
| } |
| func doEncodeX(e binary.Writer, o *X) { |
| e.Int32(o.a) |
| e.Int32(o.b) |
| e.String(o.c) |
| } |
| func doDecodeX(d binary.Reader, o *X) { |
| o.a = int32(d.Int32()) |
| o.b = int32(d.Int32()) |
| o.c = string(d.String()) |
| } |
| func (*binaryClassX) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeX(e, obj.(*X)) |
| } |
| func (*binaryClassX) New() binary.Object { |
| return &X{} |
| } |
| func (*binaryClassX) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeX(d, obj.(*X)) |
| } |
| func (o *X) WriteSimple(w binary.Writer) { |
| doEncodeX(w, o) |
| } |
| func (o *X) ReadSimple(r binary.Reader) { |
| doDecodeX(r, o) |
| } |
| func (c *binaryClassX) Schema() *binary.Entity { |
| return &entities[ixǁX] |
| } |
| |
| type binaryClassY struct{} |
| |
| func (*Y) Class() binary.Class { |
| return (*binaryClassY)(nil) |
| } |
| func doEncodeY(e binary.Writer, o *Y) { |
| e.String(o.begin) |
| e.Simple(&o.x) |
| e.String(o.end) |
| } |
| func doDecodeY(d binary.Reader, o *Y) { |
| o.begin = string(d.String()) |
| d.Simple(&o.x) |
| o.end = string(d.String()) |
| } |
| func (*binaryClassY) Encode(e binary.Encoder, obj binary.Object) { |
| doEncodeY(e, obj.(*Y)) |
| } |
| func (*binaryClassY) New() binary.Object { |
| return &Y{} |
| } |
| func (*binaryClassY) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doDecodeY(d, obj.(*Y)) |
| } |
| func (o *Y) WriteSimple(w binary.Writer) { |
| doEncodeY(w, o) |
| } |
| func (o *Y) ReadSimple(r binary.Reader) { |
| doDecodeY(r, o) |
| } |
| func (c *binaryClassY) Schema() *binary.Entity { |
| return &entities[ixǁY] |
| } |
| |
| type binaryClassX_V1 struct{ binary.FrozenClassBase } |
| |
| func (*X_V1) Class() binary.Class { |
| return &binaryClassX_V1{} |
| } |
| func doDecodeX_V1(d binary.Decoder, o *X_V1) error { |
| o.a = int32(d.Int32()) |
| o.b = int32(d.Int32()) |
| return d.Error() |
| } |
| func doUpgradeDecodeǀX_V1ǁX(d binary.Decoder, o *X) { |
| old := &X_V1{} |
| doDecodeX_V1(d, old) |
| if d.Error() != nil { |
| return |
| } |
| old.upgrade(o) // This upgrade() method is not code generated. |
| } |
| func (*binaryClassX_V1) New() binary.Object { |
| return &X{} |
| } |
| func (*binaryClassX_V1) DecodeTo(d binary.Decoder, obj binary.Object) { |
| doUpgradeDecodeǀX_V1ǁX(d, obj.(*X)) |
| } |
| |
| func (*binaryClassX_V1) Schema() *binary.Entity { return schemaX_V1 } |
| |
| var schemaX_V1 = &binary.Entity{ |
| Package: "test", |
| Identity: "X", |
| Fields: []binary.Field{ |
| {Declared: "a", Type: &schema.Primitive{Name: "int32", Method: schema.Int32}}, |
| {Declared: "b", Type: &schema.Primitive{Name: "int32", Method: schema.Int32}}, |
| }, |
| } |