2015-06-29 21:50:55 +00:00
|
|
|
{{var "v"}} := *{{ .Varname }}
|
|
|
|
{{var "l"}} := r.ReadMapStart()
|
2015-10-15 21:52:18 +00:00
|
|
|
{{var "bh"}} := z.DecBasicHandle()
|
2015-06-29 21:50:55 +00:00
|
|
|
if {{var "v"}} == nil {
|
2015-10-15 21:52:18 +00:00
|
|
|
{{var "rl"}}, _ := z.DecInferLen({{var "l"}}, {{var "bh"}}.MaxInitLen, {{ .Size }})
|
2015-10-07 20:10:00 +00:00
|
|
|
{{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}})
|
2015-06-29 21:50:55 +00:00
|
|
|
*{{ .Varname }} = {{var "v"}}
|
|
|
|
}
|
2015-10-15 21:52:18 +00:00
|
|
|
var {{var "mk"}} {{ .KTyp }}
|
|
|
|
var {{var "mv"}} {{ .Typ }}
|
2015-10-30 22:07:00 +00:00
|
|
|
var {{var "mg"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool
|
2015-10-15 21:52:18 +00:00
|
|
|
if {{var "bh"}}.MapValueReset {
|
|
|
|
{{if decElemKindPtr}}{{var "mg"}} = true
|
|
|
|
{{else if decElemKindIntf}}if !{{var "bh"}}.InterfaceReset { {{var "mg"}} = true }
|
|
|
|
{{else if not decElemKindImmutable}}{{var "mg"}} = true
|
|
|
|
{{end}} }
|
2015-06-29 21:50:55 +00:00
|
|
|
if {{var "l"}} > 0 {
|
|
|
|
for {{var "j"}} := 0; {{var "j"}} < {{var "l"}}; {{var "j"}}++ {
|
2015-10-30 22:07:00 +00:00
|
|
|
z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }})
|
2015-06-29 21:50:55 +00:00
|
|
|
{{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }}
|
2015-10-15 21:52:18 +00:00
|
|
|
{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
|
2015-06-29 21:50:55 +00:00
|
|
|
{{var "mk"}} = string({{var "bv"}})
|
2015-10-30 22:07:00 +00:00
|
|
|
}{{ end }}{{if decElemKindPtr}}
|
|
|
|
{{var "ms"}} = true{{end}}
|
2015-10-15 21:52:18 +00:00
|
|
|
if {{var "mg"}} {
|
2015-10-30 22:07:00 +00:00
|
|
|
{{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
|
|
|
|
if {{var "mok"}} {
|
|
|
|
{{var "ms"}} = false
|
|
|
|
} {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
|
2015-10-15 21:52:18 +00:00
|
|
|
} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
|
2015-10-30 22:07:00 +00:00
|
|
|
z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }})
|
2015-06-29 21:50:55 +00:00
|
|
|
{{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }}
|
2015-10-30 22:07:00 +00:00
|
|
|
if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
|
2015-06-29 21:50:55 +00:00
|
|
|
{{var "v"}}[{{var "mk"}}] = {{var "mv"}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if {{var "l"}} < 0 {
|
|
|
|
for {{var "j"}} := 0; !r.CheckBreak(); {{var "j"}}++ {
|
2015-10-30 22:07:00 +00:00
|
|
|
z.DecSendContainerState(codecSelfer_containerMapKey{{ .Sfx }})
|
2015-06-29 21:50:55 +00:00
|
|
|
{{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x }}
|
2015-10-15 21:52:18 +00:00
|
|
|
{{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */}}if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} {
|
2015-06-29 21:50:55 +00:00
|
|
|
{{var "mk"}} = string({{var "bv"}})
|
2015-10-30 22:07:00 +00:00
|
|
|
}{{ end }}{{if decElemKindPtr}}
|
|
|
|
{{var "ms"}} = true {{ end }}
|
2015-10-15 21:52:18 +00:00
|
|
|
if {{var "mg"}} {
|
2015-10-30 22:07:00 +00:00
|
|
|
{{if decElemKindPtr}}{{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}]
|
|
|
|
if {{var "mok"}} {
|
|
|
|
{{var "ms"}} = false
|
|
|
|
} {{else}}{{var "mv"}} = {{var "v"}}[{{var "mk"}}] {{end}}
|
2015-10-15 21:52:18 +00:00
|
|
|
} {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}}
|
2015-10-30 22:07:00 +00:00
|
|
|
z.DecSendContainerState(codecSelfer_containerMapValue{{ .Sfx }})
|
2015-06-29 21:50:55 +00:00
|
|
|
{{ $x := printf "%vmv%v" .TempVar .Rand }}{{ decLineVar $x }}
|
2015-10-30 22:07:00 +00:00
|
|
|
if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil {
|
2015-06-29 21:50:55 +00:00
|
|
|
{{var "v"}}[{{var "mk"}}] = {{var "mv"}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // else len==0: TODO: Should we clear map entries?
|
2015-10-30 22:07:00 +00:00
|
|
|
z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }})
|