123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- // //+build ignore
- // Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
- // Use of this source code is governed by a MIT license found in the LICENSE file.
- // ************************************************************
- // DO NOT EDIT.
- // THIS FILE IS AUTO-GENERATED from gen-helper.go.tmpl
- // ************************************************************
- package codec
- import (
- "encoding"
- "reflect"
- )
- // This file is used to generate helper code for codecgen.
- // The values here i.e. genHelper(En|De)coder are not to be used directly by
- // library users. They WILL change continously and without notice.
- //
- // To help enforce this, we create an unexported type with exported members.
- // The only way to get the type is via the one exported type that we control (somewhat).
- //
- // When static codecs are created for types, they will use this value
- // to perform encoding or decoding of primitives or known slice or map types.
- // GenHelperEncoder is exported so that it can be used externally by codecgen.
- // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
- func GenHelperEncoder(e *Encoder) (genHelperEncoder, encDriver) {
- return genHelperEncoder{e:e}, e.e
- }
- // GenHelperDecoder is exported so that it can be used externally by codecgen.
- // Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINOUSLY WITHOUT NOTICE.
- func GenHelperDecoder(d *Decoder) (genHelperDecoder, decDriver) {
- return genHelperDecoder{d:d}, d.d
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- type genHelperEncoder struct {
- e *Encoder
- F fastpathT
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- type genHelperDecoder struct {
- d *Decoder
- F fastpathT
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncBasicHandle() *BasicHandle {
- return f.e.h
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncBinary() bool {
- return f.e.be // f.e.hh.isBinaryEncoding()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncFallback(iv interface{}) {
- // println(">>>>>>>>> EncFallback")
- f.e.encodeI(iv, false, false)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncTextMarshal(iv encoding.TextMarshaler) {
- bs, fnerr := iv.MarshalText()
- f.e.marshal(bs, fnerr, false, c_UTF8)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncJSONMarshal(iv jsonMarshaler) {
- bs, fnerr := iv.MarshalJSON()
- f.e.marshal(bs, fnerr, true, c_UTF8)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncBinaryMarshal(iv encoding.BinaryMarshaler) {
- bs, fnerr := iv.MarshalBinary()
- f.e.marshal(bs, fnerr, false, c_RAW)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) TimeRtidIfBinc() uintptr {
- if _, ok := f.e.hh.(*BincHandle); ok {
- return timeTypId
- }
- return 0
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) IsJSONHandle() bool {
- return f.e.js
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) HasExtensions() bool {
- return len(f.e.h.extHandle) != 0
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncExt(v interface{}) (r bool) {
- rt := reflect.TypeOf(v)
- if rt.Kind() == reflect.Ptr {
- rt = rt.Elem()
- }
- rtid := reflect.ValueOf(rt).Pointer()
- if xfFn := f.e.h.getExt(rtid); xfFn != nil {
- f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext, f.e)
- return true
- }
- return false
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncSendContainerState(c containerState) {
- if f.e.cr != nil {
- f.e.cr.sendContainerState(c)
- }
- }
- // ---------------- DECODER FOLLOWS -----------------
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecBasicHandle() *BasicHandle {
- return f.d.h
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecBinary() bool {
- return f.d.be // f.d.hh.isBinaryEncoding()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecSwallow() {
- f.d.swallow()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecScratchBuffer() []byte {
- return f.d.b[:]
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecFallback(iv interface{}, chkPtr bool) {
- // println(">>>>>>>>> DecFallback")
- f.d.decodeI(iv, chkPtr, false, false, false)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecSliceHelperStart() (decSliceHelper, int) {
- return f.d.decSliceHelperStart()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecStructFieldNotFound(index int, name string) {
- f.d.structFieldNotFound(index, name)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecArrayCannotExpand(sliceLen, streamLen int) {
- f.d.arrayCannotExpand(sliceLen, streamLen)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecTextUnmarshal(tm encoding.TextUnmarshaler) {
- fnerr := tm.UnmarshalText(f.d.d.DecodeBytes(f.d.b[:], true, true))
- if fnerr != nil {
- panic(fnerr)
- }
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) {
- // bs := f.dd.DecodeBytes(f.d.b[:], true, true)
- // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself.
- fnerr := tm.UnmarshalJSON(f.d.nextValueBytes())
- if fnerr != nil {
- panic(fnerr)
- }
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) {
- fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, false, true))
- if fnerr != nil {
- panic(fnerr)
- }
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) TimeRtidIfBinc() uintptr {
- if _, ok := f.d.hh.(*BincHandle); ok {
- return timeTypId
- }
- return 0
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) IsJSONHandle() bool {
- return f.d.js
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) HasExtensions() bool {
- return len(f.d.h.extHandle) != 0
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecExt(v interface{}) (r bool) {
- rt := reflect.TypeOf(v).Elem()
- rtid := reflect.ValueOf(rt).Pointer()
- if xfFn := f.d.h.getExt(rtid); xfFn != nil {
- f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext)
- return true
- }
- return false
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int, truncated bool) {
- return decInferLen(clen, maxlen, unit)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecSendContainerState(c containerState) {
- if f.d.cr != nil {
- f.d.cr.sendContainerState(c)
- }
- }
- {{/*
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncDriver() encDriver {
- return f.e.e
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecDriver() decDriver {
- return f.d.d
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncNil() {
- f.e.e.EncodeNil()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncBytes(v []byte) {
- f.e.e.EncodeStringBytes(c_RAW, v)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncArrayStart(length int) {
- f.e.e.EncodeArrayStart(length)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncArrayEnd() {
- f.e.e.EncodeArrayEnd()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncArrayEntrySeparator() {
- f.e.e.EncodeArrayEntrySeparator()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncMapStart(length int) {
- f.e.e.EncodeMapStart(length)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncMapEnd() {
- f.e.e.EncodeMapEnd()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncMapEntrySeparator() {
- f.e.e.EncodeMapEntrySeparator()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) EncMapKVSeparator() {
- f.e.e.EncodeMapKVSeparator()
- }
- // ---------
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecBytes(v *[]byte) {
- *v = f.d.d.DecodeBytes(*v)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecTryNil() bool {
- return f.d.d.TryDecodeAsNil()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecContainerIsNil() (b bool) {
- return f.d.d.IsContainerType(valueTypeNil)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecContainerIsMap() (b bool) {
- return f.d.d.IsContainerType(valueTypeMap)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecContainerIsArray() (b bool) {
- return f.d.d.IsContainerType(valueTypeArray)
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecCheckBreak() bool {
- return f.d.d.CheckBreak()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecMapStart() int {
- return f.d.d.ReadMapStart()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecArrayStart() int {
- return f.d.d.ReadArrayStart()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecMapEnd() {
- f.d.d.ReadMapEnd()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecArrayEnd() {
- f.d.d.ReadArrayEnd()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecArrayEntrySeparator() {
- f.d.d.ReadArrayEntrySeparator()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecMapEntrySeparator() {
- f.d.d.ReadMapEntrySeparator()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) DecMapKVSeparator() {
- f.d.d.ReadMapKVSeparator()
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) ReadStringAsBytes(bs []byte) []byte {
- return f.d.d.DecodeStringAsBytes(bs)
- }
- // -- encode calls (primitives)
- {{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }}
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) {{ .MethodNamePfx "Enc" true }}(v {{ .Primitive }}) {
- ee := f.e.e
- {{ encmd .Primitive "v" }}
- }
- {{ end }}{{ end }}{{ end }}
- // -- decode calls (primitives)
- {{range .Values}}{{if .Primitive }}{{if ne .Primitive "interface{}" }}
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) {{ .MethodNamePfx "Dec" true }}(vp *{{ .Primitive }}) {
- dd := f.d.d
- *vp = {{ decmd .Primitive }}
- }
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperDecoder) {{ .MethodNamePfx "Read" true }}() (v {{ .Primitive }}) {
- dd := f.d.d
- v = {{ decmd .Primitive }}
- return
- }
- {{ end }}{{ end }}{{ end }}
- // -- encode calls (slices/maps)
- {{range .Values}}{{if not .Primitive }}{{if .Slice }}
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v []{{ .Elem }}) { {{ else }}
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- func (f genHelperEncoder) {{ .MethodNamePfx "Enc" false }}(v map[{{ .MapKey }}]{{ .Elem }}) { {{end}}
- f.F.{{ .MethodNamePfx "Enc" false }}V(v, false, f.e)
- }
- {{ end }}{{ end }}
- // -- decode calls (slices/maps)
- {{range .Values}}{{if not .Primitive }}
- // FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE*
- {{if .Slice }}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *[]{{ .Elem }}) {
- {{else}}func (f genHelperDecoder) {{ .MethodNamePfx "Dec" false }}(vp *map[{{ .MapKey }}]{{ .Elem }}) { {{end}}
- v, changed := f.F.{{ .MethodNamePfx "Dec" false }}V(*vp, false, true, f.d)
- if changed {
- *vp = v
- }
- }
- {{ end }}{{ end }}
- */}}
|