|
@@ -18,12 +18,14 @@ const GenVersion = {{ .Version }}
|
|
|
// This file is used to generate helper code for codecgen.
|
|
// This file is used to generate helper code for codecgen.
|
|
|
// The values here i.e. genHelper(En|De)coder are not to be used directly by
|
|
// The values here i.e. genHelper(En|De)coder are not to be used directly by
|
|
|
// library users. They WILL change continuously and without notice.
|
|
// library users. They WILL change continuously and without notice.
|
|
|
-//
|
|
|
|
|
|
|
+
|
|
|
|
|
+{{/*
|
|
|
// To help enforce this, we create an unexported type with exported members.
|
|
// To help enforce this, we create an unexported type with exported members.
|
|
|
// The only way to get the type is via the one exported type that we control (somewhat).
|
|
// The only way to get the type is via the one exported type that we control (somewhat).
|
|
|
//
|
|
//
|
|
|
// When static codecs are created for types, they will use this value
|
|
// When static codecs are created for types, they will use this value
|
|
|
// to perform encoding or decoding of primitives or known slice or map types.
|
|
// to perform encoding or decoding of primitives or known slice or map types.
|
|
|
|
|
+*/ -}}
|
|
|
|
|
|
|
|
// GenHelperEncoder is exported so that it can be used externally by codecgen.
|
|
// GenHelperEncoder is exported so that it can be used externally by codecgen.
|
|
|
//
|
|
//
|
|
@@ -66,15 +68,15 @@ func (x genHelperDecDriver) DecStructFieldKey(keyType valueType, buf *[decScratc
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
type genHelperEncoder struct {
|
|
type genHelperEncoder struct {
|
|
|
M must
|
|
M must
|
|
|
- e *Encoder
|
|
|
|
|
F fastpathT
|
|
F fastpathT
|
|
|
|
|
+ e *Encoder
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
type genHelperDecoder struct {
|
|
type genHelperDecoder struct {
|
|
|
C checkOverflow
|
|
C checkOverflow
|
|
|
- d *Decoder
|
|
|
|
|
F fastpathT
|
|
F fastpathT
|
|
|
|
|
+ d *Decoder
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
@@ -91,7 +93,6 @@ func (f genHelperEncoder) IsJSONHandle() bool {
|
|
|
}
|
|
}
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
func (f genHelperEncoder) EncFallback(iv interface{}) {
|
|
func (f genHelperEncoder) EncFallback(iv interface{}) {
|
|
|
- // println(">>>>>>>>> EncFallback")
|
|
|
|
|
// f.e.encodeI(iv, false, false)
|
|
// f.e.encodeI(iv, false, false)
|
|
|
f.e.encodeValue(reflect.ValueOf(iv), nil, false)
|
|
f.e.encodeValue(reflect.ValueOf(iv), nil, false)
|
|
|
}
|
|
}
|
|
@@ -169,13 +170,11 @@ func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte
|
|
|
}
|
|
}
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
|
|
func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
|
|
|
- // println(">>>>>>>>> DecFallback")
|
|
|
|
|
rv := reflect.ValueOf(iv)
|
|
rv := reflect.ValueOf(iv)
|
|
|
if chkPtr {
|
|
if chkPtr {
|
|
|
rv = f.d.ensureDecodeable(rv)
|
|
rv = f.d.ensureDecodeable(rv)
|
|
|
}
|
|
}
|
|
|
f.d.decodeValue(rv, nil, false)
|
|
f.d.decodeValue(rv, nil, false)
|
|
|
- // f.d.decodeValueFallback(rv)
|
|
|
|
|
}
|
|
}
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
|
|
func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
|
|
@@ -191,8 +190,7 @@ func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
|
|
|
}
|
|
}
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
|
|
func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
|
|
|
- fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes())
|
|
|
|
|
- if fnerr != nil {
|
|
|
|
|
|
|
+ if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil {
|
|
|
panic(fnerr)
|
|
panic(fnerr)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -200,15 +198,13 @@ func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
|
|
|
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
|
|
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
|
|
|
// bs := f.dd.DecodeStringAsBytes()
|
|
// bs := f.dd.DecodeStringAsBytes()
|
|
|
// grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
|
|
// grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
|
|
|
- fnerr := tm.UnmarshalJSON(f.d.nextValueBytes())
|
|
|
|
|
- if fnerr != nil {
|
|
|
|
|
|
|
+ if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil {
|
|
|
panic(fnerr)
|
|
panic(fnerr)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
|
|
|
func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
|
|
func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
|
|
|
- fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true))
|
|
|
|
|
- if fnerr != nil {
|
|
|
|
|
|
|
+ if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil {
|
|
|
panic(fnerr)
|
|
panic(fnerr)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|