gen-helper.generated.go 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. // comment this out // + build ignore
  2. // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
  3. // Use of this source code is governed by a MIT license found in the LICENSE file.
  4. // Code generated from gen-helper.go.tmpl - DO NOT EDIT.
  5. package codec
  6. import "encoding"
  7. // GenVersion is the current version of codecgen.
  8. const GenVersion = 16
  9. // This file is used to generate helper code for codecgen.
  10. // The values here i.e. genHelper(En|De)coder are not to be used directly by
  11. // library users. They WILL change continuously and without notice.
  12. // GenHelperEncoder is exported so that it can be used externally by codecgen.
  13. //
  14. // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
  15. func GenHelperEncoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) {
  16. ge = genHelperEncoder{e: e}
  17. ee = genHelperEncDriver{encDriver: e.e}
  18. return
  19. }
  20. // GenHelperDecoder is exported so that it can be used externally by codecgen.
  21. //
  22. // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
  23. func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
  24. gd = genHelperDecoder{d: d}
  25. dd = genHelperDecDriver{decDriver: d.d}
  26. return
  27. }
  28. type genHelperEncDriver struct {
  29. encDriver
  30. }
  31. type genHelperDecDriver struct {
  32. decDriver
  33. }
  34. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  35. type genHelperEncoder struct {
  36. M must
  37. F fastpathT
  38. e *Encoder
  39. }
  40. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  41. type genHelperDecoder struct {
  42. C checkOverflow
  43. F fastpathT
  44. d *Decoder
  45. }
  46. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  47. func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
  48. return f.e.h
  49. }
  50. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  51. func (f genHelperEncoder) EncBinary() bool {
  52. return f.e.be // f.e.hh.isBinaryEncoding()
  53. }
  54. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  55. func (f genHelperEncoder) IsJSONHandle() bool {
  56. return f.e.js
  57. }
  58. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  59. func (f genHelperEncoder) EncFallback(iv interface{}) {
  60. // f.e.encodeI(iv, false, false)
  61. f.e.encodeValue(rv4i(iv), nil)
  62. }
  63. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  64. func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
  65. bs, fnerr := iv.MarshalText()
  66. f.e.marshalUtf8(bs, fnerr)
  67. }
  68. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  69. func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
  70. bs, fnerr := iv.MarshalJSON()
  71. f.e.marshalAsis(bs, fnerr)
  72. }
  73. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  74. func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
  75. bs, fnerr := iv.MarshalBinary()
  76. f.e.marshalRaw(bs, fnerr)
  77. }
  78. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  79. func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) }
  80. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  81. func (f genHelperEncoder) I2Rtid(v interface{}) uintptr {
  82. return i2rtid(v)
  83. }
  84. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  85. func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) {
  86. return f.e.h.getExt(rtid, true)
  87. }
  88. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  89. func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
  90. f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext)
  91. }
  92. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  93. func (f genHelperEncoder) WriteStr(s string) {
  94. f.e.w().writestr(s)
  95. }
  96. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  97. func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) }
  98. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  99. func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
  100. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  101. func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() }
  102. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  103. func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) }
  104. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  105. func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() }
  106. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  107. func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() }
  108. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  109. func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() }
  110. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  111. func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() }
  112. // ---------------- DECODER FOLLOWS -----------------
  113. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  114. func (f genHelperDecoder) DecBasicHandle() *BasicHandle {
  115. return f.d.h
  116. }
  117. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  118. func (f genHelperDecoder) DecBinary() bool {
  119. return f.d.be // f.d.hh.isBinaryEncoding()
  120. }
  121. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  122. func (f genHelperDecoder) DecSwallow() { f.d.swallow() }
  123. // // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  124. // func (f genHelperDecoder) DecScratchBuffer() []byte {
  125. // return f.d.b[:]
  126. // }
  127. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  128. func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte {
  129. return &f.d.b
  130. }
  131. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  132. func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
  133. rv := rv4i(iv)
  134. if chkPtr {
  135. f.d.ensureDecodeable(rv)
  136. }
  137. f.d.decodeValue(rv, nil)
  138. }
  139. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  140. func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
  141. return f.d.decSliceHelperStart()
  142. }
  143. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  144. func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) {
  145. f.d.structFieldNotFound(index, name)
  146. }
  147. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  148. func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
  149. f.d.arrayCannotExpand(sliceLen, streamLen)
  150. }
  151. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  152. func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
  153. if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil {
  154. halt.errorv(fnerr)
  155. }
  156. }
  157. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  158. func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
  159. // bs := f.dd.DecodeStringAsBytes()
  160. // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
  161. if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil {
  162. halt.errorv(fnerr)
  163. }
  164. }
  165. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  166. func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
  167. if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil {
  168. halt.errorv(fnerr)
  169. }
  170. }
  171. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  172. func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() }
  173. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  174. func (f genHelperDecoder) IsJSONHandle() bool {
  175. return f.d.js
  176. }
  177. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  178. func (f genHelperDecoder) I2Rtid(v interface{}) uintptr {
  179. return i2rtid(v)
  180. }
  181. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  182. func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) {
  183. return f.d.h.getExt(rtid, true)
  184. }
  185. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  186. func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) {
  187. f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
  188. }
  189. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  190. func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
  191. return decInferLen(clen, maxlen, unit)
  192. }
  193. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  194. func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) }
  195. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  196. func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart() }
  197. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  198. func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() }
  199. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  200. func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() }
  201. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  202. func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() }
  203. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  204. func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() }
  205. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  206. func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() }
  207. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  208. func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
  209. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  210. func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
  211. // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
  212. func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() }