فهرست منبع

codec: test: skip subsequent structFieldInfo with same encName and same depth

This occurs if you embed 2 types in a struct, and both of them have a field with
the same name at the same level.

Updates #297
Ugorji Nwoke 6 سال پیش
والد
کامیت
60eb47a864
2فایلهای تغییر یافته به همراه696 افزوده شده و 102 حذف شده
  1. 679 96
      codec/values_codecgen_generated_test.go
  2. 17 6
      codec/values_test.go

+ 679 - 96
codec/values_codecgen_generated_test.go

@@ -224,41 +224,36 @@ func (x *codecgenA) CodecEncodeSelf(e *Encoder) {
 			yy2arr2 := z.EncBasicHandle().StructToArray
 			_, _ = yysep2, yy2arr2
 			const yyr2 bool = false // struct tag has 'toArray'
-			var yyq2 = [1]bool{     // should field at this index be written?
-				false || codecSelfer19780False() || len(x.BB.CC.DD) != 0, // BB
-			}
-			_ = yyq2
 			if yyr2 || yy2arr2 {
 				r.WriteArrayStart(1)
 			} else {
-				var yynn2 int
-				for _, b := range yyq2 {
-					if b {
-						yynn2++
-					}
-				}
-				r.WriteMapStart(yynn2)
-				yynn2 = 0
+				r.WriteMapStart(1)
 			}
 			if yyr2 || yy2arr2 {
 				r.WriteArrayElem()
-				if yyq2[0] {
-					yy4 := &x.BB
-					yy4.CodecEncodeSelf(e)
-				} else {
+				if x.ZZ == nil {
 					r.EncodeNil()
+				} else {
+					if false {
+					} else {
+						r.EncodeStringBytesRaw([]byte(x.ZZ))
+					}
 				}
 			} else {
-				if yyq2[0] {
-					r.WriteMapElemKey()
-					if z.IsJSONHandle() {
-						z.WriteStr("\"BB\"")
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"ZZ\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `ZZ`)
+				}
+				r.WriteMapElemValue()
+				if x.ZZ == nil {
+					r.EncodeNil()
+				} else {
+					if false {
 					} else {
-						r.EncodeStringEnc(codecSelferCcUTF819780, `BB`)
+						r.EncodeStringBytesRaw([]byte(x.ZZ))
 					}
-					r.WriteMapElemValue()
-					yy6 := &x.BB
-					yy6.CodecEncodeSelf(e)
 				}
 			}
 			if yyr2 || yy2arr2 {
@@ -318,11 +313,14 @@ func (x *codecgenA) codecDecodeSelfFromMap(l int, d *Decoder) {
 		yys3 := z.StringView(r.DecodeStringAsBytes())
 		r.ReadMapElemValue()
 		switch yys3 {
-		case "BB":
+		case "ZZ":
 			if r.TryDecodeAsNil() {
-				x.BB = codecgenB{}
+				x.ZZ = nil
 			} else {
-				x.BB.CodecDecodeSelf(d)
+				if false {
+				} else {
+					x.ZZ = r.DecodeBytes(([]byte)(x.ZZ), false)
+				}
 			}
 		default:
 			z.DecStructFieldNotFound(-1, yys3)
@@ -335,37 +333,40 @@ func (x *codecgenA) codecDecodeSelfFromArray(l int, d *Decoder) {
 	var h codecSelfer19780
 	z, r := GenHelperDecoder(d)
 	_, _, _ = h, z, r
-	var yyj5 int
-	var yyb5 bool
-	var yyhl5 bool = l >= 0
-	yyj5++
-	if yyhl5 {
-		yyb5 = yyj5 > l
+	var yyj6 int
+	var yyb6 bool
+	var yyhl6 bool = l >= 0
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
 	} else {
-		yyb5 = r.CheckBreak()
+		yyb6 = r.CheckBreak()
 	}
-	if yyb5 {
+	if yyb6 {
 		r.ReadArrayEnd()
 		return
 	}
 	r.ReadArrayElem()
 	if r.TryDecodeAsNil() {
-		x.BB = codecgenB{}
+		x.ZZ = nil
 	} else {
-		x.BB.CodecDecodeSelf(d)
+		if false {
+		} else {
+			x.ZZ = r.DecodeBytes(([]byte)(x.ZZ), false)
+		}
 	}
 	for {
-		yyj5++
-		if yyhl5 {
-			yyb5 = yyj5 > l
+		yyj6++
+		if yyhl6 {
+			yyb6 = yyj6 > l
 		} else {
-			yyb5 = r.CheckBreak()
+			yyb6 = r.CheckBreak()
 		}
-		if yyb5 {
+		if yyb6 {
 			break
 		}
 		r.ReadArrayElem()
-		z.DecStructFieldNotFound(yyj5-1, "")
+		z.DecStructFieldNotFound(yyj6-1, "")
 	}
 	r.ReadArrayEnd()
 }
@@ -392,17 +393,17 @@ func (x *codecgenB) CodecEncodeSelf(e *Encoder) {
 			}
 			if yyr2 || yy2arr2 {
 				r.WriteArrayElem()
-				yy4 := &x.CC
+				yy4 := &x.AA
 				yy4.CodecEncodeSelf(e)
 			} else {
 				r.WriteMapElemKey()
 				if z.IsJSONHandle() {
-					z.WriteStr("\"CC\"")
+					z.WriteStr("\"AA\"")
 				} else {
-					r.EncodeStringEnc(codecSelferCcUTF819780, `CC`)
+					r.EncodeStringEnc(codecSelferCcUTF819780, `AA`)
 				}
 				r.WriteMapElemValue()
-				yy6 := &x.CC
+				yy6 := &x.AA
 				yy6.CodecEncodeSelf(e)
 			}
 			if yyr2 || yy2arr2 {
@@ -462,11 +463,11 @@ func (x *codecgenB) codecDecodeSelfFromMap(l int, d *Decoder) {
 		yys3 := z.StringView(r.DecodeStringAsBytes())
 		r.ReadMapElemValue()
 		switch yys3 {
-		case "CC":
+		case "AA":
 			if r.TryDecodeAsNil() {
-				x.CC = codecgenC{}
+				x.AA = codecgenA{}
 			} else {
-				x.CC.CodecDecodeSelf(d)
+				x.AA.CodecDecodeSelf(d)
 			}
 		default:
 			z.DecStructFieldNotFound(-1, yys3)
@@ -494,9 +495,9 @@ func (x *codecgenB) codecDecodeSelfFromArray(l int, d *Decoder) {
 	}
 	r.ReadArrayElem()
 	if r.TryDecodeAsNil() {
-		x.CC = codecgenC{}
+		x.AA = codecgenA{}
 	} else {
-		x.CC.CodecDecodeSelf(d)
+		x.AA.CodecDecodeSelf(d)
 	}
 	for {
 		yyj5++
@@ -529,36 +530,41 @@ func (x *codecgenC) CodecEncodeSelf(e *Encoder) {
 			yy2arr2 := z.EncBasicHandle().StructToArray
 			_, _ = yysep2, yy2arr2
 			const yyr2 bool = false // struct tag has 'toArray'
+			var yyq2 = [1]bool{     // should field at this index be written?
+				false || codecSelfer19780False() || len(x.BB.AA.ZZ) != 0, // BB
+			}
+			_ = yyq2
 			if yyr2 || yy2arr2 {
 				r.WriteArrayStart(1)
 			} else {
-				r.WriteMapStart(1)
+				var yynn2 int
+				for _, b := range yyq2 {
+					if b {
+						yynn2++
+					}
+				}
+				r.WriteMapStart(yynn2)
+				yynn2 = 0
 			}
 			if yyr2 || yy2arr2 {
 				r.WriteArrayElem()
-				if x.DD == nil {
-					r.EncodeNil()
+				if yyq2[0] {
+					yy4 := &x.BB
+					yy4.CodecEncodeSelf(e)
 				} else {
-					if false {
-					} else {
-						r.EncodeStringBytesRaw([]byte(x.DD))
-					}
+					r.EncodeNil()
 				}
 			} else {
-				r.WriteMapElemKey()
-				if z.IsJSONHandle() {
-					z.WriteStr("\"DD\"")
-				} else {
-					r.EncodeStringEnc(codecSelferCcUTF819780, `DD`)
-				}
-				r.WriteMapElemValue()
-				if x.DD == nil {
-					r.EncodeNil()
-				} else {
-					if false {
+				if yyq2[0] {
+					r.WriteMapElemKey()
+					if z.IsJSONHandle() {
+						z.WriteStr("\"BB\"")
 					} else {
-						r.EncodeStringBytesRaw([]byte(x.DD))
+						r.EncodeStringEnc(codecSelferCcUTF819780, `BB`)
 					}
+					r.WriteMapElemValue()
+					yy6 := &x.BB
+					yy6.CodecEncodeSelf(e)
 				}
 			}
 			if yyr2 || yy2arr2 {
@@ -618,14 +624,11 @@ func (x *codecgenC) codecDecodeSelfFromMap(l int, d *Decoder) {
 		yys3 := z.StringView(r.DecodeStringAsBytes())
 		r.ReadMapElemValue()
 		switch yys3 {
-		case "DD":
+		case "BB":
 			if r.TryDecodeAsNil() {
-				x.DD = nil
+				x.BB = codecgenB{}
 			} else {
-				if false {
-				} else {
-					x.DD = r.DecodeBytes(([]byte)(x.DD), false)
-				}
+				x.BB.CodecDecodeSelf(d)
 			}
 		default:
 			z.DecStructFieldNotFound(-1, yys3)
@@ -638,40 +641,37 @@ func (x *codecgenC) codecDecodeSelfFromArray(l int, d *Decoder) {
 	var h codecSelfer19780
 	z, r := GenHelperDecoder(d)
 	_, _, _ = h, z, r
-	var yyj6 int
-	var yyb6 bool
-	var yyhl6 bool = l >= 0
-	yyj6++
-	if yyhl6 {
-		yyb6 = yyj6 > l
+	var yyj5 int
+	var yyb5 bool
+	var yyhl5 bool = l >= 0
+	yyj5++
+	if yyhl5 {
+		yyb5 = yyj5 > l
 	} else {
-		yyb6 = r.CheckBreak()
+		yyb5 = r.CheckBreak()
 	}
-	if yyb6 {
+	if yyb5 {
 		r.ReadArrayEnd()
 		return
 	}
 	r.ReadArrayElem()
 	if r.TryDecodeAsNil() {
-		x.DD = nil
+		x.BB = codecgenB{}
 	} else {
-		if false {
-		} else {
-			x.DD = r.DecodeBytes(([]byte)(x.DD), false)
-		}
+		x.BB.CodecDecodeSelf(d)
 	}
 	for {
-		yyj6++
-		if yyhl6 {
-			yyb6 = yyj6 > l
+		yyj5++
+		if yyhl5 {
+			yyb5 = yyj5 > l
 		} else {
-			yyb6 = r.CheckBreak()
+			yyb5 = r.CheckBreak()
 		}
-		if yyb6 {
+		if yyb5 {
 			break
 		}
 		r.ReadArrayElem()
-		z.DecStructFieldNotFound(yyj6-1, "")
+		z.DecStructFieldNotFound(yyj5-1, "")
 	}
 	r.ReadArrayEnd()
 }
@@ -1120,6 +1120,589 @@ func (x *codecgenI) codecDecodeSelfFromArray(l int, d *Decoder) {
 	r.ReadArrayEnd()
 }
 
+func (x *codecgenK) CodecEncodeSelf(e *Encoder) {
+	var h codecSelfer19780
+	z, r := GenHelperEncoder(e)
+	_, _, _ = h, z, r
+	if x == nil {
+		r.EncodeNil()
+	} else {
+		if false {
+		} else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
+			z.EncExtension(x, yyxt1)
+		} else {
+			yysep2 := !z.EncBinary()
+			yy2arr2 := z.EncBasicHandle().StructToArray
+			_, _ = yysep2, yy2arr2
+			const yyr2 bool = false // struct tag has 'toArray'
+			if yyr2 || yy2arr2 {
+				r.WriteArrayStart(2)
+			} else {
+				r.WriteMapStart(2)
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayElem()
+				if false {
+				} else {
+					r.EncodeInt(int64(x.X))
+				}
+			} else {
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"X\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `X`)
+				}
+				r.WriteMapElemValue()
+				if false {
+				} else {
+					r.EncodeInt(int64(x.X))
+				}
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayElem()
+				if false {
+				} else {
+					if z.EncBasicHandle().StringToRaw {
+						r.EncodeStringBytesRaw(z.BytesView(string(x.Y)))
+					} else {
+						r.EncodeStringEnc(codecSelferCcUTF819780, string(x.Y))
+					}
+				}
+			} else {
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"Y\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `Y`)
+				}
+				r.WriteMapElemValue()
+				if false {
+				} else {
+					if z.EncBasicHandle().StringToRaw {
+						r.EncodeStringBytesRaw(z.BytesView(string(x.Y)))
+					} else {
+						r.EncodeStringEnc(codecSelferCcUTF819780, string(x.Y))
+					}
+				}
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayEnd()
+			} else {
+				r.WriteMapEnd()
+			}
+		}
+	}
+}
+
+func (x *codecgenK) CodecDecodeSelf(d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	if false {
+	} else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
+		z.DecExtension(x, yyxt1)
+	} else {
+		yyct2 := r.ContainerType()
+		if yyct2 == codecSelferValueTypeMap19780 {
+			yyl2 := r.ReadMapStart()
+			if yyl2 == 0 {
+				r.ReadMapEnd()
+			} else {
+				x.codecDecodeSelfFromMap(yyl2, d)
+			}
+		} else if yyct2 == codecSelferValueTypeArray19780 {
+			yyl2 := r.ReadArrayStart()
+			if yyl2 == 0 {
+				r.ReadArrayEnd()
+			} else {
+				x.codecDecodeSelfFromArray(yyl2, d)
+			}
+		} else {
+			panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780)
+		}
+	}
+}
+
+func (x *codecgenK) codecDecodeSelfFromMap(l int, d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	var yyhl3 bool = l >= 0
+	for yyj3 := 0; ; yyj3++ {
+		if yyhl3 {
+			if yyj3 >= l {
+				break
+			}
+		} else {
+			if r.CheckBreak() {
+				break
+			}
+		}
+		r.ReadMapElemKey()
+		yys3 := z.StringView(r.DecodeStringAsBytes())
+		r.ReadMapElemValue()
+		switch yys3 {
+		case "X":
+			if r.TryDecodeAsNil() {
+				x.X = 0
+			} else {
+				x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780))
+			}
+		case "Y":
+			if r.TryDecodeAsNil() {
+				x.Y = ""
+			} else {
+				x.Y = (string)(r.DecodeString())
+			}
+		default:
+			z.DecStructFieldNotFound(-1, yys3)
+		} // end switch yys3
+	} // end for yyj3
+	r.ReadMapEnd()
+}
+
+func (x *codecgenK) codecDecodeSelfFromArray(l int, d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	var yyj6 int
+	var yyb6 bool
+	var yyhl6 bool = l >= 0
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
+	} else {
+		yyb6 = r.CheckBreak()
+	}
+	if yyb6 {
+		r.ReadArrayEnd()
+		return
+	}
+	r.ReadArrayElem()
+	if r.TryDecodeAsNil() {
+		x.X = 0
+	} else {
+		x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780))
+	}
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
+	} else {
+		yyb6 = r.CheckBreak()
+	}
+	if yyb6 {
+		r.ReadArrayEnd()
+		return
+	}
+	r.ReadArrayElem()
+	if r.TryDecodeAsNil() {
+		x.Y = ""
+	} else {
+		x.Y = (string)(r.DecodeString())
+	}
+	for {
+		yyj6++
+		if yyhl6 {
+			yyb6 = yyj6 > l
+		} else {
+			yyb6 = r.CheckBreak()
+		}
+		if yyb6 {
+			break
+		}
+		r.ReadArrayElem()
+		z.DecStructFieldNotFound(yyj6-1, "")
+	}
+	r.ReadArrayEnd()
+}
+
+func (x *codecgenL) CodecEncodeSelf(e *Encoder) {
+	var h codecSelfer19780
+	z, r := GenHelperEncoder(e)
+	_, _, _ = h, z, r
+	if x == nil {
+		r.EncodeNil()
+	} else {
+		if false {
+		} else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
+			z.EncExtension(x, yyxt1)
+		} else {
+			yysep2 := !z.EncBinary()
+			yy2arr2 := z.EncBasicHandle().StructToArray
+			_, _ = yysep2, yy2arr2
+			const yyr2 bool = false // struct tag has 'toArray'
+			if yyr2 || yy2arr2 {
+				r.WriteArrayStart(2)
+			} else {
+				r.WriteMapStart(2)
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayElem()
+				if false {
+				} else {
+					r.EncodeInt(int64(x.X))
+				}
+			} else {
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"X\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `X`)
+				}
+				r.WriteMapElemValue()
+				if false {
+				} else {
+					r.EncodeInt(int64(x.X))
+				}
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayElem()
+				if false {
+				} else {
+					r.EncodeUint(uint64(x.Y))
+				}
+			} else {
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"Y\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `Y`)
+				}
+				r.WriteMapElemValue()
+				if false {
+				} else {
+					r.EncodeUint(uint64(x.Y))
+				}
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayEnd()
+			} else {
+				r.WriteMapEnd()
+			}
+		}
+	}
+}
+
+func (x *codecgenL) CodecDecodeSelf(d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	if false {
+	} else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
+		z.DecExtension(x, yyxt1)
+	} else {
+		yyct2 := r.ContainerType()
+		if yyct2 == codecSelferValueTypeMap19780 {
+			yyl2 := r.ReadMapStart()
+			if yyl2 == 0 {
+				r.ReadMapEnd()
+			} else {
+				x.codecDecodeSelfFromMap(yyl2, d)
+			}
+		} else if yyct2 == codecSelferValueTypeArray19780 {
+			yyl2 := r.ReadArrayStart()
+			if yyl2 == 0 {
+				r.ReadArrayEnd()
+			} else {
+				x.codecDecodeSelfFromArray(yyl2, d)
+			}
+		} else {
+			panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780)
+		}
+	}
+}
+
+func (x *codecgenL) codecDecodeSelfFromMap(l int, d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	var yyhl3 bool = l >= 0
+	for yyj3 := 0; ; yyj3++ {
+		if yyhl3 {
+			if yyj3 >= l {
+				break
+			}
+		} else {
+			if r.CheckBreak() {
+				break
+			}
+		}
+		r.ReadMapElemKey()
+		yys3 := z.StringView(r.DecodeStringAsBytes())
+		r.ReadMapElemValue()
+		switch yys3 {
+		case "X":
+			if r.TryDecodeAsNil() {
+				x.X = 0
+			} else {
+				x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780))
+			}
+		case "Y":
+			if r.TryDecodeAsNil() {
+				x.Y = 0
+			} else {
+				x.Y = (uint32)(z.C.UintV(r.DecodeUint64(), 32))
+			}
+		default:
+			z.DecStructFieldNotFound(-1, yys3)
+		} // end switch yys3
+	} // end for yyj3
+	r.ReadMapEnd()
+}
+
+func (x *codecgenL) codecDecodeSelfFromArray(l int, d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	var yyj6 int
+	var yyb6 bool
+	var yyhl6 bool = l >= 0
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
+	} else {
+		yyb6 = r.CheckBreak()
+	}
+	if yyb6 {
+		r.ReadArrayEnd()
+		return
+	}
+	r.ReadArrayElem()
+	if r.TryDecodeAsNil() {
+		x.X = 0
+	} else {
+		x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780))
+	}
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
+	} else {
+		yyb6 = r.CheckBreak()
+	}
+	if yyb6 {
+		r.ReadArrayEnd()
+		return
+	}
+	r.ReadArrayElem()
+	if r.TryDecodeAsNil() {
+		x.Y = 0
+	} else {
+		x.Y = (uint32)(z.C.UintV(r.DecodeUint64(), 32))
+	}
+	for {
+		yyj6++
+		if yyhl6 {
+			yyb6 = yyj6 > l
+		} else {
+			yyb6 = r.CheckBreak()
+		}
+		if yyb6 {
+			break
+		}
+		r.ReadArrayElem()
+		z.DecStructFieldNotFound(yyj6-1, "")
+	}
+	r.ReadArrayEnd()
+}
+
+func (x *codecgenM) CodecEncodeSelf(e *Encoder) {
+	var h codecSelfer19780
+	z, r := GenHelperEncoder(e)
+	_, _, _ = h, z, r
+	if x == nil {
+		r.EncodeNil()
+	} else {
+		if false {
+		} else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
+			z.EncExtension(x, yyxt1)
+		} else {
+			yysep2 := !z.EncBinary()
+			yy2arr2 := z.EncBasicHandle().StructToArray
+			_, _ = yysep2, yy2arr2
+			const yyr2 bool = false // struct tag has 'toArray'
+			if yyr2 || yy2arr2 {
+				r.WriteArrayStart(2)
+			} else {
+				r.WriteMapStart(2)
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayElem()
+				if false {
+				} else {
+					r.EncodeInt(int64(x.codecgenK.X))
+				}
+			} else {
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"X\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `X`)
+				}
+				r.WriteMapElemValue()
+				if false {
+				} else {
+					r.EncodeInt(int64(x.codecgenK.X))
+				}
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayElem()
+				if false {
+				} else {
+					if z.EncBasicHandle().StringToRaw {
+						r.EncodeStringBytesRaw(z.BytesView(string(x.codecgenK.Y)))
+					} else {
+						r.EncodeStringEnc(codecSelferCcUTF819780, string(x.codecgenK.Y))
+					}
+				}
+			} else {
+				r.WriteMapElemKey()
+				if z.IsJSONHandle() {
+					z.WriteStr("\"Y\"")
+				} else {
+					r.EncodeStringEnc(codecSelferCcUTF819780, `Y`)
+				}
+				r.WriteMapElemValue()
+				if false {
+				} else {
+					if z.EncBasicHandle().StringToRaw {
+						r.EncodeStringBytesRaw(z.BytesView(string(x.codecgenK.Y)))
+					} else {
+						r.EncodeStringEnc(codecSelferCcUTF819780, string(x.codecgenK.Y))
+					}
+				}
+			}
+			if yyr2 || yy2arr2 {
+				r.WriteArrayEnd()
+			} else {
+				r.WriteMapEnd()
+			}
+		}
+	}
+}
+
+func (x *codecgenM) CodecDecodeSelf(d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	if false {
+	} else if yyxt1 := z.Extension(z.I2Rtid(x)); yyxt1 != nil {
+		z.DecExtension(x, yyxt1)
+	} else {
+		yyct2 := r.ContainerType()
+		if yyct2 == codecSelferValueTypeMap19780 {
+			yyl2 := r.ReadMapStart()
+			if yyl2 == 0 {
+				r.ReadMapEnd()
+			} else {
+				x.codecDecodeSelfFromMap(yyl2, d)
+			}
+		} else if yyct2 == codecSelferValueTypeArray19780 {
+			yyl2 := r.ReadArrayStart()
+			if yyl2 == 0 {
+				r.ReadArrayEnd()
+			} else {
+				x.codecDecodeSelfFromArray(yyl2, d)
+			}
+		} else {
+			panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780)
+		}
+	}
+}
+
+func (x *codecgenM) codecDecodeSelfFromMap(l int, d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	var yyhl3 bool = l >= 0
+	for yyj3 := 0; ; yyj3++ {
+		if yyhl3 {
+			if yyj3 >= l {
+				break
+			}
+		} else {
+			if r.CheckBreak() {
+				break
+			}
+		}
+		r.ReadMapElemKey()
+		yys3 := z.StringView(r.DecodeStringAsBytes())
+		r.ReadMapElemValue()
+		switch yys3 {
+		case "X":
+			if r.TryDecodeAsNil() {
+				x.codecgenK.X = 0
+			} else {
+				x.codecgenK.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780))
+			}
+		case "Y":
+			if r.TryDecodeAsNil() {
+				x.codecgenK.Y = ""
+			} else {
+				x.codecgenK.Y = (string)(r.DecodeString())
+			}
+		default:
+			z.DecStructFieldNotFound(-1, yys3)
+		} // end switch yys3
+	} // end for yyj3
+	r.ReadMapEnd()
+}
+
+func (x *codecgenM) codecDecodeSelfFromArray(l int, d *Decoder) {
+	var h codecSelfer19780
+	z, r := GenHelperDecoder(d)
+	_, _, _ = h, z, r
+	var yyj6 int
+	var yyb6 bool
+	var yyhl6 bool = l >= 0
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
+	} else {
+		yyb6 = r.CheckBreak()
+	}
+	if yyb6 {
+		r.ReadArrayEnd()
+		return
+	}
+	r.ReadArrayElem()
+	if r.TryDecodeAsNil() {
+		x.codecgenK.X = 0
+	} else {
+		x.codecgenK.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780))
+	}
+	yyj6++
+	if yyhl6 {
+		yyb6 = yyj6 > l
+	} else {
+		yyb6 = r.CheckBreak()
+	}
+	if yyb6 {
+		r.ReadArrayEnd()
+		return
+	}
+	r.ReadArrayElem()
+	if r.TryDecodeAsNil() {
+		x.codecgenK.Y = ""
+	} else {
+		x.codecgenK.Y = (string)(r.DecodeString())
+	}
+	for {
+		yyj6++
+		if yyhl6 {
+			yyb6 = yyj6 > l
+		} else {
+			yyb6 = r.CheckBreak()
+		}
+		if yyb6 {
+			break
+		}
+		r.ReadArrayElem()
+		z.DecStructFieldNotFound(yyj6-1, "")
+	}
+	r.ReadArrayEnd()
+}
+
 func (x *stringUint64T) CodecEncodeSelf(e *Encoder) {
 	var h codecSelfer19780
 	z, r := GenHelperEncoder(e)

+ 17 - 6
codec/values_test.go

@@ -36,16 +36,14 @@ type wrapStringSlice []wrapString
 // some funky types to stretch codecgen
 
 type codecgenA struct {
-	_struct struct{} `codec:",omitempty"`
-	BB      codecgenB
+	ZZ []byte
 }
-
 type codecgenB struct {
-	CC codecgenC
+	AA codecgenA
 }
-
 type codecgenC struct {
-	DD []byte
+	_struct struct{} `codec:",omitempty"`
+	BB      codecgenB
 }
 
 type TestCodecgenG struct {
@@ -58,6 +56,19 @@ type codecgenI struct {
 	codecgenH
 }
 
+type codecgenK struct {
+	X int
+	Y string
+}
+type codecgenL struct {
+	X int
+	Y uint32
+}
+type codecgenM struct {
+	codecgenK
+	codecgenL
+}
+
 // some other types
 
 type stringUint64T struct {