1
// comment this out // + build ignore
3
// Copyright (c) 2012-2020 Ugorji Nwoke. All rights reserved.
4
// Use of this source code is governed by a MIT license found in the LICENSE file.
6
// Code generated from gen-helper.go.tmpl - DO NOT EDIT.
15
// GenVersion is the current version of codecgen.
16
const GenVersion = {{ .Version }}
18
// This file is used to generate helper code for codecgen.
19
// The values here i.e. genHelper(En|De)coder are not to be used directly by
20
// library users. They WILL change continuously and without notice.
23
// To help enforce this, we create an unexported type with exported members.
24
// The only way to get the type is via the one exported type that we control (somewhat).
26
// When static codecs are created for types, they will use this value
27
// to perform encoding or decoding of primitives or known slice or map types.
30
// GenHelperEncoder is exported so that it can be used externally by codecgen.
32
// Library users: DO NOT USE IT DIRECTLY or INDIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
33
func GenHelper() (g genHelper) { return }
35
type genHelper struct {}
37
func (genHelper) Encoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) {
38
ge = genHelperEncoder{e: e}
39
ee = genHelperEncDriver{encDriver: e.e}
43
func (genHelper) Decoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
44
gd = genHelperDecoder{d: d}
45
dd = genHelperDecDriver{decDriver: d.d}
49
type genHelperEncDriver struct {
53
type genHelperDecDriver struct {
57
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
58
type genHelperEncoder struct {
64
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
65
type genHelperDecoder struct {
71
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
72
func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
75
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
76
func (f genHelperEncoder) EncWr() *encWr {
79
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
80
func (f genHelperEncoder) EncBinary() bool {
81
return f.e.be // f.e.hh.isBinaryEncoding()
83
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
84
func (f genHelperEncoder) IsJSONHandle() bool {
87
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
88
func (f genHelperEncoder) EncFallback(iv interface{}) {
89
// f.e.encodeI(iv, false, false)
90
f.e.encodeValue(reflect.ValueOf(iv), nil)
92
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
93
func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
94
bs, fnerr := iv.MarshalText()
95
f.e.marshalUtf8(bs, fnerr)
97
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
98
func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
99
bs, fnerr := iv.MarshalJSON()
100
f.e.marshalAsis(bs, fnerr)
102
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
103
func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
104
bs, fnerr := iv.MarshalBinary()
105
f.e.marshalRaw(bs, fnerr)
107
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
108
func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) }
110
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
111
func (f genHelperEncoder) Extension(v interface{}) (xfn *extTypeTagFn) {
112
return f.e.h.getExtForI(v)
114
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
115
func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
116
f.e.e.EncodeExt(v, xfFn.rt, xfFn.tag, xfFn.ext)
119
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
120
func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
121
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
122
func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() }
123
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
124
func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) }
125
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
126
func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() }
127
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
128
func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() }
129
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
130
func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() }
131
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
132
func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() }
133
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
134
func (f genHelperEncoder) EncEncodeComplex64(v complex64) { f.e.encodeComplex64(v) }
135
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
136
func (f genHelperEncoder) EncEncodeComplex128(v complex128) { f.e.encodeComplex128(v) }
137
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
138
func (f genHelperEncoder) EncEncode(v interface{}) { f.e.encode(v) }
139
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
140
func (f genHelperEncoder) EncFnGivenAddr(v interface{}) *codecFn { return f.e.h.fn(reflect.TypeOf(v).Elem()) }
141
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
142
func (f genHelperEncoder) EncEncodeNumBoolStrKindGivenAddr(v interface{}, encFn *codecFn) {
143
f.e.encodeValueNonNil(reflect.ValueOf(v).Elem(), encFn)
145
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
146
func (f genHelperEncoder) EncEncodeMapNonNil(v interface{}) {
147
if skipFastpathTypeSwitchInDirectCall || !fastpathEncodeTypeSwitch(v, f.e) {
148
f.e.encodeValueNonNil(reflect.ValueOf(v), nil)
152
// ---------------- DECODER FOLLOWS -----------------
154
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
155
func (f genHelperDecoder) DecBasicHandle() *BasicHandle {
158
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
159
func (f genHelperDecoder) DecBinary() bool {
160
return f.d.be // f.d.hh.isBinaryEncoding()
162
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
163
func (f genHelperDecoder) DecSwallow() { f.d.swallow() }
165
// // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
166
// func (f genHelperDecoder) DecScratchBuffer() []byte {
170
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
171
func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte {
174
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
175
func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
176
rv := reflect.ValueOf(iv)
178
if x, _ := isDecodeable(rv); !x {
179
f.d.haltAsNotDecodeable(rv)
182
f.d.decodeValue(rv, nil)
184
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
185
func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
186
return f.d.decSliceHelperStart()
188
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
189
func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) {
190
f.d.structFieldNotFound(index, name)
192
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
193
func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
194
f.d.arrayCannotExpand(sliceLen, streamLen)
196
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
197
func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
198
halt.onerror(tm.UnmarshalText(f.d.d.DecodeStringAsBytes()))
200
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
201
func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
202
f.d.jsonUnmarshalV(tm)
204
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
205
func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
206
halt.onerror(bm.UnmarshalBinary(f.d.d.DecodeBytes(nil)))
208
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
209
func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() }
211
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
212
func (f genHelperDecoder) IsJSONHandle() bool {
215
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
216
func (f genHelperDecoder) Extension(v interface{}) (xfn *extTypeTagFn) {
217
return f.d.h.getExtForI(v)
219
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
220
func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) {
221
f.d.d.DecodeExt(v, xfFn.rt, xfFn.tag, xfFn.ext)
223
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
224
func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
225
return decInferLen(clen, maxlen, unit)
228
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
229
func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart(f.d.d.ReadMapStart()) }
230
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
231
func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() }
232
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
233
func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart(f.d.d.ReadArrayStart()) }
234
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
235
func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() }
236
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
237
func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() }
238
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
239
func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() }
240
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
241
func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
243
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
244
func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
245
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
246
func (f genHelperDecoder) DecStringZC(v []byte) string { return f.d.stringZC(v) }
247
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
248
func (f genHelperDecoder) DecodeBytesInto(v []byte) []byte { return f.d.decodeBytesInto(v) }
249
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
250
func (f genHelperDecoder) DecContainerNext(j, containerLen int, hasLen bool) bool {
251
// return f.d.containerNext(j, containerLen, hasLen)
252
// rewriting so it can be inlined
254
return j < containerLen
256
return !f.d.checkBreak()
260
// MARKER: remove WriteStr, as it cannot be inlined as of 20230201.
261
// Instead, generated code calls (*encWr).WriteStr directly.
263
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
264
// func (f genHelperEncoder) WriteStr(s string) {
265
// f.e.encWr.writestr(s)
268
// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
269
func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {