github.com/patricebensoussan/go/codec@v1.2.99/gen-helper.generated.go (about)

     1  // comment this out // + build ignore
     2  
     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.
     5  
     6  // Code generated from gen-helper.go.tmpl - DO NOT EDIT.
     7  
     8  package codec
     9  
    10  import (
    11  	"encoding"
    12  	"reflect"
    13  )
    14  
    15  // GenVersion is the current version of codecgen.
    16  const GenVersion = 25
    17  
    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.
    21  
    22  // GenHelperEncoder is exported so that it can be used externally by codecgen.
    23  //
    24  // Library users: DO NOT USE IT DIRECTLY or INDIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
    25  func GenHelper() (g genHelper) { return }
    26  
    27  type genHelper struct{}
    28  
    29  func (genHelper) Encoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) {
    30  	ge = genHelperEncoder{e: e}
    31  	ee = genHelperEncDriver{encDriver: e.e}
    32  	return
    33  }
    34  
    35  func (genHelper) Decoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) {
    36  	gd = genHelperDecoder{d: d}
    37  	dd = genHelperDecDriver{decDriver: d.d}
    38  	return
    39  }
    40  
    41  type genHelperEncDriver struct {
    42  	encDriver
    43  }
    44  
    45  type genHelperDecDriver struct {
    46  	decDriver
    47  }
    48  
    49  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    50  type genHelperEncoder struct {
    51  	M mustHdl
    52  	F fastpathT
    53  	e *Encoder
    54  }
    55  
    56  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    57  type genHelperDecoder struct {
    58  	C checkOverflow
    59  	F fastpathT
    60  	d *Decoder
    61  }
    62  
    63  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    64  func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
    65  	return f.e.h
    66  }
    67  
    68  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    69  func (f genHelperEncoder) EncBinary() bool {
    70  	return f.e.be // f.e.hh.isBinaryEncoding()
    71  }
    72  
    73  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    74  func (f genHelperEncoder) IsJSONHandle() bool {
    75  	return f.e.js
    76  }
    77  
    78  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    79  func (f genHelperEncoder) EncFallback(iv interface{}) {
    80  	// f.e.encodeI(iv, false, false)
    81  	f.e.encodeValue(reflect.ValueOf(iv), nil)
    82  }
    83  
    84  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    85  func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
    86  	bs, fnerr := iv.MarshalText()
    87  	f.e.marshalUtf8(bs, fnerr)
    88  }
    89  
    90  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    91  func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
    92  	bs, fnerr := iv.MarshalJSON()
    93  	f.e.marshalAsis(bs, fnerr)
    94  }
    95  
    96  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
    97  func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
    98  	bs, fnerr := iv.MarshalBinary()
    99  	f.e.marshalRaw(bs, fnerr)
   100  }
   101  
   102  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   103  func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) }
   104  
   105  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   106  func (f genHelperEncoder) Extension(v interface{}) (xfn *extTypeTagFn) {
   107  	return f.e.h.getExtForI(v)
   108  }
   109  
   110  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   111  func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) {
   112  	f.e.e.EncodeExt(v, xfFn.rt, xfFn.tag, xfFn.ext)
   113  }
   114  
   115  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   116  func (f genHelperEncoder) WriteStr(s string) {
   117  	f.e.w().writestr(s)
   118  }
   119  
   120  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   121  func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) }
   122  
   123  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   124  func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() }
   125  
   126  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   127  func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) }
   128  
   129  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   130  func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() }
   131  
   132  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   133  func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() }
   134  
   135  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   136  func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() }
   137  
   138  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   139  func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() }
   140  
   141  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   142  func (f genHelperEncoder) EncEncodeComplex64(v complex64) { f.e.encodeComplex64(v) }
   143  
   144  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   145  func (f genHelperEncoder) EncEncodeComplex128(v complex128) { f.e.encodeComplex128(v) }
   146  
   147  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   148  func (f genHelperEncoder) EncEncode(v interface{}) { f.e.encode(v) }
   149  
   150  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   151  func (f genHelperEncoder) EncEncodeMapNonNil(v interface{}) {
   152  	if skipFastpathTypeSwitchInDirectCall || !fastpathEncodeTypeSwitch(v, f.e) {
   153  		f.e.encodeValue(reflect.ValueOf(v), nil)
   154  	}
   155  }
   156  
   157  // ---------------- DECODER FOLLOWS -----------------
   158  
   159  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   160  func (f genHelperDecoder) DecBasicHandle() *BasicHandle {
   161  	return f.d.h
   162  }
   163  
   164  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   165  func (f genHelperDecoder) DecBinary() bool {
   166  	return f.d.be // f.d.hh.isBinaryEncoding()
   167  }
   168  
   169  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   170  func (f genHelperDecoder) DecSwallow() { f.d.swallow() }
   171  
   172  // // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   173  // func (f genHelperDecoder) DecScratchBuffer() []byte {
   174  // 	return f.d.b[:]
   175  // }
   176  
   177  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   178  func (f genHelperDecoder) DecScratchArrayBuffer() *[decScratchByteArrayLen]byte {
   179  	return &f.d.b
   180  }
   181  
   182  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   183  func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
   184  	rv := reflect.ValueOf(iv)
   185  	if chkPtr {
   186  		if x, _ := isDecodeable(rv); !x {
   187  			f.d.haltAsNotDecodeable(rv)
   188  		}
   189  	}
   190  	f.d.decodeValue(rv, nil)
   191  }
   192  
   193  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   194  func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
   195  	return f.d.decSliceHelperStart()
   196  }
   197  
   198  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   199  func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) {
   200  	f.d.structFieldNotFound(index, name)
   201  }
   202  
   203  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   204  func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
   205  	f.d.arrayCannotExpand(sliceLen, streamLen)
   206  }
   207  
   208  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   209  func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
   210  	halt.onerror(tm.UnmarshalText(f.d.d.DecodeStringAsBytes()))
   211  }
   212  
   213  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   214  func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
   215  	f.d.jsonUnmarshalV(tm)
   216  }
   217  
   218  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   219  func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
   220  	halt.onerror(bm.UnmarshalBinary(f.d.d.DecodeBytes(nil)))
   221  }
   222  
   223  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   224  func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() }
   225  
   226  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   227  func (f genHelperDecoder) IsJSONHandle() bool {
   228  	return f.d.js
   229  }
   230  
   231  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   232  func (f genHelperDecoder) Extension(v interface{}) (xfn *extTypeTagFn) {
   233  	return f.d.h.getExtForI(v)
   234  }
   235  
   236  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   237  func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) {
   238  	f.d.d.DecodeExt(v, xfFn.rt, xfFn.tag, xfFn.ext)
   239  }
   240  
   241  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   242  func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) {
   243  	return decInferLen(clen, maxlen, unit)
   244  }
   245  
   246  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   247  func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart(f.d.d.ReadMapStart()) }
   248  
   249  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   250  func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() }
   251  
   252  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   253  func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart(f.d.d.ReadArrayStart()) }
   254  
   255  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   256  func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() }
   257  
   258  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   259  func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() }
   260  
   261  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   262  func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() }
   263  
   264  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   265  func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() }
   266  
   267  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   268  func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() }
   269  
   270  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   271  func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() }
   272  
   273  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   274  func (f genHelperDecoder) DecStringZC(v []byte) string { return f.d.stringZC(v) }
   275  
   276  // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
   277  func (f genHelperDecoder) DecodeBytesInto(v []byte) []byte { return f.d.decodeBytesInto(v) }