Commit f43b849e authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #20770 from liggitt/ugorji-var-reset

Auto commit by PR queue bot
parents a2ce07e5 dd5d98d8
...@@ -926,7 +926,7 @@ ...@@ -926,7 +926,7 @@
}, },
{ {
"ImportPath": "github.com/ugorji/go/codec", "ImportPath": "github.com/ugorji/go/codec",
"Rev": "4a79e5b7b21e51ae8d61641bca20399b79735a32" "Rev": "f4485b318aadd133842532f841dc205a8e339d74"
}, },
{ {
"ImportPath": "github.com/vishvananda/netlink", "ImportPath": "github.com/vishvananda/netlink",
......
...@@ -186,7 +186,7 @@ package codec ...@@ -186,7 +186,7 @@ package codec
// Name string // Name string
// Ys []Y // Ys []Y
// Ys chan <- Y // Ys chan <- Y
// Ys func(interface{}) -> call this interface for each entry in there. // Ys func(Y) -> call this function for each entry
// } // }
// - Consider adding a isZeroer interface { isZero() bool } // - Consider adding a isZeroer interface { isZero() bool }
// It is used within isEmpty, for omitEmpty support. // It is used within isEmpty, for omitEmpty support.
......
...@@ -508,7 +508,7 @@ func (d *cborDecDriver) DecodeNaked() { ...@@ -508,7 +508,7 @@ func (d *cborDecDriver) DecodeNaked() {
n.v = valueTypeExt n.v = valueTypeExt
n.u = d.decUint() n.u = d.decUint()
n.l = nil n.l = nil
d.bdRead = false // d.bdRead = false
// d.d.decode(&re.Value) // handled by decode itself. // d.d.decode(&re.Value) // handled by decode itself.
// decodeFurther = true // decodeFurther = true
default: default:
......
...@@ -583,14 +583,16 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) { ...@@ -583,14 +583,16 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
if d.mtid == 0 || d.mtid == mapIntfIntfTypId { if d.mtid == 0 || d.mtid == mapIntfIntfTypId {
l := len(n.ms) l := len(n.ms)
n.ms = append(n.ms, nil) n.ms = append(n.ms, nil)
d.decode(&n.ms[l]) var v2 interface{} = &n.ms[l]
rvn = reflect.ValueOf(&n.ms[l]).Elem() d.decode(v2)
rvn = reflect.ValueOf(v2).Elem()
n.ms = n.ms[:l] n.ms = n.ms[:l]
} else if d.mtid == mapStrIntfTypId { // for json performance } else if d.mtid == mapStrIntfTypId { // for json performance
l := len(n.ns) l := len(n.ns)
n.ns = append(n.ns, nil) n.ns = append(n.ns, nil)
d.decode(&n.ns[l]) var v2 interface{} = &n.ns[l]
rvn = reflect.ValueOf(&n.ns[l]).Elem() d.decode(v2)
rvn = reflect.ValueOf(v2).Elem()
n.ns = n.ns[:l] n.ns = n.ns[:l]
} else { } else {
rvn = reflect.New(d.h.MapType).Elem() rvn = reflect.New(d.h.MapType).Elem()
...@@ -601,8 +603,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) { ...@@ -601,8 +603,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
if d.stid == 0 || d.stid == intfSliceTypId { if d.stid == 0 || d.stid == intfSliceTypId {
l := len(n.ss) l := len(n.ss)
n.ss = append(n.ss, nil) n.ss = append(n.ss, nil)
d.decode(&n.ss[l]) var v2 interface{} = &n.ss[l]
rvn = reflect.ValueOf(&n.ss[l]).Elem() d.decode(v2)
rvn = reflect.ValueOf(v2).Elem()
n.ss = n.ss[:l] n.ss = n.ss[:l]
} else { } else {
rvn = reflect.New(d.h.SliceType).Elem() rvn = reflect.New(d.h.SliceType).Elem()
...@@ -615,9 +618,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) { ...@@ -615,9 +618,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
l := len(n.is) l := len(n.is)
n.is = append(n.is, nil) n.is = append(n.is, nil)
v2 := &n.is[l] v2 := &n.is[l]
n.is = n.is[:l]
d.decode(v2) d.decode(v2)
v = *v2 v = *v2
n.is = n.is[:l]
} }
bfn := d.h.getExtForTag(tag) bfn := d.h.getExtForTag(tag)
if bfn == nil { if bfn == nil {
...@@ -1453,8 +1456,8 @@ func (d *Decoder) swallow() { ...@@ -1453,8 +1456,8 @@ func (d *Decoder) swallow() {
l := len(n.is) l := len(n.is)
n.is = append(n.is, nil) n.is = append(n.is, nil)
v2 := &n.is[l] v2 := &n.is[l]
n.is = n.is[:l]
d.decode(v2) d.decode(v2)
n.is = n.is[:l]
} }
} }
} }
......
...@@ -473,7 +473,7 @@ func (f *encFnInfo) kSlice(rv reflect.Value) { ...@@ -473,7 +473,7 @@ func (f *encFnInfo) kSlice(rv reflect.Value) {
for j := 0; j < l; j++ { for j := 0; j < l; j++ {
if cr != nil { if cr != nil {
if ti.mbs { if ti.mbs {
if l%2 == 0 { if j%2 == 0 {
cr.sendContainerState(containerMapKey) cr.sendContainerState(containerMapKey)
} else { } else {
cr.sendContainerState(containerMapValue) cr.sendContainerState(containerMapValue)
...@@ -1188,7 +1188,8 @@ func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr, ...@@ -1188,7 +1188,8 @@ func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr,
if fn == nil { if fn == nil {
rt := rv.Type() rt := rv.Type()
rtid := reflect.ValueOf(rt).Pointer() rtid := reflect.ValueOf(rt).Pointer()
fn = e.getEncFn(rtid, rt, true, true) // fn = e.getEncFn(rtid, rt, true, true)
fn = e.getEncFn(rtid, rt, checkFastpath, checkCodecSelfer)
} }
fn.f(&fn.i, rv) fn.f(&fn.i, rv)
if sptr != 0 { if sptr != 0 {
...@@ -1265,7 +1266,7 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo ...@@ -1265,7 +1266,7 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo
} else { } else {
rk := rt.Kind() rk := rt.Kind()
if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) { if fastpathEnabled && checkFastpath && (rk == reflect.Map || rk == reflect.Slice) {
if rt.PkgPath() == "" { if rt.PkgPath() == "" { // un-named slice or map
if idx := fastpathAV.index(rtid); idx != -1 { if idx := fastpathAV.index(rtid); idx != -1 {
fn.f = fastpathAV[idx].encfn fn.f = fastpathAV[idx].encfn
} }
......
...@@ -165,7 +165,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { ...@@ -165,7 +165,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
{{range .Values}}{{if not .Primitive}}{{if not .MapKey }} {{range .Values}}{{if not .Primitive}}{{if not .MapKey }}
func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) { func (f *encFnInfo) {{ .MethodNamePfx "fastpathEnc" false }}R(rv reflect.Value) {
fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e) if f.ti.mbs {
fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e)
} else {
fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv.Interface().([]{{ .Elem }}), fastpathCheckNilFalse, f.e)
}
} }
func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) { func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) {
ee := e.e ee := e.e
...@@ -182,6 +186,31 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil b ...@@ -182,6 +186,31 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil b
if cr != nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}} if cr != nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}}
} }
func (_ fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, checkNil bool, e *Encoder) {
ee := e.e
cr := e.cr
if checkNil && v == nil {
ee.EncodeNil()
return
}
if len(v)%2 == 1 {
e.errorf("mapBySlice requires even slice length, but got %v", len(v))
return
}
ee.EncodeMapStart(len(v) / 2)
for j, v2 := range v {
if cr != nil {
if j%2 == 0 {
cr.sendContainerState(containerMapKey)
} else {
cr.sendContainerState(containerMapValue)
}
}
{{ encmd .Elem "v2"}}
}
if cr != nil { cr.sendContainerState(containerMapEnd) }
}
{{end}}{{end}}{{end}} {{end}}{{end}}{{end}}
{{range .Values}}{{if not .Primitive}}{{if .MapKey }} {{range .Values}}{{if not .Primitive}}{{if .MapKey }}
......
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} {{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} {{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}}
var {{var "c"}} bool {{/* // changed */}} var {{var "c"}} bool {{/* // changed */}}
_ = {{var "c"}}{{end}}
if {{var "l"}} == 0 { if {{var "l"}} == 0 {
{{if isSlice }}if {{var "v"}} == nil { {{if isSlice }}if {{var "v"}} == nil {
{{var "v"}} = []{{ .Typ }}{} {{var "v"}} = []{{ .Typ }}{}
...@@ -26,6 +27,8 @@ if {{var "l"}} == 0 { ...@@ -26,6 +27,8 @@ if {{var "l"}} == 0 {
} }
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}} {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
var {{var "rt"}} bool {{/* truncated */}} var {{var "rt"}} bool {{/* truncated */}}
_, _ = {{var "rl"}}, {{var "rt"}}
{{var "rr"}} = {{var "l"}} // len({{var "v"}})
if {{var "l"}} > cap({{var "v"}}) { if {{var "l"}} > cap({{var "v"}}) {
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}}) {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
{{ else }}{{if not .Immutable }} {{ else }}{{if not .Immutable }}
......
...@@ -68,8 +68,9 @@ z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }}) ...@@ -68,8 +68,9 @@ z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }})
const genDecListTmpl = ` const genDecListTmpl = `
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} {{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} {{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}{{if not isArray}}
var {{var "c"}} bool {{/* // changed */}} var {{var "c"}} bool {{/* // changed */}}
_ = {{var "c"}}{{end}}
if {{var "l"}} == 0 { if {{var "l"}} == 0 {
{{if isSlice }}if {{var "v"}} == nil { {{if isSlice }}if {{var "v"}} == nil {
{{var "v"}} = []{{ .Typ }}{} {{var "v"}} = []{{ .Typ }}{}
...@@ -95,6 +96,8 @@ if {{var "l"}} == 0 { ...@@ -95,6 +96,8 @@ if {{var "l"}} == 0 {
} }
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}} {{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
var {{var "rt"}} bool {{/* truncated */}} var {{var "rt"}} bool {{/* truncated */}}
_, _ = {{var "rl"}}, {{var "rt"}}
{{var "rr"}} = {{var "l"}} // len({{var "v"}})
if {{var "l"}} > cap({{var "v"}}) { if {{var "l"}} > cap({{var "v"}}) {
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}}) {{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
{{ else }}{{if not .Immutable }} {{ else }}{{if not .Immutable }}
......
...@@ -21,6 +21,8 @@ import ( ...@@ -21,6 +21,8 @@ import (
"sync" "sync"
"text/template" "text/template"
"time" "time"
"unicode"
"unicode/utf8"
) )
// --------------------------------------------------- // ---------------------------------------------------
...@@ -266,6 +268,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn ...@@ -266,6 +268,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
x.line("type " + x.hn + " struct{}") x.line("type " + x.hn + " struct{}")
x.line("") x.line("")
x.varsfxreset()
x.line("func init() {") x.line("func init() {")
x.linef("if %sGenVersion != %v {", x.cpfx, GenVersion) x.linef("if %sGenVersion != %v {", x.cpfx, GenVersion)
x.line("_, file, _, _ := runtime.Caller(0)") x.line("_, file, _, _ := runtime.Caller(0)")
...@@ -309,6 +312,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn ...@@ -309,6 +312,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
for _, t := range x.ts { for _, t := range x.ts {
rtid := reflect.ValueOf(t).Pointer() rtid := reflect.ValueOf(t).Pointer()
// generate enc functions for all these slice/map types. // generate enc functions for all these slice/map types.
x.varsfxreset()
x.linef("func (x %s) enc%s(v %s%s, e *%sEncoder) {", x.hn, x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), x.cpfx) x.linef("func (x %s) enc%s(v %s%s, e *%sEncoder) {", x.hn, x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), x.cpfx)
x.genRequiredMethodVars(true) x.genRequiredMethodVars(true)
switch t.Kind() { switch t.Kind() {
...@@ -323,6 +327,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn ...@@ -323,6 +327,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
x.line("") x.line("")
// generate dec functions for all these slice/map types. // generate dec functions for all these slice/map types.
x.varsfxreset()
x.linef("func (x %s) dec%s(v *%s, d *%sDecoder) {", x.hn, x.genMethodNameT(t), x.genTypeName(t), x.cpfx) x.linef("func (x %s) dec%s(v *%s, d *%sDecoder) {", x.hn, x.genMethodNameT(t), x.genTypeName(t), x.cpfx)
x.genRequiredMethodVars(false) x.genRequiredMethodVars(false)
switch t.Kind() { switch t.Kind() {
...@@ -377,7 +382,7 @@ func (x *genRunner) genRefPkgs(t reflect.Type) { ...@@ -377,7 +382,7 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
x.imn[tpkg] = tpkg x.imn[tpkg] = tpkg
} else { } else {
x.imc++ x.imc++
x.imn[tpkg] = "pkg" + strconv.FormatUint(x.imc, 10) + "_" + tpkg[idx+1:] x.imn[tpkg] = "pkg" + strconv.FormatUint(x.imc, 10) + "_" + genGoIdentifier(tpkg[idx+1:], false)
} }
} }
} }
...@@ -408,6 +413,10 @@ func (x *genRunner) varsfx() string { ...@@ -408,6 +413,10 @@ func (x *genRunner) varsfx() string {
return strconv.FormatUint(x.c, 10) return strconv.FormatUint(x.c, 10)
} }
func (x *genRunner) varsfxreset() {
x.c = 0
}
func (x *genRunner) out(s string) { func (x *genRunner) out(s string) {
if _, err := io.WriteString(x.w, s); err != nil { if _, err := io.WriteString(x.w, s); err != nil {
panic(err) panic(err)
...@@ -494,6 +503,7 @@ func (x *genRunner) selfer(encode bool) { ...@@ -494,6 +503,7 @@ func (x *genRunner) selfer(encode bool) {
// always make decode use a pointer receiver, // always make decode use a pointer receiver,
// and structs always use a ptr receiver (encode|decode) // and structs always use a ptr receiver (encode|decode)
isptr := !encode || t.Kind() == reflect.Struct isptr := !encode || t.Kind() == reflect.Struct
x.varsfxreset()
fnSigPfx := "func (x " fnSigPfx := "func (x "
if isptr { if isptr {
fnSigPfx += "*" fnSigPfx += "*"
...@@ -566,9 +576,28 @@ func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) { ...@@ -566,9 +576,28 @@ func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) {
} else { } else {
x.linef("h.dec%s((*%s)(%s), d)", x.genMethodNameT(t), x.genTypeName(t), varname) x.linef("h.dec%s((*%s)(%s), d)", x.genMethodNameT(t), x.genTypeName(t), varname)
} }
if _, ok := x.tm[t]; !ok { x.registerXtraT(t)
x.tm[t] = struct{}{} }
x.ts = append(x.ts, t)
func (x *genRunner) registerXtraT(t reflect.Type) {
// recursively register the types
if _, ok := x.tm[t]; ok {
return
}
var tkey reflect.Type
switch t.Kind() {
case reflect.Chan, reflect.Slice, reflect.Array:
case reflect.Map:
tkey = t.Key()
default:
return
}
x.tm[t] = struct{}{}
x.ts = append(x.ts, t)
// check if this refers to any xtra types eg. a slice of array: add the array
x.registerXtraT(t.Elem())
if tkey != nil {
x.registerXtraT(tkey)
} }
} }
...@@ -608,22 +637,33 @@ func (x *genRunner) encVar(varname string, t reflect.Type) { ...@@ -608,22 +637,33 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
} }
// enc will encode a variable (varname) of type T, // enc will encode a variable (varname) of type t,
// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type *T (to prevent copying) // except t is of kind reflect.Struct or reflect.Array, wherein varname is of type ptrTo(T) (to prevent copying)
func (x *genRunner) enc(varname string, t reflect.Type) { func (x *genRunner) enc(varname string, t reflect.Type) {
// varName here must be to a pointer to a struct/array, or to a value directly.
rtid := reflect.ValueOf(t).Pointer() rtid := reflect.ValueOf(t).Pointer()
// We call CodecEncodeSelf if one of the following are honored: // We call CodecEncodeSelf if one of the following are honored:
// - the type already implements Selfer, call that // - the type already implements Selfer, call that
// - the type has a Selfer implementation just created, use that // - the type has a Selfer implementation just created, use that
// - the type is in the list of the ones we will generate for, but it is not currently being generated // - the type is in the list of the ones we will generate for, but it is not currently being generated
mi := x.varsfx()
tptr := reflect.PtrTo(t) tptr := reflect.PtrTo(t)
tk := t.Kind() tk := t.Kind()
if x.checkForSelfer(t, varname) { if x.checkForSelfer(t, varname) {
if t.Implements(selferTyp) || (tptr.Implements(selferTyp) && (tk == reflect.Array || tk == reflect.Struct)) { if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T
x.line(varname + ".CodecEncodeSelf(e)") if tptr.Implements(selferTyp) || t.Implements(selferTyp) {
return x.line(varname + ".CodecEncodeSelf(e)")
return
}
} else { // varname is of type T
if t.Implements(selferTyp) {
x.line(varname + ".CodecEncodeSelf(e)")
return
} else if tptr.Implements(selferTyp) {
x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname)
x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi)
return
}
} }
if _, ok := x.te[rtid]; ok { if _, ok := x.te[rtid]; ok {
...@@ -653,7 +693,6 @@ func (x *genRunner) enc(varname string, t reflect.Type) { ...@@ -653,7 +693,6 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// check if // check if
// - type is RawExt // - type is RawExt
// - the type implements (Text|JSON|Binary)(Unm|M)arshal // - the type implements (Text|JSON|Binary)(Unm|M)arshal
mi := x.varsfx()
x.linef("%sm%s := z.EncBinary()", genTempVarPfx, mi) x.linef("%sm%s := z.EncBinary()", genTempVarPfx, mi)
x.linef("_ = %sm%s", genTempVarPfx, mi) x.linef("_ = %sm%s", genTempVarPfx, mi)
x.line("if false {") //start if block x.line("if false {") //start if block
...@@ -676,15 +715,31 @@ func (x *genRunner) enc(varname string, t reflect.Type) { ...@@ -676,15 +715,31 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// first check if extensions are configued, before doing the interface conversion // first check if extensions are configued, before doing the interface conversion
x.linef("} else if z.HasExtensions() && z.EncExt(%s) {", varname) x.linef("} else if z.HasExtensions() && z.EncExt(%s) {", varname)
} }
if t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) { if tk == reflect.Array || tk == reflect.Struct { // varname is of type *T
x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname) if t.Implements(binaryMarshalerTyp) || tptr.Implements(binaryMarshalerTyp) {
} x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname)
if t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) { }
x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname) if t.Implements(jsonMarshalerTyp) || tptr.Implements(jsonMarshalerTyp) {
} else if t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) { x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname)
x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname) } else if t.Implements(textMarshalerTyp) || tptr.Implements(textMarshalerTyp) {
x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname)
}
} else { // varname is of type T
if t.Implements(binaryMarshalerTyp) {
x.linef("} else if %sm%s { z.EncBinaryMarshal(%v) ", genTempVarPfx, mi, varname)
} else if tptr.Implements(binaryMarshalerTyp) {
x.linef("} else if %sm%s { z.EncBinaryMarshal(&%v) ", genTempVarPfx, mi, varname)
}
if t.Implements(jsonMarshalerTyp) {
x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", genTempVarPfx, mi, varname)
} else if tptr.Implements(jsonMarshalerTyp) {
x.linef("} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", genTempVarPfx, mi, varname)
} else if t.Implements(textMarshalerTyp) {
x.linef("} else if !%sm%s { z.EncTextMarshal(%v) ", genTempVarPfx, mi, varname)
} else if tptr.Implements(textMarshalerTyp) {
x.linef("} else if !%sm%s { z.EncTextMarshal(&%v) ", genTempVarPfx, mi, varname)
}
} }
x.line("} else {") x.line("} else {")
switch t.Kind() { switch t.Kind() {
...@@ -1020,6 +1075,8 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) { ...@@ -1020,6 +1075,8 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) {
} }
} }
// dec will decode a variable (varname) of type ptrTo(t).
// t is always a basetype (i.e. not of kind reflect.Ptr).
func (x *genRunner) dec(varname string, t reflect.Type) { func (x *genRunner) dec(varname string, t reflect.Type) {
// assumptions: // assumptions:
// - the varname is to a pointer already. No need to take address of it // - the varname is to a pointer already. No need to take address of it
...@@ -1592,6 +1649,26 @@ func genImportPath(t reflect.Type) (s string) { ...@@ -1592,6 +1649,26 @@ func genImportPath(t reflect.Type) (s string) {
return return
} }
// A go identifier is (letter|_)[letter|number|_]*
func genGoIdentifier(s string, checkFirstChar bool) string {
b := make([]byte, 0, len(s))
t := make([]byte, 4)
var n int
for i, r := range s {
if checkFirstChar && i == 0 && !unicode.IsLetter(r) {
b = append(b, '_')
}
// r must be unicode_letter, unicode_digit or _
if unicode.IsLetter(r) || unicode.IsDigit(r) {
n = utf8.EncodeRune(t, r)
b = append(b, t[:n]...)
} else {
b = append(b, '_')
}
}
return string(b)
}
func genNonPtr(t reflect.Type) reflect.Type { func genNonPtr(t reflect.Type) reflect.Type {
for t.Kind() == reflect.Ptr { for t.Kind() == reflect.Ptr {
t = t.Elem() t = t.Elem()
......
...@@ -206,10 +206,22 @@ func (e *jsonEncDriver) EncodeFloat64(f float64) { ...@@ -206,10 +206,22 @@ func (e *jsonEncDriver) EncodeFloat64(f float64) {
} }
func (e *jsonEncDriver) EncodeInt(v int64) { func (e *jsonEncDriver) EncodeInt(v int64) {
if x := e.h.IntegerAsString; x == 'A' || x == 'L' && (v > 1<<53 || v < -(1<<53)) {
e.w.writen1('"')
e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
e.w.writen1('"')
return
}
e.w.writeb(strconv.AppendInt(e.b[:0], v, 10)) e.w.writeb(strconv.AppendInt(e.b[:0], v, 10))
} }
func (e *jsonEncDriver) EncodeUint(v uint64) { func (e *jsonEncDriver) EncodeUint(v uint64) {
if x := e.h.IntegerAsString; x == 'A' || x == 'L' && v > 1<<53 {
e.w.writen1('"')
e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
e.w.writen1('"')
return
}
e.w.writeb(strconv.AppendUint(e.b[:0], v, 10)) e.w.writeb(strconv.AppendUint(e.b[:0], v, 10))
} }
...@@ -636,6 +648,11 @@ func (d *jsonDecDriver) decNum(storeBytes bool) { ...@@ -636,6 +648,11 @@ func (d *jsonDecDriver) decNum(storeBytes bool) {
d.tok = b d.tok = b
} }
b := d.tok b := d.tok
var str bool
if b == '"' {
str = true
b = d.r.readn1()
}
if !(b == '+' || b == '-' || b == '.' || (b >= '0' && b <= '9')) { if !(b == '+' || b == '-' || b == '.' || (b >= '0' && b <= '9')) {
d.d.errorf("json: decNum: got first char '%c'", b) d.d.errorf("json: decNum: got first char '%c'", b)
return return
...@@ -650,6 +667,10 @@ func (d *jsonDecDriver) decNum(storeBytes bool) { ...@@ -650,6 +667,10 @@ func (d *jsonDecDriver) decNum(storeBytes bool) {
n.reset() n.reset()
d.bs = d.bs[:0] d.bs = d.bs[:0]
if str && storeBytes {
d.bs = append(d.bs, '"')
}
// The format of a number is as below: // The format of a number is as below:
// parsing: sign? digit* dot? digit* e? sign? digit* // parsing: sign? digit* dot? digit* e? sign? digit*
// states: 0 1* 2 3* 4 5* 6 7 // states: 0 1* 2 3* 4 5* 6 7
...@@ -740,6 +761,14 @@ LOOP: ...@@ -740,6 +761,14 @@ LOOP:
default: default:
break LOOP break LOOP
} }
case '"':
if str {
if storeBytes {
d.bs = append(d.bs, '"')
}
b, eof = r.readn1eof()
}
break LOOP
default: default:
break LOOP break LOOP
} }
...@@ -1110,6 +1139,19 @@ type JsonHandle struct { ...@@ -1110,6 +1139,19 @@ type JsonHandle struct {
// - If positive, indent by that number of spaces. // - If positive, indent by that number of spaces.
// - If negative, indent by that number of tabs. // - If negative, indent by that number of tabs.
Indent int8 Indent int8
// IntegerAsString controls how integers (signed and unsigned) are encoded.
//
// Per the JSON Spec, JSON numbers are 64-bit floating point numbers.
// Consequently, integers > 2^53 cannot be represented as a JSON number without losing precision.
// This can be mitigated by configuring how to encode integers.
//
// IntegerAsString interpretes the following values:
// - if 'L', then encode integers > 2^53 as a json string.
// - if 'A', then encode all integers as a json string
// containing the exact integer representation as a decimal.
// - else encode all integers as a json number (default)
IntegerAsString uint8
} }
func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {
......
...@@ -171,7 +171,7 @@ do ...@@ -171,7 +171,7 @@ do
'xf') zforce=1;; 'xf') zforce=1;;
'xb') zbak=1;; 'xb') zbak=1;;
'xx') zexternal=1;; 'xx') zexternal=1;;
*) echo "prebuild.sh accepts [-fb] only"; return 1;; *) echo "prebuild.sh accepts [-fbx] only"; return 1;;
esac esac
done done
shift $((OPTIND-1)) shift $((OPTIND-1))
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
# sudo apt-get install python-pip # sudo apt-get install python-pip
# pip install --user msgpack-python msgpack-rpc-python cbor # pip install --user msgpack-python msgpack-rpc-python cbor
# Ensure all "string" keys are utf strings (else encoded as bytes)
import cbor, msgpack, msgpackrpc, sys, os, threading import cbor, msgpack, msgpackrpc, sys, os, threading
def get_test_data_list(): def get_test_data_list():
...@@ -26,35 +28,39 @@ def get_test_data_list(): ...@@ -26,35 +28,39 @@ def get_test_data_list():
-3232.0, -3232.0,
-6464646464.0, -6464646464.0,
3232.0, 3232.0,
6464.0,
6464646464.0, 6464646464.0,
False, False,
True, True,
u"null",
None, None,
u"someday", u"someday",
u"",
u"bytestring",
1328176922000002000, 1328176922000002000,
u"",
-2206187877999998000, -2206187877999998000,
u"bytestring",
270, 270,
u"none",
-2013855847999995777, -2013855847999995777,
#-6795364578871345152, #-6795364578871345152,
] ]
l1 = [ l1 = [
{ "true": True, { "true": True,
"false": False }, "false": False },
{ "true": "True", { "true": u"True",
"false": False, "false": False,
"uint16(1616)": 1616 }, "uint16(1616)": 1616 },
{ "list": [1616, 32323232, True, -3232.0, {"TRUE":True, "FALSE":False}, [True, False] ], { "list": [1616, 32323232, True, -3232.0, {"TRUE":True, "FALSE":False}, [True, False] ],
"int32":32323232, "bool": True, "int32":32323232, "bool": True,
"LONG STRING": "123456789012345678901234567890123456789012345678901234567890", "LONG STRING": u"123456789012345678901234567890123456789012345678901234567890",
"SHORT STRING": "1234567890" }, "SHORT STRING": u"1234567890" },
{ True: "true", 8: False, "false": 0 } { True: "true", 138: False, "false": 200 }
] ]
l = [] l = []
l.extend(l0) l.extend(l0)
l.append(l0) l.append(l0)
l.append(1)
l.extend(l1) l.extend(l1)
return l return l
......
...@@ -95,6 +95,8 @@ for current in ${index[@]}; do ...@@ -95,6 +95,8 @@ for current in ${index[@]}; do
pushd "$(dirname ${file})" > /dev/null pushd "$(dirname ${file})" > /dev/null
base_file=$(basename "${file}") base_file=$(basename "${file}")
base_generated_file=$(basename "${generated_file}") base_generated_file=$(basename "${generated_file}")
# temporarily move the generated file to a non-go file so it doesn't influence the verify codecgen
mv "${base_generated_file}" "${base_generated_file}.bak"
# We use '-d 1234' flag to have a deterministic output everytime. # We use '-d 1234' flag to have a deterministic output everytime.
# The constant was just randomly chosen. # The constant was just randomly chosen.
${CODECGEN} -d 1234 -o "${base_generated_file}.1tmp" "${base_file}" ${CODECGEN} -d 1234 -o "${base_generated_file}.1tmp" "${base_file}"
...@@ -102,6 +104,8 @@ for current in ${index[@]}; do ...@@ -102,6 +104,8 @@ for current in ${index[@]}; do
sed 's/YEAR/2015/' "${initial_dir}/hack/boilerplate/boilerplate.go.txt" > "${base_generated_file}.tmp" sed 's/YEAR/2015/' "${initial_dir}/hack/boilerplate/boilerplate.go.txt" > "${base_generated_file}.tmp"
cat "${base_generated_file}.1tmp" >> "${base_generated_file}.tmp" cat "${base_generated_file}.1tmp" >> "${base_generated_file}.tmp"
rm "${base_generated_file}.1tmp" rm "${base_generated_file}.1tmp"
# restore the generated file
mv "${base_generated_file}.bak" "${base_generated_file}"
ret=0 ret=0
diff -Naupr -I 'Auto generated by' "${base_generated_file}" "${base_generated_file}.tmp" || ret=$? diff -Naupr -I 'Auto generated by' "${base_generated_file}" "${base_generated_file}.tmp" || ret=$?
if [[ $ret -eq 0 ]]; then if [[ $ret -eq 0 ]]; then
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -111,13 +111,13 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -111,13 +111,13 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("metadata")) r.EncodeString(codecSelferC_UTF81234, string("metadata"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yy5 := &x.ObjectMeta yy6 := &x.ObjectMeta
yy5.CodecEncodeSelf(e) yy6.CodecEncodeSelf(e)
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yym7 := z.EncBinary() yym9 := z.EncBinary()
_ = yym7 _ = yym9
if false { if false {
} else { } else {
r.EncodeInt(int64(x.Value)) r.EncodeInt(int64(x.Value))
...@@ -126,8 +126,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -126,8 +126,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("value")) r.EncodeString(codecSelferC_UTF81234, string("value"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym8 := z.EncBinary() yym10 := z.EncBinary()
_ = yym8 _ = yym10
if false { if false {
} else { } else {
r.EncodeInt(int64(x.Value)) r.EncodeInt(int64(x.Value))
...@@ -136,8 +136,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -136,8 +136,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) {
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[2] { if yyq2[2] {
yym10 := z.EncBinary() yym12 := z.EncBinary()
_ = yym10 _ = yym12
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) r.EncodeString(codecSelferC_UTF81234, string(x.Kind))
...@@ -150,8 +150,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -150,8 +150,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("kind")) r.EncodeString(codecSelferC_UTF81234, string("kind"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym11 := z.EncBinary() yym13 := z.EncBinary()
_ = yym11 _ = yym13
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.Kind)) r.EncodeString(codecSelferC_UTF81234, string(x.Kind))
...@@ -161,8 +161,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -161,8 +161,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) {
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[3] { if yyq2[3] {
yym13 := z.EncBinary() yym15 := z.EncBinary()
_ = yym13 _ = yym15
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion))
...@@ -175,8 +175,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -175,8 +175,8 @@ func (x *TestResource) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("apiVersion")) r.EncodeString(codecSelferC_UTF81234, string("apiVersion"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym14 := z.EncBinary() yym16 := z.EncBinary()
_ = yym14 _ = yym16
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion)) r.EncodeString(codecSelferC_UTF81234, string(x.APIVersion))
...@@ -196,25 +196,25 @@ func (x *TestResource) CodecDecodeSelf(d *codec1978.Decoder) { ...@@ -196,25 +196,25 @@ func (x *TestResource) CodecDecodeSelf(d *codec1978.Decoder) {
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
yym15 := z.DecBinary() yym1 := z.DecBinary()
_ = yym15 _ = yym1
if false { if false {
} else if z.HasExtensions() && z.DecExt(x) { } else if z.HasExtensions() && z.DecExt(x) {
} else { } else {
yyct16 := r.ContainerType() yyct2 := r.ContainerType()
if yyct16 == codecSelferValueTypeMap1234 { if yyct2 == codecSelferValueTypeMap1234 {
yyl16 := r.ReadMapStart() yyl2 := r.ReadMapStart()
if yyl16 == 0 { if yyl2 == 0 {
z.DecSendContainerState(codecSelfer_containerMapEnd1234) z.DecSendContainerState(codecSelfer_containerMapEnd1234)
} else { } else {
x.codecDecodeSelfFromMap(yyl16, d) x.codecDecodeSelfFromMap(yyl2, d)
} }
} else if yyct16 == codecSelferValueTypeArray1234 { } else if yyct2 == codecSelferValueTypeArray1234 {
yyl16 := r.ReadArrayStart() yyl2 := r.ReadArrayStart()
if yyl16 == 0 { if yyl2 == 0 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} else { } else {
x.codecDecodeSelfFromArray(yyl16, d) x.codecDecodeSelfFromArray(yyl2, d)
} }
} else { } else {
panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234) panic(codecSelferOnlyMapOrArrayEncodeToStructErr1234)
...@@ -226,12 +226,12 @@ func (x *TestResource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -226,12 +226,12 @@ func (x *TestResource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yys17Slc = z.DecScratchBuffer() // default slice to decode into var yys3Slc = z.DecScratchBuffer() // default slice to decode into
_ = yys17Slc _ = yys3Slc
var yyhl17 bool = l >= 0 var yyhl3 bool = l >= 0
for yyj17 := 0; ; yyj17++ { for yyj3 := 0; ; yyj3++ {
if yyhl17 { if yyhl3 {
if yyj17 >= l { if yyj3 >= l {
break break
} }
} else { } else {
...@@ -240,16 +240,16 @@ func (x *TestResource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -240,16 +240,16 @@ func (x *TestResource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
} }
} }
z.DecSendContainerState(codecSelfer_containerMapKey1234) z.DecSendContainerState(codecSelfer_containerMapKey1234)
yys17Slc = r.DecodeBytes(yys17Slc, true, true) yys3Slc = r.DecodeBytes(yys3Slc, true, true)
yys17 := string(yys17Slc) yys3 := string(yys3Slc)
z.DecSendContainerState(codecSelfer_containerMapValue1234) z.DecSendContainerState(codecSelfer_containerMapValue1234)
switch yys17 { switch yys3 {
case "metadata": case "metadata":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ObjectMeta = pkg2_api.ObjectMeta{} x.ObjectMeta = pkg2_api.ObjectMeta{}
} else { } else {
yyv18 := &x.ObjectMeta yyv4 := &x.ObjectMeta
yyv18.CodecDecodeSelf(d) yyv4.CodecDecodeSelf(d)
} }
case "value": case "value":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
...@@ -270,9 +270,9 @@ func (x *TestResource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -270,9 +270,9 @@ func (x *TestResource) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
x.APIVersion = string(r.DecodeString()) x.APIVersion = string(r.DecodeString())
} }
default: default:
z.DecStructFieldNotFound(-1, yys17) z.DecStructFieldNotFound(-1, yys3)
} // end switch yys17 } // end switch yys3
} // end for yyj17 } // end for yyj3
z.DecSendContainerState(codecSelfer_containerMapEnd1234) z.DecSendContainerState(codecSelfer_containerMapEnd1234)
} }
...@@ -280,16 +280,16 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -280,16 +280,16 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj22 int var yyj8 int
var yyb22 bool var yyb8 bool
var yyhl22 bool = l >= 0 var yyhl8 bool = l >= 0
yyj22++ yyj8++
if yyhl22 { if yyhl8 {
yyb22 = yyj22 > l yyb8 = yyj8 > l
} else { } else {
yyb22 = r.CheckBreak() yyb8 = r.CheckBreak()
} }
if yyb22 { if yyb8 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -297,16 +297,16 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -297,16 +297,16 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ObjectMeta = pkg2_api.ObjectMeta{} x.ObjectMeta = pkg2_api.ObjectMeta{}
} else { } else {
yyv23 := &x.ObjectMeta yyv9 := &x.ObjectMeta
yyv23.CodecDecodeSelf(d) yyv9.CodecDecodeSelf(d)
} }
yyj22++ yyj8++
if yyhl22 { if yyhl8 {
yyb22 = yyj22 > l yyb8 = yyj8 > l
} else { } else {
yyb22 = r.CheckBreak() yyb8 = r.CheckBreak()
} }
if yyb22 { if yyb8 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -316,13 +316,13 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -316,13 +316,13 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
} else { } else {
x.Value = int(r.DecodeInt(codecSelferBitsize1234)) x.Value = int(r.DecodeInt(codecSelferBitsize1234))
} }
yyj22++ yyj8++
if yyhl22 { if yyhl8 {
yyb22 = yyj22 > l yyb8 = yyj8 > l
} else { } else {
yyb22 = r.CheckBreak() yyb8 = r.CheckBreak()
} }
if yyb22 { if yyb8 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -332,13 +332,13 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -332,13 +332,13 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
} else { } else {
x.Kind = string(r.DecodeString()) x.Kind = string(r.DecodeString())
} }
yyj22++ yyj8++
if yyhl22 { if yyhl8 {
yyb22 = yyj22 > l yyb8 = yyj8 > l
} else { } else {
yyb22 = r.CheckBreak() yyb8 = r.CheckBreak()
} }
if yyb22 { if yyb8 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -349,17 +349,17 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -349,17 +349,17 @@ func (x *TestResource) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
x.APIVersion = string(r.DecodeString()) x.APIVersion = string(r.DecodeString())
} }
for { for {
yyj22++ yyj8++
if yyhl22 { if yyhl8 {
yyb22 = yyj22 > l yyb8 = yyj8 > l
} else { } else {
yyb22 = r.CheckBreak() yyb8 = r.CheckBreak()
} }
if yyb22 { if yyb8 {
break break
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj22-1, "") z.DecStructFieldNotFound(yyj8-1, "")
} }
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment