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