Debian Codegraph @

vendor/github.com/ugorji/go/codec/gen-helper.generated.go

raw
1 /* // +build ignore */
2
3 // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
4 // Use of this source code is governed by a MIT license found in the LICENSE file.
5
6 // ************************************************************
7 // DO NOT EDIT.
8 // THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl
9 // ************************************************************
10
11 package codec
12
13 import (
14 "encoding"
15 "reflect"
16 )
17
18 // GenVersion is the current version of codecgen.
19 const GenVersion = 8
20
21 // This file is used to generate helper code for codecgen.
22 // The values here i.e. genHelper(En|De)coder are not to be used directly by
23 // library users. They WILL change continuously and without notice.
24 //
25 // To help enforce this, we create an unexported type with exported members.
26 // The only way to get the type is via the one exported type that we control (somewhat).
27 //
28 // When static codecs are created for types, they will use this value
29 // to perform encoding or decoding of primitives or known slice or map types.
30
31 // GenHelperEncoder is exported so that it can be used externally by codecgen.
32 //
33 // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
34 func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) {
35 return genHelperEncoder{e: e}, e.e
36 }
37
38 // GenHelperDecoder is exported so that it can be used externally by codecgen.
39 //
40 // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
41 func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) {
42 return genHelperDecoder{d: d}, d.d
43 }
44
45 // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
46 func BasicHandleDoNotUse(h Handle) *BasicHandle {
47 return h.getBasicHandle()
48 }
49
50 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
51 type genHelperEncoder struct {
52 e *Encoder
53 F fastpathT
54 }
55
56 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
57 type genHelperDecoder struct {
58 d *Decoder
59 F fastpathT
60 }
61
62 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
63 func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
64 return f.e.h
65 }
66
67 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
68 func (f genHelperEncoder) EncBinary() bool {
69 return f.e.cf.be // f.e.hh.isBinaryEncoding()
70 }
71
72 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
73 func (f genHelperEncoder) EncFallback(iv interface{}) {
74 // println(">>>>>>>>> EncFallback")
75 // f.e.encodeI(iv, false, false)
76 f.e.encodeValue(reflect.ValueOf(iv), nil, false)
77 }
78
79 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
80 func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
81 bs, fnerr := iv.MarshalText()
82 f.e.marshal(bs, fnerr, false, c_UTF8)
83 }
84
85 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
86 func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
87 bs, fnerr := iv.MarshalJSON()
88 f.e.marshal(bs, fnerr, true, c_UTF8)
89 }
90
91 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
92 func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
93 bs, fnerr := iv.MarshalBinary()
94 f.e.marshal(bs, fnerr, false, c_RAW)
95 }
96
97 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
98 func (f genHelperEncoder) EncRaw(iv Raw) {
99 f.e.rawBytes(iv)
100 }
101
102 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
103 func (f genHelperEncoder) TimeRtidIfBinc() uintptr {
104 if _, ok := f.e.hh.(*BincHandle); ok {
105 return timeTypId
106 }
107 return 0
108 }
109
110 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
111 func (f genHelperEncoder) IsJSONHandle() bool {
112 return f.e.cf.js
113 }
114
115 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
116 func (f genHelperEncoder) HasExtensions() bool {
117 return len(f.e.h.extHandle) != 0
118 }
119
120 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
121 func (f genHelperEncoder) EncExt(v interface{}) (r bool) {
122 rt := reflect.TypeOf(v)
123 if rt.Kind() == reflect.Ptr {
124 rt = rt.Elem()
125 }
126 rtid := rt2id(rt)
127 if xfFn := f.e.h.getExt(rtid); xfFn != nil {
128 f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
129 return true
130 }
131 return false
132 }
133
134 // ---------------- DECODER FOLLOWS -----------------
135
136 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
137 func (f genHelperDecoder) DecBasicHandle() *BasicHandle {
138 return f.d.h
139 }
140
141 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
142 func (f genHelperDecoder) DecBinary() bool {
143 return f.d.be // f.d.hh.isBinaryEncoding()
144 }
145
146 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
147 func (f genHelperDecoder) DecSwallow() {
148 f.d.swallow()
149 }
150
151 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
152 func (f genHelperDecoder) DecScratchBuffer() []byte {
153 return f.d.b[:]
154 }
155
156 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
157 func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
158 // println(">>>>>>>>> DecFallback")
159 rv := reflect.ValueOf(iv)
160 if chkPtr {
161 rv = f.d.ensureDecodeable(rv)
162 }
163 f.d.decodeValue(rv, nil, false, false)
164 // f.d.decodeValueFallback(rv)
165 }
166
167 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
168 func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
169 return f.d.decSliceHelperStart()
170 }
171
172 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
173 func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) {
174 f.d.structFieldNotFound(index, name)
175 }
176
177 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
178 func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
179 f.d.arrayCannotExpand(sliceLen, streamLen)
180 }
181
182 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
183 func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
184 fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes())
185 if fnerr != nil {
186 panic(fnerr)
187 }
188 }
189
190 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
191 func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
192 // bs := f.dd.DecodeStringAsBytes()
193 // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
194 fnerr := tm.UnmarshalJSON(f.d.nextValueBytes())
195 if fnerr != nil {
196 panic(fnerr)
197 }
198 }
199
200 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
201 func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
202 fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true))
203 if fnerr != nil {
204 panic(fnerr)
205 }
206 }
207
208 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
209 func (f genHelperDecoder) DecRaw() []byte {
210 return f.d.rawBytes()
211 }
212
213 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
214 func (f genHelperDecoder) TimeRtidIfBinc() uintptr {
215 if _, ok := f.d.hh.(*BincHandle); ok {
216 return timeTypId
217 }
218 return 0
219 }
220
221 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
222 func (f genHelperDecoder) IsJSONHandle() bool {
223 return f.d.js
224 }
225
226 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
227 func (f genHelperDecoder) HasExtensions() bool {
228 return len(f.d.h.extHandle) != 0
229 }
230
231 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
232 func (f genHelperDecoder) DecExt(v interface{}) (r bool) {
233 rt := reflect.TypeOf(v).Elem()
234 rtid := rt2id(rt)
235 if xfFn := f.d.h.getExt(rtid); xfFn != nil {
236 f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
237 return true
238 }
239 return false
240 }
241
242 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
243 func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
244 return decInferLen(clen, maxlen, unit)
245 }
246
247 // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
248 func (f genHelperDecoder) StringView(v []byte) string {
249 return stringView(v)
250 }