diff --git a/glide.lock b/glide.lock index 6c2f7fe89..bfa0e2bcf 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: f82bf395df6f00004b1794606a9256d5c69b62deb5498b574a08b2b5d15f7a6a -updated: 2019-10-12T11:11:23.472932-04:00 +updated: 2019-10-12T11:22:30.564437-04:00 imports: - name: cloud.google.com/go version: 8c41231e01b2085512d98153bcffb847ff9b4b9f @@ -87,10 +87,6 @@ imports: version: 67fc4837d267bc9bfd6e47f77783fcc3dffc68de - name: github.com/spf13/pflag version: 298182f68c66c05229eb03ac171abe6e309ee79a -- name: github.com/ugorji/go - version: 42bc974514ff101a54c6b72a0e4dee29d96c0b26 - subpackages: - - codec - name: golang.org/x/crypto version: e84da0312774c21d64ee2317962ef669b27ffb41 subpackages: diff --git a/vendor/github.com/ugorji/go/.travis.yml b/vendor/github.com/ugorji/go/.travis.yml deleted file mode 100644 index 1812b2bcf..000000000 --- a/vendor/github.com/ugorji/go/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -language: go -sudo: false -go: - - master - - 1.12.x - - 1.11.x - - 1.10.x - - 1.9.x - # go testing suite support, which we use, was introduced in go 1.7 - # testing.TB, TB.Helper() was introduced in go 1.9 - # Consequently, tests will only compile for go 1.9+ -script: - - go test -tags "alltests" -run Suite -coverprofile coverage.txt github.com/ugorji/go/codec - - go test -tags "alltests safe" -run Suite -coverprofile coverage.safe.txt github.com/ugorji/go/codec - - go test -tags "alltests codecgen" -run Suite -coverprofile coverage.codecgen.txt github.com/ugorji/go/codec - # we use if block below, so that we still return with success even if skipped. - # Previously, we used [[...]] && go test ..., which returned exit code 0 and broke the build. - - | - if [[ "${TRAVIS_GO_VERSION}" == "1.9.x" ]]; then - GOARCH=386 go test -tags "alltests" -run Suite -coverprofile coverage.386.txt github.com/ugorji/go/codec - fi - - | - if [[ "${TRAVIS_GO_VERSION}" == "1.10.x" ]]; then - GOARCH=386 go test -tags "alltests safe" -run Suite -coverprofile coverage.386.safe.txt github.com/ugorji/go/codec - fi - - | - if [[ "${TRAVIS_GO_VERSION}" == "1.11.x" ]]; then - GOARCH=386 go test -tags "alltests codecgen" -run Suite -coverprofile coverage.386.codecgen.txt github.com/ugorji/go/codec - fi - - | - if [[ "${TRAVIS_GO_VERSION}" == "1.12.x" ]]; then - echo "XXXX RACE" && go test "-race" -tags "alltests" -run Suite -coverprofile coverage.race.txt github.com/ugorji/go/codec; - fi - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/ugorji/go/FAQ.md b/vendor/github.com/ugorji/go/FAQ.md deleted file mode 100644 index bff22ebac..000000000 --- a/vendor/github.com/ugorji/go/FAQ.md +++ /dev/null @@ -1,49 +0,0 @@ -# FAQ - -## Managing Binary Size - -This package adds some size to any binary that depends on it. -This is because we include an auto-generated file: `fast-path.generated.go` -to help with performance when encoding/decoding slices and maps of -built in numeric, boolean, string and interface{} types. - -Prior to 2019-05-16, this package could add about `11MB` to the size of -your binaries. We have now trimmed that in half, and the package -contributes about `5.5MB`. This compares favorably to other packages like -`json-iterator/go` `(3.3MB)` and `net/http` `(3.5MB)`. - -Furthermore, you can bypass building `fast-path.generated.go`, by building -(or running tests and benchmarks) with the tag: `notfastpath`. - - go install -tags notfastpath - go build -tags notfastpath - go test -tags notfastpath - -With the tag `notfastpath`, we trim that size to about `2.8MB`. - -Be aware that, at least in our representative microbenchmarks for cbor (for example), -passing `notfastpath` tag causes significant performance loss (about 33%). -*YMMV*. - -## Resolving Module Issues - -Prior to v1.1.5, go-codec unknowingly introduced some headaches for its -users while introducing module support. We tried to make -`github.com/ugorji/go/codec` a module. At that time, multi-repository -module support was weak, so we reverted and made `github.com/ugorji/go/` -the module. However, folks previously used go-codec in module mode -before it formally supported modules. Eventually, different established packages -had go.mod files contain various real and pseudo versions of go-codec -which causes `go` to barf with `ambiguous import` error. - -To resolve this, from v1.1.5 and up, we use a requirements cycle between -modules `github.com/ugorji/go/codec` and `github.com/ugorji/go/`, -tagging them with parallel consistent tags (`codec/vX.Y.Z and vX.Y.Z`) -to the same commit. - -Fixing `ambiguous import` failure is now as simple as running - -``` -go get -u github.com/ugorji/go/codec@latest -``` - diff --git a/vendor/github.com/ugorji/go/LICENSE b/vendor/github.com/ugorji/go/LICENSE deleted file mode 100644 index 95a0f0541..000000000 --- a/vendor/github.com/ugorji/go/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2012-2015 Ugorji Nwoke. -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/ugorji/go/README.md b/vendor/github.com/ugorji/go/README.md deleted file mode 100644 index cf3d04c61..000000000 --- a/vendor/github.com/ugorji/go/README.md +++ /dev/null @@ -1,299 +0,0 @@ -[![Sourcegraph](https://sourcegraph.com/github.com/ugorji/go/-/badge.svg?v=4)](https://sourcegraph.com/github.com/ugorji/go/-/tree/codec?badge) -[![Build Status](https://travis-ci.org/ugorji/go.svg?branch=master)](https://travis-ci.org/ugorji/go) -[![codecov](https://codecov.io/gh/ugorji/go/branch/master/graph/badge.svg?v=4)](https://codecov.io/gh/ugorji/go) -[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/ugorji/go/codec) -[![rcard](https://goreportcard.com/badge/github.com/ugorji/go/codec?v=4)](https://goreportcard.com/report/github.com/ugorji/go/codec) -[![License](http://img.shields.io/badge/license-mit-blue.svg?style=flat-square)](https://raw.githubusercontent.com/ugorji/go/master/LICENSE) - -# go-codec - -This repository contains the `go-codec` library. - -To install: - -``` -go get github.com/ugorji/go/codec -``` - -# Package Documentation - - -Package codec provides a High Performance, Feature-Rich Idiomatic Go 1.4+ -codec/encoding library for binc, msgpack, cbor, json. - -Supported Serialization formats are: - - - msgpack: https://github.com/msgpack/msgpack - - binc: http://github.com/ugorji/binc - - cbor: http://cbor.io http://tools.ietf.org/html/rfc7049 - - json: http://json.org http://tools.ietf.org/html/rfc7159 - - simple: - -This package will carefully use 'package unsafe' for performance reasons in -specific places. You can build without unsafe use by passing the safe or -appengine tag i.e. 'go install -tags=safe ...'. - -For detailed usage information, read the primer at -http://ugorji.net/blog/go-codec-primer . - -The idiomatic Go support is as seen in other encoding packages in the -standard library (ie json, xml, gob, etc). - -Rich Feature Set includes: - - - Simple but extremely powerful and feature-rich API - - Support for go 1.4 and above, while selectively using newer APIs for later releases - - Excellent code coverage ( > 90% ) - - Very High Performance. - Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X. - - Careful selected use of 'unsafe' for targeted performance gains. - - 100% safe mode supported, where 'unsafe' is not used at all. - - Lock-free (sans mutex) concurrency for scaling to 100's of cores - - In-place updates during decode, with option to zero value in maps and slices prior to decode - - Coerce types where appropriate - e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc - - Corner Cases: - Overflows, nil maps/slices, nil values in streams are handled correctly - - Standard field renaming via tags - - Support for omitting empty fields during an encoding - - Encoding from any value and decoding into pointer to any value - (struct, slice, map, primitives, pointers, interface{}, etc) - - Extensions to support efficient encoding/decoding of any named types - - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces - - Support IsZero() bool to determine if a value is a zero value. - Analogous to time.Time.IsZero() bool. - - Decoding without a schema (into a interface{}). - Includes Options to configure what specific map or slice type to use - when decoding an encoded list or map into a nil interface{} - - Mapping a non-interface type to an interface, so we can decode appropriately - into any interface type with a correctly configured non-interface value. - - Encode a struct as an array, and decode struct from an array in the data stream - - Option to encode struct keys as numbers (instead of strings) - (to support structured streams with fields encoded as numeric codes) - - Comprehensive support for anonymous fields - - Fast (no-reflection) encoding/decoding of common maps and slices - - Code-generation for faster performance, supported in go 1.6+ - - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats - - Support indefinite-length formats to enable true streaming - (for formats which support it e.g. json, cbor) - - Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes. - This mostly applies to maps, where iteration order is non-deterministic. - - NIL in data stream decoded as zero value - - Never silently skip data when decoding. - User decides whether to return an error or silently skip data when keys or indexes - in the data stream do not map to fields in the struct. - - Detect and error when encoding a cyclic reference (instead of stack overflow shutdown) - - Encode/Decode from/to chan types (for iterative streaming support) - - Drop-in replacement for encoding/json. `json:` key in struct tag supported. - - Provides a RPC Server and Client Codec for net/rpc communication protocol. - - Handle unique idiosyncrasies of codecs e.g. - - For messagepack, configure how ambiguities in handling raw bytes are resolved - - For messagepack, provide rpc server/client codec to support - msgpack-rpc protocol defined at: - https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md - - -## Extension Support - -Users can register a function to handle the encoding or decoding of their -custom types. - -There are no restrictions on what the custom type can be. Some examples: - -```go - type BisSet []int - type BitSet64 uint64 - type UUID string - type MyStructWithUnexportedFields struct { a int; b bool; c []int; } - type GifImage struct { ... } -``` - -As an illustration, MyStructWithUnexportedFields would normally be encoded -as an empty map because it has no exported fields, while UUID would be -encoded as a string. However, with extension support, you can encode any of -these however you like. - -There is also seamless support provided for registering an extension (with a -tag) but letting the encoding mechanism default to the standard way. - - -## Custom Encoding and Decoding - -This package maintains symmetry in the encoding and decoding halfs. We -determine how to encode or decode by walking this decision tree - - - is there an extension registered for the type? - - is type a codec.Selfer? - - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler? - - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler? - - is format text-based, and type an encoding.TextMarshaler and TextUnmarshaler? - - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc - -This symmetry is important to reduce chances of issues happening because the -encoding and decoding sides are out of sync e.g. decoded via very specific -encoding.TextUnmarshaler but encoded via kind-specific generalized mode. - -Consequently, if a type only defines one-half of the symmetry (e.g. it -implements UnmarshalJSON() but not MarshalJSON() ), then that type doesn't -satisfy the check and we will continue walking down the decision tree. - - -## RPC - -RPC Client and Server Codecs are implemented, so the codecs can be used with -the standard net/rpc package. - - -## Usage - -The Handle is SAFE for concurrent READ, but NOT SAFE for concurrent -modification. - -The Encoder and Decoder are NOT safe for concurrent use. - -Consequently, the usage model is basically: - - - Create and initialize the Handle before any use. - Once created, DO NOT modify it. - - Multiple Encoders or Decoders can now use the Handle concurrently. - They only read information off the Handle (never write). - - However, each Encoder or Decoder MUST not be used concurrently - - To re-use an Encoder/Decoder, call Reset(...) on it first. - This allows you use state maintained on the Encoder/Decoder. - -Sample usage model: - -```go - // create and configure Handle - var ( - bh codec.BincHandle - mh codec.MsgpackHandle - ch codec.CborHandle - ) - - mh.MapType = reflect.TypeOf(map[string]interface{}(nil)) - - // configure extensions - // e.g. for msgpack, define functions and enable Time support for tag 1 - // mh.SetExt(reflect.TypeOf(time.Time{}), 1, myExt) - - // create and use decoder/encoder - var ( - r io.Reader - w io.Writer - b []byte - h = &bh // or mh to use msgpack - ) - - dec = codec.NewDecoder(r, h) - dec = codec.NewDecoderBytes(b, h) - err = dec.Decode(&v) - - enc = codec.NewEncoder(w, h) - enc = codec.NewEncoderBytes(&b, h) - err = enc.Encode(v) - - //RPC Server - go func() { - for { - conn, err := listener.Accept() - rpcCodec := codec.GoRpc.ServerCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h) - rpc.ServeCodec(rpcCodec) - } - }() - - //RPC Communication (client side) - conn, err = net.Dial("tcp", "localhost:5555") - rpcCodec := codec.GoRpc.ClientCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h) - client := rpc.NewClientWithCodec(rpcCodec) -``` - - -## Running Tests - -To run tests, use the following: - -``` - go test -``` - -To run the full suite of tests, use the following: - -``` - go test -tags alltests -run Suite -``` - -You can run the tag 'safe' to run tests or build in safe mode. e.g. - -``` - go test -tags safe -run Json - go test -tags "alltests safe" -run Suite -``` - -## Running Benchmarks - -``` - cd bench - go test -bench . -benchmem -benchtime 1s -``` - -Please see http://github.com/ugorji/go-codec-bench . - - -## Caveats - -Struct fields matching the following are ignored during encoding and -decoding - - - struct tag value set to - - - func, complex numbers, unsafe pointers - - unexported and not embedded - - unexported and embedded and not struct kind - - unexported and embedded pointers (from go1.10) - -Every other field in a struct will be encoded/decoded. - -Embedded fields are encoded as if they exist in the top-level struct, with -some caveats. See Encode documentation. - -## Exported Package API - -```go -const CborStreamBytes byte = 0x5f ... -const GenVersion = 16 -var SelfExt = &extFailWrapper{} -var GoRpc goRpc -var MsgpackSpecRpc msgpackSpecRpc -func GenHelperDecoder(d *Decoder) (gd genHelperDecoder, dd genHelperDecDriver) -func GenHelperEncoder(e *Encoder) (ge genHelperEncoder, ee genHelperEncDriver) -type BasicHandle struct{ ... } -type BincHandle struct{ ... } -type BytesExt interface{ ... } -type CborHandle struct{ ... } -type DecodeOptions struct{ ... } -type Decoder struct{ ... } - func NewDecoder(r io.Reader, h Handle) *Decoder - func NewDecoderBytes(in []byte, h Handle) *Decoder -type EncodeOptions struct{ ... } -type Encoder struct{ ... } - func NewEncoder(w io.Writer, h Handle) *Encoder - func NewEncoderBytes(out *[]byte, h Handle) *Encoder -type Ext interface{ ... } -type Handle interface{ ... } -type InterfaceExt interface{ ... } -type JsonHandle struct{ ... } -type MapBySlice interface{ ... } -type MissingFielder interface{ ... } -type MsgpackHandle struct{ ... } -type MsgpackSpecRpcMultiArgs []interface{} -type RPCOptions struct{ ... } -type Raw []byte -type RawExt struct{ ... } -type Rpc interface{ ... } -type Selfer interface{ ... } -type SimpleHandle struct{ ... } -type TypeInfos struct{ ... } - func NewTypeInfos(tags []string) *TypeInfos -``` diff --git a/vendor/github.com/ugorji/go/codec/0_importpath.go b/vendor/github.com/ugorji/go/codec/0_importpath.go deleted file mode 100644 index adbe862c2..000000000 --- a/vendor/github.com/ugorji/go/codec/0_importpath.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec // import "github.com/ugorji/go/codec" - -// This establishes that this package must be imported as github.com/ugorji/go/codec. -// It makes forking easier, and plays well with pre-module releases of go. diff --git a/vendor/github.com/ugorji/go/codec/bench/.gitignore b/vendor/github.com/ugorji/go/codec/bench/.gitignore deleted file mode 100644 index 608fc95fb..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*_generated_*.* - diff --git a/vendor/github.com/ugorji/go/codec/bench/README.md b/vendor/github.com/ugorji/go/codec/bench/README.md deleted file mode 100644 index 170719d2f..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/README.md +++ /dev/null @@ -1,153 +0,0 @@ -# go-codec-bench - -This is a comparison of different binary and text encodings. - -We compare the codecs provided by github.com/ugorji/go/codec package, -against other libraries: - -[github.com/ugorji/go/codec](http://github.com/ugorji/go) provides: - - - msgpack: [http://github.com/msgpack/msgpack] - - binc: [http://github.com/ugorji/binc] - - cbor: [http://cbor.io] [http://tools.ietf.org/html/rfc7049] - - simple: - - json: [http://json.org] [http://tools.ietf.org/html/rfc7159] - -Other codecs compared include: - - - [gopkg.in/vmihailenco/msgpack.v2](http://gopkg.in/vmihailenco/msgpack.v2) - - [gopkg.in/mgo.v2/bson](http://gopkg.in/mgo.v2/bson) - - [github.com/davecgh/go-xdr/xdr2](https://godoc.org/github.com/davecgh/go-xdr/xdr) - - [github.com/Sereal/Sereal/Go/sereal](https://godoc.org/github.com/Sereal/Sereal/Go/sereal) - - [code.google.com/p/cbor/go](http://code.google.com/p/cbor/go) - - [github.com/tinylib/msgp](http://github.com/tinylib/msgp) - - [github.com/tinylib/msgp](http://godoc.org/github.com/tinylib/msgp) - - [github.com/pquerna/ffjson/ffjson](http://godoc.org/github.com/pquerna/ffjson/ffjson) - - [bitbucket.org/bodhisnarkva/cbor/go](http://godoc.org/bitbucket.org/bodhisnarkva/cbor/go) - - [github.com/json-iterator/go](http://godoc.org/github.com/json-iterator/go) - - [github.com/mailru/easyjson](http://godoc.org/github.com/mailru/easyjson) - -# Data - -The data being serialized is a `TestStruc` randomly generated values. -See https://github.com/ugorji/go-codec-bench/blob/master/codec/values_test.go for the -definition of the TestStruc. - -# Run Benchmarks - -See https://github.com/ugorji/go-codec-bench/blob/master/codec/bench.sh -for how to download the external libraries which we benchmark against, -generate the files for the types when needed, -and run the suite of tests. - -The 3 suite of benchmarks are - - - CodecSuite - - XSuite - - CodecXSuite - -``` -# Note that `bench.sh` may be in the codec sub-directory, and should be run from there. - -# download the code and all its dependencies -./bench.sh -d - -# code-generate files needed for benchmarks against ffjson, easyjson, msgp, etc -./bench.sh -c - -# run the full suite of tests -./bench.sh -s - -# Below, see how to just run some specific suite of tests, knowing the right tags and flags ... -# See bench.sh for different iterations - -# Run suite of tests in default mode (selectively using unsafe in specific areas) -go test -tags "alltests x" -bench "CodecXSuite" -benchmem -# Run suite of tests in safe mode (no usage of unsafe) -go test -tags "alltests x safe" -bench "CodecXSuite" -benchmem -# Run suite of tests in codecgen mode, including all tests which are generated (msgp, ffjson, etc) -go test -tags "alltests x generated" -bench "CodecXGenSuite" -benchmem - -``` - -# Issues - -The following issues are seen currently (11/20/2014): - -- _code.google.com/p/cbor/go_ fails on encoding and decoding the test struct -- _github.com/davecgh/go-xdr/xdr2_ fails on encoding and decoding the test struct -- _github.com/Sereal/Sereal/Go/sereal_ fails on decoding the serialized test struct - -# Representative Benchmark Results - -Please see the [benchmarking blog post for detailed representative results](http://ugorji.net/blog/benchmarking-serialization-in-go). - -A snapshot of some results on my 2016 MacBook Pro is below. -**Note: errors are truncated, and lines re-arranged, for readability**. - -Below are results of running the entire suite on 2017-11-20 (ie running ./bench.sh -s). - -What you should notice: - -- Results get better with codecgen, showing about 20-50% performance improvement. - Users should carefully weigh the performance improvements against the - usability and binary-size increases, as performance is already extremely good - without the codecgen path. - -See https://github.com/ugorji/go-codec-bench/blob/master/bench.out.txt for latest run of bench.sh as of 2017-11-20 - -* snippet of bench.out.txt, running without codecgen * -``` -BenchmarkCodecXSuite/options-false.../Benchmark__Msgpack____Encode-8 10000 183961 ns/op 10224 B/op 75 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Binc_______Encode-8 10000 206362 ns/op 12551 B/op 80 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Simple_____Encode-8 10000 193966 ns/op 10224 B/op 75 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Cbor_______Encode-8 10000 192666 ns/op 10224 B/op 75 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Json_______Encode-8 3000 475767 ns/op 10352 B/op 75 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Std_Json___Encode-8 3000 525223 ns/op 256049 B/op 835 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Gob________Encode-8 5000 270550 ns/op 333548 B/op 959 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__JsonIter___Encode-8 3000 478130 ns/op 183552 B/op 3262 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Bson_______Encode-8 2000 747360 ns/op 715539 B/op 5629 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__VMsgpack___Encode-8 2000 637388 ns/op 320385 B/op 542 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Sereal_____Encode-8 5000 361369 ns/op 294541 B/op 4286 allocs/op -------------------------------- -BenchmarkCodecXSuite/options-false.../Benchmark__Msgpack____Decode-8 5000 370340 ns/op 120352 B/op 1210 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Binc_______Decode-8 3000 443650 ns/op 126144 B/op 1263 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Simple_____Decode-8 3000 381155 ns/op 120352 B/op 1210 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Cbor_______Decode-8 5000 370754 ns/op 120352 B/op 1210 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Json_______Decode-8 2000 719658 ns/op 159289 B/op 1478 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Std_Json___Decode-8 1000 2204258 ns/op 276336 B/op 6959 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Gob________Decode-8 5000 383884 ns/op 256684 B/op 3261 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__JsonIter___Decode-8 2000 907079 ns/op 301520 B/op 7769 allocs/op -BenchmarkCodecXSuite/options-false.../Benchmark__Bson_______Decode-8 2000 1146851 ns/op 373121 B/op 15703 allocs/op -``` - -* snippet of bench.out.txt, running with codecgen * -``` -BenchmarkCodecXGenSuite/options-false.../Benchmark__Msgpack____Encode-8 10000 124729 ns/op 6224 B/op 7 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Binc_______Encode-8 10000 119745 ns/op 6256 B/op 7 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Simple_____Encode-8 10000 132501 ns/op 6224 B/op 7 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Cbor_______Encode-8 10000 129706 ns/op 6224 B/op 7 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Json_______Encode-8 3000 436958 ns/op 6352 B/op 7 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Std_Json___Encode-8 3000 539884 ns/op 256049 B/op 835 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Gob________Encode-8 5000 270663 ns/op 333548 B/op 959 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__JsonIter___Encode-8 3000 476215 ns/op 183552 B/op 3262 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Bson_______Encode-8 2000 741688 ns/op 715539 B/op 5629 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__VMsgpack___Encode-8 2000 649516 ns/op 320385 B/op 542 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Msgp_______Encode-8 30000 57573 ns/op 0 B/op 0 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Easyjson___Encode-8 5000 366701 ns/op 92762 B/op 14 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Ffjson_____Encode-8 3000 568665 ns/op 219803 B/op 1569 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Sereal_____Encode-8 5000 365595 ns/op 296303 B/op 4285 allocs/op -------------------------------- -BenchmarkCodecXGenSuite/options-false.../Benchmark__Msgpack____Decode-8 10000 244013 ns/op 131912 B/op 1112 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Binc_______Decode-8 5000 280478 ns/op 131944 B/op 1112 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Simple_____Decode-8 5000 247863 ns/op 131912 B/op 1112 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Cbor_______Decode-8 10000 244624 ns/op 131912 B/op 1112 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Json_______Decode-8 3000 571572 ns/op 170824 B/op 1376 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Std_Json___Decode-8 1000 2224320 ns/op 276337 B/op 6959 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Gob________Decode-8 5000 387137 ns/op 256683 B/op 3261 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__JsonIter___Decode-8 2000 913324 ns/op 301472 B/op 7769 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Bson_______Decode-8 2000 1139852 ns/op 373121 B/op 15703 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Msgp_______Decode-8 10000 124270 ns/op 112688 B/op 1058 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Easyjson___Decode-8 3000 521070 ns/op 184176 B/op 1371 allocs/op -BenchmarkCodecXGenSuite/options-false.../Benchmark__Ffjson_____Decode-8 2000 970256 ns/op 161798 B/op 1927 allocs/op -``` diff --git a/vendor/github.com/ugorji/go/codec/bench/bench.sh b/vendor/github.com/ugorji/go/codec/bench/bench.sh deleted file mode 100755 index 5d0dd4710..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/bench.sh +++ /dev/null @@ -1,232 +0,0 @@ -#!/bin/bash - -# download the code and all its dependencies -_go_get() { - go get -u \ - "github.com/ugorji/go/codec" "github.com/ugorji/go/codec"/codecgen \ - github.com/tinylib/msgp/msgp github.com/tinylib/msgp \ - github.com/pquerna/ffjson/ffjson github.com/pquerna/ffjson \ - github.com/Sereal/Sereal/Go/sereal \ - bitbucket.org/bodhisnarkva/cbor/go \ - github.com/davecgh/go-xdr/xdr2 \ - gopkg.in/mgo.v2/bson \ - gopkg.in/vmihailenco/msgpack.v2 \ - github.com/json-iterator/go \ - go.mongodb.org/mongo-driver/bson \ - github.com/mailru/easyjson/... -} - -# add generated tag to the top of each file -_prependbt() { - cat > ${2} <> ${2} - rm -f ${1} -} - -# To run the full suite of benchmarks, including executing against the external frameworks -# listed above, you MUST first run code generation for the frameworks that support it. -# -# If you want to run the benchmarks against code generated values. -# Then first generate the code generated values from values_test.go named typed. -# we cannot normally read a _test.go file, so temporarily copy it into a readable file. -_gen() { - local zsfx="_generated_test.go" - # local z=`pwd` - # z=${z%%/src/*} - # Note: ensure you run the codecgen for this codebase - cp values_test.go v.go && - echo "codecgen ..." && - codecgen -nx -rt codecgen -t 'codecgen generated' -o values_codecgen${zsfx} -d 19780 v.go && - echo "msgp ... " && - msgp -unexported -tests=false -o=m9.go -file=v.go && - _prependbt m9.go values_msgp${zsfx} && - echo "easyjson ... " && - easyjson -all -no_std_marshalers -omit_empty -output_filename e9.go v.go && - _prependbt e9.go values_easyjson${zsfx} && - echo "ffjson ... " && - ffjson -force-regenerate -reset-fields -w f9.go v.go && - _prependbt f9.go values_ffjson${zsfx} && - sed -i '' -e 's+ MarshalJSON(+ _MarshalJSON(+g' values_ffjson${zsfx} && - sed -i '' -e 's+ UnmarshalJSON(+ _UnmarshalJSON(+g' values_ffjson${zsfx} && - rm -f easyjson-bootstrap*.go ffjson-inception* && - rm -f v.go && - echo "... DONE" -} - -# run the full suite of tests -# -# Basically, its a sequence of -# go test -tags "alltests x safe codecgen generated" -bench "CodecSuite or AllSuite or XSuite" -benchmem -# - -_suite_tests() { - if [[ "${do_x}" = "1" ]]; then - printf "\n==== X Baseline ====\n" - go test "${zargs[@]}" -tags x -v - else - printf "\n==== Baseline ====\n" - go test "${zargs[@]}" -v - fi - if [[ "${do_x}" = "1" ]]; then - printf "\n==== X Generated ====\n" - go test "${zargs[@]}" -tags "x generated" -v - else - printf "\n==== Generated ====\n" - go test "${zargs[@]}" -tags "generated" -v - fi -} - -_suite_tests_strip_file_line() { - # sed -e 's/^\([^a-zA-Z0-9]\+\)[a-zA-Z0-9_]\+\.go:[0-9]\+:/\1/' - sed -e 's/[a-zA-Z0-9_]*.go:[0-9]*://g' -} - -_suite_any() { - local x="$1" - local g="$2" - local b="$3" - shift; shift; shift - local a=( "" "safe" "notfastpath" "notfastpath safe" "codecgen" "codecgen safe") - if [[ "$g" = "g" ]]; then a=( "generated" "generated safe"); fi - for i in "${a[@]}"; do - echo ">>>> bench TAGS: 'alltests $x $i' SUITE: $b" - go test "${zargs[@]}" -tags "alltests $x $i" -bench "$b" -benchmem "$@" - done -} - -# _suite() { -# local t="alltests x" -# local a=( "" "safe" "notfastpath" "notfastpath safe" "codecgen" "codecgen safe") -# for i in "${a[@]}" -# do -# echo ">>>> bench TAGS: '$t $i' SUITE: BenchmarkCodecXSuite" -# go test "${zargs[@]}" -tags "$t $i" -bench BenchmarkCodecXSuite -benchmem "$@" -# done -# } - -# _suite_gen() { -# local t="alltests x" -# local b=( "generated" "generated safe") -# for i in "${b[@]}" -# do -# echo ">>>> bench TAGS: '$t $i' SUITE: BenchmarkCodecXGenSuite" -# go test "${zargs[@]}" -tags "$t $i" -bench BenchmarkCodecXGenSuite -benchmem "$@" -# done -# } - -# _suite_json() { -# local t="alltests x" -# local a=( "" "safe" "notfastpath" "notfastpath safe" "codecgen" "codecgen safe") -# for i in "${a[@]}" -# do -# echo ">>>> bench TAGS: '$t $i' SUITE: BenchmarkCodecQuickAllJsonSuite" -# go test "${zargs[@]}" -tags "$t $i" -bench BenchmarkCodecQuickAllJsonSuite -benchmem "$@" -# done -# } - -# _suite_very_quick_json() { -# # Quickly get numbers for json, stdjson, jsoniter and json (codecgen)" -# echo ">>>> very quick json bench" -# go test "${zargs[@]}" -tags "alltests x" -bench "__(Json|Std_Json|JsonIter)__" -benchmem "$@" -# echo -# go test "${zargs[@]}" -tags "alltests codecgen" -bench "__Json____" -benchmem "$@" -# } - -_suite_very_quick_json_via_suite() { - # Quickly get numbers for json, stdjson, jsoniter and json (codecgen)" - echo ">>>> very quick json bench" - local prefix="BenchmarkCodecVeryQuickAllJsonSuite/json-all-bd1......../" - go test "${zargs[@]}" -tags "alltests x" -bench BenchmarkCodecVeryQuickAllJsonSuite -benchmem "$@" | - sed -e "s+^$prefix++" - echo "---- CODECGEN RESULTS ----" - go test "${zargs[@]}" -tags "x generated" -bench "__(Json|Easyjson)__" -benchmem "$@" -} - -_suite_very_quick_json_non_suite() { - # Quickly get numbers for json, stdjson, jsoniter and json (codecgen)" - echo ">>>> very quick json bench" - for j in "En" "De"; do - echo "---- codecgen ----" - # go test "${zargs[@]}" -tags "generated" -bench "__(Json|Easyjson)__.*${j}" -benchmem "$@" - go test "${zargs[@]}" -tags "x generated" -bench "__(Json|Easyjson)__.*${j}" -benchmem "$@" - echo "---- no codecgen ----" - # go test "${zargs[@]}" -tags "" -bench "__(Json|Std_Json|JsonIter)__.*${j}" -benchmem "$@" - go test "${zargs[@]}" -tags "x" -bench "__(Json|Std_Json|JsonIter)__.*${j}" -benchmem "$@" - echo - done -} - -_suite_very_quick_json_only_profile() { - local a="Json" - case "$1" in - Json|Cbor|Msgpack|Simple|Binc) a="${1}"; shift ;; - esac - local b="${1}" - go test "${zargs[@]}" -tags "alltests" -bench "__${a}__.*${b}" \ - -benchmem -benchtime 4s \ - -cpuprofile cpu.out -memprofile mem.out -memprofilerate 1 -} - -_suite_trim_output() { - grep -v -E "^(goos:|goarch:|pkg:|PASS|ok|=== RUN|--- PASS)" -} - -_usage() { - printf "usage: bench.sh -[dcbsgjqp] for \n" - printf "\t-d download\n" - printf "\t-c code-generate\n" - printf "\t-tx tests (show stats for each format and whether encoded == decoded); if x, do external also\n" - printf "\t-sgx run test suite for codec; if g, use generated files; if x, do external also\n" - printf "\t-jqp run test suite for [json, json-quick, json-profile]\n" -} - -_main() { - if [[ "$1" == "" || "$1" == "-h" || "$1" == "-?" ]] - then - _usage - return 1 - fi - local zargs=("-count" "1") - local args=() - local do_x="0" - local do_g="0" - while getopts "dcbsjqptxklg" flag - do - case "$flag" in - d|c|b|s|j|q|p|t|x|k|l|g) args+=( "$flag" ) ;; - *) _usage; return 1 ;; - esac - done - shift "$((OPTIND-1))" - - [[ " ${args[*]} " == *"x"* ]] && do_x="1" - [[ " ${args[*]} " == *"g"* ]] && do_g="1" - [[ " ${args[*]} " == *"k"* ]] && zargs+=("-gcflags" "all=-B") - [[ " ${args[*]} " == *"l"* ]] && zargs+=("-gcflags" "all=-l=4") - [[ " ${args[*]} " == *"d"* ]] && _go_get "$@" - [[ " ${args[*]} " == *"c"* ]] && _gen "$@" - - [[ " ${args[*]} " == *"s"* && "${do_x}" == 0 && "${do_g}" == 0 ]] && _suite_any - - BenchmarkCodecSuite "$@" | _suite_trim_output - [[ " ${args[*]} " == *"s"* && "${do_x}" == 0 && "${do_g}" == 1 ]] && _suite_any - g BenchmarkCodecSuite "$@" | _suite_trim_output - [[ " ${args[*]} " == *"s"* && "${do_x}" == 1 && "${do_g}" == 0 ]] && _suite_any x - BenchmarkCodecXSuite "$@" | _suite_trim_output - [[ " ${args[*]} " == *"s"* && "${do_x}" == 1 && "${do_g}" == 1 ]] && _suite_any x g BenchmarkCodecXGenSuite "$@" | _suite_trim_output - - [[ " ${args[*]} " == *"j"* ]] && _suite_any x - BenchmarkCodecQuickAllJsonSuite "$@" | _suite_trim_output - [[ " ${args[*]} " == *"q"* ]] && _suite_very_quick_json_non_suite "$@" | _suite_trim_output - [[ " ${args[*]} " == *"p"* ]] && _suite_very_quick_json_only_profile "$@" | _suite_trim_output - [[ " ${args[*]} " == *"t"* ]] && _suite_tests "$@" | _suite_trim_output | _suite_tests_strip_file_line - - true - # shift $((OPTIND-1)) -} - -if [ "." = `dirname $0` ] -then - _main "$@" -else - echo "bench.sh must be run from the directory it resides in" - _usage -fi diff --git a/vendor/github.com/ugorji/go/codec/bench/bench_test.go b/vendor/github.com/ugorji/go/codec/bench/bench_test.go deleted file mode 100644 index 4c4ec62a0..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/bench_test.go +++ /dev/null @@ -1,275 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// bench_test is the "helper" file for all benchmarking tests. -// -// There are also benchmarks which depend on just codec and the stdlib, -// and benchmarks which depend on external libraries. -// It is an explicit goal that you can run benchmarks without external -// dependencies (which is why the 'x' build tag was explicitly introduced). -// -// There are 2 ways of running tests: -// - generated -// - not generated -// -// Consequently, we have 4 groups: -// - codec_bench (gen, !gen) -// - stdlib_bench (!gen only) -// - x_bench (!gen only) -// - x_bench_gen (gen only) -// -// We also have 4 matching suite files. -// - z_all_bench (rename later to z_all_codec_bench???) -// - z_all_stdlib_bench -// - z_all_x_bench -// - z_all_x_bench_gen -// -// Finally, we have a single test (TestBenchInit) that -// will log information about whether each format can -// encode or not, how long to encode (unscientifically), -// and the encode size. -// -// This test MUST be run always, as it calls init() internally - -import ( - "reflect" - "runtime" - "testing" - "time" -) - -// Sample way to run: -// go test -bi -bv -bd=1 -benchmem -bench=. - -const ( - benchUnscientificRes = true - benchVerify = true - benchRecover = true - benchShowJsonOnError = true -) - -var ( - benchTs *TestStruc - approxSize int - benchCheckers []benchChecker -) - -type benchEncFn func(interface{}, []byte) ([]byte, error) -type benchDecFn func([]byte, interface{}) error -type benchIntfFn func() interface{} - -type benchChecker struct { - name string - encodefn benchEncFn - decodefn benchDecFn -} - -func init() { - testPreInitFns = append(testPreInitFns, benchPreInit) - // testPostInitFns = append(testPostInitFns, codecbenchPostInit) -} - -func benchPreInit() { - benchTs = newTestStruc(testDepth, testNumRepeatString, true, !testSkipIntf, testMapStringKeyOnly) - approxSize = approxDataSize(reflect.ValueOf(benchTs)) * 3 / 2 // multiply by 1.5 to appease msgp, and prevent alloc - // bytesLen := 1024 * 4 * (testDepth + 1) * (testDepth + 1) - // if bytesLen < approxSize { - // bytesLen = approxSize - // } -} - -func benchReinit() { - benchCheckers = nil -} - -func benchmarkDivider() { - // logTv(nil, "-------------------------------\n") - println() -} - -// func Test0(t *testing.T) { -// testOnce.Do(testInitAll) -// } - -func TestBenchInit(t *testing.T) { - testOnce.Do(testInitAll) - if !testing.Verbose() { - return - } - // t.Logf("..............................................") - t.Logf("BENCHMARK INIT: %v", time.Now()) - // t.Logf("To run full benchmark comparing encodings, use: \"go test -bench=.\"") - t.Logf("Benchmark: ") - t.Logf("\tStruct recursive Depth: %d", testDepth) - if approxSize > 0 { - t.Logf("\tApproxDeepSize Of benchmark Struct: %d bytes", approxSize) - } - if benchUnscientificRes { - t.Logf("Benchmark One-Pass Run (with Unscientific Encode/Decode times): ") - } else { - t.Logf("Benchmark One-Pass Run:") - } - for _, bc := range benchCheckers { - doBenchCheck(t, bc.name, bc.encodefn, bc.decodefn) - } - if testVerbose { - t.Logf("..............................................") - t.Logf("<<<<====>>>> depth: %v, ts: %#v\n", testDepth, benchTs) - } - runtime.GC() - time.Sleep(100 * time.Millisecond) -} - -var vBenchTs = TestStruc{} - -func fnBenchNewTs() interface{} { - vBenchTs = TestStruc{} - return &vBenchTs - // return new(TestStruc) -} - -// const benchCheckDoDeepEqual = false - -func benchRecoverPanic(t *testing.B) { - if benchRecover { - if r := recover(); r != nil { - t.Logf("(recovered) panic: %v\n", r) - } - } -} - -func benchRecoverPanicT(t *testing.T) { - if benchRecover { - if r := recover(); r != nil { - t.Logf("(recovered) panic: %v\n", r) - } - } -} - -func doBenchCheck(t *testing.T, name string, encfn benchEncFn, decfn benchDecFn) { - // if benchUnscientificRes { - // t.Logf("-------------- %s ----------------", name) - // } - defer benchRecoverPanicT(t) - runtime.GC() - tnow := time.Now() - buf, err := encfn(benchTs, nil) - if err != nil { - t.Logf("\t%10s: **** Error encoding benchTs: %v", name, err) - return - } - encDur := time.Since(tnow) - encLen := len(buf) - runtime.GC() - if !benchUnscientificRes { - t.Logf("\t%10s: len: %d bytes\n", name, encLen) - return - } - tnow = time.Now() - var ts2 TestStruc - if err = decfn(buf, &ts2); err != nil { - t.Logf("\t%10s: **** Error decoding into new TestStruc: %v", name, err) - return - } - decDur := time.Since(tnow) - // if benchCheckDoDeepEqual { - if benchVerify { - err = deepEqual(benchTs, &ts2) - if err == nil { - t.Logf("\t%10s: len: %d bytes,\t encode: %v,\t decode: %v,\tencoded == decoded", name, encLen, encDur, decDur) - } else { - t.Logf("\t%10s: len: %d bytes,\t encode: %v,\t decode: %v,\tencoded != decoded: %v", name, encLen, encDur, decDur, err) - // if benchShowJsonOnError && strings.Contains(name, "json") { - // fmt.Printf("\n\n%s\n\n", buf) - // //fmt.Printf("\n\n%#v\n\n", benchTs) - // //fmt.Printf("\n\n%#v\n\n", &ts2) - // return - // } - - // if strings.Contains(name, "json") { - // println(">>>>>") - // f1, _ := os.Create("1.out") - // f2, _ := os.Create("2.out") - // f3, _ := os.Create("3.json") - // buf3, _ := json.MarshalIndent(&ts2, "", "\t") - // spew.Config.SortKeys = true - // spew.Config.SpewKeys = true - // println("^^^^^^^^^^^^^^") - // spew.Fdump(f1, benchTs) - // println("^^^^^^^^^^^^^^") - // spew.Fdump(f2, &ts2) - // println("^^^^^^^^^^^^^^") - // f3.Write(buf3) - // f1.Close() - // f2.Close() - // f3.Close() - // } - // t.Logf("\t: err: %v,\n benchTs: %#v\n\n, ts2: %#v\n\n", err, benchTs, ts2) // TODO: remove - // t.Logf("BenchVerify: Error comparing en|decoded TestStruc: %v", err) - // return - // t.Logf("BenchVerify: Error comparing benchTs: %v\n--------\n%v\n--------\n%v", err, benchTs, ts2) - // if strings.Contains(name, "json") { - // t.Logf("\n\tDECODED FROM\n--------\n%s", buf) - // } - } - } else { - t.Logf("\t%10s: len: %d bytes,\t encode: %v,\t decode: %v", name, encLen, encDur, decDur) - } - return -} - -func fnBenchmarkEncode(b *testing.B, encName string, ts interface{}, encfn benchEncFn) { - defer benchRecoverPanic(b) - testOnce.Do(testInitAll) - var err error - bs := make([]byte, 0, approxSize) - runtime.GC() - b.ResetTimer() - for i := 0; i < b.N; i++ { - if _, err = encfn(ts, bs); err != nil { - break - } - } - if err != nil { - b.Logf("Error encoding benchTs: %s: %v", encName, err) - b.FailNow() - } -} - -func fnBenchmarkDecode(b *testing.B, encName string, ts interface{}, - encfn benchEncFn, decfn benchDecFn, newfn benchIntfFn, -) { - defer benchRecoverPanic(b) - testOnce.Do(testInitAll) - bs := make([]byte, 0, approxSize) - buf, err := encfn(ts, bs) - if err != nil { - b.Logf("Error encoding benchTs: %s: %v", encName, err) - b.FailNow() - } - // if false && benchVerify { // do not do benchVerify during decode - // // ts2 := newfn() - // ts1 := ts.(*TestStruc) - // ts2 := new(TestStruc) - // if err = decfn(buf, ts2); err != nil { - // failT(b, "BenchVerify: Error decoding benchTs: %s: %v", encName, err) - // } - // if err = deepEqual(ts1, ts2); err != nil { - // failT(b, "BenchVerify: Error comparing benchTs: %s: %v", encName, err) - // } - // } - runtime.GC() - b.ResetTimer() - for i := 0; i < b.N; i++ { - ts = newfn() - if err = decfn(buf, ts); err != nil { - break - } - } - if err != nil { - b.Logf("Error decoding into new TestStruc: %s: %v", encName, err) - b.FailNow() - } -} diff --git a/vendor/github.com/ugorji/go/codec/bench/codec_bench_test.go b/vendor/github.com/ugorji/go/codec/bench/codec_bench_test.go deleted file mode 100644 index 11bacaf8a..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/codec_bench_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "testing" -) - -func init() { - testPreInitFns = append(testPreInitFns, codecBenchPreInit) - // testPostInitFns = append(testPostInitFns, codecbenchPostInit) -} - -func codecBenchPreInit() { - benchCheckers = append(benchCheckers, - benchChecker{"msgpack", fnMsgpackEncodeFn, fnMsgpackDecodeFn}, - benchChecker{"binc", fnBincEncodeFn, fnBincDecodeFn}, - benchChecker{"simple", fnSimpleEncodeFn, fnSimpleDecodeFn}, - benchChecker{"cbor", fnCborEncodeFn, fnCborDecodeFn}, - benchChecker{"json", fnJsonEncodeFn, fnJsonDecodeFn}, - ) -} - -// ------------ tests below - -func fnMsgpackEncodeFn(ts interface{}, bsIn []byte) (bs []byte, err error) { - return sTestCodecEncode(ts, bsIn, fnBenchmarkByteBuf, testMsgpackH, &testMsgpackH.BasicHandle) -} - -func fnMsgpackDecodeFn(buf []byte, ts interface{}) error { - return sTestCodecDecode(buf, ts, testMsgpackH, &testMsgpackH.BasicHandle) -} - -func fnBincEncodeFn(ts interface{}, bsIn []byte) (bs []byte, err error) { - return sTestCodecEncode(ts, bsIn, fnBenchmarkByteBuf, testBincH, &testBincH.BasicHandle) -} - -func fnBincDecodeFn(buf []byte, ts interface{}) error { - return sTestCodecDecode(buf, ts, testBincH, &testBincH.BasicHandle) -} - -func fnSimpleEncodeFn(ts interface{}, bsIn []byte) (bs []byte, err error) { - return sTestCodecEncode(ts, bsIn, fnBenchmarkByteBuf, testSimpleH, &testSimpleH.BasicHandle) -} - -func fnSimpleDecodeFn(buf []byte, ts interface{}) error { - return sTestCodecDecode(buf, ts, testSimpleH, &testSimpleH.BasicHandle) -} - -func fnCborEncodeFn(ts interface{}, bsIn []byte) (bs []byte, err error) { - return sTestCodecEncode(ts, bsIn, fnBenchmarkByteBuf, testCborH, &testCborH.BasicHandle) -} - -func fnCborDecodeFn(buf []byte, ts interface{}) error { - return sTestCodecDecode(buf, ts, testCborH, &testCborH.BasicHandle) -} - -func fnJsonEncodeFn(ts interface{}, bsIn []byte) (bs []byte, err error) { - return sTestCodecEncode(ts, bsIn, fnBenchmarkByteBuf, testJsonH, &testJsonH.BasicHandle) -} - -func fnJsonDecodeFn(buf []byte, ts interface{}) error { - return sTestCodecDecode(buf, ts, testJsonH, &testJsonH.BasicHandle) -} - -// ----------- ENCODE ------------------ - -func Benchmark__Msgpack____Encode(b *testing.B) { - fnBenchmarkEncode(b, "msgpack", benchTs, fnMsgpackEncodeFn) -} - -func Benchmark__Binc_______Encode(b *testing.B) { - fnBenchmarkEncode(b, "binc", benchTs, fnBincEncodeFn) -} - -func Benchmark__Simple_____Encode(b *testing.B) { - fnBenchmarkEncode(b, "simple", benchTs, fnSimpleEncodeFn) -} - -func Benchmark__Cbor_______Encode(b *testing.B) { - fnBenchmarkEncode(b, "cbor", benchTs, fnCborEncodeFn) -} - -func Benchmark__Json_______Encode(b *testing.B) { - fnBenchmarkEncode(b, "json", benchTs, fnJsonEncodeFn) -} - -// ----------- DECODE ------------------ - -func Benchmark__Msgpack____Decode(b *testing.B) { - fnBenchmarkDecode(b, "msgpack", benchTs, fnMsgpackEncodeFn, fnMsgpackDecodeFn, fnBenchNewTs) -} - -func Benchmark__Binc_______Decode(b *testing.B) { - fnBenchmarkDecode(b, "binc", benchTs, fnBincEncodeFn, fnBincDecodeFn, fnBenchNewTs) -} - -func Benchmark__Simple_____Decode(b *testing.B) { - fnBenchmarkDecode(b, "simple", benchTs, fnSimpleEncodeFn, fnSimpleDecodeFn, fnBenchNewTs) -} - -func Benchmark__Cbor_______Decode(b *testing.B) { - fnBenchmarkDecode(b, "cbor", benchTs, fnCborEncodeFn, fnCborDecodeFn, fnBenchNewTs) -} - -func Benchmark__Json_______Decode(b *testing.B) { - fnBenchmarkDecode(b, "json", benchTs, fnJsonEncodeFn, fnJsonDecodeFn, fnBenchNewTs) -} diff --git a/vendor/github.com/ugorji/go/codec/bench/doc.go b/vendor/github.com/ugorji/go/codec/bench/doc.go deleted file mode 100644 index ef68af9b8..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/doc.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -/* -Package codec provides a -High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library -for binc, msgpack, cbor, json. - -Here, we have the benchmark files comparing against other encoding libraries. - -See README.md for more details. -*/ -package codec - diff --git a/vendor/github.com/ugorji/go/codec/bench/shared_test.go b/vendor/github.com/ugorji/go/codec/bench/shared_test.go deleted file mode 100644 index 4852c5f04..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/shared_test.go +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// This file sets up the variables used, including testInitFns. -// Each file should add initialization that should be performed -// after flags are parsed. -// -// init is a multi-step process: -// - setup vars (handled by init functions in each file) -// - parse flags -// - setup derived vars (handled by pre-init registered functions - registered in init function) -// - post init (handled by post-init registered functions - registered in init function) -// This way, no one has to manage carefully control the initialization -// using file names, etc. -// -// Tests which require external dependencies need the -tag=x parameter. -// They should be run as: -// go test -tags=x -run=. -// Benchmarks should also take this parameter, to include the sereal, xdr, etc. -// To run against codecgen, etc, make sure you pass extra parameters. -// Example usage: -// go test "-tags=x codecgen" -bench=. -// -// To fully test everything: -// go test -tags=x -benchtime=100ms -tv -bg -bi -brw -bu -v -run=. -bench=. - -// Handling flags -// codec_test.go will define a set of global flags for testing, including: -// - Use Reset -// - Use IO reader/writer (vs direct bytes) -// - Set Canonical -// - Set InternStrings -// - Use Symbols -// -// This way, we can test them all by running same set of tests with a different -// set of flags. -// -// Following this, all the benchmarks will utilize flags set by codec_test.go -// and will not redefine these "global" flags. - -import ( - "bytes" - "flag" - "io" - "io/ioutil" - "log" - "sync" -) - -import . "github.com/ugorji/go/codec" - -type testHED struct { - H Handle - E *Encoder - D *Decoder -} - -type ioReaderWrapper struct { - r io.Reader -} - -func (x ioReaderWrapper) Read(p []byte) (n int, err error) { - return x.r.Read(p) -} - -type ioWriterWrapper struct { - w io.Writer -} - -func (x ioWriterWrapper) Write(p []byte) (n int, err error) { - return x.w.Write(p) -} - -var ( - // testNoopH = NoopHandle(8) - testMsgpackH = &MsgpackHandle{} - testBincH = &BincHandle{} - testSimpleH = &SimpleHandle{} - testCborH = &CborHandle{} - testJsonH = &JsonHandle{} - - testHandles []Handle - testPreInitFns []func() - testPostInitFns []func() - - testOnce sync.Once - - testHEDs []testHED -) - -// flag variables used by tests (and bench) -var ( - testVerbose bool - - //depth of 0 maps to ~400bytes json-encoded string, 1 maps to ~1400 bytes, etc - //For depth>1, we likely trigger stack growth for encoders, making benchmarking unreliable. - testDepth int - - testMaxInitLen int - - testInitDebug bool - testUseReset bool - testSkipIntf bool - testUseMust bool - - testUseIoEncDec int - testUseIoWrapper bool - - testNumRepeatString int - - testRpcBufsize int - testMapStringKeyOnly bool -) - -// variables that are not flags, but which can configure the handles -var ( - testEncodeOptions EncodeOptions - testDecodeOptions DecodeOptions -) - -func init() { - log.SetOutput(ioutil.Discard) // don't allow things log to standard out/err - testHEDs = make([]testHED, 0, 32) - testHandles = append(testHandles, - // testNoopH, - testMsgpackH, testBincH, testSimpleH, testCborH, testJsonH) - // JSON should do HTMLCharsAsIs by default - testJsonH.HTMLCharsAsIs = true - // set ExplicitRelease on each handle - testMsgpackH.ExplicitRelease = true - testBincH.ExplicitRelease = true - testSimpleH.ExplicitRelease = true - testCborH.ExplicitRelease = true - testJsonH.ExplicitRelease = true - - testInitFlags() - benchInitFlags() -} - -func testInitFlags() { - // delete(testDecOpts.ExtFuncs, timeTyp) - flag.BoolVar(&testVerbose, "tv", false, "Text Extra Verbose Logging if -v if set") - flag.BoolVar(&testInitDebug, "tg", false, "Test Init Debug") - flag.IntVar(&testUseIoEncDec, "ti", -1, "Use IO Reader/Writer for Marshal/Unmarshal ie >= 0") - flag.BoolVar(&testUseIoWrapper, "tiw", false, "Wrap the IO Reader/Writer with a base pass-through reader/writer") - - flag.BoolVar(&testSkipIntf, "tf", false, "Skip Interfaces") - flag.BoolVar(&testUseReset, "tr", false, "Use Reset") - flag.IntVar(&testNumRepeatString, "trs", 8, "Create string variables by repeating a string N times") - flag.BoolVar(&testUseMust, "tm", true, "Use Must(En|De)code") - - flag.IntVar(&testMaxInitLen, "tx", 0, "Max Init Len") - - flag.IntVar(&testDepth, "tsd", 0, "Test Struc Depth") - flag.BoolVar(&testMapStringKeyOnly, "tsk", false, "use maps with string keys only") -} - -func benchInitFlags() { - // flags reproduced here for compatibility (duplicate some in testInitFlags) - flag.BoolVar(&testMapStringKeyOnly, "bs", false, "use maps with string keys only") - flag.IntVar(&testDepth, "bd", 1, "Bench Depth") -} - -func testHEDGet(h Handle) *testHED { - for i := range testHEDs { - v := &testHEDs[i] - if v.H == h { - return v - } - } - testHEDs = append(testHEDs, testHED{h, NewEncoder(nil, h), NewDecoder(nil, h)}) - return &testHEDs[len(testHEDs)-1] -} - -func testReinit() { - testOnce = sync.Once{} - testHEDs = nil -} - -func testInitAll() { - // only parse it once. - if !flag.Parsed() { - flag.Parse() - } - for _, f := range testPreInitFns { - f() - } - for _, f := range testPostInitFns { - f() - } -} - -func sTestCodecEncode(ts interface{}, bsIn []byte, fn func([]byte) *bytes.Buffer, - h Handle, bh *BasicHandle) (bs []byte, err error) { - // bs = make([]byte, 0, approxSize) - var e *Encoder - var buf *bytes.Buffer - if testUseReset { - e = testHEDGet(h).E - } else { - e = NewEncoder(nil, h) - } - var oldWriteBufferSize int - if testUseIoEncDec >= 0 { - buf = fn(bsIn) - // set the encode options for using a buffer - oldWriteBufferSize = bh.WriterBufferSize - bh.WriterBufferSize = testUseIoEncDec - if testUseIoWrapper { - e.Reset(ioWriterWrapper{buf}) - } else { - e.Reset(buf) - } - } else { - bs = bsIn - e.ResetBytes(&bs) - } - if testUseMust { - e.MustEncode(ts) - } else { - err = e.Encode(ts) - } - if testUseIoEncDec >= 0 { - bs = buf.Bytes() - bh.WriterBufferSize = oldWriteBufferSize - } - if !testUseReset { - e.Release() - } - return -} - -func sTestCodecDecode(bs []byte, ts interface{}, h Handle, bh *BasicHandle) (err error) { - var d *Decoder - // var buf *bytes.Reader - if testUseReset { - d = testHEDGet(h).D - } else { - d = NewDecoder(nil, h) - } - var oldReadBufferSize int - if testUseIoEncDec >= 0 { - buf := bytes.NewReader(bs) - oldReadBufferSize = bh.ReaderBufferSize - bh.ReaderBufferSize = testUseIoEncDec - if testUseIoWrapper { - d.Reset(ioReaderWrapper{buf}) - } else { - d.Reset(buf) - } - } else { - d.ResetBytes(bs) - } - if testUseMust { - d.MustDecode(ts) - } else { - err = d.Decode(ts) - } - if testUseIoEncDec >= 0 { - bh.ReaderBufferSize = oldReadBufferSize - } - if !testUseReset { - d.Release() - } - return -} - -// // --- functions below are used by both benchmarks and tests - -// // log message only when testVerbose = true (ie go test ... -- -tv). -// // -// // These are for intormational messages that do not necessarily -// // help with diagnosing a failure, or which are too large. -// func logTv(x interface{}, format string, args ...interface{}) { -// if !testVerbose { -// return -// } -// if t, ok := x.(testing.TB); ok { // only available from go 1.9 -// t.Helper() -// } -// logT(x, format, args...) -// } - -// // logT logs messages when running as go test -v -// // -// // Use it for diagnostics messages that help diagnost failure, -// // and when the output is not too long ie shorter than like 100 characters. -// // -// // In general, any logT followed by failT should call this. -// func logT(x interface{}, format string, args ...interface{}) { -// if x == nil { -// if len(format) == 0 || format[len(format)-1] != '\n' { -// format = format + "\n" -// } -// fmt.Printf(format, args...) -// return -// } -// if t, ok := x.(testing.TB); ok { // only available from go 1.9 -// t.Helper() -// t.Logf(format, args...) -// } -// } - -// func failTv(x testing.TB, args ...interface{}) { -// x.Helper() -// if testVerbose { -// failTMsg(x, args...) -// } -// x.FailNow() -// } - -// func failT(x testing.TB, args ...interface{}) { -// x.Helper() -// failTMsg(x, args...) -// x.FailNow() -// } - -// func failTMsg(x testing.TB, args ...interface{}) { -// x.Helper() -// if len(args) > 0 { -// if format, ok := args[0].(string); ok { -// logT(x, format, args[1:]...) -// } else if len(args) == 1 { -// logT(x, "%v", args[0]) -// } else { -// logT(x, "%v", args) -// } -// } -// } - -// --- functions below are used only by benchmarks alone - -func fnBenchmarkByteBuf(bsIn []byte) (buf *bytes.Buffer) { - // var buf bytes.Buffer - // buf.Grow(approxSize) - buf = bytes.NewBuffer(bsIn) - buf.Truncate(0) - return -} - -// func benchFnCodecEncode(ts interface{}, bsIn []byte, h Handle) (bs []byte, err error) { -// return testCodecEncode(ts, bsIn, fnBenchmarkByteBuf, h) -// } - -// func benchFnCodecDecode(bs []byte, ts interface{}, h Handle) (err error) { -// return testCodecDecode(bs, ts, h) -// } diff --git a/vendor/github.com/ugorji/go/codec/bench/stdlib_bench_test.go b/vendor/github.com/ugorji/go/codec/bench/stdlib_bench_test.go deleted file mode 100644 index c4660b687..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/stdlib_bench_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// +build !generated - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bytes" - "encoding/gob" - "encoding/json" - "encoding/xml" - "testing" -) - -func init() { - testPreInitFns = append(testPreInitFns, stdlibBenchPreInit) - // testPostInitFns = append(testPostInitFns, codecbenchPostInit) -} - -func stdlibBenchPreInit() { - benchCheckers = append(benchCheckers, - benchChecker{"std-json", fnStdJsonEncodeFn, fnStdJsonDecodeFn}, - benchChecker{"gob", fnGobEncodeFn, fnGobDecodeFn}, - benchChecker{"std-xml", fnStdXmlEncodeFn, fnStdXmlDecodeFn}, - ) -} - -// ------------ tests below - -func fnGobEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - buf := fnBenchmarkByteBuf(bsIn) - err := gob.NewEncoder(buf).Encode(ts) - return buf.Bytes(), err -} - -func fnGobDecodeFn(buf []byte, ts interface{}) error { - return gob.NewDecoder(bytes.NewReader(buf)).Decode(ts) -} - -func fnStdXmlEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - buf := fnBenchmarkByteBuf(bsIn) - err := xml.NewEncoder(buf).Encode(ts) - return buf.Bytes(), err -} - -func fnStdXmlDecodeFn(buf []byte, ts interface{}) error { - return xml.NewDecoder(bytes.NewReader(buf)).Decode(ts) -} - -func fnStdJsonEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - if testUseIoEncDec >= 0 { - buf := fnBenchmarkByteBuf(bsIn) - err := json.NewEncoder(buf).Encode(ts) - return buf.Bytes(), err - } - return json.Marshal(ts) -} - -func fnStdJsonDecodeFn(buf []byte, ts interface{}) error { - if testUseIoEncDec >= 0 { - return json.NewDecoder(bytes.NewReader(buf)).Decode(ts) - } - return json.Unmarshal(buf, ts) -} - -// ----------- ENCODE ------------------ - -func Benchmark__Std_Json___Encode(b *testing.B) { - fnBenchmarkEncode(b, "std-json", benchTs, fnStdJsonEncodeFn) -} - -func Benchmark__Gob________Encode(b *testing.B) { - fnBenchmarkEncode(b, "gob", benchTs, fnGobEncodeFn) -} - -func Benchmark__Std_Xml____Encode(b *testing.B) { - fnBenchmarkEncode(b, "std-xml", benchTs, fnStdXmlEncodeFn) -} - -// ----------- DECODE ------------------ - -func Benchmark__Std_Json___Decode(b *testing.B) { - fnBenchmarkDecode(b, "std-json", benchTs, fnStdJsonEncodeFn, fnStdJsonDecodeFn, fnBenchNewTs) -} - -func Benchmark__Gob________Decode(b *testing.B) { - fnBenchmarkDecode(b, "gob", benchTs, fnGobEncodeFn, fnGobDecodeFn, fnBenchNewTs) -} - -func Benchmark__Std_Xml____Decode(b *testing.B) { - fnBenchmarkDecode(b, "std-xml", benchTs, fnStdXmlEncodeFn, fnStdXmlDecodeFn, fnBenchNewTs) -} diff --git a/vendor/github.com/ugorji/go/codec/bench/values_test.go b/vendor/github.com/ugorji/go/codec/bench/values_test.go deleted file mode 120000 index ca206becb..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/values_test.go +++ /dev/null @@ -1 +0,0 @@ -../values_test.go \ No newline at end of file diff --git a/vendor/github.com/ugorji/go/codec/bench/x_bench_gen_test.go b/vendor/github.com/ugorji/go/codec/bench/x_bench_gen_test.go deleted file mode 100644 index f77089a3e..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/x_bench_gen_test.go +++ /dev/null @@ -1,125 +0,0 @@ -// +build x -// +build generated - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bytes" - "errors" - "fmt" - "testing" - - "github.com/mailru/easyjson" - "github.com/pquerna/ffjson/ffjson" - "github.com/tinylib/msgp/msgp" -) - -/* - To update all these, use: - go get -u github.com/tinylib/msgp/msgp github.com/tinylib/msgp \ - github.com/pquerna/ffjson/ffjson github.com/pquerna/ffjson \ - github.com/mailru/easyjson/... - - Known Issues with external libraries: - - msgp io.R/W support doesn't work. It throws error - -*/ - -func init() { - testPreInitFns = append(testPreInitFns, benchXGenPreInit) -} - -func benchXGenPreInit() { - benchCheckers = append(benchCheckers, - benchChecker{"msgp", fnMsgpEncodeFn, fnMsgpDecodeFn}, - benchChecker{"easyjson", fnEasyjsonEncodeFn, fnEasyjsonDecodeFn}, - benchChecker{"ffjson", fnFfjsonEncodeFn, fnFfjsonDecodeFn}, - ) -} - -func fnEasyjsonEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - ts2, ok := ts.(easyjson.Marshaler) - if !ok || ts2 == nil { - return nil, errors.New("easyjson: input is not a easyjson.Marshaler") - } - if testUseIoEncDec >= 0 { - buf := bytes.NewBuffer(bsIn[:0]) // new(bytes.Buffer) - _, err := easyjson.MarshalToWriter(ts2, buf) - return buf.Bytes(), err - } - return easyjson.Marshal(ts2) - // return ts.(json.Marshaler).MarshalJSON() -} - -func fnEasyjsonDecodeFn(buf []byte, ts interface{}) error { - ts2, ok := ts.(easyjson.Unmarshaler) - if !ok { - return errors.New("easyjson: input is not a easyjson.Unmarshaler") - } - if testUseIoEncDec >= 0 { - return easyjson.UnmarshalFromReader(bytes.NewReader(buf), ts2) - } - return easyjson.Unmarshal(buf, ts2) - // return ts.(json.Unmarshaler).UnmarshalJSON(buf) -} - -func fnFfjsonEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - return ffjson.Marshal(ts) - // return ts.(json.Marshaler).MarshalJSON() -} - -func fnFfjsonDecodeFn(buf []byte, ts interface{}) error { - return ffjson.Unmarshal(buf, ts) - // return ts.(json.Unmarshaler).UnmarshalJSON(buf) -} - -func fnMsgpEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - if _, ok := ts.(msgp.Encodable); !ok { - return nil, fmt.Errorf("msgp: input of type %T is not a msgp.Encodable", ts) - } - if testUseIoEncDec >= 0 { - buf := fnBenchmarkByteBuf(bsIn) - err := ts.(msgp.Encodable).EncodeMsg(msgp.NewWriter(buf)) - return buf.Bytes(), err - } - return ts.(msgp.Marshaler).MarshalMsg(bsIn[:0]) // msgp appends to slice. -} - -func fnMsgpDecodeFn(buf []byte, ts interface{}) (err error) { - if _, ok := ts.(msgp.Decodable); !ok { - return fmt.Errorf("msgp: input of type %T is not a msgp.Decodable", ts) - } - if testUseIoEncDec >= 0 { - err = ts.(msgp.Decodable).DecodeMsg(msgp.NewReader(bytes.NewReader(buf))) - return - } - _, err = ts.(msgp.Unmarshaler).UnmarshalMsg(buf) - return -} - -func Benchmark__Msgp_______Encode(b *testing.B) { - fnBenchmarkEncode(b, "msgp", benchTs, fnMsgpEncodeFn) -} - -func Benchmark__Msgp_______Decode(b *testing.B) { - fnBenchmarkDecode(b, "msgp", benchTs, fnMsgpEncodeFn, fnMsgpDecodeFn, fnBenchNewTs) -} - -func Benchmark__Easyjson___Encode(b *testing.B) { - fnBenchmarkEncode(b, "easyjson", benchTs, fnEasyjsonEncodeFn) -} - -func Benchmark__Easyjson___Decode(b *testing.B) { - fnBenchmarkDecode(b, "easyjson", benchTs, fnEasyjsonEncodeFn, fnEasyjsonDecodeFn, fnBenchNewTs) -} - -func Benchmark__Ffjson_____Encode(b *testing.B) { - fnBenchmarkEncode(b, "ffjson", benchTs, fnFfjsonEncodeFn) -} - -func Benchmark__Ffjson_____Decode(b *testing.B) { - fnBenchmarkDecode(b, "ffjson", benchTs, fnFfjsonEncodeFn, fnFfjsonDecodeFn, fnBenchNewTs) -} diff --git a/vendor/github.com/ugorji/go/codec/bench/x_bench_test.go b/vendor/github.com/ugorji/go/codec/bench/x_bench_test.go deleted file mode 100644 index de2261520..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/x_bench_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// +build x -// +build !generated - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bytes" - "testing" - - gcbor "bitbucket.org/bodhisnarkva/cbor/go" // gcbor "code.google.com/p/cbor/go" - "github.com/Sereal/Sereal/Go/sereal" - xdr "github.com/davecgh/go-xdr/xdr2" - jsoniter "github.com/json-iterator/go" - "go.mongodb.org/mongo-driver/bson" // "github.com/mongodb/mongo-go-driver/bson" - mgobson "gopkg.in/mgo.v2/bson" //"labix.org/v2/mgo/bson" - vmsgpack "gopkg.in/vmihailenco/msgpack.v2" //"github.com/vmihailenco/msgpack" -) - -/* - To update all these, use: - go get -u github.com/tinylib/msgp/msgp github.com/tinylib/msgp \ - github.com/pquerna/ffjson/ffjson github.com/pquerna/ffjson \ - github.com/Sereal/Sereal/Go/sereal \ - bitbucket.org/bodhisnarkva/cbor/go \ - github.com/davecgh/go-xdr/xdr2 \ - gopkg.in/mgo.v2/bson \ - gopkg.in/vmihailenco/msgpack.v2 \ - github.com/json-iterator/go \ - github.com/mailru/easyjson/... - - Known Issues with external libraries: - - msgp io.R/W support doesn't work. It throws error - -*/ - -func init() { - testPreInitFns = append(testPreInitFns, benchXPreInit) - _ = bson.NewDecoder -} - -func benchXPreInit() { - benchCheckers = append(benchCheckers, - benchChecker{"json-iter", fnJsonIterEncodeFn, fnJsonIterDecodeFn}, - benchChecker{"v-msgpack", fnVMsgpackEncodeFn, fnVMsgpackDecodeFn}, - benchChecker{"bson", fnBsonEncodeFn, fnBsonDecodeFn}, - benchChecker{"mgobson", fnMgobsonEncodeFn, fnMgobsonDecodeFn}, - // place codecs with issues at the end, so as not to make results too ugly - benchChecker{"gcbor", fnGcborEncodeFn, fnGcborDecodeFn}, // this logs fat ugly message, but we log.SetOutput(ioutil.Discard) - benchChecker{"xdr", fnXdrEncodeFn, fnXdrDecodeFn}, - benchChecker{"sereal", fnSerealEncodeFn, fnSerealDecodeFn}, - ) -} - -func fnVMsgpackEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - if testUseIoEncDec >= 0 { - buf := bytes.NewBuffer(bsIn[:0]) // new(bytes.Buffer) - err := vmsgpack.NewEncoder(buf).Encode(ts) - return buf.Bytes(), err - } - return vmsgpack.Marshal(ts) -} - -func fnVMsgpackDecodeFn(buf []byte, ts interface{}) error { - if testUseIoEncDec >= 0 { - return vmsgpack.NewDecoder(bytes.NewReader(buf)).Decode(ts) - } - return vmsgpack.Unmarshal(buf, ts) -} - -func fnBsonEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - return bson.Marshal(ts) -} - -func fnBsonDecodeFn(buf []byte, ts interface{}) error { - return bson.Unmarshal(buf, ts) -} - -func fnMgobsonEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - return mgobson.Marshal(ts) -} - -func fnMgobsonDecodeFn(buf []byte, ts interface{}) error { - return mgobson.Unmarshal(buf, ts) -} - -func fnJsonIterEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - if testUseIoEncDec >= 0 { - buf := bytes.NewBuffer(bsIn[:0]) // new(bytes.Buffer) - err := jsoniter.NewEncoder(buf).Encode(ts) - return buf.Bytes(), err - } - return jsoniter.Marshal(ts) -} - -func fnJsonIterDecodeFn(buf []byte, ts interface{}) error { - if testUseIoEncDec >= 0 { - return jsoniter.NewDecoder(bytes.NewReader(buf)).Decode(ts) - } - return jsoniter.Unmarshal(buf, ts) -} - -func fnXdrEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - buf := fnBenchmarkByteBuf(bsIn) - i, err := xdr.Marshal(buf, ts) - return buf.Bytes()[:i], err -} - -func fnXdrDecodeFn(buf []byte, ts interface{}) error { - _, err := xdr.Unmarshal(bytes.NewReader(buf), ts) - return err -} - -func fnSerealEncodeFn(ts interface{}, bsIn []byte) ([]byte, error) { - return sereal.Marshal(ts) -} - -func fnSerealDecodeFn(buf []byte, ts interface{}) error { - return sereal.Unmarshal(buf, ts) -} - -func fnGcborEncodeFn(ts interface{}, bsIn []byte) (bs []byte, err error) { - buf := fnBenchmarkByteBuf(bsIn) - err = gcbor.NewEncoder(buf).Encode(ts) - return buf.Bytes(), err -} - -func fnGcborDecodeFn(buf []byte, ts interface{}) error { - return gcbor.NewDecoder(bytes.NewReader(buf)).Decode(ts) -} - -func Benchmark__JsonIter___Encode(b *testing.B) { - fnBenchmarkEncode(b, "jsoniter", benchTs, fnJsonIterEncodeFn) -} - -func Benchmark__JsonIter___Decode(b *testing.B) { - fnBenchmarkDecode(b, "jsoniter", benchTs, fnJsonIterEncodeFn, fnJsonIterDecodeFn, fnBenchNewTs) -} - -// Place codecs with issues at the bottom, so as not to make results look too ugly. - -func Benchmark__Mgobson____Encode(b *testing.B) { - fnBenchmarkEncode(b, "mgobson", benchTs, fnMgobsonEncodeFn) -} - -func Benchmark__Mgobson____Decode(b *testing.B) { - fnBenchmarkDecode(b, "mgobson", benchTs, fnMgobsonEncodeFn, fnMgobsonDecodeFn, fnBenchNewTs) -} - -func Benchmark__Bson_______Encode(b *testing.B) { - fnBenchmarkEncode(b, "bson", benchTs, fnBsonEncodeFn) -} - -func Benchmark__Bson_______Decode(b *testing.B) { - fnBenchmarkDecode(b, "bson", benchTs, fnBsonEncodeFn, fnBsonDecodeFn, fnBenchNewTs) -} - -func Benchmark__VMsgpack___Encode(b *testing.B) { - fnBenchmarkEncode(b, "v-msgpack", benchTs, fnVMsgpackEncodeFn) -} - -func Benchmark__VMsgpack___Decode(b *testing.B) { - fnBenchmarkDecode(b, "v-msgpack", benchTs, fnVMsgpackEncodeFn, fnVMsgpackDecodeFn, fnBenchNewTs) -} - -func Benchmark__Gcbor______Encode(b *testing.B) { - fnBenchmarkEncode(b, "gcbor", benchTs, fnGcborEncodeFn) -} - -func Benchmark__Gcbor______Decode(b *testing.B) { - fnBenchmarkDecode(b, "gcbor", benchTs, fnGcborEncodeFn, fnGcborDecodeFn, fnBenchNewTs) -} - -func Benchmark__Xdr________Encode(b *testing.B) { - fnBenchmarkEncode(b, "xdr", benchTs, fnXdrEncodeFn) -} - -func Benchmark__Xdr________Decode(b *testing.B) { - fnBenchmarkDecode(b, "xdr", benchTs, fnXdrEncodeFn, fnXdrDecodeFn, fnBenchNewTs) -} - -func Benchmark__Sereal_____Encode(b *testing.B) { - fnBenchmarkEncode(b, "sereal", benchTs, fnSerealEncodeFn) -} - -func Benchmark__Sereal_____Decode(b *testing.B) { - fnBenchmarkDecode(b, "sereal", benchTs, fnSerealEncodeFn, fnSerealDecodeFn, fnBenchNewTs) -} diff --git a/vendor/github.com/ugorji/go/codec/bench/z_all_bench_test.go b/vendor/github.com/ugorji/go/codec/bench/z_all_bench_test.go deleted file mode 100644 index 3b8a22e92..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/z_all_bench_test.go +++ /dev/null @@ -1,207 +0,0 @@ -// +build alltests -// +build go1.7 - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// see notes in z_all_test.go - -import ( - "strconv" - "sync" - "testing" - "time" -) - -import . "github.com/ugorji/go/codec" - -var benchmarkGroupOnce sync.Once - -var benchmarkGroupSave struct { - testUseIoEncDec int - testUseReset bool - - testDepth int - testMapStringKeyOnly bool -} - -func benchmarkGroupInitAll() { - testInitAll() // calls flag.Parse - benchmarkGroupSave.testUseIoEncDec = testUseIoEncDec - benchmarkGroupSave.testUseReset = testUseReset - - benchmarkGroupSave.testDepth = testDepth - benchmarkGroupSave.testMapStringKeyOnly = testMapStringKeyOnly -} - -func benchmarkGroupReset() { - testUseIoEncDec = benchmarkGroupSave.testUseIoEncDec - testUseReset = benchmarkGroupSave.testUseReset - - testDepth = benchmarkGroupSave.testDepth - testMapStringKeyOnly = benchmarkGroupSave.testMapStringKeyOnly - - testDecodeOptions.ZeroCopy = true -} - -func benchmarkOneFn(fns []func(*testing.B)) func(*testing.B) { - switch len(fns) { - case 0: - return nil - case 1: - return fns[0] - default: - return func(t *testing.B) { - for _, f := range fns { - f(t) - } - } - } -} - -func benchmarkSuiteNoop(b *testing.B) { - testOnce.Do(testInitAll) - b.ResetTimer() - for i := 0; i < b.N; i++ { - time.Sleep(10 * time.Millisecond) - } -} - -func benchmarkSuite(t *testing.B, fns ...func(t *testing.B)) { - benchmarkGroupOnce.Do(benchmarkGroupInitAll) - - f := benchmarkOneFn(fns) - // find . -name "*_test.go" | xargs grep -e 'flag.' | cut -d '&' -f 2 | cut -d ',' -f 1 | grep -e '^bench' - - testReinit() // so flag.Parse() is called first, and never called again - benchReinit() - - testDecodeOptions = DecodeOptions{} - testEncodeOptions = EncodeOptions{} - - benchmarkGroupReset() - - testReinit() - benchReinit() - t.Run("options-false...", f) - - benchmarkGroupReset() - - testUseIoEncDec = 1024 - testReinit() - benchReinit() - t.Run("use-bufio-!bytes", f) - - benchmarkGroupReset() - - testUseReset = true - testReinit() - benchReinit() - t.Run("reset-enc-dec...", f) - - benchmarkGroupReset() -} - -func benchmarkVeryQuickSuite(t *testing.B, name string, fns ...func(t *testing.B)) { - benchmarkDivider() - benchmarkGroupOnce.Do(benchmarkGroupInitAll) - benchmarkGroupReset() - - // bd=1 2 | ti=-1, 1024 | - - testUseIoEncDec = -1 - // testDepth = depth - testReinit() - benchReinit() - - t.Run(name+"-bd"+strconv.Itoa(testDepth)+"........", benchmarkOneFn(fns)) - benchmarkGroupReset() -} - -func benchmarkQuickSuite(t *testing.B, name string, fns ...func(t *testing.B)) { - benchmarkVeryQuickSuite(t, name, fns...) - - // encoded size of TestStruc is between 20K and 30K for bd=1 // consider buffer=1024 * 16 * testDepth - testUseIoEncDec = 1024 // (value of defEncByteBufSize): use smaller buffer, and more flushes - it's ok. - // testDepth = depth - testReinit() - benchReinit() - t.Run(name+"-bd"+strconv.Itoa(testDepth)+"-buf"+strconv.Itoa(testUseIoEncDec), benchmarkOneFn(fns)) - - testUseIoEncDec = 0 - // testDepth = depth - testReinit() - benchReinit() - t.Run(name+"-bd"+strconv.Itoa(testDepth)+"-io.....", benchmarkOneFn(fns)) - - benchmarkGroupReset() -} - -/* -z='bench_test.go' -find . -name "$z" | xargs grep -e '^func Benchmark.*Encode' | \ - cut -d '(' -f 1 | cut -d ' ' -f 2 | \ - while read f; do echo "t.Run(\"$f\", $f)"; done && -echo && -find . -name "$z" | xargs grep -e '^func Benchmark.*Decode' | \ - cut -d '(' -f 1 | cut -d ' ' -f 2 | \ - while read f; do echo "t.Run(\"$f\", $f)"; done -*/ - -func benchmarkCodecGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__Msgpack____Encode", Benchmark__Msgpack____Encode) - t.Run("Benchmark__Binc_______Encode", Benchmark__Binc_______Encode) - t.Run("Benchmark__Simple_____Encode", Benchmark__Simple_____Encode) - t.Run("Benchmark__Cbor_______Encode", Benchmark__Cbor_______Encode) - t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode) - benchmarkDivider() - t.Run("Benchmark__Msgpack____Decode", Benchmark__Msgpack____Decode) - t.Run("Benchmark__Binc_______Decode", Benchmark__Binc_______Decode) - t.Run("Benchmark__Simple_____Decode", Benchmark__Simple_____Decode) - t.Run("Benchmark__Cbor_______Decode", Benchmark__Cbor_______Decode) - t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode) -} - -func BenchmarkCodecSuite(t *testing.B) { benchmarkSuite(t, benchmarkCodecGroup) } - -func benchmarkJsonEncodeGroup(t *testing.B) { - t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode) -} - -func benchmarkJsonDecodeGroup(t *testing.B) { - t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode) -} - -func benchmarkCborEncodeGroup(t *testing.B) { - t.Run("Benchmark__Cbor_______Encode", Benchmark__Cbor_______Encode) -} - -func benchmarkCborDecodeGroup(t *testing.B) { - t.Run("Benchmark__Cbor_______Decode", Benchmark__Cbor_______Decode) -} - -func BenchmarkCodecQuickSuite(t *testing.B) { - benchmarkQuickSuite(t, "cbor", benchmarkCborEncodeGroup) - benchmarkQuickSuite(t, "cbor", benchmarkCborDecodeGroup) - benchmarkQuickSuite(t, "json", benchmarkJsonEncodeGroup) - benchmarkQuickSuite(t, "json", benchmarkJsonDecodeGroup) - - // depths := [...]int{1, 4} - // for _, d := range depths { - // benchmarkQuickSuite(t, d, benchmarkJsonEncodeGroup) - // benchmarkQuickSuite(t, d, benchmarkJsonDecodeGroup) - // } - - // benchmarkQuickSuite(t, 1, benchmarkJsonEncodeGroup) - // benchmarkQuickSuite(t, 4, benchmarkJsonEncodeGroup) - // benchmarkQuickSuite(t, 1, benchmarkJsonDecodeGroup) - // benchmarkQuickSuite(t, 4, benchmarkJsonDecodeGroup) - - // benchmarkQuickSuite(t, 1, benchmarkJsonEncodeGroup, benchmarkJsonDecodeGroup) - // benchmarkQuickSuite(t, 4, benchmarkJsonEncodeGroup, benchmarkJsonDecodeGroup) - // benchmarkQuickSuite(t, benchmarkJsonEncodeGroup) - // benchmarkQuickSuite(t, benchmarkJsonDecodeGroup) -} diff --git a/vendor/github.com/ugorji/go/codec/bench/z_all_stdlib_bench_test.go b/vendor/github.com/ugorji/go/codec/bench/z_all_stdlib_bench_test.go deleted file mode 100644 index 7f218ab1e..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/z_all_stdlib_bench_test.go +++ /dev/null @@ -1,23 +0,0 @@ -// +build alltests -// +build go1.7 -// +build !generated - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import "testing" - -func benchmarkStdlibGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode) - t.Run("Benchmark__Gob________Encode", Benchmark__Gob________Encode) - // t.Run("Benchmark__Std_Xml____Encode", Benchmark__Std_Xml____Encode) - benchmarkDivider() - t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode) - t.Run("Benchmark__Gob________Decode", Benchmark__Gob________Decode) - // t.Run("Benchmark__Std_Xml____Decode", Benchmark__Std_Xml____Decode) -} - -func BenchmarkStdlibSuite(t *testing.B) { benchmarkSuite(t, benchmarkStdlibGroup) } diff --git a/vendor/github.com/ugorji/go/codec/bench/z_all_x_bench_gen_test.go b/vendor/github.com/ugorji/go/codec/bench/z_all_x_bench_gen_test.go deleted file mode 100644 index eeb6981c2..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/z_all_x_bench_gen_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// +build alltests -// +build go1.7 -// +build x -// +build generated - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// see notes in z_all_bench_test.go - -import "testing" - -func benchmarkCodecXGenGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__Msgpack____Encode", Benchmark__Msgpack____Encode) - t.Run("Benchmark__Binc_______Encode", Benchmark__Binc_______Encode) - t.Run("Benchmark__Simple_____Encode", Benchmark__Simple_____Encode) - t.Run("Benchmark__Cbor_______Encode", Benchmark__Cbor_______Encode) - t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode) - t.Run("Benchmark__Msgp_______Encode", Benchmark__Msgp_______Encode) - t.Run("Benchmark__Easyjson___Encode", Benchmark__Easyjson___Encode) - t.Run("Benchmark__Ffjson_____Encode", Benchmark__Ffjson_____Encode) - - benchmarkDivider() - t.Run("Benchmark__Msgpack____Decode", Benchmark__Msgpack____Decode) - t.Run("Benchmark__Binc_______Decode", Benchmark__Binc_______Decode) - t.Run("Benchmark__Simple_____Decode", Benchmark__Simple_____Decode) - t.Run("Benchmark__Cbor_______Decode", Benchmark__Cbor_______Decode) - t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode) - t.Run("Benchmark__Msgp_______Decode", Benchmark__Msgp_______Decode) - t.Run("Benchmark__Easyjson___Decode", Benchmark__Easyjson___Decode) - t.Run("Benchmark__Ffjson_____Decode", Benchmark__Ffjson_____Decode) -} - -func BenchmarkCodecXGenSuite(t *testing.B) { benchmarkSuite(t, benchmarkCodecXGenGroup) } diff --git a/vendor/github.com/ugorji/go/codec/bench/z_all_x_bench_test.go b/vendor/github.com/ugorji/go/codec/bench/z_all_x_bench_test.go deleted file mode 100644 index 9b27e6292..000000000 --- a/vendor/github.com/ugorji/go/codec/bench/z_all_x_bench_test.go +++ /dev/null @@ -1,128 +0,0 @@ -// +build alltests -// +build go1.7 -// +build x -// +build !generated - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// see notes in z_all_bench_test.go - -import "testing" - -// Note: The following cannot parse TestStruc effectively, -// even with changes to remove arrays and minimize integer size to fit into int64 space. -// -// So we exclude them, listed below: -// encode: gcbor, xdr -// decode: gcbor, vmsgpack, xdr, sereal - -func benchmarkXGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode) - t.Run("Benchmark__Bson_______Encode", Benchmark__Bson_______Encode) - t.Run("Benchmark__Mgobson____Encode", Benchmark__Mgobson____Encode) - t.Run("Benchmark__VMsgpack___Encode", Benchmark__VMsgpack___Encode) - // t.Run("Benchmark__Gcbor______Encode", Benchmark__Gcbor______Encode) - // t.Run("Benchmark__Xdr________Encode", Benchmark__Xdr________Encode) - t.Run("Benchmark__Sereal_____Encode", Benchmark__Sereal_____Encode) - - benchmarkDivider() - t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode) - t.Run("Benchmark__Bson_______Decode", Benchmark__Bson_______Decode) - t.Run("Benchmark__Mgobson____Decode", Benchmark__Mgobson____Decode) - // t.Run("Benchmark__VMsgpack___Decode", Benchmark__VMsgpack___Decode) - // t.Run("Benchmark__Gcbor______Decode", Benchmark__Gcbor______Decode) - // t.Run("Benchmark__Xdr________Decode", Benchmark__Xdr________Decode) - // t.Run("Benchmark__Sereal_____Decode", Benchmark__Sereal_____Decode) -} - -func benchmarkCodecXGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__Msgpack____Encode", Benchmark__Msgpack____Encode) - t.Run("Benchmark__Binc_______Encode", Benchmark__Binc_______Encode) - t.Run("Benchmark__Simple_____Encode", Benchmark__Simple_____Encode) - t.Run("Benchmark__Cbor_______Encode", Benchmark__Cbor_______Encode) - t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode) - t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode) - t.Run("Benchmark__Gob________Encode", Benchmark__Gob________Encode) - // t.Run("Benchmark__Std_Xml____Encode", Benchmark__Std_Xml____Encode) - t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode) - t.Run("Benchmark__Bson_______Encode", Benchmark__Bson_______Encode) - t.Run("Benchmark__Mgobson____Encode", Benchmark__Mgobson____Encode) - t.Run("Benchmark__VMsgpack___Encode", Benchmark__VMsgpack___Encode) - // t.Run("Benchmark__Gcbor______Encode", Benchmark__Gcbor______Encode) - // t.Run("Benchmark__Xdr________Encode", Benchmark__Xdr________Encode) - t.Run("Benchmark__Sereal_____Encode", Benchmark__Sereal_____Encode) - - benchmarkDivider() - t.Run("Benchmark__Msgpack____Decode", Benchmark__Msgpack____Decode) - t.Run("Benchmark__Binc_______Decode", Benchmark__Binc_______Decode) - t.Run("Benchmark__Simple_____Decode", Benchmark__Simple_____Decode) - t.Run("Benchmark__Cbor_______Decode", Benchmark__Cbor_______Decode) - t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode) - t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode) - t.Run("Benchmark__Gob________Decode", Benchmark__Gob________Decode) - // t.Run("Benchmark__Std_Xml____Decode", Benchmark__Std_Xml____Decode) - t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode) - t.Run("Benchmark__Bson_______Decode", Benchmark__Bson_______Decode) - t.Run("Benchmark__Mgobson____Decode", Benchmark__Mgobson____Decode) - // t.Run("Benchmark__VMsgpack___Decode", Benchmark__VMsgpack___Decode) - // t.Run("Benchmark__Gcbor______Decode", Benchmark__Gcbor______Decode) - // t.Run("Benchmark__Xdr________Decode", Benchmark__Xdr________Decode) - // t.Run("Benchmark__Sereal_____Decode", Benchmark__Sereal_____Decode) -} - -var benchmarkXSkipMsg = `>>>> Skipping - these cannot (en|de)code TestStruc - encode (gcbor, xdr, xml), decode (gcbor, vmsgpack, xdr, sereal, xml)` - -func BenchmarkXSuite(t *testing.B) { - println(benchmarkXSkipMsg) - benchmarkSuite(t, benchmarkXGroup) -} - -func BenchmarkCodecXSuite(t *testing.B) { - println(benchmarkXSkipMsg) - benchmarkSuite(t, benchmarkCodecXGroup) -} - -func benchmarkAllJsonEncodeGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__Json_______Encode", Benchmark__Json_______Encode) - t.Run("Benchmark__Std_Json___Encode", Benchmark__Std_Json___Encode) - t.Run("Benchmark__JsonIter___Encode", Benchmark__JsonIter___Encode) -} - -func benchmarkAllJsonDecodeGroup(t *testing.B) { - benchmarkDivider() - t.Run("Benchmark__Json_______Decode", Benchmark__Json_______Decode) - t.Run("Benchmark__Std_Json___Decode", Benchmark__Std_Json___Decode) - t.Run("Benchmark__JsonIter___Decode", Benchmark__JsonIter___Decode) -} - -func BenchmarkCodecVeryQuickAllJsonSuite(t *testing.B) { - benchmarkVeryQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup) -} - -func BenchmarkCodecQuickAllJsonSuite(t *testing.B) { - benchmarkQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup) - // benchmarkQuickSuite(t, "json-all", benchmarkAllJsonEncodeGroup) - // benchmarkQuickSuite(t, "json-all", benchmarkAllJsonDecodeGroup) - - // depths := [...]int{1, 4} - // for _, d := range depths { - // benchmarkQuickSuite(t, d, benchmarkAllJsonEncodeGroup) - // benchmarkQuickSuite(t, d, benchmarkAllJsonDecodeGroup) - // } - - // benchmarkQuickSuite(t, 1, benchmarkAllJsonEncodeGroup) - // benchmarkQuickSuite(t, 4, benchmarkAllJsonEncodeGroup) - // benchmarkQuickSuite(t, 1, benchmarkAllJsonDecodeGroup) - // benchmarkQuickSuite(t, 4, benchmarkAllJsonDecodeGroup) - - // benchmarkQuickSuite(t, 1, benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup) - // benchmarkQuickSuite(t, 4, benchmarkAllJsonEncodeGroup, benchmarkAllJsonDecodeGroup) - // benchmarkQuickSuite(t, benchmarkAllJsonEncodeGroup) - // benchmarkQuickSuite(t, benchmarkAllJsonDecodeGroup) -} diff --git a/vendor/github.com/ugorji/go/codec/binc.go b/vendor/github.com/ugorji/go/codec/binc.go deleted file mode 100644 index 1623b7f02..000000000 --- a/vendor/github.com/ugorji/go/codec/binc.go +++ /dev/null @@ -1,1255 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "math" - "time" -) - -const bincDoPrune = true // No longer needed. Needed before as C lib did not support pruning. - -// vd as low 4 bits (there are 16 slots) -const ( - bincVdSpecial byte = iota - bincVdPosInt - bincVdNegInt - bincVdFloat - - bincVdString - bincVdByteArray - bincVdArray - bincVdMap - - bincVdTimestamp - bincVdSmallInt - bincVdUnicodeOther - bincVdSymbol - - bincVdDecimal - _ // open slot - _ // open slot - bincVdCustomExt = 0x0f -) - -const ( - bincSpNil byte = iota - bincSpFalse - bincSpTrue - bincSpNan - bincSpPosInf - bincSpNegInf - bincSpZeroFloat - bincSpZero - bincSpNegOne -) - -const ( - bincFlBin16 byte = iota - bincFlBin32 - _ // bincFlBin32e - bincFlBin64 - _ // bincFlBin64e - // others not currently supported -) - -var ( - bincdescSpecialVsNames = map[byte]string{ - bincSpNil: "nil", - bincSpFalse: "false", - bincSpTrue: "true", - bincSpNan: "float", - bincSpPosInf: "float", - bincSpNegInf: "float", - bincSpZeroFloat: "float", - bincSpZero: "uint", - bincSpNegOne: "int", - } - bincdescVdNames = map[byte]string{ - bincVdSpecial: "special", - bincVdSmallInt: "uint", - bincVdPosInt: "uint", - bincVdFloat: "float", - bincVdSymbol: "string", - bincVdString: "string", - bincVdByteArray: "bytes", - bincVdTimestamp: "time", - bincVdCustomExt: "ext", - bincVdArray: "array", - bincVdMap: "map", - } -) - -func bincdesc(vd, vs byte) (s string) { - if vd == bincVdSpecial { - s = bincdescSpecialVsNames[vs] - } else { - s = bincdescVdNames[vd] - } - if s == "" { - s = "unknown" - } - return - - // switch vd { - // case bincVdSpecial: - // switch vs { - // case bincSpNil: - // return "nil" - // case bincSpFalse: - // return "false" - // case bincSpTrue: - // return "true" - // case bincSpNan, bincSpPosInf, bincSpNegInf, bincSpZeroFloat: - // return "float" - // case bincSpZero: - // return "uint" - // case bincSpNegOne: - // return "int" - // default: - // return "unknown" - // } - // case bincVdSmallInt, bincVdPosInt: - // return "uint" - // case bincVdNegInt: - // return "int" - // case bincVdFloat: - // return "float" - // case bincVdSymbol: - // return "string" - // case bincVdString: - // return "string" - // case bincVdByteArray: - // return "bytes" - // case bincVdTimestamp: - // return "time" - // case bincVdCustomExt: - // return "ext" - // case bincVdArray: - // return "array" - // case bincVdMap: - // return "map" - // default: - // return "unknown" - // } -} - -type bincEncDriver struct { - noBuiltInTypes - encDriverNoopContainerWriter - h *BincHandle - m map[string]uint16 // symbols - b [8]byte // scratch, used for encoding numbers - bigendian style - s uint16 // symbols sequencer - _ [4]uint64 // padding - e Encoder -} - -func (e *bincEncDriver) encoder() *Encoder { - return &e.e -} - -func (e *bincEncDriver) EncodeNil() { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpNil) -} - -func (e *bincEncDriver) EncodeTime(t time.Time) { - if t.IsZero() { - e.EncodeNil() - } else { - bs := bincEncodeTime(t) - e.e.encWr.writen1(bincVdTimestamp<<4 | uint8(len(bs))) - e.e.encWr.writeb(bs) - } -} - -func (e *bincEncDriver) EncodeBool(b bool) { - if b { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpTrue) - } else { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpFalse) - } -} - -func (e *bincEncDriver) EncodeFloat32(f float32) { - if f == 0 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZeroFloat) - return - } - e.e.encWr.writen1(bincVdFloat<<4 | bincFlBin32) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(math.Float32bits(f)) -} - -func (e *bincEncDriver) EncodeFloat64(f float64) { - if f == 0 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZeroFloat) - return - } - bigen.PutUint64(e.b[:8], math.Float64bits(f)) - if bincDoPrune { - i := 7 - for ; i >= 0 && (e.b[i] == 0); i-- { - } - i++ - if i <= 6 { - e.e.encWr.writen1(bincVdFloat<<4 | 0x8 | bincFlBin64) - e.e.encWr.writen1(byte(i)) - e.e.encWr.writeb(e.b[:i]) - return - } - } - e.e.encWr.writen1(bincVdFloat<<4 | bincFlBin64) - e.e.encWr.writeb(e.b[:8]) -} - -func (e *bincEncDriver) encIntegerPrune(bd byte, pos bool, v uint64, lim uint8) { - if lim == 4 { - bigen.PutUint32(e.b[:lim], uint32(v)) - } else { - bigen.PutUint64(e.b[:lim], v) - } - if bincDoPrune { - i := pruneSignExt(e.b[:lim], pos) - e.e.encWr.writen1(bd | lim - 1 - byte(i)) - e.e.encWr.writeb(e.b[i:lim]) - } else { - e.e.encWr.writen1(bd | lim - 1) - e.e.encWr.writeb(e.b[:lim]) - } -} - -func (e *bincEncDriver) EncodeInt(v int64) { - // const nbd byte = bincVdNegInt << 4 - if v >= 0 { - e.encUint(bincVdPosInt<<4, true, uint64(v)) - } else if v == -1 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpNegOne) - } else { - e.encUint(bincVdNegInt<<4, false, uint64(-v)) - } -} - -func (e *bincEncDriver) EncodeUint(v uint64) { - e.encUint(bincVdPosInt<<4, true, v) -} - -func (e *bincEncDriver) encUint(bd byte, pos bool, v uint64) { - if v == 0 { - e.e.encWr.writen1(bincVdSpecial<<4 | bincSpZero) - } else if pos && v >= 1 && v <= 16 { - e.e.encWr.writen1(bincVdSmallInt<<4 | byte(v-1)) - } else if v <= math.MaxUint8 { - e.e.encWr.writen2(bd|0x0, byte(v)) - } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd | 0x01) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v)) - } else if v <= math.MaxUint32 { - e.encIntegerPrune(bd, pos, v, 4) - } else { - e.encIntegerPrune(bd, pos, v, 8) - } -} - -func (e *bincEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) { - var bs []byte - if ext == SelfExt { - bs = e.e.blist.get(1024)[:0] - e.e.sideEncode(v, &bs) - } else { - bs = ext.WriteExt(v) - } - if bs == nil { - e.EncodeNil() - return - } - e.encodeExtPreamble(uint8(xtag), len(bs)) - e.e.encWr.writeb(bs) - if ext == SelfExt { - e.e.blist.put(bs) - } -} - -func (e *bincEncDriver) EncodeRawExt(re *RawExt) { - e.encodeExtPreamble(uint8(re.Tag), len(re.Data)) - e.e.encWr.writeb(re.Data) -} - -func (e *bincEncDriver) encodeExtPreamble(xtag byte, length int) { - e.encLen(bincVdCustomExt<<4, uint64(length)) - e.e.encWr.writen1(xtag) -} - -func (e *bincEncDriver) WriteArrayStart(length int) { - e.encLen(bincVdArray<<4, uint64(length)) -} - -func (e *bincEncDriver) WriteMapStart(length int) { - e.encLen(bincVdMap<<4, uint64(length)) -} - -func (e *bincEncDriver) EncodeSymbol(v string) { - // if WriteSymbolsNoRefs { - // e.encodeString(cUTF8, v) - // return - // } - - //symbols only offer benefit when string length > 1. - //This is because strings with length 1 take only 2 bytes to store - //(bd with embedded length, and single byte for string val). - - l := len(v) - if l == 0 { - e.encBytesLen(cUTF8, 0) - return - } else if l == 1 { - e.encBytesLen(cUTF8, 1) - e.e.encWr.writen1(v[0]) - return - } - if e.m == nil { - e.m = make(map[string]uint16, 16) - } - ui, ok := e.m[v] - if ok { - if ui <= math.MaxUint8 { - e.e.encWr.writen2(bincVdSymbol<<4, byte(ui)) - } else { - e.e.encWr.writen1(bincVdSymbol<<4 | 0x8) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(ui) - } - } else { - e.s++ - ui = e.s - //ui = uint16(atomic.AddUint32(&e.s, 1)) - e.m[v] = ui - var lenprec uint8 - if l <= math.MaxUint8 { - // lenprec = 0 - } else if l <= math.MaxUint16 { - lenprec = 1 - } else if int64(l) <= math.MaxUint32 { - lenprec = 2 - } else { - lenprec = 3 - } - if ui <= math.MaxUint8 { - e.e.encWr.writen2(bincVdSymbol<<4|0x0|0x4|lenprec, byte(ui)) - } else { - e.e.encWr.writen1(bincVdSymbol<<4 | 0x8 | 0x4 | lenprec) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(ui) - } - if lenprec == 0 { - e.e.encWr.writen1(byte(l)) - } else if lenprec == 1 { - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(l)) - } else if lenprec == 2 { - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(l)) - } else { - bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(l)) - } - e.e.encWr.writestr(v) - } -} - -func (e *bincEncDriver) EncodeString(v string) { - if e.h.StringToRaw { - e.encLen(bincVdByteArray<<4, uint64(len(v))) // e.encBytesLen(c, l) - if len(v) > 0 { - e.e.encWr.writestr(v) - } - return - } - e.EncodeStringEnc(cUTF8, v) -} - -func (e *bincEncDriver) EncodeStringEnc(c charEncoding, v string) { - if e.e.c == containerMapKey && c == cUTF8 && (e.h.AsSymbols == 1) { - e.EncodeSymbol(v) - return - } - e.encLen(bincVdString<<4, uint64(len(v))) // e.encBytesLen(c, l) - if len(v) > 0 { - e.e.encWr.writestr(v) - } -} - -func (e *bincEncDriver) EncodeStringBytesRaw(v []byte) { - if v == nil { - e.EncodeNil() - return - } - e.encLen(bincVdByteArray<<4, uint64(len(v))) // e.encBytesLen(c, l) - if len(v) > 0 { - e.e.encWr.writeb(v) - } -} - -func (e *bincEncDriver) encBytesLen(c charEncoding, length uint64) { - // NOTE: we currently only support UTF-8 (string) and RAW (bytearray). - // We should consider supporting bincUnicodeOther. - - if c == cRAW { - e.encLen(bincVdByteArray<<4, length) - } else { - e.encLen(bincVdString<<4, length) - } -} - -func (e *bincEncDriver) encLen(bd byte, l uint64) { - if l < 12 { - e.e.encWr.writen1(bd | uint8(l+4)) - } else { - e.encLenNumber(bd, l) - } -} - -func (e *bincEncDriver) encLenNumber(bd byte, v uint64) { - if v <= math.MaxUint8 { - e.e.encWr.writen2(bd, byte(v)) - } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd | 0x01) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v)) - } else if v <= math.MaxUint32 { - e.e.encWr.writen1(bd | 0x02) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(v)) - } else { - e.e.encWr.writen1(bd | 0x03) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(v)) - } -} - -//------------------------------------ - -type bincDecDriver struct { - decDriverNoopContainerReader - noBuiltInTypes - - h *BincHandle - bdRead bool - bd byte - vd byte - vs byte - - fnil bool - // _ [3]byte // padding - // linear searching on this slice is ok, - // because we typically expect < 32 symbols in each stream. - s map[uint16][]byte // []bincDecSymbol - - b [8]byte // scratch for decoding numbers - big endian style - _ [4]uint64 // padding cache-aligned - - d Decoder -} - -func (d *bincDecDriver) decoder() *Decoder { - return &d.d -} - -func (d *bincDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() - d.vd = d.bd >> 4 - d.vs = d.bd & 0x0f - d.bdRead = true -} - -// func (d *bincDecDriver) uncacheRead() { -// if d.bdRead { -// d.d.decRd.unreadn1() -// d.bdRead = false -// } -// } - -func (d *bincDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == bincVdSpecial<<4|bincSpNil { - d.bdRead = false - d.fnil = true - null = true - } - return -} - -// func (d *bincDecDriver) Nil() bool { -// return d.fnil -// } - -func (d *bincDecDriver) TryNil() bool { - return d.advanceNil() -} - -func (d *bincDecDriver) ContainerType() (vt valueType) { - if !d.bdRead { - d.readNextBd() - } - d.fnil = false - // if d.vd == bincVdSpecial && d.vs == bincSpNil { - if d.bd == bincVdSpecial<<4|bincSpNil { - d.bdRead = false - d.fnil = true - return valueTypeNil - } else if d.vd == bincVdByteArray { - return valueTypeBytes - } else if d.vd == bincVdString { - return valueTypeString - } else if d.vd == bincVdArray { - return valueTypeArray - } else if d.vd == bincVdMap { - return valueTypeMap - } - return valueTypeUnset -} - -func (d *bincDecDriver) DecodeTime() (t time.Time) { - if d.advanceNil() { - return - } - if d.vd != bincVdTimestamp { - d.d.errorf("cannot decode time - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - t, err := bincDecodeTime(d.d.decRd.readx(uint(d.vs))) - if err != nil { - panic(err) - } - d.bdRead = false - return -} - -func (d *bincDecDriver) decFloatPre(vs, defaultLen byte) { - if vs&0x8 == 0 { - d.d.decRd.readb(d.b[0:defaultLen]) - } else { - l := d.d.decRd.readn1() - if l > 8 { - d.d.errorf("cannot read float - at most 8 bytes used to represent float - received %v bytes", l) - return - } - for i := l; i < 8; i++ { - d.b[i] = 0 - } - d.d.decRd.readb(d.b[0:l]) - } -} - -func (d *bincDecDriver) decFloat() (f float64) { - //if true { f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))); break; } - if x := d.vs & 0x7; x == bincFlBin32 { - d.decFloatPre(d.vs, 4) - f = float64(math.Float32frombits(bigen.Uint32(d.b[0:4]))) - } else if x == bincFlBin64 { - d.decFloatPre(d.vs, 8) - f = math.Float64frombits(bigen.Uint64(d.b[0:8])) - } else { - d.d.errorf("read float - only float32 and float64 are supported - %s %x-%x/%s", - msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - return -} - -func (d *bincDecDriver) decUint() (v uint64) { - // need to inline the code (interface conversion and type assertion expensive) - switch d.vs { - case 0: - v = uint64(d.d.decRd.readn1()) - case 1: - d.d.decRd.readb(d.b[6:8]) - v = uint64(bigen.Uint16(d.b[6:8])) - case 2: - d.b[4] = 0 - d.d.decRd.readb(d.b[5:8]) - v = uint64(bigen.Uint32(d.b[4:8])) - case 3: - d.d.decRd.readb(d.b[4:8]) - v = uint64(bigen.Uint32(d.b[4:8])) - case 4, 5, 6: - lim := 7 - d.vs - d.d.decRd.readb(d.b[lim:8]) - for i := uint8(0); i < lim; i++ { - d.b[i] = 0 - } - v = uint64(bigen.Uint64(d.b[:8])) - case 7: - d.d.decRd.readb(d.b[:8]) - v = uint64(bigen.Uint64(d.b[:8])) - default: - d.d.errorf("unsigned integers with greater than 64 bits of precision not supported") - return - } - return -} - -func (d *bincDecDriver) decCheckInteger() (ui uint64, neg bool) { - vd, vs := d.vd, d.vs - if vd == bincVdPosInt { - ui = d.decUint() - } else if vd == bincVdNegInt { - ui = d.decUint() - neg = true - } else if vd == bincVdSmallInt { - ui = uint64(d.vs) + 1 - } else if vd == bincVdSpecial { - if vs == bincSpZero { - //i = 0 - } else if vs == bincSpNegOne { - neg = true - ui = 1 - } else { - d.d.errorf("integer decode fails - invalid special value from descriptor %x-%x/%s", - d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - } else { - d.d.errorf("integer can only be decoded from int/uint. d.bd: 0x%x, d.vd: 0x%x", d.bd, d.vd) - return - } - return -} - -func (d *bincDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } - ui, neg := d.decCheckInteger() - i = chkOvf.SignedIntV(ui) - if neg { - i = -i - } - d.bdRead = false - return -} - -func (d *bincDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } - ui, neg := d.decCheckInteger() - if neg { - d.d.errorf("assigning negative signed value to unsigned integer type") - return - } - d.bdRead = false - return -} - -func (d *bincDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return - } - vd, vs := d.vd, d.vs - if vd == bincVdSpecial { - d.bdRead = false - if vs == bincSpNan { - return math.NaN() - } else if vs == bincSpPosInf { - return math.Inf(1) - } else if vs == bincSpZeroFloat || vs == bincSpZero { - return - } else if vs == bincSpNegInf { - return math.Inf(-1) - } else { - d.d.errorf("float - invalid special value from descriptor %x-%x/%s", - d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - } else if vd == bincVdFloat { - f = d.decFloat() - } else { - f = float64(d.DecodeInt64()) - } - d.bdRead = false - return -} - -// bool can be decoded from bool only (single byte). -func (d *bincDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return - } - if d.bd == (bincVdSpecial | bincSpFalse) { - // b = false - } else if d.bd == (bincVdSpecial | bincSpTrue) { - b = true - } else { - d.d.errorf("bool - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - d.bdRead = false - return -} - -func (d *bincDecDriver) ReadMapStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - if d.vd != bincVdMap { - d.d.errorf("map - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - length = d.decLen() - d.bdRead = false - return -} - -func (d *bincDecDriver) ReadArrayStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - if d.vd != bincVdArray { - d.d.errorf("array - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - length = d.decLen() - d.bdRead = false - return -} - -func (d *bincDecDriver) decLen() int { - if d.vs > 3 { - return int(d.vs - 4) - } - return int(d.decLenNumber()) -} - -func (d *bincDecDriver) decLenNumber() (v uint64) { - if x := d.vs; x == 0 { - v = uint64(d.d.decRd.readn1()) - } else if x == 1 { - d.d.decRd.readb(d.b[6:8]) - v = uint64(bigen.Uint16(d.b[6:8])) - } else if x == 2 { - d.d.decRd.readb(d.b[4:8]) - v = uint64(bigen.Uint32(d.b[4:8])) - } else { - d.d.decRd.readb(d.b[:8]) - v = bigen.Uint64(d.b[:8]) - } - return -} - -func (d *bincDecDriver) decStringBytes(bs []byte, zerocopy bool) (bs2 []byte) { - if d.advanceNil() { - return - } - var slen = -1 - // var ok bool - switch d.vd { - case bincVdString, bincVdByteArray: - slen = d.decLen() - if zerocopy { - if d.d.bytes { - bs2 = d.d.decRd.rb.readx(uint(slen)) - } else if len(bs) == 0 { - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, d.d.b[:]) - } else { - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, bs) - } - } else { - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, bs) - } - case bincVdSymbol: - // zerocopy doesn't apply for symbols, - // as the values must be stored in a table for later use. - // - //from vs: extract numSymbolBytes, containsStringVal, strLenPrecision, - //extract symbol - //if containsStringVal, read it and put in map - //else look in map for string value - var symbol uint16 - vs := d.vs - if vs&0x8 == 0 { - symbol = uint16(d.d.decRd.readn1()) - } else { - symbol = uint16(bigen.Uint16(d.d.decRd.readx(2))) - } - if d.s == nil { - // d.s = pool4mapU16Bytes.Get().(map[uint16][]byte) // make([]bincDecSymbol, 0, 16) - d.s = make(map[uint16][]byte, 16) - } - - if vs&0x4 == 0 { - bs2 = d.s[symbol] - } else { - switch vs & 0x3 { - case 0: - slen = int(d.d.decRd.readn1()) - case 1: - slen = int(bigen.Uint16(d.d.decRd.readx(2))) - case 2: - slen = int(bigen.Uint32(d.d.decRd.readx(4))) - case 3: - slen = int(bigen.Uint64(d.d.decRd.readx(8))) - } - // since using symbols, do not store any part of - // the parameter bs in the map, as it might be a shared buffer. - // bs2 = decByteSlice(d.d.r(), slen, bs) - bs2 = decByteSlice(d.d.r(), slen, d.d.h.MaxInitLen, nil) - d.s[symbol] = bs2 - // d.s = append(d.s, bincDecSymbol{i: symbol, s: s, b: bs2}) - } - default: - d.d.errorf("string/bytes - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - d.bdRead = false - return -} - -func (d *bincDecDriver) DecodeStringAsBytes() (s []byte) { - return d.decStringBytes(d.d.b[:], true) -} - -func (d *bincDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return - } - // check if an "array" of uint8's (see ContainerType for how to infer if an array) - if d.vd == bincVdArray { - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - slen := d.ReadArrayStart() - bs = usableByteSlice(bs, slen) - for i := 0; i < slen; i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs - } - var clen int - if d.vd == bincVdString || d.vd == bincVdByteArray { - clen = d.decLen() - } else { - d.d.errorf("bytes - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - d.bdRead = false - if d.d.bytes && (zerocopy || d.h.ZeroCopy) { - return d.d.decRd.rb.readx(uint(clen)) - } - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - return decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, bs) -} - -func (d *bincDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - if xtag > 0xff { - d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag) - return - } - if d.advanceNil() { - return - } - realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag)) - realxtag := uint64(realxtag1) - if ext == nil { - re := rv.(*RawExt) - re.Tag = realxtag - re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs) - } else if ext == SelfExt { - d.d.sideDecode(rv, xbs) - } else { - ext.ReadExt(rv, xbs) - } -} - -func (d *bincDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) { - if d.vd == bincVdCustomExt { - l := d.decLen() - xtag = d.d.decRd.readn1() - if verifyTag && xtag != tag { - d.d.errorf("wrong extension tag - got %b, expecting: %v", xtag, tag) - return - } - if d.d.bytes { - xbs = d.d.decRd.rb.readx(uint(l)) - } else { - xbs = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) - } - } else if d.vd == bincVdByteArray { - xbs = d.DecodeBytes(nil, true) - } else { - d.d.errorf("ext - expecting extensions or byte array - %s %x-%x/%s", - msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - return - } - d.bdRead = false - return -} - -func (d *bincDecDriver) DecodeNaked() { - if !d.bdRead { - d.readNextBd() - } - - d.fnil = false - n := d.d.naked() - var decodeFurther bool - - switch d.vd { - case bincVdSpecial: - switch d.vs { - case bincSpNil: - n.v = valueTypeNil - d.fnil = true - case bincSpFalse: - n.v = valueTypeBool - n.b = false - case bincSpTrue: - n.v = valueTypeBool - n.b = true - case bincSpNan: - n.v = valueTypeFloat - n.f = math.NaN() - case bincSpPosInf: - n.v = valueTypeFloat - n.f = math.Inf(1) - case bincSpNegInf: - n.v = valueTypeFloat - n.f = math.Inf(-1) - case bincSpZeroFloat: - n.v = valueTypeFloat - n.f = float64(0) - case bincSpZero: - n.v = valueTypeUint - n.u = uint64(0) // int8(0) - case bincSpNegOne: - n.v = valueTypeInt - n.i = int64(-1) // int8(-1) - default: - d.d.errorf("cannot infer value - unrecognized special value from descriptor %x-%x/%s", - d.vd, d.vs, bincdesc(d.vd, d.vs)) - } - case bincVdSmallInt: - n.v = valueTypeUint - n.u = uint64(int8(d.vs)) + 1 // int8(d.vs) + 1 - case bincVdPosInt: - n.v = valueTypeUint - n.u = d.decUint() - case bincVdNegInt: - n.v = valueTypeInt - n.i = -(int64(d.decUint())) - case bincVdFloat: - n.v = valueTypeFloat - n.f = d.decFloat() - case bincVdSymbol: - n.v = valueTypeSymbol - n.s = string(d.DecodeStringAsBytes()) - case bincVdString: - n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - case bincVdByteArray: - fauxUnionReadRawBytes(d, &d.d, n, d.h.RawToString) - case bincVdTimestamp: - n.v = valueTypeTime - tt, err := bincDecodeTime(d.d.decRd.readx(uint(d.vs))) - if err != nil { - panic(err) - } - n.t = tt - case bincVdCustomExt: - n.v = valueTypeExt - l := d.decLen() - n.u = uint64(d.d.decRd.readn1()) - if d.d.bytes { - n.l = d.d.decRd.rb.readx(uint(l)) - } else { - n.l = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) - } - case bincVdArray: - n.v = valueTypeArray - decodeFurther = true - case bincVdMap: - n.v = valueTypeMap - decodeFurther = true - default: - d.d.errorf("cannot infer value - %s %x-%x/%s", msgBadDesc, d.vd, d.vs, bincdesc(d.vd, d.vs)) - } - - if !decodeFurther { - d.bdRead = false - } - if n.v == valueTypeUint && d.h.SignedInteger { - n.v = valueTypeInt - n.i = int64(n.u) - } -} - -//------------------------------------ - -//BincHandle is a Handle for the Binc Schema-Free Encoding Format -//defined at https://github.com/ugorji/binc . -// -//BincHandle currently supports all Binc features with the following EXCEPTIONS: -// - only integers up to 64 bits of precision are supported. -// big integers are unsupported. -// - Only IEEE 754 binary32 and binary64 floats are supported (ie Go float32 and float64 types). -// extended precision and decimal IEEE 754 floats are unsupported. -// - Only UTF-8 strings supported. -// Unicode_Other Binc types (UTF16, UTF32) are currently unsupported. -// -//Note that these EXCEPTIONS are temporary and full support is possible and may happen soon. -type BincHandle struct { - BasicHandle - binaryEncodingType - // noElemSeparators - - // AsSymbols defines what should be encoded as symbols. - // - // Encoding as symbols can reduce the encoded size significantly. - // - // However, during decoding, each string to be encoded as a symbol must - // be checked to see if it has been seen before. Consequently, encoding time - // will increase if using symbols, because string comparisons has a clear cost. - // - // Values: - // - 0: default: library uses best judgement - // - 1: use symbols - // - 2: do not use symbols - AsSymbols uint8 - - // AsSymbols: may later on introduce more options ... - // - m: map keys - // - s: struct fields - // - n: none - // - a: all: same as m, s, ... - - _ [7]uint64 // padding (cache-aligned) -} - -// Name returns the name of the handle: binc -func (h *BincHandle) Name() string { return "binc" } - -func (h *BincHandle) newEncDriver() encDriver { - var e = &bincEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e -} - -func (h *BincHandle) newDecDriver() decDriver { - d := &bincDecDriver{h: h} - d.d.d = d - d.d.init(h) - d.reset() - return d -} - -func (e *bincEncDriver) reset() { - e.s = 0 - e.m = nil -} - -func (e *bincEncDriver) atEndOfEncode() { - if e.m != nil { - for k := range e.m { - delete(e.m, k) - } - } -} - -func (d *bincDecDriver) reset() { - d.s = nil - d.bd, d.bdRead, d.vd, d.vs = 0, false, 0, 0 - d.fnil = false -} - -func (d *bincDecDriver) atEndOfDecode() { - if d.s != nil { - for k := range d.s { - delete(d.s, k) - } - } -} - -// var timeDigits = [...]byte{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} - -// EncodeTime encodes a time.Time as a []byte, including -// information on the instant in time and UTC offset. -// -// Format Description -// -// A timestamp is composed of 3 components: -// -// - secs: signed integer representing seconds since unix epoch -// - nsces: unsigned integer representing fractional seconds as a -// nanosecond offset within secs, in the range 0 <= nsecs < 1e9 -// - tz: signed integer representing timezone offset in minutes east of UTC, -// and a dst (daylight savings time) flag -// -// When encoding a timestamp, the first byte is the descriptor, which -// defines which components are encoded and how many bytes are used to -// encode secs and nsecs components. *If secs/nsecs is 0 or tz is UTC, it -// is not encoded in the byte array explicitly*. -// -// Descriptor 8 bits are of the form `A B C DDD EE`: -// A: Is secs component encoded? 1 = true -// B: Is nsecs component encoded? 1 = true -// C: Is tz component encoded? 1 = true -// DDD: Number of extra bytes for secs (range 0-7). -// If A = 1, secs encoded in DDD+1 bytes. -// If A = 0, secs is not encoded, and is assumed to be 0. -// If A = 1, then we need at least 1 byte to encode secs. -// DDD says the number of extra bytes beyond that 1. -// E.g. if DDD=0, then secs is represented in 1 byte. -// if DDD=2, then secs is represented in 3 bytes. -// EE: Number of extra bytes for nsecs (range 0-3). -// If B = 1, nsecs encoded in EE+1 bytes (similar to secs/DDD above) -// -// Following the descriptor bytes, subsequent bytes are: -// -// secs component encoded in `DDD + 1` bytes (if A == 1) -// nsecs component encoded in `EE + 1` bytes (if B == 1) -// tz component encoded in 2 bytes (if C == 1) -// -// secs and nsecs components are integers encoded in a BigEndian -// 2-complement encoding format. -// -// tz component is encoded as 2 bytes (16 bits). Most significant bit 15 to -// Least significant bit 0 are described below: -// -// Timezone offset has a range of -12:00 to +14:00 (ie -720 to +840 minutes). -// Bit 15 = have\_dst: set to 1 if we set the dst flag. -// Bit 14 = dst\_on: set to 1 if dst is in effect at the time, or 0 if not. -// Bits 13..0 = timezone offset in minutes. It is a signed integer in Big Endian format. -// -func bincEncodeTime(t time.Time) []byte { - // t := rv2i(rv).(time.Time) - tsecs, tnsecs := t.Unix(), t.Nanosecond() - var ( - bd byte - btmp [8]byte - bs [16]byte - i int = 1 - ) - l := t.Location() - if l == time.UTC { - l = nil - } - if tsecs != 0 { - bd = bd | 0x80 - bigen.PutUint64(btmp[:], uint64(tsecs)) - f := pruneSignExt(btmp[:], tsecs >= 0) - bd = bd | (byte(7-f) << 2) - copy(bs[i:], btmp[f:]) - i = i + (8 - f) - } - if tnsecs != 0 { - bd = bd | 0x40 - bigen.PutUint32(btmp[:4], uint32(tnsecs)) - f := pruneSignExt(btmp[:4], true) - bd = bd | byte(3-f) - copy(bs[i:], btmp[f:4]) - i = i + (4 - f) - } - if l != nil { - bd = bd | 0x20 - // Note that Go Libs do not give access to dst flag. - _, zoneOffset := t.Zone() - // zoneName, zoneOffset := t.Zone() - zoneOffset /= 60 - z := uint16(zoneOffset) - bigen.PutUint16(btmp[:2], z) - // clear dst flags - bs[i] = btmp[0] & 0x3f - bs[i+1] = btmp[1] - i = i + 2 - } - bs[0] = bd - return bs[0:i] -} - -// bincDecodeTime decodes a []byte into a time.Time. -func bincDecodeTime(bs []byte) (tt time.Time, err error) { - bd := bs[0] - var ( - tsec int64 - tnsec uint32 - tz uint16 - i byte = 1 - i2 byte - n byte - ) - if bd&(1<<7) != 0 { - var btmp [8]byte - n = ((bd >> 2) & 0x7) + 1 - i2 = i + n - copy(btmp[8-n:], bs[i:i2]) - // if first bit of bs[i] is set, then fill btmp[0..8-n] with 0xff (ie sign extend it) - if bs[i]&(1<<7) != 0 { - copy(btmp[0:8-n], bsAll0xff) - // for j,k := byte(0), 8-n; j < k; j++ { btmp[j] = 0xff } - } - i = i2 - tsec = int64(bigen.Uint64(btmp[:])) - } - if bd&(1<<6) != 0 { - var btmp [4]byte - n = (bd & 0x3) + 1 - i2 = i + n - copy(btmp[4-n:], bs[i:i2]) - i = i2 - tnsec = bigen.Uint32(btmp[:]) - } - if bd&(1<<5) == 0 { - tt = time.Unix(tsec, int64(tnsec)).UTC() - return - } - // In stdlib time.Parse, when a date is parsed without a zone name, it uses "" as zone name. - // However, we need name here, so it can be shown when time is printf.d. - // Zone name is in form: UTC-08:00. - // Note that Go Libs do not give access to dst flag, so we ignore dst bits - - i2 = i + 2 - tz = bigen.Uint16(bs[i:i2]) - // i = i2 - // sign extend sign bit into top 2 MSB (which were dst bits): - if tz&(1<<13) == 0 { // positive - tz = tz & 0x3fff //clear 2 MSBs: dst bits - } else { // negative - tz = tz | 0xc000 //set 2 MSBs: dst bits - } - tzint := int16(tz) - if tzint == 0 { - tt = time.Unix(tsec, int64(tnsec)).UTC() - } else { - // For Go Time, do not use a descriptive timezone. - // It's unnecessary, and makes it harder to do a reflect.DeepEqual. - // The Offset already tells what the offset should be, if not on UTC and unknown zone name. - // var zoneName = timeLocUTCName(tzint) - tt = time.Unix(tsec, int64(tnsec)).In(time.FixedZone("", int(tzint)*60)) - } - return -} - -// func timeLocUTCName(tzint int16) string { -// if tzint == 0 { -// return "UTC" -// } -// var tzname = []byte("UTC+00:00") -// //tzname := fmt.Sprintf("UTC%s%02d:%02d", tzsign, tz/60, tz%60) //perf issue using Sprintf.. inline below. -// //tzhr, tzmin := tz/60, tz%60 //faster if u convert to int first -// var tzhr, tzmin int16 -// if tzint < 0 { -// tzname[3] = '-' -// tzhr, tzmin = -tzint/60, (-tzint)%60 -// } else { -// tzhr, tzmin = tzint/60, tzint%60 -// } -// tzname[4] = timeDigits[tzhr/10] -// tzname[5] = timeDigits[tzhr%10] -// tzname[7] = timeDigits[tzmin/10] -// tzname[8] = timeDigits[tzmin%10] -// return string(tzname) -// //return time.FixedZone(string(tzname), int(tzint)*60) -// } - -var _ decDriver = (*bincDecDriver)(nil) -var _ encDriver = (*bincEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/build.sh b/vendor/github.com/ugorji/go/codec/build.sh deleted file mode 100755 index 5b8715785..000000000 --- a/vendor/github.com/ugorji/go/codec/build.sh +++ /dev/null @@ -1,272 +0,0 @@ -#!/bin/bash - -# Run all the different permutations of all the tests and other things -# This helps ensure that nothing gets broken. - -_tests() { - local vet="" # TODO: make it off - local gover=$( go version | cut -f 3 -d ' ' ) - # note that codecgen requires fastpath, so you cannot do "codecgen notfastpath" - local a=( "" "safe" "notfastpath" "notfastpath safe" "codecgen" "codecgen safe" ) - for i in "${a[@]}" - do - echo ">>>> TAGS: $i" - local i2=${i:-default} - case $gover in - go1.[0-6]*) go test ${zargs[*]} -tags "$i" "$@" ;; - *) go vet -printfuncs "errorf" "$@" && - go test ${zargs[*]} -vet "$vet" -tags "alltests $i" -run "Suite" -coverprofile "${i2// /-}.cov.out" "$@" ;; - esac - if [[ "$?" != 0 ]]; then return 1; fi - done - echo "++++++++ TEST SUITES ALL PASSED ++++++++" -} - - -# is a generation needed? -_ng() { - local a="$1" - if [[ ! -e "$a" ]]; then echo 1; return; fi - for i in `ls -1 *.go.tmpl gen.go values_test.go` - do - if [[ "$a" -ot "$i" ]]; then echo 1; return; fi - done -} - -_prependbt() { - cat > ${2} <> ${2} - rm -f ${1} -} - -# _build generates fast-path.go and gen-helper.go. -_build() { - if ! [[ "${zforce}" || $(_ng "fast-path.generated.go") || $(_ng "gen-helper.generated.go") || $(_ng "gen.generated.go") ]]; then return 0; fi - - if [ "${zbak}" ]; then - _zts=`date '+%m%d%Y_%H%M%S'` - _gg=".generated.go" - [ -e "gen-helper${_gg}" ] && mv gen-helper${_gg} gen-helper${_gg}__${_zts}.bak - [ -e "fast-path${_gg}" ] && mv fast-path${_gg} fast-path${_gg}__${_zts}.bak - [ -e "gen${_gg}" ] && mv gen${_gg} gen${_gg}__${_zts}.bak - fi - rm -f gen-helper.generated.go fast-path.generated.go gen.generated.go \ - *safe.generated.go *_generated_test.go *.generated_ffjson_expose.go - - cat > gen.generated.go <> gen.generated.go < gen-dec-map.go.tmpl - cat >> gen.generated.go <> gen.generated.go < gen-dec-array.go.tmpl - cat >> gen.generated.go <> gen.generated.go < gen-enc-chan.go.tmpl - cat >> gen.generated.go < gen-from-tmpl.codec.generated.go < gen-from-tmpl.generated.go < " + fnameOut + " ______") -fin, err := os.Open(fnameIn) -if err != nil { panic(err) } -defer fin.Close() -fout, err := os.Create(fnameOut) -if err != nil { panic(err) } -defer fout.Close() -err = codec.GenInternalGoFile(fin, fout) -if err != nil { panic(err) } -} - -func main() { -run("fast-path.go.tmpl", "fast-path.generated.go") -run("gen-helper.go.tmpl", "gen-helper.generated.go") -run("mammoth-test.go.tmpl", "mammoth_generated_test.go") -run("mammoth2-test.go.tmpl", "mammoth2_generated_test.go") -// run("sort-slice.go.tmpl", "sort-slice.generated.go") -} -EOF - - sed -e 's+// __DO_NOT_REMOVE__NEEDED_FOR_REPLACING__IMPORT_PATH__FOR_CODEC_BENCH__+import . "github.com/ugorji/go/codec"+' \ - shared_test.go > bench/shared_test.go - - # explicitly return 0 if this passes, else return 1 - go run -tags "prebuild" prebuild.go || return 1 - go run -tags "notfastpath safe codecgen.exec" gen-from-tmpl.generated.go || return 1 - rm -f gen-from-tmpl.*generated.go - return 0 -} - -_codegenerators() { - local c5="_generated_test.go" - local c7="$PWD/codecgen" - local c8="$c7/__codecgen" - local c9="codecgen-scratch.go" - - if ! [[ $zforce || $(_ng "values_codecgen${c5}") ]]; then return 0; fi - - # Note: ensure you run the codecgen for this codebase/directory i.e. ./codecgen/codecgen - true && - echo "codecgen ... " && - if [[ $zforce || ! -f "$c8" || "$c7/gen.go" -nt "$c8" ]]; then - echo "rebuilding codecgen ... " && ( cd codecgen && go build -o $c8 ${zargs[*]} . ) - fi && - $c8 -rt codecgen -t 'codecgen generated' -o values_codecgen${c5} -d 19780 $zfin $zfin2 && - cp mammoth2_generated_test.go $c9 && - $c8 -t 'codecgen,!notfastpath generated,!notfastpath' -o mammoth2_codecgen${c5} -d 19781 mammoth2_generated_test.go && - rm -f $c9 && - echo "generators done!" -} - -_prebuild() { - echo "prebuild: zforce: $zforce" - local d="$PWD" - local zfin="test_values.generated.go" - local zfin2="test_values_flex.generated.go" - local zpkg="github.com/ugorji/go/codec" - # zpkg=${d##*/src/} - # zgobase=${d%%/src/*} - # rm -f *_generated_test.go - rm -f codecgen-*.go && - _build && - cp $d/values_test.go $d/$zfin && - cp $d/values_flex_test.go $d/$zfin2 && - _codegenerators && - if [[ "$(type -t _codegenerators_external )" = "function" ]]; then _codegenerators_external ; fi && - if [[ $zforce ]]; then go install ${zargs[*]} .; fi && - echo "prebuild done successfully" - rm -f $d/$zfin $d/$zfin2 - # unset zfin zfin2 zpkg -} - -_make() { - local makeforce=${zforce} - zforce=1 - (cd codecgen && go install ${zargs[*]} .) && _prebuild && go install ${zargs[*]} . - zforce=${makeforce} -} - -_clean() { - rm -f gen-from-tmpl.*generated.go \ - codecgen-*.go \ - test_values.generated.go test_values_flex.generated.go -} - -_release() { - local reply - read -p "Pre-release validation takes a few minutes and MUST be run from within GOPATH/src. Confirm y/n? " -n 1 -r reply - echo - if [[ ! $reply =~ ^[Yy]$ ]]; then return 1; fi - - # expects GOROOT, GOROOT_BOOTSTRAP to have been set. - if [[ -z "${GOROOT// }" || -z "${GOROOT_BOOTSTRAP// }" ]]; then return 1; fi - # (cd $GOROOT && git checkout -f master && git pull && git reset --hard) - (cd $GOROOT && git pull) - local f=`pwd`/make.release.out - cat > $f <>$f - if [[ "$i" != "master" ]]; then i="release-branch.go$i"; fi - (false || - (echo "===== BUILDING GO SDK for branch: $i ... =====" && - cd $GOROOT && - git checkout -f $i && git reset --hard && git clean -f . && - cd src && ./make.bash >>$f 2>&1 && sleep 1 ) ) && - echo "===== GO SDK BUILD DONE =====" && - _prebuild && - echo "===== PREBUILD DONE with exit: $? =====" && - _tests "$@" - if [[ "$?" != 0 ]]; then return 1; fi - done - zforce=${makeforce} - echo "++++++++ RELEASE TEST SUITES ALL PASSED ++++++++" -} - -_usage() { - cat < [tests, make, prebuild (force), inlining diagnostics, mid-stack inlining, race detector] - -v -> verbose -EOF - if [[ "$(type -t _usage_run)" = "function" ]]; then _usage_run ; fi -} - -_main() { - if [[ -z "$1" ]]; then _usage; return 1; fi - local x - local zforce - local zargs=() - local zverbose=() - local zbenchflags="" - OPTIND=1 - while getopts ":ctmnrgpfvlyzdb:" flag - do - case "x$flag" in - 'xf') zforce=1 ;; - 'xv') zverbose+=(1) ;; - 'xl') zargs+=("-gcflags"); zargs+=("-l=4") ;; - 'xn') zargs+=("-gcflags"); zargs+=("-m=2") ;; - 'xd') zargs+=("-race") ;; - 'xb') x='b'; zbenchflags=${OPTARG} ;; - x\?) _usage; return 1 ;; - *) x=$flag ;; - esac - done - shift $((OPTIND-1)) - # echo ">>>> _main: extra args: $@" - case "x$x" in - 'xt') _tests "$@" ;; - 'xm') _make "$@" ;; - 'xr') _release "$@" ;; - 'xg') _go ;; - 'xp') _prebuild "$@" ;; - 'xc') _clean "$@" ;; - 'xy') _analyze_extra "$@" ;; - 'xz') _analyze "$@" ;; - 'xb') _bench "$@" ;; - esac - # unset zforce zargs zbenchflags -} - -[ "." = `dirname $0` ] && _main "$@" - diff --git a/vendor/github.com/ugorji/go/codec/cbor.go b/vendor/github.com/ugorji/go/codec/cbor.go deleted file mode 100644 index 8483fa3a6..000000000 --- a/vendor/github.com/ugorji/go/codec/cbor.go +++ /dev/null @@ -1,884 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "math" - "time" -) - -// major -const ( - cborMajorUint byte = iota - cborMajorNegInt - cborMajorBytes - cborMajorString - cborMajorArray - cborMajorMap - cborMajorTag - cborMajorSimpleOrFloat -) - -// simple -const ( - cborBdFalse byte = 0xf4 + iota - cborBdTrue - cborBdNil - cborBdUndefined - cborBdExt - cborBdFloat16 - cborBdFloat32 - cborBdFloat64 -) - -// indefinite -const ( - cborBdIndefiniteBytes byte = 0x5f - cborBdIndefiniteString byte = 0x7f - cborBdIndefiniteArray byte = 0x9f - cborBdIndefiniteMap byte = 0xbf - cborBdBreak byte = 0xff -) - -// These define some in-stream descriptors for -// manual encoding e.g. when doing explicit indefinite-length -const ( - CborStreamBytes byte = 0x5f - CborStreamString byte = 0x7f - CborStreamArray byte = 0x9f - CborStreamMap byte = 0xbf - CborStreamBreak byte = 0xff -) - -// base values -const ( - cborBaseUint byte = 0x00 - cborBaseNegInt byte = 0x20 - cborBaseBytes byte = 0x40 - cborBaseString byte = 0x60 - cborBaseArray byte = 0x80 - cborBaseMap byte = 0xa0 - cborBaseTag byte = 0xc0 - cborBaseSimple byte = 0xe0 -) - -// const ( -// cborSelfDesrTag byte = 0xd9 -// cborSelfDesrTag2 byte = 0xd9 -// cborSelfDesrTag3 byte = 0xf7 -// ) - -var ( - cbordescSimpleNames = map[byte]string{ - cborBdNil: "nil", - cborBdFalse: "false", - cborBdTrue: "true", - cborBdFloat16: "float", - cborBdFloat32: "float", - cborBdFloat64: "float", - cborBdIndefiniteBytes: "bytes*", - cborBdIndefiniteString: "string*", - cborBdIndefiniteArray: "array*", - cborBdIndefiniteMap: "map*", - } - cbordescMajorNames = map[byte]string{ - cborMajorUint: "(u)int", - cborMajorNegInt: "int", - cborMajorBytes: "bytes", - cborMajorString: "string", - cborMajorArray: "array", - cborMajorMap: "map", - cborMajorTag: "tag", - cborMajorSimpleOrFloat: "simple", - } -) - -func cbordesc(bd byte) (s string) { - bm := bd >> 5 - if bm == cborMajorSimpleOrFloat { - s = cbordescSimpleNames[bd] - if s == "" { - s = "unknown(simple)" - } - } else { - s = cbordescMajorNames[bm] - if s == "" { - s = "unknown" - } - } - return - - // switch bd >> 5 { - // case cborMajorUint: - // return "(u)int" - // case cborMajorNegInt: - // return "int" - // case cborMajorBytes: - // return "bytes" - // case cborMajorString: - // return "string" - // case cborMajorArray: - // return "array" - // case cborMajorMap: - // return "map" - // case cborMajorTag: - // return "tag" - // case cborMajorSimpleOrFloat: // default - // switch bd { - // case cborBdNil: - // return "nil" - // case cborBdFalse: - // return "false" - // case cborBdTrue: - // return "true" - // case cborBdFloat16, cborBdFloat32, cborBdFloat64: - // return "float" - // case cborBdIndefiniteBytes: - // return "bytes*" - // case cborBdIndefiniteString: - // return "string*" - // case cborBdIndefiniteArray: - // return "array*" - // case cborBdIndefiniteMap: - // return "map*" - // default: - // return "unknown(simple)" - // } - // } - // return "unknown" -} - -// ------------------- - -type cborEncDriver struct { - noBuiltInTypes - encDriverNoopContainerWriter - h *CborHandle - x [8]byte - _ [6]uint64 // padding - e Encoder -} - -func (e *cborEncDriver) encoder() *Encoder { - return &e.e -} - -func (e *cborEncDriver) EncodeNil() { - e.e.encWr.writen1(cborBdNil) -} - -func (e *cborEncDriver) EncodeBool(b bool) { - if b { - e.e.encWr.writen1(cborBdTrue) - } else { - e.e.encWr.writen1(cborBdFalse) - } -} - -func (e *cborEncDriver) EncodeFloat32(f float32) { - e.e.encWr.writen1(cborBdFloat32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(math.Float32bits(f)) -} - -func (e *cborEncDriver) EncodeFloat64(f float64) { - e.e.encWr.writen1(cborBdFloat64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(math.Float64bits(f)) -} - -func (e *cborEncDriver) encUint(v uint64, bd byte) { - if v <= 0x17 { - e.e.encWr.writen1(byte(v) + bd) - } else if v <= math.MaxUint8 { - e.e.encWr.writen2(bd+0x18, uint8(v)) - } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd + 0x19) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(v)) - } else if v <= math.MaxUint32 { - e.e.encWr.writen1(bd + 0x1a) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(v)) - } else { // if v <= math.MaxUint64 { - e.e.encWr.writen1(bd + 0x1b) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(v) - } -} - -func (e *cborEncDriver) EncodeInt(v int64) { - if v < 0 { - e.encUint(uint64(-1-v), cborBaseNegInt) - } else { - e.encUint(uint64(v), cborBaseUint) - } -} - -func (e *cborEncDriver) EncodeUint(v uint64) { - e.encUint(v, cborBaseUint) -} - -func (e *cborEncDriver) encLen(bd byte, length int) { - e.encUint(uint64(length), bd) -} - -func (e *cborEncDriver) EncodeTime(t time.Time) { - if t.IsZero() { - e.EncodeNil() - } else if e.h.TimeRFC3339 { - e.encUint(0, cborBaseTag) - e.encStringBytesS(cborBaseString, t.Format(time.RFC3339Nano)) - } else { - e.encUint(1, cborBaseTag) - t = t.UTC().Round(time.Microsecond) - sec, nsec := t.Unix(), uint64(t.Nanosecond()) - if nsec == 0 { - e.EncodeInt(sec) - } else { - e.EncodeFloat64(float64(sec) + float64(nsec)/1e9) - } - } -} - -func (e *cborEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext) { - e.encUint(uint64(xtag), cborBaseTag) - if ext == SelfExt { - rv2 := baseRV(rv) - e.e.encodeValue(rv2, e.h.fnNoExt(rv2.Type())) - } else if v := ext.ConvertExt(rv); v == nil { - e.EncodeNil() - } else { - e.e.encode(v) - } -} - -func (e *cborEncDriver) EncodeRawExt(re *RawExt) { - e.encUint(uint64(re.Tag), cborBaseTag) - // only encodes re.Value (never re.Data) - if re.Value != nil { - e.e.encode(re.Value) - } else { - e.EncodeNil() - } -} - -func (e *cborEncDriver) WriteArrayStart(length int) { - if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdIndefiniteArray) - } else { - e.encLen(cborBaseArray, length) - } -} - -func (e *cborEncDriver) WriteMapStart(length int) { - if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdIndefiniteMap) - } else { - e.encLen(cborBaseMap, length) - } -} - -func (e *cborEncDriver) WriteMapEnd() { - if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdBreak) - } -} - -func (e *cborEncDriver) WriteArrayEnd() { - if e.h.IndefiniteLength { - e.e.encWr.writen1(cborBdBreak) - } -} - -func (e *cborEncDriver) EncodeString(v string) { - if e.h.StringToRaw { - e.EncodeStringBytesRaw(bytesView(v)) - return - } - e.encStringBytesS(cborBaseString, v) -} - -func (e *cborEncDriver) EncodeStringBytesRaw(v []byte) { - if v == nil { - e.EncodeNil() - } else { - e.encStringBytesS(cborBaseBytes, stringView(v)) - } -} - -func (e *cborEncDriver) encStringBytesS(bb byte, v string) { - if e.h.IndefiniteLength { - if bb == cborBaseBytes { - e.e.encWr.writen1(cborBdIndefiniteBytes) - } else { - e.e.encWr.writen1(cborBdIndefiniteString) - } - var vlen uint = uint(len(v)) - blen := vlen / 4 - if blen == 0 { - blen = 64 - } else if blen > 1024 { - blen = 1024 - } - for i := uint(0); i < vlen; { - var v2 string - i2 := i + blen - if i2 >= i && i2 < vlen { - v2 = v[i:i2] - } else { - v2 = v[i:] - } - e.encLen(bb, len(v2)) - e.e.encWr.writestr(v2) - i = i2 - } - e.e.encWr.writen1(cborBdBreak) - } else { - e.encLen(bb, len(v)) - e.e.encWr.writestr(v) - } -} - -// ---------------------- - -type cborDecDriver struct { - decDriverNoopContainerReader - h *CborHandle - bdRead bool - bd byte - st bool // skip tags - fnil bool // found nil - noBuiltInTypes - _ [6]uint64 // padding cache-aligned - d Decoder -} - -func (d *cborDecDriver) decoder() *Decoder { - return &d.d -} - -func (d *cborDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() - d.bdRead = true -} - -func (d *cborDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == cborBdNil || d.bd == cborBdUndefined { - d.bdRead = false - d.fnil = true - null = true - } - return -} - -// skipTags is called to skip any tags in the stream. -// -// Since any value can be tagged, then we should call skipTags -// before any value is decoded. -// -// By definition, skipTags should not be called before -// checking for break, or nil or undefined. -func (d *cborDecDriver) skipTags() { - for d.bd>>5 == cborMajorTag { - d.decUint() - d.bd = d.d.decRd.readn1() - } -} - -// func (d *cborDecDriver) uncacheRead() { -// if d.bdRead { -// d.d.decRd.unreadn1() -// d.bdRead = false -// } -// } - -func (d *cborDecDriver) ContainerType() (vt valueType) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.st { - d.skipTags() - } - if d.bd == cborBdNil { - d.bdRead = false // always consume nil after seeing it in container type - d.fnil = true - return valueTypeNil - } else if d.bd == cborBdIndefiniteBytes || (d.bd>>5 == cborMajorBytes) { - return valueTypeBytes - } else if d.bd == cborBdIndefiniteString || (d.bd>>5 == cborMajorString) { - return valueTypeString - } else if d.bd == cborBdIndefiniteArray || (d.bd>>5 == cborMajorArray) { - return valueTypeArray - } else if d.bd == cborBdIndefiniteMap || (d.bd>>5 == cborMajorMap) { - return valueTypeMap - } - return valueTypeUnset -} - -// func (d *cborDecDriver) Nil() bool { -// return d.fnil -// } - -func (d *cborDecDriver) TryNil() bool { - return d.advanceNil() -} - -func (d *cborDecDriver) CheckBreak() (v bool) { - if !d.bdRead { - d.readNextBd() - } - if d.bd == cborBdBreak { - d.bdRead = false - v = true - } - return -} - -func (d *cborDecDriver) decUint() (ui uint64) { - v := d.bd & 0x1f - if v <= 0x17 { - ui = uint64(v) - } else { - if v == 0x18 { - ui = uint64(d.d.decRd.readn1()) - } else if v == 0x19 { - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) - } else if v == 0x1a { - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) - } else if v == 0x1b { - ui = uint64(bigen.Uint64(d.d.decRd.readx(8))) - } else { - d.d.errorf("invalid descriptor decoding uint: %x/%s", d.bd, cbordesc(d.bd)) - return - } - } - return -} - -func (d *cborDecDriver) decCheckInteger() (neg bool) { - if d.st { - d.skipTags() - } - major := d.bd >> 5 - if major == cborMajorUint { - } else if major == cborMajorNegInt { - neg = true - } else { - d.d.errorf("invalid integer; got major %v from descriptor %x/%s, expected %v or %v", - major, d.bd, cbordesc(d.bd), cborMajorUint, cborMajorNegInt) - } - return -} - -func cborDecInt64(ui uint64, neg bool) (i int64) { - // check if this number can be converted to an int without overflow - if neg { - i = -(chkOvf.SignedIntV(ui + 1)) - } else { - i = chkOvf.SignedIntV(ui) - } - return -} - -func (d *cborDecDriver) decLen() int { - return int(d.decUint()) -} - -func (d *cborDecDriver) decAppendIndefiniteBytes(bs []byte) []byte { - d.bdRead = false - for !d.CheckBreak() { - if major := d.bd >> 5; major != cborMajorBytes && major != cborMajorString { - d.d.errorf("invalid indefinite string/bytes; got major %v, expected %x/%s", - major, d.bd, cbordesc(d.bd)) - } - n := uint(d.decLen()) - oldLen := uint(len(bs)) - newLen := oldLen + n - if newLen > uint(cap(bs)) { - bs2 := make([]byte, newLen, 2*uint(cap(bs))+n) - copy(bs2, bs) - bs = bs2 - } else { - bs = bs[:newLen] - } - d.d.decRd.readb(bs[oldLen:newLen]) - // bs = append(bs, d.d.decRd.readn()...) - d.bdRead = false - } - d.bdRead = false - return bs -} - -func (d *cborDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } - neg := d.decCheckInteger() - ui := d.decUint() - d.bdRead = false - return cborDecInt64(ui, neg) -} - -func (d *cborDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } - if d.decCheckInteger() { - d.d.errorf("cannot assign negative signed value to unsigned type") - } - ui = d.decUint() - d.bdRead = false - return -} - -func (d *cborDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return - } - if d.st { - d.skipTags() - } - switch d.bd { - case cborBdFloat16: - f = float64(math.Float32frombits(halfFloatToFloatBits(bigen.Uint16(d.d.decRd.readx(2))))) - case cborBdFloat32: - f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) - case cborBdFloat64: - f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) - default: - major := d.bd >> 5 - if major == cborMajorUint { - f = float64(cborDecInt64(d.decUint(), false)) - } else if major == cborMajorNegInt { - f = float64(cborDecInt64(d.decUint(), true)) - } else { - d.d.errorf("invalid float descriptor; got %d/%s, expected float16/32/64 or (-)int", - d.bd, cbordesc(d.bd)) - } - } - d.bdRead = false - return -} - -// bool can be decoded from bool only (single byte). -func (d *cborDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return - } - if d.st { - d.skipTags() - } - if d.bd == cborBdTrue { - b = true - } else if d.bd == cborBdFalse { - } else { - d.d.errorf("not bool - %s %x/%s", msgBadDesc, d.bd, cbordesc(d.bd)) - return - } - d.bdRead = false - return -} - -func (d *cborDecDriver) ReadMapStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - if d.st { - d.skipTags() - } - d.bdRead = false - if d.bd == cborBdIndefiniteMap { - return decContainerLenUnknown - } - if d.bd>>5 != cborMajorMap { - d.d.errorf("error reading map; got major type: %x, expected %x/%s", - d.bd>>5, cborMajorMap, cbordesc(d.bd)) - } - return d.decLen() -} - -func (d *cborDecDriver) ReadArrayStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - if d.st { - d.skipTags() - } - d.bdRead = false - if d.bd == cborBdIndefiniteArray { - return decContainerLenUnknown - } - if d.bd>>5 != cborMajorArray { - d.d.errorf("invalid array; got major type: %x, expect: %x/%s", - d.bd>>5, cborMajorArray, cbordesc(d.bd)) - } - return d.decLen() -} - -func (d *cborDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return - } - if d.st { - d.skipTags() - } - if d.bd == cborBdIndefiniteBytes || d.bd == cborBdIndefiniteString { - d.bdRead = false - if bs == nil { - if zerocopy { - return d.decAppendIndefiniteBytes(d.d.b[:0]) - } - return d.decAppendIndefiniteBytes(zeroByteSlice) - } - return d.decAppendIndefiniteBytes(bs[:0]) - } - if d.bd == cborBdIndefiniteArray { - d.bdRead = false - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - if bs == nil { - bs = []byte{} - } else { - bs = bs[:0] - } - for !d.CheckBreak() { - bs = append(bs, uint8(chkOvf.UintV(d.DecodeUint64(), 8))) - } - return bs - } - if d.bd>>5 == cborMajorArray { - d.bdRead = false - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - slen := d.decLen() - bs = usableByteSlice(bs, slen) - for i := 0; i < len(bs); i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs - } - clen := d.decLen() - d.bdRead = false - if d.d.bytes && (zerocopy || d.h.ZeroCopy) { - return d.d.decRd.rb.readx(uint(clen)) - } - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - return decByteSlice(d.d.r(), clen, d.h.MaxInitLen, bs) -} - -func (d *cborDecDriver) DecodeStringAsBytes() (s []byte) { - return d.DecodeBytes(d.d.b[:], true) -} - -func (d *cborDecDriver) DecodeTime() (t time.Time) { - if d.advanceNil() { - return - } - if d.bd>>5 != cborMajorTag { - d.d.errorf("error reading tag; expected major type: %x, got: %x", cborMajorTag, d.bd>>5) - } - xtag := d.decUint() - d.bdRead = false - return d.decodeTime(xtag) -} - -func (d *cborDecDriver) decodeTime(xtag uint64) (t time.Time) { - switch xtag { - case 0: - var err error - if t, err = time.Parse(time.RFC3339, stringView(d.DecodeStringAsBytes())); err != nil { - d.d.errorv(err) - } - case 1: - f1, f2 := math.Modf(d.DecodeFloat64()) - t = time.Unix(int64(f1), int64(f2*1e9)) - default: - d.d.errorf("invalid tag for time.Time - expecting 0 or 1, got 0x%x", xtag) - } - t = t.UTC().Round(time.Microsecond) - return -} - -func (d *cborDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - if d.advanceNil() { - return - } - if d.bd>>5 != cborMajorTag { - d.d.errorf("error reading tag; expected major type: %x, got: %x", cborMajorTag, d.bd>>5) - } - realxtag := d.decUint() - d.bdRead = false - if ext == nil { - re := rv.(*RawExt) - re.Tag = realxtag - d.d.decode(&re.Value) - } else if xtag != realxtag { - d.d.errorf("Wrong extension tag. Got %b. Expecting: %v", realxtag, xtag) - return - } else if ext == SelfExt { - rv2 := baseRV(rv) - d.d.decodeValue(rv2, d.h.fnNoExt(rv2.Type())) - } else { - d.d.interfaceExtConvertAndDecode(rv, ext) - } - d.bdRead = false -} - -func (d *cborDecDriver) DecodeNaked() { - if !d.bdRead { - d.readNextBd() - } - - d.fnil = false - n := d.d.naked() - var decodeFurther bool - - switch d.bd >> 5 { - case cborMajorUint: - if d.h.SignedInteger { - n.v = valueTypeInt - n.i = d.DecodeInt64() - } else { - n.v = valueTypeUint - n.u = d.DecodeUint64() - } - case cborMajorNegInt: - n.v = valueTypeInt - n.i = d.DecodeInt64() - case cborMajorBytes: - fauxUnionReadRawBytes(d, &d.d, n, d.h.RawToString) - case cborMajorString: - n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - case cborMajorArray: - n.v = valueTypeArray - decodeFurther = true - case cborMajorMap: - n.v = valueTypeMap - decodeFurther = true - case cborMajorTag: - n.v = valueTypeExt - n.u = d.decUint() - n.l = nil - if n.u == 0 || n.u == 1 { - d.bdRead = false - n.v = valueTypeTime - n.t = d.decodeTime(n.u) - } else if d.st && d.h.getExtForTag(n.u) == nil { - // d.skipTags() // no need to call this - tags already skipped - d.bdRead = false - d.DecodeNaked() - return // return when done (as true recursive function) - } - case cborMajorSimpleOrFloat: - switch d.bd { - case cborBdNil, cborBdUndefined: - n.v = valueTypeNil - d.fnil = true - case cborBdFalse: - n.v = valueTypeBool - n.b = false - case cborBdTrue: - n.v = valueTypeBool - n.b = true - case cborBdFloat16, cborBdFloat32, cborBdFloat64: - n.v = valueTypeFloat - n.f = d.DecodeFloat64() - case cborBdIndefiniteBytes: - fauxUnionReadRawBytes(d, &d.d, n, d.h.RawToString) - case cborBdIndefiniteString: - n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - case cborBdIndefiniteArray: - n.v = valueTypeArray - decodeFurther = true - case cborBdIndefiniteMap: - n.v = valueTypeMap - decodeFurther = true - default: - d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd) - } - default: // should never happen - d.d.errorf("decodeNaked: Unrecognized d.bd: 0x%x", d.bd) - } - if !decodeFurther { - d.bdRead = false - } -} - -// ------------------------- - -// CborHandle is a Handle for the CBOR encoding format, -// defined at http://tools.ietf.org/html/rfc7049 and documented further at http://cbor.io . -// -// CBOR is comprehensively supported, including support for: -// - indefinite-length arrays/maps/bytes/strings -// - (extension) tags in range 0..0xffff (0 .. 65535) -// - half, single and double-precision floats -// - all numbers (1, 2, 4 and 8-byte signed and unsigned integers) -// - nil, true, false, ... -// - arrays and maps, bytes and text strings -// -// None of the optional extensions (with tags) defined in the spec are supported out-of-the-box. -// Users can implement them as needed (using SetExt), including spec-documented ones: -// - timestamp, BigNum, BigFloat, Decimals, -// - Encoded Text (e.g. URL, regexp, base64, MIME Message), etc. -type CborHandle struct { - binaryEncodingType - // noElemSeparators - BasicHandle - - // IndefiniteLength=true, means that we encode using indefinitelength - IndefiniteLength bool - - // TimeRFC3339 says to encode time.Time using RFC3339 format. - // If unset, we encode time.Time using seconds past epoch. - TimeRFC3339 bool - - // SkipUnexpectedTags says to skip over any tags for which extensions are - // not defined. This is in keeping with the cbor spec on "Optional Tagging of Items". - // - // Furthermore, this allows the skipping over of the Self Describing Tag 0xd9d9f7. - SkipUnexpectedTags bool - - _ [7]uint64 // padding (cache-aligned) -} - -// Name returns the name of the handle: cbor -func (h *CborHandle) Name() string { return "cbor" } - -func (h *CborHandle) newEncDriver() encDriver { - var e = &cborEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e -} - -func (h *CborHandle) newDecDriver() decDriver { - d := &cborDecDriver{h: h, st: h.SkipUnexpectedTags} - d.d.d = d - d.d.cbor = true - d.d.init(h) - d.reset() - return d -} - -func (e *cborEncDriver) reset() { -} - -func (d *cborDecDriver) reset() { - d.bd = 0 - d.bdRead = false - d.fnil = false - d.st = d.h.SkipUnexpectedTags -} - -var _ decDriver = (*cborDecDriver)(nil) -var _ encDriver = (*cborEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/cbor_test.go b/vendor/github.com/ugorji/go/codec/cbor_test.go deleted file mode 100644 index 31b9a313f..000000000 --- a/vendor/github.com/ugorji/go/codec/cbor_test.go +++ /dev/null @@ -1,368 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bufio" - "bytes" - "encoding/hex" - "math" - "os" - "regexp" - "strings" - "testing" -) - -func TestCborIndefiniteLength(t *testing.T) { - oldMapType := testCborH.MapType - defer func() { - testCborH.MapType = oldMapType - }() - testCborH.MapType = testMapStrIntfTyp - // var ( - // M1 map[string][]byte - // M2 map[uint64]bool - // L1 []interface{} - // S1 []string - // B1 []byte - // ) - var v, vv interface{} - // define it (v), encode it using indefinite lengths, decode it (vv), compare v to vv - v = map[string]interface{}{ - "one-byte-key": []byte{1, 2, 3, 4, 5, 6}, - "two-string-key": "two-value", - "three-list-key": []interface{}{true, false, uint64(1), int64(-1)}, - } - var buf bytes.Buffer - // buf.Reset() - e := NewEncoder(&buf, testCborH) - buf.WriteByte(cborBdIndefiniteMap) - //---- - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode("one-") - e.MustEncode("byte-") - e.MustEncode("key") - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdIndefiniteBytes) - e.MustEncode([]byte{1, 2, 3}) - e.MustEncode([]byte{4, 5, 6}) - buf.WriteByte(cborBdBreak) - - //---- - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode("two-") - e.MustEncode("string-") - e.MustEncode("key") - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode([]byte("two-")) // encode as bytes, to check robustness of code - e.MustEncode([]byte("value")) - buf.WriteByte(cborBdBreak) - - //---- - buf.WriteByte(cborBdIndefiniteString) - e.MustEncode("three-") - e.MustEncode("list-") - e.MustEncode("key") - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdIndefiniteArray) - e.MustEncode(true) - e.MustEncode(false) - e.MustEncode(uint64(1)) - e.MustEncode(int64(-1)) - buf.WriteByte(cborBdBreak) - - buf.WriteByte(cborBdBreak) // close map - - NewDecoderBytes(buf.Bytes(), testCborH).MustDecode(&vv) - if err := deepEqual(v, vv); err != nil { - t.Logf("-------- Before and After marshal do not match: Error: %v", err) - if testVerbose { - t.Logf(" ....... GOLDEN: (%T) %#v", v, v) - t.Logf(" ....... DECODED: (%T) %#v", vv, vv) - } - t.FailNow() - } -} - -type testCborGolden struct { - Base64 string `codec:"cbor"` - Hex string `codec:"hex"` - Roundtrip bool `codec:"roundtrip"` - Decoded interface{} `codec:"decoded"` - Diagnostic string `codec:"diagnostic"` - Skip bool `codec:"skip"` -} - -// Some tests are skipped because they include numbers outside the range of int64/uint64 -func TestCborGoldens(t *testing.T) { - oldMapType := testCborH.MapType - defer func() { - testCborH.MapType = oldMapType - }() - testCborH.MapType = testMapStrIntfTyp - // decode test-cbor-goldens.json into a list of []*testCborGolden - // for each one, - // - decode hex into []byte bs - // - decode bs into interface{} v - // - compare both using deepequal - // - for any miss, record it - var gs []*testCborGolden - f, err := os.Open("test-cbor-goldens.json") - if err != nil { - t.Logf("error opening test-cbor-goldens.json: %v", err) - t.FailNow() - } - defer f.Close() - jh := new(JsonHandle) - jh.MapType = testMapStrIntfTyp - // d := NewDecoder(f, jh) - d := NewDecoder(bufio.NewReader(f), jh) - // err = d.Decode(&gs) - d.MustDecode(&gs) - if err != nil { - t.Logf("error json decoding test-cbor-goldens.json: %v", err) - t.FailNow() - } - - tagregex := regexp.MustCompile(`[\d]+\(.+?\)`) - hexregex := regexp.MustCompile(`h'([0-9a-fA-F]*)'`) - for i, g := range gs { - // fmt.Printf("%v, skip: %v, isTag: %v, %s\n", i, g.Skip, tagregex.MatchString(g.Diagnostic), g.Diagnostic) - // skip tags or simple or those with prefix, as we can't verify them. - if g.Skip || strings.HasPrefix(g.Diagnostic, "simple(") || tagregex.MatchString(g.Diagnostic) { - // fmt.Printf("%v: skipped\n", i) - if testVerbose { - t.Logf("[%v] skipping because skip=true OR unsupported simple value or Tag Value", i) - } - continue - } - // println("++++++++++++", i, "g.Diagnostic", g.Diagnostic) - if hexregex.MatchString(g.Diagnostic) { - // println(i, "g.Diagnostic matched hex") - if s2 := g.Diagnostic[2 : len(g.Diagnostic)-1]; s2 == "" { - g.Decoded = zeroByteSlice - } else if bs2, err2 := hex.DecodeString(s2); err2 == nil { - g.Decoded = bs2 - } - // fmt.Printf("%v: hex: %v\n", i, g.Decoded) - } - bs, err := hex.DecodeString(g.Hex) - if err != nil { - t.Logf("[%v] error hex decoding %s [%v]: %v", i, g.Hex, g.Hex, err) - t.FailNow() - } - var v interface{} - NewDecoderBytes(bs, testCborH).MustDecode(&v) - if _, ok := v.(RawExt); ok { - continue - } - // check the diagnostics to compare - switch g.Diagnostic { - case "Infinity": - b := math.IsInf(v.(float64), 1) - testCborError(t, i, math.Inf(1), v, nil, &b) - case "-Infinity": - b := math.IsInf(v.(float64), -1) - testCborError(t, i, math.Inf(-1), v, nil, &b) - case "NaN": - // println(i, "checking NaN") - b := math.IsNaN(v.(float64)) - testCborError(t, i, math.NaN(), v, nil, &b) - case "undefined": - b := v == nil - testCborError(t, i, nil, v, nil, &b) - default: - v0 := g.Decoded - // testCborCoerceJsonNumber(rv4i(&v0)) - testCborError(t, i, v0, v, deepEqual(v0, v), nil) - } - } -} - -func testCborError(t *testing.T, i int, v0, v1 interface{}, err error, equal *bool) { - if err == nil && equal == nil { - // fmt.Printf("%v testCborError passed (err and equal nil)\n", i) - return - } - if err != nil { - t.Logf("[%v] deepEqual error: %v", i, err) - if testVerbose { - t.Logf(" ....... GOLDEN: (%T) %#v", v0, v0) - t.Logf(" ....... DECODED: (%T) %#v", v1, v1) - } - t.FailNow() - } - if equal != nil && !*equal { - t.Logf("[%v] values not equal", i) - if testVerbose { - t.Logf(" ....... GOLDEN: (%T) %#v", v0, v0) - t.Logf(" ....... DECODED: (%T) %#v", v1, v1) - } - t.FailNow() - } - // fmt.Printf("%v testCborError passed (checks passed)\n", i) -} - -func TestCborHalfFloat(t *testing.T) { - m := map[uint16]float64{ - // using examples from - // https://en.wikipedia.org/wiki/Half-precision_floating-point_format - 0x3c00: 1, - 0x3c01: 1 + math.Pow(2, -10), - 0xc000: -2, - 0x7bff: 65504, - 0x0400: math.Pow(2, -14), - 0x03ff: math.Pow(2, -14) - math.Pow(2, -24), - 0x0001: math.Pow(2, -24), - 0x0000: 0, - 0x8000: -0.0, - } - var ba [3]byte - ba[0] = cborBdFloat16 - var res float64 - for k, v := range m { - res = 0 - bigen.PutUint16(ba[1:], k) - testUnmarshalErr(&res, ba[:3], testCborH, t, "-") - if res == v { - if testVerbose { - t.Logf("equal floats: from %x %b, %v", k, k, v) - } - } else { - t.Logf("unequal floats: from %x %b, %v != %v", k, k, res, v) - t.FailNow() - } - } -} - -func TestCborSkipTags(t *testing.T) { - type Tcbortags struct { - A string - M map[string]interface{} - // A []interface{} - } - var b8 [8]byte - var w bytesEncAppender - w.b = []byte{} - - // To make it easier, - // - use tags between math.MaxUint8 and math.MaxUint16 (incl SelfDesc) - // - use 1 char strings for key names - // - use 3-6 char strings for map keys - // - use integers that fit in 2 bytes (between 0x20 and 0xff) - - var tags = [...]uint64{math.MaxUint8 * 2, math.MaxUint8 * 8, 55799, math.MaxUint16 / 2} - var tagIdx int - var doAddTag bool - addTagFn8To16 := func() { - if !doAddTag { - return - } - // writes a tag between MaxUint8 and MaxUint16 (culled from cborEncDriver.encUint) - w.writen1(cborBaseTag + 0x19) - // bigenHelper.writeUint16 - bigen.PutUint16(b8[:2], uint16(tags[tagIdx%len(tags)])) - w.writeb(b8[:2]) - tagIdx++ - } - - var v Tcbortags - v.A = "cbor" - v.M = make(map[string]interface{}) - v.M["111"] = uint64(111) - v.M["111.11"] = 111.11 - v.M["true"] = true - // v.A = append(v.A, 222, 22.22, "true") - - // make stream manually (interspacing tags around it) - // WriteMapStart - e.encLen(cborBaseMap, length) - encUint(length, bd) - // EncodeStringEnc - e.encStringBytesS(cborBaseString, v) - - fnEncode := func() { - w.b = w.b[:0] - addTagFn8To16() - // write v (Tcbortags, with 3 fields = map with 3 entries) - w.writen1(2 + cborBaseMap) // 3 fields = 3 entries - // write v.A - var s = "A" - w.writen1(byte(len(s)) + cborBaseString) - w.writestr(s) - w.writen1(byte(len(v.A)) + cborBaseString) - w.writestr(v.A) - //w.writen1(0) - - addTagFn8To16() - s = "M" - w.writen1(byte(len(s)) + cborBaseString) - w.writestr(s) - - addTagFn8To16() - w.writen1(byte(len(v.M)) + cborBaseMap) - - addTagFn8To16() - s = "111" - w.writen1(byte(len(s)) + cborBaseString) - w.writestr(s) - w.writen2(cborBaseUint+0x18, uint8(111)) - - addTagFn8To16() - s = "111.11" - w.writen1(byte(len(s)) + cborBaseString) - w.writestr(s) - w.writen1(cborBdFloat64) - bigen.PutUint64(b8[:8], math.Float64bits(111.11)) - w.writeb(b8[:8]) - - addTagFn8To16() - s = "true" - w.writen1(byte(len(s)) + cborBaseString) - w.writestr(s) - w.writen1(cborBdTrue) - } - - var h CborHandle - h.SkipUnexpectedTags = true - h.Canonical = true - - var gold []byte - NewEncoderBytes(&gold, &h).MustEncode(v) - // xdebug2f("encoded: gold: %v", gold) - - // w.b is the encoded bytes - var v2 Tcbortags - doAddTag = false - fnEncode() - // xdebug2f("manual: no-tags: %v", w.b) - - testDeepEqualErr(gold, w.b, t, "cbor-skip-tags--bytes---") - NewDecoderBytes(w.b, &h).MustDecode(&v2) - testDeepEqualErr(v, v2, t, "cbor-skip-tags--no-tags-") - - var v3 Tcbortags - doAddTag = true - fnEncode() - // xdebug2f("manual: has-tags: %v", w.b) - NewDecoderBytes(w.b, &h).MustDecode(&v3) - testDeepEqualErr(v, v2, t, "cbor-skip-tags--has-tags") - - // Github 300 - tests naked path - { - expected := []interface{}{"x", uint64(0x0)} - toDecode := []byte{0x82, 0x61, 0x78, 0x00} - - var raw interface{} - - NewDecoderBytes(toDecode, &h).MustDecode(&raw) - testDeepEqualErr(expected, raw, t, "cbor-skip-tags--gh-300---no-skips") - - toDecode = []byte{0xd9, 0xd9, 0xf7, 0x82, 0x61, 0x78, 0x00} - raw = nil - NewDecoderBytes(toDecode, &h).MustDecode(&raw) - testDeepEqualErr(expected, raw, t, "cbor-skip-tags--gh-300--has-skips") - } -} diff --git a/vendor/github.com/ugorji/go/codec/codec_test.go b/vendor/github.com/ugorji/go/codec/codec_test.go deleted file mode 100644 index d3abb619c..000000000 --- a/vendor/github.com/ugorji/go/codec/codec_test.go +++ /dev/null @@ -1,4178 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// TODO: -// -// We get wrong file/line numbers for calls to test(Marshal|Unmarshal|DeepEqual)Err helper functions. -// This is solved by t.Helper function, but this only exists from go1.9+. -// -// For now, we don't include t.Helper, so the tests can be run (without a suite) -// in go 1.4+ - -import ( - "bufio" - "bytes" - "encoding/gob" - "errors" - "fmt" - "io" - "io/ioutil" - "math" - "math/rand" - "net" - "net/rpc" - "os" - "os/exec" - "path/filepath" - "reflect" - "runtime" - "strconv" - "strings" - "sync/atomic" - "testing" - "time" -) - -func init() { - testPreInitFns = append(testPreInitFns, testInit) - // fmt.Printf("sizeof: Decoder: %v, Encoder: %v, fauxUnion: %v\n", - // reflect.TypeOf((*Decoder)(nil)).Elem().Size(), - // reflect.TypeOf((*Encoder)(nil)).Elem().Size(), - // reflect.TypeOf((*fauxUnion)(nil)).Elem().Size(), - // ) -} - -type testCustomStringT string - -// make this a mapbyslice -type testMbsT []interface{} - -func (testMbsT) MapBySlice() {} - -type testMbsCustStrT []testCustomStringT - -func (testMbsCustStrT) MapBySlice() {} - -// type testSelferRecur struct{} - -// func (s *testSelferRecur) CodecEncodeSelf(e *Encoder) { -// e.MustEncode(s) -// } -// func (s *testSelferRecur) CodecDecodeSelf(d *Decoder) { -// d.MustDecode(s) -// } - -type testIntfMapI interface { - GetIntfMapV() string -} - -type testIntfMapT1 struct { - IntfMapV string -} - -func (x *testIntfMapT1) GetIntfMapV() string { return x.IntfMapV } - -type testIntfMapT2 struct { - IntfMapV string -} - -func (x testIntfMapT2) GetIntfMapV() string { return x.IntfMapV } - -var testErrWriterErr = errors.New("testErrWriterErr") - -type testErrWriter struct{} - -func (x *testErrWriter) Write(p []byte) (int, error) { - return 0, testErrWriterErr -} - -// ---- - -type testVerifyFlag uint8 - -const ( - _ testVerifyFlag = 1 << iota - testVerifyMapTypeSame - testVerifyMapTypeStrIntf - testVerifyMapTypeIntfIntf - // testVerifySliceIntf - testVerifyForPython - testVerifyDoNil - testVerifyTimeAsInteger -) - -func (f testVerifyFlag) isset(v testVerifyFlag) bool { - return f&v == v -} - -// const testSkipRPCTests = false - -var ( - testTableNumPrimitives int - testTableIdxTime int - testTableNumMaps int - - // set this when running using bufio, etc - testSkipRPCTests = false -) - -var ( - skipVerifyVal interface{} = &(struct{}{}) - - testMapStrIntfTyp = reflect.TypeOf(map[string]interface{}(nil)) - - // For Go Time, do not use a descriptive timezone. - // It's unnecessary, and makes it harder to do a reflect.DeepEqual. - // The Offset already tells what the offset should be, if not on UTC and unknown zone name. - timeLoc = time.FixedZone("", -8*60*60) // UTC-08:00 //time.UTC-8 - timeToCompare1 = time.Date(2012, 2, 2, 2, 2, 2, 2000, timeLoc).UTC() - timeToCompare2 = time.Date(1900, 2, 2, 2, 2, 2, 2000, timeLoc).UTC() - timeToCompare3 = time.Unix(0, 270).UTC() // use value that must be encoded as uint64 for nanoseconds (for cbor/msgpack comparison) - //timeToCompare4 = time.Time{}.UTC() // does not work well with simple cbor time encoding (overflow) - timeToCompare4 = time.Unix(-2013855848, 4223).UTC() - - table []interface{} // main items we encode - // will encode a float32 as float64, or large int as uint - testRpcInt = new(TestRpcInt) -) - -var wrapInt64Typ = reflect.TypeOf(wrapInt64(0)) -var wrapBytesTyp = reflect.TypeOf(wrapBytes(nil)) -var testSelfExtTyp = reflect.TypeOf((*TestSelfExtImpl)(nil)).Elem() -var testSelfExt2Typ = reflect.TypeOf((*TestSelfExtImpl2)(nil)).Elem() - -func testByteBuf(in []byte) *bytes.Buffer { - return bytes.NewBuffer(in) -} - -type TestABC struct { - A, B, C string -} - -func (x *TestABC) MarshalBinary() ([]byte, error) { - return []byte(fmt.Sprintf("%s %s %s", x.A, x.B, x.C)), nil -} -func (x *TestABC) MarshalText() ([]byte, error) { - return []byte(fmt.Sprintf("%s %s %s", x.A, x.B, x.C)), nil -} -func (x *TestABC) MarshalJSON() ([]byte, error) { - return []byte(fmt.Sprintf(`"%s %s %s"`, x.A, x.B, x.C)), nil -} - -func (x *TestABC) UnmarshalBinary(data []byte) (err error) { - ss := strings.Split(string(data), " ") - x.A, x.B, x.C = ss[0], ss[1], ss[2] - return -} -func (x *TestABC) UnmarshalText(data []byte) (err error) { - return x.UnmarshalBinary(data) -} -func (x *TestABC) UnmarshalJSON(data []byte) (err error) { - return x.UnmarshalBinary(data[1 : len(data)-1]) -} - -type TestABC2 struct { - A, B, C string -} - -func (x TestABC2) MarshalText() ([]byte, error) { - return []byte(fmt.Sprintf("%s %s %s", x.A, x.B, x.C)), nil -} -func (x *TestABC2) UnmarshalText(data []byte) (err error) { - ss := strings.Split(string(data), " ") - x.A, x.B, x.C = ss[0], ss[1], ss[2] - return - // _, err = fmt.Sscanf(string(data), "%s %s %s", &x.A, &x.B, &x.C) -} - -type TestSimplish struct { - Ii int - Ss string - Ar [2]*TestSimplish - Sl []*TestSimplish - Mm map[string]*TestSimplish -} - -type TestRpcABC struct { - A, B, C string -} - -type TestRpcInt struct { - i int -} - -func (r *TestRpcInt) Update(n int, res *int) error { r.i = n; *res = r.i; return nil } -func (r *TestRpcInt) Square(ignore int, res *int) error { *res = r.i * r.i; return nil } -func (r *TestRpcInt) Mult(n int, res *int) error { *res = r.i * n; return nil } -func (r *TestRpcInt) EchoStruct(arg TestRpcABC, res *string) error { - *res = fmt.Sprintf("%#v", arg) - return nil -} -func (r *TestRpcInt) Echo123(args []string, res *string) error { - *res = fmt.Sprintf("%#v", args) - return nil -} - -type TestRawValue struct { - R Raw - I int -} - -// ---- - -type testUnixNanoTimeExt struct { - // keep timestamp here, so that do not incur interface-conversion costs - // ts int64 -} - -func (x *testUnixNanoTimeExt) WriteExt(v interface{}) []byte { - v2 := v.(*time.Time) - bs := make([]byte, 8) - bigen.PutUint64(bs, uint64(v2.UnixNano())) - return bs -} -func (x *testUnixNanoTimeExt) ReadExt(v interface{}, bs []byte) { - v2 := v.(*time.Time) - ui := bigen.Uint64(bs) - *v2 = time.Unix(0, int64(ui)).UTC() -} -func (x *testUnixNanoTimeExt) ConvertExt(v interface{}) interface{} { - v2 := v.(*time.Time) // structs are encoded by passing the ptr - return v2.UTC().UnixNano() -} - -func (x *testUnixNanoTimeExt) UpdateExt(dest interface{}, v interface{}) { - // xdebugf("testUnixNanoTimeExt: v: %#v", v) - tt := dest.(*time.Time) - *tt = time.Unix(0, v.(int64)).UTC() - // switch v2 := v.(type) { - // case int64: - // *tt = time.Unix(0, v2).UTC() - // case uint64: - // *tt = time.Unix(0, int64(v2)).UTC() - // //case float64: - // //case string: - // default: - // panic(fmt.Sprintf("unsupported format for time conversion: expecting int64/uint64; got %T", v)) - // } -} - -// ---- - -type wrapInt64Ext int64 - -func (x *wrapInt64Ext) WriteExt(v interface{}) []byte { - v2 := uint64(int64(v.(wrapInt64))) - bs := make([]byte, 8) - bigen.PutUint64(bs, v2) - return bs -} -func (x *wrapInt64Ext) ReadExt(v interface{}, bs []byte) { - v2 := v.(*wrapInt64) - ui := bigen.Uint64(bs) - *v2 = wrapInt64(int64(ui)) -} -func (x *wrapInt64Ext) ConvertExt(v interface{}) interface{} { - return int64(v.(wrapInt64)) -} -func (x *wrapInt64Ext) UpdateExt(dest interface{}, v interface{}) { - v2 := dest.(*wrapInt64) - *v2 = wrapInt64(v.(int64)) -} - -// ---- - -type wrapBytesExt struct{} - -func (x *wrapBytesExt) WriteExt(v interface{}) []byte { - return ([]byte)(v.(wrapBytes)) -} -func (x *wrapBytesExt) ReadExt(v interface{}, bs []byte) { - v2 := v.(*wrapBytes) - *v2 = wrapBytes(bs) -} -func (x *wrapBytesExt) ConvertExt(v interface{}) interface{} { - return ([]byte)(v.(wrapBytes)) -} -func (x *wrapBytesExt) UpdateExt(dest interface{}, v interface{}) { - v2 := dest.(*wrapBytes) - // some formats (e.g. json) cannot nakedly determine []byte from string, so expect both - switch v3 := v.(type) { - case []byte: - *v2 = wrapBytes(v3) - case string: - *v2 = wrapBytes([]byte(v3)) - default: - panic("UpdateExt for wrapBytesExt expects string or []byte") - } - // *v2 = wrapBytes(v.([]byte)) -} - -// ---- - -// timeExt is an extension handler for time.Time, that uses binc model for encoding/decoding time. -// we used binc model, as that is the only custom time representation that we designed ourselves. -type timeExt struct{} - -func (x timeExt) WriteExt(v interface{}) (bs []byte) { - switch v2 := v.(type) { - case time.Time: - bs = bincEncodeTime(v2) - case *time.Time: - bs = bincEncodeTime(*v2) - default: - panic(fmt.Errorf("unsupported format for time conversion: expecting time.Time; got %T", v2)) - } - return -} -func (x timeExt) ReadExt(v interface{}, bs []byte) { - tt, err := bincDecodeTime(bs) - if err != nil { - panic(err) - } - *(v.(*time.Time)) = tt -} - -func (x timeExt) ConvertExt(v interface{}) interface{} { - return x.WriteExt(v) -} -func (x timeExt) UpdateExt(v interface{}, src interface{}) { - x.ReadExt(v, src.([]byte)) -} - -// ---- - -func testCodecEncode(ts interface{}, bsIn []byte, - fn func([]byte) *bytes.Buffer, h Handle) (bs []byte, err error) { - return sTestCodecEncode(ts, bsIn, fn, h, basicHandle(h)) -} - -func testCodecDecode(bs []byte, ts interface{}, h Handle) (err error) { - return sTestCodecDecode(bs, ts, h, basicHandle(h)) -} - -func checkErrT(t *testing.T, err error) { - if err != nil { - t.Logf(err.Error()) - t.FailNow() - } -} - -func checkEqualT(t *testing.T, v1 interface{}, v2 interface{}, desc string) { - if err := deepEqual(v1, v2); err != nil { - t.Logf("Not Equal: %s: %v. v1: %v, v2: %v", desc, err, v1, v2) - t.FailNow() - } -} - -func testInit() { - gob.Register(new(TestStrucFlex)) - if testInitDebug { // TODO: fix testInit to be done on demand, and uncomment below - // ts0 := newTestStrucFlex(2, testNumRepeatString, false, !testSkipIntf, testMapStringKeyOnly) - // logTv(nil, "====> depth: %v, ts: %#v\n", 2, ts0) - } - - for _, v := range testHandles { - bh := basicHandle(v) - // pre-fill them first - bh.EncodeOptions = testEncodeOptions - bh.DecodeOptions = testDecodeOptions - // bh.InterfaceReset = true - // bh.PreferArrayOverSlice = true - // modify from flag'ish things - bh.MaxInitLen = testMaxInitLen - } - - testMsgpackH.WriteExt = true - - var tTimeExt timeExt - var tBytesExt wrapBytesExt - var tI64Ext wrapInt64Ext - - // create legacy functions suitable for deprecated AddExt functionality, - // and use on some places for testSimpleH e.g. for time.Time and wrapInt64 - var ( - myExtEncFn = func(x BytesExt, rv reflect.Value) (bs []byte, err error) { - defer panicToErr(errDecoratorDef{}, &err) - bs = x.WriteExt(rv.Interface()) - return - } - myExtDecFn = func(x BytesExt, rv reflect.Value, bs []byte) (err error) { - defer panicToErr(errDecoratorDef{}, &err) - x.ReadExt(rv.Interface(), bs) - return - } - timeExtEncFn = func(rv reflect.Value) (bs []byte, err error) { return myExtEncFn(tTimeExt, rv) } - timeExtDecFn = func(rv reflect.Value, bs []byte) (err error) { return myExtDecFn(tTimeExt, rv, bs) } - wrapInt64ExtEncFn = func(rv reflect.Value) (bs []byte, err error) { return myExtEncFn(&tI64Ext, rv) } - wrapInt64ExtDecFn = func(rv reflect.Value, bs []byte) (err error) { return myExtDecFn(&tI64Ext, rv, bs) } - ) - - chkErr := func(err error) { - if err != nil { - panic(err) - } - } - - // time.Time is a native type, so extensions will have no effect. - // However, we add these here to ensure nothing happens. - chkErr(testSimpleH.AddExt(timeTyp, 1, timeExtEncFn, timeExtDecFn)) - // testBincH.SetBytesExt(timeTyp, 1, timeExt{}) // time is builtin for binc - chkErr(testMsgpackH.SetBytesExt(timeTyp, 1, timeExt{})) - chkErr(testCborH.SetInterfaceExt(timeTyp, 1, &testUnixNanoTimeExt{})) - // testJsonH.SetInterfaceExt(timeTyp, 1, &testUnixNanoTimeExt{}) - - // Add extensions for the testSelfExt - chkErr(testSimpleH.SetBytesExt(testSelfExtTyp, 78, SelfExt)) - chkErr(testMsgpackH.SetBytesExt(testSelfExtTyp, 78, SelfExt)) - chkErr(testBincH.SetBytesExt(testSelfExtTyp, 78, SelfExt)) - chkErr(testJsonH.SetInterfaceExt(testSelfExtTyp, 78, SelfExt)) - chkErr(testCborH.SetInterfaceExt(testSelfExtTyp, 78, SelfExt)) - - chkErr(testSimpleH.SetBytesExt(testSelfExt2Typ, 79, SelfExt)) - chkErr(testMsgpackH.SetBytesExt(testSelfExt2Typ, 79, SelfExt)) - chkErr(testBincH.SetBytesExt(testSelfExt2Typ, 79, SelfExt)) - chkErr(testJsonH.SetInterfaceExt(testSelfExt2Typ, 79, SelfExt)) - chkErr(testCborH.SetInterfaceExt(testSelfExt2Typ, 79, SelfExt)) - - // Now, add extensions for the type wrapInt64 and wrapBytes, - // so we can execute the Encode/Decode Ext paths. - - chkErr(testSimpleH.SetBytesExt(wrapBytesTyp, 32, &tBytesExt)) - chkErr(testMsgpackH.SetBytesExt(wrapBytesTyp, 32, &tBytesExt)) - chkErr(testBincH.SetBytesExt(wrapBytesTyp, 32, &tBytesExt)) - chkErr(testJsonH.SetInterfaceExt(wrapBytesTyp, 32, &tBytesExt)) - chkErr(testCborH.SetInterfaceExt(wrapBytesTyp, 32, &tBytesExt)) - - chkErr(testSimpleH.AddExt(wrapInt64Typ, 16, wrapInt64ExtEncFn, wrapInt64ExtDecFn)) - // chkErr(testSimpleH.SetBytesExt(wrapInt64Typ, 16, &tI64Ext)) - chkErr(testMsgpackH.SetBytesExt(wrapInt64Typ, 16, &tI64Ext)) - chkErr(testBincH.SetBytesExt(wrapInt64Typ, 16, &tI64Ext)) - chkErr(testJsonH.SetInterfaceExt(wrapInt64Typ, 16, &tI64Ext)) - chkErr(testCborH.SetInterfaceExt(wrapInt64Typ, 16, &tI64Ext)) - - // primitives MUST be an even number, so it can be used as a mapBySlice also. - primitives := []interface{}{ - int8(-8), - int16(-1616), - int32(-32323232), - int64(-6464646464646464), - uint8(192), - uint16(1616), - uint32(32323232), - uint64(6464646464646464), - byte(192), - float32(-3232.0), - float64(-6464646464.0), - float32(3232.0), - float64(6464.0), - float64(6464646464.0), - false, - true, - "null", - nil, - "some&day>some lp { // testTableNumPrimitives+1 is the mapBySlice - av[i] = skipVerifyVal - continue - } - av[i] = testVerifyVal(v, f, h) - } - // only do the python verify up to the maps, skipping the last 2 maps. - av = av[:testTableNumPrimitives+2+testTableNumMaps-2] - case f.isset(testVerifyDoNil): - for i, v := range table { - if i > lp { - av[i] = skipVerifyVal - continue - } - av[i] = testVerifyVal(v, f, h) - } - default: - for i, v := range table { - if i == lp { - av[i] = skipVerifyVal - continue - } - //av[i] = testVerifyVal(v, testVerifyMapTypeSame) - switch v.(type) { - case []interface{}: - av[i] = testVerifyVal(v, f, h) - case testMbsT: - av[i] = testVerifyVal(v, f, h) - case map[string]interface{}: - av[i] = testVerifyVal(v, f, h) - case map[interface{}]interface{}: - av[i] = testVerifyVal(v, f, h) - case time.Time: - av[i] = testVerifyVal(v, f, h) - default: - av[i] = v - } - } - } - return -} - -func testVerifyValInt(v int64, isMsgp bool) (v2 interface{}) { - if isMsgp { - if v >= 0 && v <= 127 { - v2 = uint64(v) - } else { - v2 = int64(v) - } - } else if v >= 0 { - v2 = uint64(v) - } else { - v2 = int64(v) - } - return -} - -func testVerifyVal(v interface{}, f testVerifyFlag, h Handle) (v2 interface{}) { - //for python msgpack, - // - all positive integers are unsigned 64-bit ints - // - all floats are float64 - _, isMsgp := h.(*MsgpackHandle) - _, isCbor := h.(*CborHandle) - switch iv := v.(type) { - case int8: - v2 = testVerifyValInt(int64(iv), isMsgp) - // fmt.Printf(">>>> is msgp: %v, v: %T, %v ==> v2: %T, %v\n", isMsgp, v, v, v2, v2) - case int16: - v2 = testVerifyValInt(int64(iv), isMsgp) - case int32: - v2 = testVerifyValInt(int64(iv), isMsgp) - case int64: - v2 = testVerifyValInt(int64(iv), isMsgp) - case uint8: - v2 = uint64(iv) - case uint16: - v2 = uint64(iv) - case uint32: - v2 = uint64(iv) - case uint64: - v2 = uint64(iv) - case float32: - v2 = float64(iv) - case float64: - v2 = float64(iv) - case []interface{}: - m2 := make([]interface{}, len(iv)) - for j, vj := range iv { - m2[j] = testVerifyVal(vj, f, h) - } - v2 = m2 - case testMbsT: - m2 := make([]interface{}, len(iv)) - for j, vj := range iv { - m2[j] = testVerifyVal(vj, f, h) - } - v2 = testMbsT(m2) - case map[string]bool: - switch { - case f.isset(testVerifyMapTypeSame): - m2 := make(map[string]bool) - for kj, kv := range iv { - m2[kj] = kv - } - v2 = m2 - case f.isset(testVerifyMapTypeStrIntf): - m2 := make(map[string]interface{}) - for kj, kv := range iv { - m2[kj] = kv - } - v2 = m2 - case f.isset(testVerifyMapTypeIntfIntf): - m2 := make(map[interface{}]interface{}) - for kj, kv := range iv { - m2[kj] = kv - } - v2 = m2 - } - case map[string]interface{}: - switch { - case f.isset(testVerifyMapTypeSame): - m2 := make(map[string]interface{}) - for kj, kv := range iv { - m2[kj] = testVerifyVal(kv, f, h) - } - v2 = m2 - case f.isset(testVerifyMapTypeStrIntf): - m2 := make(map[string]interface{}) - for kj, kv := range iv { - m2[kj] = testVerifyVal(kv, f, h) - } - v2 = m2 - case f.isset(testVerifyMapTypeIntfIntf): - m2 := make(map[interface{}]interface{}) - for kj, kv := range iv { - m2[kj] = testVerifyVal(kv, f, h) - } - v2 = m2 - } - case map[interface{}]interface{}: - m2 := make(map[interface{}]interface{}) - for kj, kv := range iv { - m2[testVerifyVal(kj, f, h)] = testVerifyVal(kv, f, h) - } - v2 = m2 - case time.Time: - switch { - case f.isset(testVerifyTimeAsInteger): - if iv2 := iv.UnixNano(); iv2 >= 0 { - v2 = uint64(iv2) - } else { - v2 = int64(iv2) - } - case isMsgp: - v2 = iv.UTC() - case isCbor: - // fmt.Printf("%%%% cbor verifier\n") - v2 = iv.UTC().Round(time.Microsecond) - default: - v2 = v - } - default: - v2 = v - } - return -} - -func testUnmarshal(v interface{}, data []byte, h Handle) (err error) { - return testCodecDecode(data, v, h) -} - -func testMarshal(v interface{}, h Handle) (bs []byte, err error) { - return testCodecEncode(v, nil, testByteBuf, h) -} - -func testMarshalErr(v interface{}, h Handle, t *testing.T, name string) (bs []byte) { - // t.Helper() - bs, err := testMarshal(v, h) - if err != nil { - t.Logf("%s: marshal failed: %v", name, err) - if testVerbose { - t.Logf("Error encoding %s: %v, Err: %v", name, v, err) - } - t.FailNow() - } - return -} - -func testUnmarshalErr(v interface{}, data []byte, h Handle, t *testing.T, name string) { - // t.Helper() - if err := testUnmarshal(v, data, h); err != nil { - t.Logf("%s: unmarshal failed: %v", name, err) - if testVerbose { - t.Logf("Error Decoding into %s: %v, Err: %v", name, v, err) - } - t.FailNow() - } -} - -func testDeepEqualErr(v1, v2 interface{}, t *testing.T, name string) { - // t.Helper() - if err := deepEqual(v1, v2); err == nil { - if testVerbose { - t.Logf("%s: values equal", name) - } - } else { - t.Logf("%s: values not equal: %v", name, err) - if testVerbose { - t.Logf("%s: values not equal: %v. 1: %#v, 2: %#v", name, err, v1, v2) - } - t.FailNow() - } -} - -func testReadWriteCloser(c io.ReadWriteCloser) io.ReadWriteCloser { - if testRpcBufsize <= 0 && rand.Int63()%2 == 0 { - return c - } - return struct { - io.Closer - *bufio.Reader - *bufio.Writer - }{c, bufio.NewReaderSize(c, testRpcBufsize), bufio.NewWriterSize(c, testRpcBufsize)} -} - -// doTestCodecTableOne allows us test for different variations based on arguments passed. -func doTestCodecTableOne(t *testing.T, testNil bool, h Handle, - vs []interface{}, vsVerify []interface{}) { - //if testNil, then just test for when a pointer to a nil interface{} is passed. It should work. - //Current setup allows us test (at least manually) the nil interface or typed interface. - if testVerbose { - t.Logf("================ TestNil: %v ================\n", testNil) - } - for i, v0 := range vs { - if testVerbose { - t.Logf("..............................................") - t.Logf(" Testing: #%d:, %T, %#v\n", i, v0, v0) - } - // if a TestStrucFlex and we are doing a testNil, - // ensure the fields which are not encodeable are set to nil appropriately - // i.e. MstrUi64TSelf - var mapMstrUi64TSelf map[stringUint64T]*stringUint64T - var mapMsu2wss map[stringUint64T]wrapStringSlice - tsflex, _ := v0.(*TestStrucFlex) - if testNil && tsflex != nil { - mapMstrUi64TSelf = tsflex.MstrUi64TSelf - mapMsu2wss = tsflex.Msu2wss - tsflex.MstrUi64TSelf = nil - tsflex.Msu2wss = nil - } - b0 := testMarshalErr(v0, h, t, "v0") - var b1 = b0 - if len(b1) > 256 { - b1 = b1[:256] - } - if testVerbose { - if h.isBinary() { - t.Logf(" Encoded bytes: len: %v, %v\n", len(b0), b1) - } else { - t.Logf(" Encoded string: len: %v, %s\n", len(b0), b0) - // println("########### encoded string: " + string(b0)) - } - } - var v1 interface{} - var err error - if testNil { - err = testUnmarshal(&v1, b0, h) - if tsflex != nil { - tsflex.MstrUi64TSelf = mapMstrUi64TSelf - tsflex.Msu2wss = mapMsu2wss - } - } else { - if v0 != nil { - v0rt := reflect.TypeOf(v0) // ptr - if v0rt.Kind() == reflect.Ptr { - err = testUnmarshal(v0, b0, h) - v1 = v0 - } else { - rv1 := reflect.New(v0rt) - err = testUnmarshal(rv1.Interface(), b0, h) - v1 = rv1.Elem().Interface() - // v1 = reflect.Indirect(rv4i(v1)).Interface() - } - } - } - - if testVerbose { - t.Logf(" v1 returned: %T, %v %#v", v1, v1, v1) - } - // if v1 != nil { - // t.Logf(" v1 returned: %T, %#v", v1, v1) - // //we always indirect, because ptr to typed value may be passed (if not testNil) - // v1 = reflect.Indirect(rv4i(v1)).Interface() - // } - if err != nil { - t.Logf("-------- Error: %v. Partial return: %v", err, v1) - t.FailNow() - } - v0check := vsVerify[i] - if v0check == skipVerifyVal { - if testVerbose { - t.Logf(" Nil Check skipped: Decoded: %T, %#v\n", v1, v1) - } - continue - } - - if err = deepEqual(v0check, v1); err == nil { - t.Logf("++++++++ Before and After marshal matched\n") - } else { - // t.Logf("-------- Before and After marshal do not match: Error: %v"+ - // " ====> GOLDEN: (%T) %#v, DECODED: (%T) %#v\n", err, v0check, v0check, v1, v1) - t.Logf("-------- FAIL: Before and After marshal do not match: Error: %v", err) - if testVerbose { - t.Logf(" ....... GOLDEN: (%T) %v %#v", v0check, v0check, v0check) - t.Logf(" ....... DECODED: (%T) %v %#v", v1, v1, v1) - } - t.FailNow() - } - } -} - -func testCodecTableOne(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // func TestMsgpackAllExperimental(t *testing.T) { - // dopts := testDecOpts(nil, nil, false, true, true), - - numPrim, numMap, idxTime, idxMap := testTableNumPrimitives, testTableNumMaps, testTableIdxTime, testTableNumPrimitives+2 - - //println("#################") - tableVerify := testTableVerify(testVerifyMapTypeSame, h) - tableTestNilVerify := testTableVerify(testVerifyDoNil|testVerifyMapTypeStrIntf, h) - switch v := h.(type) { - case *MsgpackHandle: - var oldWriteExt bool - _ = oldWriteExt - oldWriteExt = v.WriteExt - v.WriteExt = true - doTestCodecTableOne(t, false, h, table, tableVerify) - v.WriteExt = oldWriteExt - case *JsonHandle: - //skip []interface{} containing time.Time, as it encodes as a number, but cannot decode back to time.Time. - //As there is no real support for extension tags in json, this must be skipped. - doTestCodecTableOne(t, false, h, table[:numPrim], tableVerify[:numPrim]) - doTestCodecTableOne(t, false, h, table[idxMap:], tableVerify[idxMap:]) - default: - doTestCodecTableOne(t, false, h, table, tableVerify) - } - // func TestMsgpackAll(t *testing.T) { - - // //skip []interface{} containing time.Time - // doTestCodecTableOne(t, false, h, table[:numPrim], tableVerify[:numPrim]) - // doTestCodecTableOne(t, false, h, table[numPrim+1:], tableVerify[numPrim+1:]) - // func TestMsgpackNilStringMap(t *testing.T) { - var oldMapType reflect.Type - v := basicHandle(h) - - oldMapType, v.MapType = v.MapType, testMapStrIntfTyp - // defer func() { v.MapType = oldMapType }() - //skip time.Time, []interface{} containing time.Time, last map, and newStruc - doTestCodecTableOne(t, true, h, table[:idxTime], tableTestNilVerify[:idxTime]) - doTestCodecTableOne(t, true, h, table[idxMap:idxMap+numMap-1], tableTestNilVerify[idxMap:idxMap+numMap-1]) // failing one for msgpack - v.MapType = oldMapType - // func TestMsgpackNilIntf(t *testing.T) { - - //do last map and newStruc - idx2 := idxMap + numMap - 1 - doTestCodecTableOne(t, true, h, table[idx2:], tableTestNilVerify[idx2:]) - //TODO? What is this one? - //doTestCodecTableOne(t, true, h, table[17:18], tableTestNilVerify[17:18]) -} - -func testCodecMiscOne(t *testing.T, h Handle) { - var err error - testOnce.Do(testInitAll) - b := testMarshalErr(32, h, t, "32") - // Cannot do this nil one, because faster type assertion decoding will panic - // var i *int32 - // if err = testUnmarshal(b, i, nil); err == nil { - // t.Logf("------- Expecting error because we cannot unmarshal to int32 nil ptr") - // t.FailNow() - // } - var i2 int32 - testUnmarshalErr(&i2, b, h, t, "int32-ptr") - if i2 != int32(32) { - t.Logf("------- didn't unmarshal to 32: Received: %d", i2) - t.FailNow() - } - - // func TestMsgpackDecodePtr(t *testing.T) { - ts := newTestStrucFlex(testDepth, testNumRepeatString, false, !testSkipIntf, testMapStringKeyOnly) - b = testMarshalErr(ts, h, t, "pointer-to-struct") - if len(b) < 40 { - t.Logf("------- Size must be > 40. Size: %d", len(b)) - t.FailNow() - } - var b1 = b - if len(b1) > 256 { - b1 = b1[:256] - } - if testVerbose { - if h.isBinary() { - t.Logf("------- b: size: %v, value: %v", len(b), b1) - } else { - t.Logf("------- b: size: %v, value: %s", len(b), b1) - } - } - ts2 := emptyTestStrucFlex() - testUnmarshalErr(ts2, b, h, t, "pointer-to-struct") - if ts2.I64 != math.MaxInt64*2/3 { - t.Logf("------- Unmarshal wrong. Expect I64 = 64. Got: %v", ts2.I64) - t.FailNow() - } - - // func TestMsgpackIntfDecode(t *testing.T) { - m := map[string]int{"A": 2, "B": 3} - p := []interface{}{m} - bs := testMarshalErr(p, h, t, "p") - - m2 := map[string]int{} - p2 := []interface{}{m2} - testUnmarshalErr(&p2, bs, h, t, "&p2") - - if m2["A"] != 2 || m2["B"] != 3 { - t.Logf("FAIL: m2 not as expected: expecting: %v, got: %v", m, m2) - t.FailNow() - } - - // log("m: %v, m2: %v, p: %v, p2: %v", m, m2, p, p2) - checkEqualT(t, p, p2, "p=p2") - checkEqualT(t, m, m2, "m=m2") - if err = deepEqual(p, p2); err == nil { - if testVerbose { - t.Logf("p and p2 match") - } - } else { - t.Logf("Not Equal: %v. p: %v, p2: %v", err, p, p2) - t.FailNow() - } - if err = deepEqual(m, m2); err == nil { - if testVerbose { - t.Logf("m and m2 match") - } - } else { - t.Logf("Not Equal: %v. m: %v, m2: %v", err, m, m2) - t.FailNow() - } - - // func TestMsgpackDecodeStructSubset(t *testing.T) { - // test that we can decode a subset of the stream - mm := map[string]interface{}{"A": 5, "B": 99, "C": 333} - bs = testMarshalErr(mm, h, t, "mm") - type ttt struct { - A uint8 - C int32 - } - var t2 ttt - testUnmarshalErr(&t2, bs, h, t, "t2") - t3 := ttt{5, 333} - checkEqualT(t, t2, t3, "t2=t3") - - // println(">>>>>") - // test simple arrays, non-addressable arrays, slices - type tarr struct { - A int64 - B [3]int64 - C []byte - D [3]byte - } - var tarr0 = tarr{1, [3]int64{2, 3, 4}, []byte{4, 5, 6}, [3]byte{7, 8, 9}} - // test both pointer and non-pointer (value) - for _, tarr1 := range []interface{}{tarr0, &tarr0} { - bs = testMarshalErr(tarr1, h, t, "tarr1") - if _, ok := h.(*JsonHandle); ok { - if testVerbose { - t.Logf("Marshal as: %s", bs) - } - } - var tarr2 tarr - testUnmarshalErr(&tarr2, bs, h, t, "tarr2") - checkEqualT(t, tarr0, tarr2, "tarr0=tarr2") - } - - // test byte array, even if empty (msgpack only) - if h == testMsgpackH { - type ystruct struct { - Anarray []byte - } - var ya = ystruct{} - testUnmarshalErr(&ya, []byte{0x91, 0x90}, h, t, "ya") - } - - var tt1, tt2 time.Time - tt2 = time.Now() - bs = testMarshalErr(tt1, h, t, "zero-time-enc") - testUnmarshalErr(&tt2, bs, h, t, "zero-time-dec") - testDeepEqualErr(tt1, tt2, t, "zero-time-eq") - - // test encoding a slice of byte (but not []byte) and decoding into a []byte - var sw = []wrapUint8{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'} - var bw []byte // ("ABCDEFGHIJ") - bs = testMarshalErr(sw, h, t, "wrap-bytes-enc") - testUnmarshalErr(&bw, bs, h, t, "wrap-bytes-dec") - testDeepEqualErr(bw, []byte("ABCDEFGHIJ"), t, "wrap-bytes-eq") -} - -func testCodecEmbeddedPointer(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - type Z int - type A struct { - AnInt int - } - type B struct { - *Z - *A - MoreInt int - } - var z Z = 4 - x1 := &B{&z, &A{5}, 6} - bs := testMarshalErr(x1, h, t, "x1") - var x2 = new(B) - testUnmarshalErr(x2, bs, h, t, "x2") - checkEqualT(t, x1, x2, "x1=x2") -} - -func testCodecUnderlyingType(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // Manual Test. - // Run by hand, with accompanying printf.statements in fast-path.go - // to ensure that the fast functions are called. - type T1 map[string]string - v := T1{"1": "1s", "2": "2s"} - var bs []byte - var err error - NewEncoderBytes(&bs, h).MustEncode(v) - if err != nil { - t.Logf("Error during encode: %v", err) - t.FailNow() - } - var v2 T1 - NewDecoderBytes(bs, h).MustDecode(&v2) - if err != nil { - t.Logf("Error during decode: %v", err) - t.FailNow() - } -} - -func testCodecChan(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // - send a slice []*int64 (sl1) into an chan (ch1) with cap > len(s1) - // - encode ch1 as a stream array - // - decode a chan (ch2), with cap > len(s1) from the stream array - // - receive from ch2 into slice sl2 - // - compare sl1 and sl2 - // - do this for codecs: json, cbor (covers all types) - - { - if testVerbose { - t.Logf("*int64") - } - sl1 := make([]*int64, 4) - for i := range sl1 { - var j int64 = int64(i) - sl1[i] = &j - } - ch1 := make(chan *int64, 4) - for _, j := range sl1 { - ch1 <- j - } - var bs []byte - NewEncoderBytes(&bs, h).MustEncode(ch1) - ch2 := make(chan *int64, 8) - NewDecoderBytes(bs, h).MustDecode(&ch2) - close(ch2) - var sl2 []*int64 - for j := range ch2 { - sl2 = append(sl2, j) - } - if err := deepEqual(sl1, sl2); err != nil { - t.Logf("FAIL: Not Match: %v; len: %v, %v", err, len(sl1), len(sl2)) - if testVerbose { - t.Logf("sl1: %#v, sl2: %#v", sl1, sl2) - } - t.FailNow() - } - } - - { - if testVerbose { - t.Logf("testBytesT []byte - input []byte") - } - type testBytesT []byte - sl1 := make([]testBytesT, 4) - for i := range sl1 { - var j = []byte(strings.Repeat(strconv.FormatInt(int64(i), 10), i)) - sl1[i] = j - } - ch1 := make(chan testBytesT, 4) - for _, j := range sl1 { - ch1 <- j - } - var bs []byte - NewEncoderBytes(&bs, h).MustEncode(ch1) - ch2 := make(chan testBytesT, 8) - NewDecoderBytes(bs, h).MustDecode(&ch2) - close(ch2) - var sl2 []testBytesT - for j := range ch2 { - // t.Logf(">>>> from chan: is nil? %v, %v", j == nil, j) - sl2 = append(sl2, j) - } - if err := deepEqual(sl1, sl2); err != nil { - t.Logf("FAIL: Not Match: %v; len: %v, %v", err, len(sl1), len(sl2)) - if testVerbose { - t.Logf("sl1: %#v, sl2: %#v", sl1, sl2) - } - t.FailNow() - } - } - { - if testVerbose { - t.Logf("testBytesT byte - input string/testBytesT") - } - type testBytesT byte - sl1 := make([]testBytesT, 4) - for i := range sl1 { - var j = strconv.FormatInt(int64(i), 10)[0] - sl1[i] = testBytesT(j) - } - ch1 := make(chan testBytesT, 4) - for _, j := range sl1 { - ch1 <- j - } - var bs []byte - NewEncoderBytes(&bs, h).MustEncode(ch1) - ch2 := make(chan testBytesT, 8) - NewDecoderBytes(bs, h).MustDecode(&ch2) - close(ch2) - var sl2 []testBytesT - for j := range ch2 { - sl2 = append(sl2, j) - } - if err := deepEqual(sl1, sl2); err != nil { - t.Logf("FAIL: Not Match: %v; len: %v, %v", err, len(sl1), len(sl2)) - t.FailNow() - } - } - - { - if testVerbose { - t.Logf("*[]byte") - } - sl1 := make([]byte, 4) - for i := range sl1 { - var j = strconv.FormatInt(int64(i), 10)[0] - sl1[i] = byte(j) - } - ch1 := make(chan byte, 4) - for _, j := range sl1 { - ch1 <- j - } - var bs []byte - NewEncoderBytes(&bs, h).MustEncode(ch1) - ch2 := make(chan byte, 8) - NewDecoderBytes(bs, h).MustDecode(&ch2) - close(ch2) - var sl2 []byte - for j := range ch2 { - sl2 = append(sl2, j) - } - if err := deepEqual(sl1, sl2); err != nil { - t.Logf("FAIL: Not Match: %v; len: %v, %v", err, len(sl1), len(sl2)) - t.FailNow() - } - } - -} - -func testCodecRpcOne(t *testing.T, rr Rpc, h Handle, doRequest bool, exitSleepMs time.Duration, -) (port int) { - testOnce.Do(testInitAll) - if testSkipRPCTests { - return - } - // rpc needs EOF, which is sent via a panic, and so must be recovered. - if !recoverPanicToErr { - t.Logf("EXPECTED. set recoverPanicToErr=true, since rpc needs EOF") - t.FailNow() - } - - if jsonH, ok := h.(*JsonHandle); ok && !jsonH.TermWhitespace { - jsonH.TermWhitespace = true - defer func() { jsonH.TermWhitespace = false }() - } - srv := rpc.NewServer() - srv.Register(testRpcInt) - ln, err := net.Listen("tcp", "127.0.0.1:0") // listen on ipv4 localhost - t.Logf("connFn: addr: %v, network: %v, port: %v", ln.Addr(), ln.Addr().Network(), (ln.Addr().(*net.TCPAddr)).Port) - // log("listener: %v", ln.Addr()) - checkErrT(t, err) - port = (ln.Addr().(*net.TCPAddr)).Port - // var opts *DecoderOptions - // opts := testDecOpts - // opts.MapType = mapStrIntfTyp - serverExitChan := make(chan bool, 1) - var serverExitFlag uint64 - serverFn := func() { - for { - conn1, err1 := ln.Accept() - // if err1 != nil { - // //fmt.Printf("accept err1: %v\n", err1) - // continue - // } - if atomic.LoadUint64(&serverExitFlag) == 1 { - serverExitChan <- true - if conn1 != nil { - conn1.Close() - } - return // exit serverFn goroutine - } - if err1 == nil && conn1 != nil { - sc := rr.ServerCodec(testReadWriteCloser(conn1), h) - srv.ServeCodec(sc) - } - } - } - - clientFn := func(cc rpc.ClientCodec) { - cl := rpc.NewClientWithCodec(cc) - defer cl.Close() - // defer func() { println("##### client closing"); cl.Close() }() - var up, sq, mult int - var rstr string - // log("Calling client") - checkErrT(t, cl.Call("TestRpcInt.Update", 5, &up)) - // log("Called TestRpcInt.Update") - checkEqualT(t, testRpcInt.i, 5, "testRpcInt.i=5") - checkEqualT(t, up, 5, "up=5") - checkErrT(t, cl.Call("TestRpcInt.Square", 1, &sq)) - checkEqualT(t, sq, 25, "sq=25") - checkErrT(t, cl.Call("TestRpcInt.Mult", 20, &mult)) - checkEqualT(t, mult, 100, "mult=100") - checkErrT(t, cl.Call("TestRpcInt.EchoStruct", TestRpcABC{"Aa", "Bb", "Cc"}, &rstr)) - checkEqualT(t, rstr, fmt.Sprintf("%#v", TestRpcABC{"Aa", "Bb", "Cc"}), "rstr=") - checkErrT(t, cl.Call("TestRpcInt.Echo123", []string{"A1", "B2", "C3"}, &rstr)) - checkEqualT(t, rstr, fmt.Sprintf("%#v", []string{"A1", "B2", "C3"}), "rstr=") - } - - connFn := func() (bs net.Conn) { - // log("calling f1") - bs, err2 := net.Dial(ln.Addr().Network(), ln.Addr().String()) - checkErrT(t, err2) - return - } - - exitFn := func() { - atomic.StoreUint64(&serverExitFlag, 1) - bs := connFn() - <-serverExitChan - bs.Close() - // serverExitChan <- true - } - - go serverFn() - runtime.Gosched() - //time.Sleep(100 * time.Millisecond) - if exitSleepMs == 0 { - defer ln.Close() - defer exitFn() - } - if doRequest { - bs := connFn() - cc := rr.ClientCodec(testReadWriteCloser(bs), h) - clientFn(cc) - } - if exitSleepMs != 0 { - go func() { - defer ln.Close() - time.Sleep(exitSleepMs) - exitFn() - }() - } - return -} - -func doTestMapEncodeForCanonical(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // println("doTestMapEncodeForCanonical") - v1 := map[stringUint64T]interface{}{ - stringUint64T{"a", 1}: 1, - stringUint64T{"b", 2}: "hello", - stringUint64T{"c", 3}: map[string]interface{}{ - "c/a": 1, - "c/b": "world", - "c/c": []int{1, 2, 3, 4}, - "c/d": map[string]interface{}{ - "c/d/a": "fdisajfoidsajfopdjsaopfjdsapofda", - "c/d/b": "fdsafjdposakfodpsakfopdsakfpodsakfpodksaopfkdsopafkdopsa", - "c/d/c": "poir02 ir30qif4p03qir0pogjfpoaerfgjp ofke[padfk[ewapf kdp[afep[aw", - "c/d/d": "fdsopafkd[sa f-32qor-=4qeof -afo-erfo r-eafo 4e- o r4-qwo ag", - "c/d/e": "kfep[a sfkr0[paf[a foe-[wq ewpfao-q ro3-q ro-4qof4-qor 3-e orfkropzjbvoisdb", - "c/d/f": "", - }, - "c/e": map[int]string{ - 1: "1", - 22: "22", - 333: "333", - 4444: "4444", - 55555: "55555", - }, - "c/f": map[string]int{ - "1": 1, - "22": 22, - "333": 333, - "4444": 4444, - "55555": 55555, - }, - "c/g": map[bool]int{ - false: 0, - true: 1, - }, - "c/t": map[time.Time]int64{ - time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC): time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC).UnixNano(), - time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC): time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC).UnixNano(), - time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC): time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC).UnixNano(), - }, - }, - } - var v2 map[stringUint64T]interface{} - var b1, b2, b3 []byte - - // encode v1 into b1, decode b1 into v2, encode v2 into b2, and compare b1 and b2. - // OR - // encode v1 into b1, decode b1 into v2, encode v2 into b2 and b3, and compare b2 and b3. - // e.g. when doing cbor indefinite, we may haveto use out-of-band encoding - // where each key is encoded as an indefinite length string, which makes it not the same - // order as the strings were lexicographically ordered before. - - var cborIndef bool - if ch, ok := h.(*CborHandle); ok { - cborIndef = ch.IndefiniteLength - } - bh := basicHandle(h) - if !bh.Canonical { - bh.Canonical = true - defer func() { bh.Canonical = false }() - } - - e1 := NewEncoderBytes(&b1, h) - e1.MustEncode(v1) - d1 := NewDecoderBytes(b1, h) - d1.MustDecode(&v2) - // testDeepEqualErr(v1, v2, t, "huh?") - e2 := NewEncoderBytes(&b2, h) - e2.MustEncode(v2) - var b1t, b2t = b1, b2 - if cborIndef { - e2 = NewEncoderBytes(&b3, h) - e2.MustEncode(v2) - b1t, b2t = b2, b3 - } - - if !bytes.Equal(b1t, b2t) { - t.Logf("Unequal bytes: %v VS %v", b1t, b2t) - t.FailNow() - } -} - -func doTestStdEncIntf(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - args := [][2]interface{}{ - {&TestABC{"A", "BB", "CCC"}, new(TestABC)}, - {&TestABC2{"AAA", "BB", "C"}, new(TestABC2)}, - } - for _, a := range args { - var b []byte - e := NewEncoderBytes(&b, h) - e.MustEncode(a[0]) - d := NewDecoderBytes(b, h) - d.MustDecode(a[1]) - if err := deepEqual(a[0], a[1]); err == nil { - if testVerbose { - t.Logf("++++ Objects match") - } - } else { - t.Logf("---- FAIL: Objects do not match: y0: %v, y1: %v, err: %v", a[0], a[1], err) - t.FailNow() - } - } -} - -func doTestEncCircularRef(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - type T1 struct { - S string - B bool - T interface{} - } - type T2 struct { - S string - T *T1 - } - type T3 struct { - S string - T *T2 - } - t1 := T1{"t1", true, nil} - t2 := T2{"t2", &t1} - t3 := T3{"t3", &t2} - t1.T = &t3 - - var bs []byte - var err error - - bh := basicHandle(h) - if !bh.CheckCircularRef { - bh.CheckCircularRef = true - defer func() { bh.CheckCircularRef = false }() - } - err = NewEncoderBytes(&bs, h).Encode(&t3) - if err == nil { - t.Logf("expecting error due to circular reference. found none") - t.FailNow() - } - if x := err.Error(); strings.Contains(x, "circular") || strings.Contains(x, "cyclic") { - if testVerbose { - t.Logf("error detected as expected: %v", x) - } - } else { - t.Logf("FAIL: error detected was not as expected: %v", x) - t.FailNow() - } -} - -// TestAnonCycleT{1,2,3} types are used to test anonymous cycles. -// They are top-level, so that they can have circular references. -type ( - TestAnonCycleT1 struct { - S string - TestAnonCycleT2 - } - TestAnonCycleT2 struct { - S2 string - TestAnonCycleT3 - } - TestAnonCycleT3 struct { - *TestAnonCycleT1 - } -) - -func doTestAnonCycle(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - var x TestAnonCycleT1 - x.S = "hello" - x.TestAnonCycleT2.S2 = "hello.2" - x.TestAnonCycleT2.TestAnonCycleT3.TestAnonCycleT1 = &x - - // just check that you can get typeInfo for T1 - rt := reflect.TypeOf((*TestAnonCycleT1)(nil)).Elem() - rtid := rt2id(rt) - pti := basicHandle(h).getTypeInfo(rtid, rt) - if testVerbose { - t.Logf("[%s] pti: %v", h.Name(), pti) - } -} - -func doTestErrWriter(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - var ew testErrWriter - w := bufio.NewWriterSize(&ew, 4) - enc := NewEncoder(w, h) - for i := 0; i < 4; i++ { - err := enc.Encode("ugorji") - if ev, ok := err.(encodeError); ok { - err = ev.Cause() - } - if err != testErrWriterErr { - t.Logf("%s: expecting err: %v, received: %v", name, testErrWriterErr, err) - t.FailNow() - } - } -} - -func doTestJsonLargeInteger(t *testing.T, v interface{}, ias uint8) { - testOnce.Do(testInitAll) - if testVerbose { - t.Logf("Running doTestJsonLargeInteger: v: %#v, ias: %c", v, ias) - } - oldIAS := testJsonH.IntegerAsString - defer func() { testJsonH.IntegerAsString = oldIAS }() - testJsonH.IntegerAsString = ias - - var vu uint - var vi int - var vb bool - var b []byte - e := NewEncoderBytes(&b, testJsonH) - e.MustEncode(v) - e.MustEncode(true) - d := NewDecoderBytes(b, testJsonH) - // below, we validate that the json string or number was encoded, - // then decode, and validate that the correct value was decoded. - fnStrChk := func() { - // check that output started with ", and ended with " true - // if !(len(b) >= 7 && b[0] == '"' && string(b[len(b)-7:]) == `" true `) { - if !(len(b) >= 5 && b[0] == '"' && string(b[len(b)-5:]) == `"true`) { - t.Logf("Expecting a JSON string, got: '%s'", b) - t.FailNow() - } - } - - switch ias { - case 'L': - switch v2 := v.(type) { - case int: - v2n := int64(v2) // done to work with 32-bit OS - if v2n > 1<<53 || (v2n < 0 && -v2n > 1<<53) { - fnStrChk() - } - case uint: - v2n := uint64(v2) // done to work with 32-bit OS - if v2n > 1<<53 { - fnStrChk() - } - } - case 'A': - fnStrChk() - default: - // check that output doesn't contain " at all - for _, i := range b { - if i == '"' { - t.Logf("Expecting a JSON Number without quotation: got: %s", b) - t.FailNow() - } - } - } - switch v2 := v.(type) { - case int: - d.MustDecode(&vi) - d.MustDecode(&vb) - // check that vb = true, and vi == v2 - if !(vb && vi == v2) { - t.Logf("Expecting equal values from %s: got golden: %v, decoded: %v", b, v2, vi) - t.FailNow() - } - case uint: - d.MustDecode(&vu) - d.MustDecode(&vb) - // check that vb = true, and vi == v2 - if !(vb && vu == v2) { - t.Logf("Expecting equal values from %s: got golden: %v, decoded: %v", b, v2, vu) - t.FailNow() - } - } -} - -func doTestRawValue(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - bh := basicHandle(h) - if !bh.Raw { - bh.Raw = true - defer func() { bh.Raw = false }() - } - - var i, i2 int - var v, v2 TestRawValue - var bs, bs2 []byte - - i = 1234 //1234567890 - v = TestRawValue{I: i} - e := NewEncoderBytes(&bs, h) - e.MustEncode(v.I) - if testVerbose { - t.Logf(">>> raw: %v\n", bs) - } - - v.R = Raw(bs) - e.ResetBytes(&bs2) - e.MustEncode(v) - - if testVerbose { - t.Logf(">>> bs2: %v\n", bs2) - } - d := NewDecoderBytes(bs2, h) - d.MustDecode(&v2) - d.ResetBytes(v2.R) - if testVerbose { - t.Logf(">>> v2.R: %v\n", ([]byte)(v2.R)) - } - d.MustDecode(&i2) - - if testVerbose { - t.Logf(">>> Encoded %v, decoded %v\n", i, i2) - } - // t.Logf("Encoded %v, decoded %v", i, i2) - if i != i2 { - t.Logf("Error: encoded %v, decoded %v", i, i2) - t.FailNow() - } -} - -// Comprehensive testing that generates data encoded from python handle (cbor, msgpack), -// and validates that our code can read and write it out accordingly. -// We keep this unexported here, and put actual test in ext_dep_test.go. -// This way, it can be excluded by excluding file completely. -func doTestPythonGenStreams(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - t.Logf("TestPythonGenStreams-%v", name) - tmpdir, err := ioutil.TempDir("", "golang-"+name+"-test") - if err != nil { - t.Logf("-------- Unable to create temp directory\n") - t.FailNow() - } - defer os.RemoveAll(tmpdir) - if testVerbose { - t.Logf("tmpdir: %v", tmpdir) - } - cmd := exec.Command("python", "test.py", "testdata", tmpdir) - //cmd.Stdin = strings.NewReader("some input") - //cmd.Stdout = &out - var cmdout []byte - if cmdout, err = cmd.CombinedOutput(); err != nil { - t.Logf("-------- Error running test.py testdata. Err: %v", err) - t.Logf(" %v", string(cmdout)) - t.FailNow() - } - - bh := basicHandle(h) - - oldMapType := bh.MapType - tablePythonVerify := testTableVerify(testVerifyForPython|testVerifyTimeAsInteger|testVerifyMapTypeStrIntf, h) - for i, v := range tablePythonVerify { - // if v == uint64(0) && h == testMsgpackH { - // v = int64(0) - // } - bh.MapType = oldMapType - //load up the golden file based on number - //decode it - //compare to in-mem object - //encode it again - //compare to output stream - if testVerbose { - t.Logf("..............................................") - } - t.Logf(" Testing: #%d: %T, %#v\n", i, v, v) - var bss []byte - bss, err = ioutil.ReadFile(filepath.Join(tmpdir, strconv.Itoa(i)+"."+name+".golden")) - if err != nil { - t.Logf("-------- Error reading golden file: %d. Err: %v", i, err) - t.FailNow() - continue - } - bh.MapType = testMapStrIntfTyp - - var v1 interface{} - if err = testUnmarshal(&v1, bss, h); err != nil { - t.Logf("-------- Error decoding stream: %d: Err: %v", i, err) - t.FailNow() - continue - } - if v == skipVerifyVal { - continue - } - //no need to indirect, because we pass a nil ptr, so we already have the value - //if v1 != nil { v1 = reflect.Indirect(rv4i(v1)).Interface() } - if err = deepEqual(v, v1); err == nil { - if testVerbose { - t.Logf("++++++++ Objects match: %T, %v", v, v) - } - } else { - t.Logf("-------- FAIL: Objects do not match: %v. Source: %T. Decoded: %T", err, v, v1) - if testVerbose { - t.Logf("-------- GOLDEN: %#v", v) - // t.Logf("-------- DECODED: %#v <====> %#v", v1, reflect.Indirect(rv4i(v1)).Interface()) - t.Logf("-------- DECODED: %#v <====> %#v", v1, reflect.Indirect(rv4i(v1)).Interface()) - } - t.FailNow() - } - bsb, err := testMarshal(v1, h) - if err != nil { - t.Logf("Error encoding to stream: %d: Err: %v", i, err) - t.FailNow() - continue - } - if err = deepEqual(bsb, bss); err == nil { - if testVerbose { - t.Logf("++++++++ Bytes match") - } - } else { - t.Logf("???????? FAIL: Bytes do not match. %v.", err) - xs := "--------" - if rv4i(v).Kind() == reflect.Map { - xs = " " - t.Logf("%s It's a map. Ok that they don't match (dependent on ordering).", xs) - } else { - t.Logf("%s It's not a map. They should match.", xs) - t.FailNow() - } - if testVerbose { - t.Logf("%s FROM_FILE: %4d] %v", xs, len(bss), bss) - t.Logf("%s ENCODED: %4d] %v", xs, len(bsb), bsb) - } - } - } - bh.MapType = oldMapType -} - -// To test MsgpackSpecRpc, we test 3 scenarios: -// - Go Client to Go RPC Service (contained within TestMsgpackRpcSpec) -// - Go client to Python RPC Service (contained within doTestMsgpackRpcSpecGoClientToPythonSvc) -// - Python Client to Go RPC Service (contained within doTestMsgpackRpcSpecPythonClientToGoSvc) -// -// This allows us test the different calling conventions -// - Go Service requires only one argument -// - Python Service allows multiple arguments - -func doTestMsgpackRpcSpecGoClientToPythonSvc(t *testing.T) { - if testSkipRPCTests { - return - } - testOnce.Do(testInitAll) - // openPorts are between 6700 and 6800 - r := rand.New(rand.NewSource(time.Now().UnixNano())) - openPort := strconv.FormatInt(6700+r.Int63n(99), 10) - // openPort := "6792" - cmd := exec.Command("python", "test.py", "rpc-server", openPort, "4") - checkErrT(t, cmd.Start()) - bs, err2 := net.Dial("tcp", ":"+openPort) - for i := 0; i < 10 && err2 != nil; i++ { - time.Sleep(50 * time.Millisecond) // time for python rpc server to start - bs, err2 = net.Dial("tcp", ":"+openPort) - } - checkErrT(t, err2) - cc := MsgpackSpecRpc.ClientCodec(testReadWriteCloser(bs), testMsgpackH) - cl := rpc.NewClientWithCodec(cc) - defer cl.Close() - var rstr string - checkErrT(t, cl.Call("EchoStruct", TestRpcABC{"Aa", "Bb", "Cc"}, &rstr)) - //checkEqualT(t, rstr, "{'A': 'Aa', 'B': 'Bb', 'C': 'Cc'}") - var mArgs MsgpackSpecRpcMultiArgs = []interface{}{"A1", "B2", "C3"} - checkErrT(t, cl.Call("Echo123", mArgs, &rstr)) - checkEqualT(t, rstr, "1:A1 2:B2 3:C3", "rstr=") - cmd.Process.Kill() -} - -func doTestMsgpackRpcSpecPythonClientToGoSvc(t *testing.T) { - if testSkipRPCTests { - return - } - testOnce.Do(testInitAll) - port := testCodecRpcOne(t, MsgpackSpecRpc, testMsgpackH, false, 1*time.Second) - //time.Sleep(1000 * time.Millisecond) - cmd := exec.Command("python", "test.py", "rpc-client-go-service", strconv.Itoa(port)) - var cmdout []byte - var err error - if cmdout, err = cmd.CombinedOutput(); err != nil { - t.Logf("-------- Error running test.py rpc-client-go-service. Err: %v", err) - t.Logf(" %v", string(cmdout)) - t.FailNow() - } - checkEqualT(t, string(cmdout), - fmt.Sprintf("%#v\n%#v\n", []string{"A1", "B2", "C3"}, TestRpcABC{"Aa", "Bb", "Cc"}), "cmdout=") -} - -func doTestSwallowAndZero(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - v1 := newTestStrucFlex(testDepth, testNumRepeatString, false, false, testMapStringKeyOnly) - var b1 []byte - - e1 := NewEncoderBytes(&b1, h) - e1.MustEncode(v1) - d1 := NewDecoderBytes(b1, h) - d1.swallow() - if d1.r().numread() != uint(len(b1)) { - t.Logf("swallow didn't consume all encoded bytes: %v out of %v", d1.r().numread(), len(b1)) - t.FailNow() - } - setZero(v1) - testDeepEqualErr(v1, &TestStrucFlex{}, t, "filled-and-zeroed") -} - -func doTestRawExt(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - var b []byte - var v RawExt // interface{} - _, isJson := h.(*JsonHandle) - _, isCbor := h.(*CborHandle) - bh := basicHandle(h) - // isValuer := isJson || isCbor - // _ = isValuer - for _, r := range []RawExt{ - {Tag: 99, Value: "9999", Data: []byte("9999")}, - } { - e := NewEncoderBytes(&b, h) - e.MustEncode(&r) - // fmt.Printf(">>>> rawext: isnil? %v, %d - %v\n", b == nil, len(b), b) - d := NewDecoderBytes(b, h) - d.MustDecode(&v) - var r2 = r - switch { - case isJson: - r2.Tag = 0 - r2.Data = nil - case isCbor: - r2.Data = nil - default: - r2.Value = nil - } - testDeepEqualErr(v, r2, t, "rawext-default") - // switch h.(type) { - // case *JsonHandle: - // testDeepEqualErr(r.Value, v, t, "rawext-json") - // default: - // var r2 = r - // if isValuer { - // r2.Data = nil - // } else { - // r2.Value = nil - // } - // testDeepEqualErr(v, r2, t, "rawext-default") - // } - } - - // Add testing for Raw also - if b != nil { - b = b[:0] - } - oldRawMode := bh.Raw - defer func() { bh.Raw = oldRawMode }() - bh.Raw = true - - var v2 Raw - for _, s := range []string{ - "goodbye", - "hello", - } { - e := NewEncoderBytes(&b, h) - e.MustEncode(&s) - // fmt.Printf(">>>> rawext: isnil? %v, %d - %v\n", b == nil, len(b), b) - var r Raw = make([]byte, len(b)) - copy(r, b) - d := NewDecoderBytes(b, h) - d.MustDecode(&v2) - testDeepEqualErr(v2, r, t, "raw-default") - } - -} - -// func doTestTimeExt(t *testing.T, h Handle) { -// var t = time.Now() -// // add time ext to the handle -// } - -func doTestMapStructKey(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - var b []byte - var v interface{} // map[stringUint64T]wrapUint64Slice // interface{} - bh := basicHandle(h) - m := map[stringUint64T]wrapUint64Slice{ - stringUint64T{"55555", 55555}: []wrapUint64{12345}, - stringUint64T{"333", 333}: []wrapUint64{123}, - } - oldCanonical := bh.Canonical - oldMapType := bh.MapType - defer func() { - bh.Canonical = oldCanonical - bh.MapType = oldMapType - }() - - bh.MapType = reflect.TypeOf((*map[stringUint64T]wrapUint64Slice)(nil)).Elem() - for _, bv := range [2]bool{true, false} { - b, v = nil, nil - bh.Canonical = bv - e := NewEncoderBytes(&b, h) - e.MustEncode(m) - d := NewDecoderBytes(b, h) - d.MustDecode(&v) - testDeepEqualErr(v, m, t, "map-structkey") - } -} - -func doTestDecodeNilMapValue(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - type Struct struct { - Field map[uint16]map[uint32]struct{} - } - - bh := basicHandle(h) - oldMapType := bh.MapType - oldDeleteOnNilMapValue := bh.DeleteOnNilMapValue - defer func() { - bh.MapType = oldMapType - bh.DeleteOnNilMapValue = oldDeleteOnNilMapValue - }() - bh.MapType = reflect.TypeOf(map[interface{}]interface{}(nil)) - bh.DeleteOnNilMapValue = false - - _, isJsonHandle := h.(*JsonHandle) - - toEncode := Struct{Field: map[uint16]map[uint32]struct{}{ - 1: nil, - }} - - bs, err := testMarshal(toEncode, h) - if err != nil { - t.Logf("Error encoding: %v, Err: %v", toEncode, err) - t.FailNow() - } - if isJsonHandle { - t.Logf("json encoded: %s\n", bs) - } - - var decoded Struct - err = testUnmarshal(&decoded, bs, h) - if err != nil { - t.Logf("Error decoding: %v", err) - t.FailNow() - } - if !reflect.DeepEqual(decoded, toEncode) { - t.Logf("Decoded value %#v != %#v", decoded, toEncode) - t.FailNow() - } -} - -func doTestEmbeddedFieldPrecedence(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - type Embedded struct { - Field byte - } - type Struct struct { - Field byte - Embedded - } - toEncode := Struct{ - Field: 1, - Embedded: Embedded{Field: 2}, - } - _, isJsonHandle := h.(*JsonHandle) - handle := basicHandle(h) - oldMapType := handle.MapType - defer func() { handle.MapType = oldMapType }() - - handle.MapType = reflect.TypeOf(map[interface{}]interface{}(nil)) - - bs, err := testMarshal(toEncode, h) - if err != nil { - t.Logf("Error encoding: %v, Err: %v", toEncode, err) - t.FailNow() - } - - var decoded Struct - err = testUnmarshal(&decoded, bs, h) - if err != nil { - t.Logf("Error decoding: %v", err) - t.FailNow() - } - - if decoded.Field != toEncode.Field { - t.Logf("Decoded result %v != %v", decoded.Field, toEncode.Field) // hex to look at what was encoded - if isJsonHandle { - t.Logf("JSON encoded as: %s", bs) // hex to look at what was encoded - } - t.FailNow() - } -} - -func doTestLargeContainerLen(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - m := make(map[int][]struct{}) - for i := range []int{ - 0, 1, - math.MaxInt8, math.MaxInt8 + 4, math.MaxInt8 - 4, - math.MaxInt16, math.MaxInt16 + 4, math.MaxInt16 - 4, - math.MaxInt32, math.MaxInt32 - 4, - // math.MaxInt32 + 4, // bombs on 32-bit - // math.MaxInt64, math.MaxInt64 - 4, // bombs on 32-bit - - math.MaxUint8, math.MaxUint8 + 4, math.MaxUint8 - 4, - math.MaxUint16, math.MaxUint16 + 4, math.MaxUint16 - 4, - // math.MaxUint32, math.MaxUint32 + 4, math.MaxUint32 - 4, // bombs on 32-bit - } { - m[i] = make([]struct{}, i) - } - bs := testMarshalErr(m, h, t, "-") - var m2 = make(map[int][]struct{}) - testUnmarshalErr(m2, bs, h, t, "-") - testDeepEqualErr(m, m2, t, "-") - - // do same tests for large strings (encoded as symbols or not) - // skip if 32-bit or not using unsafe mode - if safeMode || (32<<(^uint(0)>>63)) < 64 { - return - } - - // now, want to do tests for large strings, which - // could be encoded as symbols. - // to do this, we create a simple one-field struct, - // use use flags to switch from symbols to non-symbols - - hbinc, okbinc := h.(*BincHandle) - if okbinc { - oldAsSymbols := hbinc.AsSymbols - defer func() { hbinc.AsSymbols = oldAsSymbols }() - } - var out []byte = make([]byte, 0, math.MaxUint16*3/2) - var in []byte = make([]byte, math.MaxUint16*3/2) - for i := range in { - in[i] = 'A' - } - e := NewEncoder(nil, h) - for _, i := range []int{ - 0, 1, 4, 8, 12, 16, 28, 32, 36, - math.MaxInt8, math.MaxInt8 + 4, math.MaxInt8 - 4, - math.MaxInt16, math.MaxInt16 + 4, math.MaxInt16 - 4, - - math.MaxUint8, math.MaxUint8 + 4, math.MaxUint8 - 4, - math.MaxUint16, math.MaxUint16 + 4, math.MaxUint16 - 4, - } { - var m1, m2 map[string]bool - m1 = make(map[string]bool, 1) - var s1 = stringView(in[:i]) - // fmt.Printf("testcontainerlen: large string: i: %v, |%s|\n", i, s1) - m1[s1] = true - - if okbinc { - hbinc.AsSymbols = 2 - } - out = out[:0] - e.ResetBytes(&out) - e.MustEncode(m1) - // bs, _ = testMarshalErr(m1, h, t, "-") - m2 = make(map[string]bool, 1) - testUnmarshalErr(m2, out, h, t, "no-symbols") - testDeepEqualErr(m1, m2, t, "no-symbols") - - if okbinc { - // now, do as symbols - hbinc.AsSymbols = 1 - out = out[:0] - e.ResetBytes(&out) - e.MustEncode(m1) - // bs, _ = testMarshalErr(m1, h, t, "-") - m2 = make(map[string]bool, 1) - testUnmarshalErr(m2, out, h, t, "symbols") - testDeepEqualErr(m1, m2, t, "symbols") - } - } - -} - -func testRandomFillRV(v reflect.Value) { - testOnce.Do(testInitAll) - fneg := func() int64 { - i := rand.Intn(1) - if i == 1 { - return 1 - } - return -1 - } - - switch v.Kind() { - case reflect.Invalid: - case reflect.Ptr: - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - testRandomFillRV(v.Elem()) - case reflect.Interface: - if v.IsNil() { - v.Set(rv4i("nothing")) - } else { - testRandomFillRV(v.Elem()) - } - case reflect.Struct: - for i, n := 0, v.NumField(); i < n; i++ { - testRandomFillRV(v.Field(i)) - } - case reflect.Slice: - if v.IsNil() { - v.Set(reflect.MakeSlice(v.Type(), 4, 4)) - } - fallthrough - case reflect.Array: - for i, n := 0, v.Len(); i < n; i++ { - testRandomFillRV(v.Index(i)) - } - case reflect.Map: - if v.IsNil() { - v.Set(reflect.MakeMap(v.Type())) - } - if v.Len() == 0 { - kt, vt := v.Type().Key(), v.Type().Elem() - for i := 0; i < 4; i++ { - k0 := reflect.New(kt).Elem() - v0 := reflect.New(vt).Elem() - testRandomFillRV(k0) - testRandomFillRV(v0) - v.SetMapIndex(k0, v0) - } - } else { - for _, k := range v.MapKeys() { - testRandomFillRV(v.MapIndex(k)) - } - } - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - v.SetInt(fneg() * rand.Int63n(127)) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - v.SetUint(uint64(rand.Int63n(255))) - case reflect.Bool: - v.SetBool(fneg() == 1) - case reflect.Float32, reflect.Float64: - v.SetFloat(float64(fneg()) * float64(rand.Float32())) - case reflect.String: - // ensure this string can test the extent of json string decoding - v.SetString(strings.Repeat(strconv.FormatInt(rand.Int63n(99), 10), rand.Intn(8)) + - "- ABC \x41=\x42 \u2318 - \r \b \f - \u2028 and \u2029 .") - default: - panic(fmt.Errorf("testRandomFillRV: unsupported type: %v", v.Kind())) - } -} - -func testMammoth(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - var b []byte - - var m, m2 TestMammoth - testRandomFillRV(rv4i(&m).Elem()) - b = testMarshalErr(&m, h, t, "mammoth-"+name) - // xdebugf("%s", b) - testUnmarshalErr(&m2, b, h, t, "mammoth-"+name) - testDeepEqualErr(&m, &m2, t, "mammoth-"+name) - var mm, mm2 TestMammoth2Wrapper - testRandomFillRV(rv4i(&mm).Elem()) - b = testMarshalErr(&mm, h, t, "mammoth2-"+name) - // os.Stderr.Write([]byte("\n\n\n\n" + string(b) + "\n\n\n\n")) - testUnmarshalErr(&mm2, b, h, t, "mammoth2-"+name) - testDeepEqualErr(&mm, &mm2, t, "mammoth2-"+name) - // testMammoth2(t, name, h) -} - -func testTime(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - // test time which uses the time.go implementation (ie Binc) - var tt, tt2 time.Time - // time in 1990 - tt = time.Unix(20*366*24*60*60, 1000*900).In(time.FixedZone("UGO", -5*60*60)) - // fmt.Printf("time tt: %v\n", tt) - b := testMarshalErr(tt, h, t, "time-"+name) - testUnmarshalErr(&tt2, b, h, t, "time-"+name) - // per go documentation, test time with .Equal not == - if !tt2.Equal(tt) { - t.Logf("%s: values not equal: 1: %v, 2: %v", name, tt2, tt) - t.FailNow() - } - // testDeepEqualErr(tt.UTC(), tt2, t, "time-"+name) -} - -func testUintToInt(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - var golden = [...]int64{ - 0, 1, 22, 333, 4444, 55555, 666666, - // msgpack ones - 24, 128, - // standard ones - math.MaxUint8, math.MaxUint8 + 4, math.MaxUint8 - 4, - math.MaxUint16, math.MaxUint16 + 4, math.MaxUint16 - 4, - math.MaxUint32, math.MaxUint32 + 4, math.MaxUint32 - 4, - math.MaxInt8, math.MaxInt8 + 4, math.MaxInt8 - 4, - math.MaxInt16, math.MaxInt16 + 4, math.MaxInt16 - 4, - math.MaxInt32, math.MaxInt32 + 4, math.MaxInt32 - 4, - math.MaxInt64, math.MaxInt64 - 4, - } - var i int64 - var ui, ui2 uint64 - var fi float64 - var b []byte - for _, v := range golden { - i = v - ui = 0 - b = testMarshalErr(i, h, t, "int2uint-"+name) - testUnmarshalErr(&ui, b, h, t, "int2uint-"+name) - if ui != uint64(i) { - t.Logf("%s: values not equal: %v, %v", name, ui, uint64(i)) - t.FailNow() - } - - ui = uint64(i) - i = 0 - b = testMarshalErr(ui, h, t, "uint2int-"+name) - testUnmarshalErr(&i, b, h, t, "uint2int-"+name) - if i != int64(ui) { - t.Logf("%s: values not equal: %v, %v", name, i, int64(ui)) - t.FailNow() - } - - if v == math.MaxInt64 { - ui = uint64(-(v - 1)) - } else { - ui = uint64(-v) - } - // xdebugf("testing %x", ui) - b = testMarshalErr(ui, h, t, "negint2uint-"+name) - testUnmarshalErr(&ui2, b, h, t, "negint2uint-"+name) - if ui2 != ui { - t.Logf("%s: values not equal: %v, %v", name, ui2, ui) - t.FailNow() - } - - fi = 0 - b = testMarshalErr(i, h, t, "int2float-"+name) - testUnmarshalErr(&fi, b, h, t, "int2float-"+name) - if fi != float64(i) { - t.Logf("%s: values not equal: %v, %v", name, fi, float64(i)) - t.FailNow() - } - } -} - -func doTestDifferentMapOrSliceType(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - - // - maptype, slicetype: diff from map[string]intf, map[intf]intf or []intf, etc - // include map[interface{}]string where some keys are []byte. - // To test, take a sequence of []byte and string, and decode into []string and []interface. - // Also, decode into map[string]string, map[string]interface{}, map[interface{}]string - - bh := basicHandle(h) - oldM, oldS := bh.MapType, bh.SliceType - defer func() { bh.MapType, bh.SliceType = oldM, oldS }() - - var b []byte - - var vi = []interface{}{ - "hello 1", - []byte("hello 2"), - "hello 3", - []byte("hello 4"), - "hello 5", - } - var vs []string - var v2i, v2s testMbsT - var v2ss testMbsCustStrT - // encode it as a map or as a slice - for i, v := range vi { - vv, ok := v.(string) - if !ok { - vv = string(v.([]byte)) - } - vs = append(vs, vv) - v2i = append(v2i, v, strconv.FormatInt(int64(i+1), 10)) - v2s = append(v2s, vv, strconv.FormatInt(int64(i+1), 10)) - v2ss = append(v2ss, testCustomStringT(vv), testCustomStringT(strconv.FormatInt(int64(i+1), 10))) - } - - var v2d interface{} - - // encode vs as a list, and decode into a list and compare - var goldSliceS = []string{"hello 1", "hello 2", "hello 3", "hello 4", "hello 5"} - var goldSliceI = []interface{}{"hello 1", "hello 2", "hello 3", "hello 4", "hello 5"} - var goldSlice = []interface{}{goldSliceS, goldSliceI} - for j, g := range goldSlice { - bh.SliceType = reflect.TypeOf(g) - name := fmt.Sprintf("slice-%s-%v", name, j+1) - b = testMarshalErr(vs, h, t, name) - v2d = nil - // v2d = reflect.New(bh.SliceType).Elem().Interface() - testUnmarshalErr(&v2d, b, h, t, name) - testDeepEqualErr(v2d, goldSlice[j], t, name) - } - - // to ensure that we do not use fast-path for map[intf]string, use a custom string type (for goldMapIS). - // this will allow us to test out the path that sees a []byte where a map has an interface{} type, - // and convert it to a string for the decoded map key. - - // encode v2i as a map, and decode into a map and compare - var goldMapSS = map[string]string{"hello 1": "1", "hello 2": "2", "hello 3": "3", "hello 4": "4", "hello 5": "5"} - var goldMapSI = map[string]interface{}{"hello 1": "1", "hello 2": "2", "hello 3": "3", "hello 4": "4", "hello 5": "5"} - var goldMapIS = map[interface{}]testCustomStringT{"hello 1": "1", "hello 2": "2", "hello 3": "3", "hello 4": "4", "hello 5": "5"} - var goldMap = []interface{}{goldMapSS, goldMapSI, goldMapIS} - for j, g := range goldMap { - bh.MapType = reflect.TypeOf(g) - name := fmt.Sprintf("map-%s-%v", name, j+1) - // for formats that clearly differentiate binary from string, use v2i - // else use the v2s (with all strings, no []byte) - v2d = nil - // v2d = reflect.New(bh.MapType).Elem().Interface() - switch h.(type) { - case *MsgpackHandle, *BincHandle, *CborHandle: - b = testMarshalErr(v2i, h, t, name) - testUnmarshalErr(&v2d, b, h, t, name) - testDeepEqualErr(v2d, goldMap[j], t, name) - default: - b = testMarshalErr(v2s, h, t, name) - testUnmarshalErr(&v2d, b, h, t, name) - testDeepEqualErr(v2d, goldMap[j], t, name) - b = testMarshalErr(v2ss, h, t, name) - v2d = nil - testUnmarshalErr(&v2d, b, h, t, name) - testDeepEqualErr(v2d, goldMap[j], t, name) - } - } - -} - -func doTestScalars(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - - // for each scalar: - // - encode its ptr - // - encode it (non-ptr) - // - check that bytes are same - // - make a copy (using reflect) - // - check that same - // - set zero on it - // - check that its equal to 0 value - // - decode into new - // - compare to original - - bh := basicHandle(h) - if !bh.Canonical { - bh.Canonical = true - defer func() { bh.Canonical = false }() - } - - vi := []interface{}{ - int(0), - int8(0), - int16(0), - int32(0), - int64(0), - uint(0), - uint8(0), - uint16(0), - uint32(0), - uint64(0), - uintptr(0), - float32(0), - float64(0), - bool(false), - string(""), - []byte(nil), - } - for _, v := range fastpathAV { - vi = append(vi, reflect.Zero(v.rt).Interface()) - } - for _, v := range vi { - rv := reflect.New(reflect.TypeOf(v)).Elem() - testRandomFillRV(rv) - v = rv.Interface() - - rv2 := reflect.New(rv.Type()) - rv2.Elem().Set(rv) - vp := rv2.Interface() - - var tname string - switch rv.Kind() { - case reflect.Map: - tname = "map[" + rv.Type().Key().Name() + "]" + rv.Type().Elem().Name() - case reflect.Slice: - tname = "[]" + rv.Type().Elem().Name() - default: - tname = rv.Type().Name() - } - - var b, b1, b2 []byte - b1 = testMarshalErr(v, h, t, tname+"-enc") - // store b1 into b, as b1 slice is reused for next marshal - b = make([]byte, len(b1)) - copy(b, b1) - b2 = testMarshalErr(vp, h, t, tname+"-enc-ptr") - testDeepEqualErr(b1, b2, t, tname+"-enc-eq") - setZero(vp) - testDeepEqualErr(rv2.Elem().Interface(), reflect.Zero(rv.Type()).Interface(), t, tname+"-enc-eq-zero-ref") - - vp = rv2.Interface() - testUnmarshalErr(vp, b, h, t, tname+"-dec") - testDeepEqualErr(rv2.Elem().Interface(), v, t, tname+"-dec-eq") - } -} - -func doTestIntfMapping(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - rti := reflect.TypeOf((*testIntfMapI)(nil)).Elem() - defer func() { basicHandle(h).Intf2Impl(rti, nil) }() - - type T9 struct { - I testIntfMapI - } - - for i, v := range []testIntfMapI{ - // Use a valid string to test some extents of json string decoding - &testIntfMapT1{"ABC \x41=\x42 \u2318 - \r \b \f - \u2028 and \u2029 ."}, - testIntfMapT2{"DEF"}, - } { - if err := basicHandle(h).Intf2Impl(rti, reflect.TypeOf(v)); err != nil { - t.Logf("Error mapping %v to %T", rti, v) - t.FailNow() - } - var v1, v2 T9 - v1 = T9{v} - b := testMarshalErr(v1, h, t, name+"-enc-"+strconv.Itoa(i)) - testUnmarshalErr(&v2, b, h, t, name+"-dec-"+strconv.Itoa(i)) - testDeepEqualErr(v1, v2, t, name+"-dec-eq-"+strconv.Itoa(i)) - } -} - -func doTestOmitempty(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - if basicHandle(h).StructToArray { - t.Skipf("Skipping OmitEmpty test when StructToArray=true") - } - type T1 struct { - A int `codec:"a"` - B *int `codec:"b,omitempty"` - C int `codec:"c,omitempty"` - } - type T2 struct { - A int `codec:"a"` - } - var v1 T1 - var v2 T2 - b1 := testMarshalErr(v1, h, t, name+"-omitempty") - b2 := testMarshalErr(v2, h, t, name+"-no-omitempty-trunc") - testDeepEqualErr(b1, b2, t, name+"-omitempty-cmp") -} - -func doTestMissingFields(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - if codecgen { - t.Skipf("Skipping Missing Fields tests as it is not honored by codecgen") - } - if basicHandle(h).StructToArray { - t.Skipf("Skipping Missing Fields test when StructToArray=true") - } - // encode missingFielderT2, decode into missingFielderT1, encode it out again, decode into new missingFielderT2, compare - v1 := missingFielderT2{S: "true seven eight", B: true, F: 777.0, I: -888} - b1 := testMarshalErr(v1, h, t, name+"-missing-enc-2") - // xdebugf("marshal into b1: %s", b1) - var v2 missingFielderT1 - testUnmarshalErr(&v2, b1, h, t, name+"-missing-dec-1") - // xdebugf("unmarshal into v2: %v", v2) - b2 := testMarshalErr(&v2, h, t, name+"-missing-enc-1") - // xdebugf("marshal into b2: %s", b2) - var v3 missingFielderT2 - testUnmarshalErr(&v3, b2, h, t, name+"-missing-dec-2") - // xdebugf("unmarshal into v3: %v", v3) - testDeepEqualErr(v1, v3, t, name+"-missing-cmp-2") -} - -func doTestMaxDepth(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - type T struct { - I interface{} // value to encode - M int16 // maxdepth - S bool // use swallow (decode into typed struct with only A1) - E interface{} // error to find - } - type T1 struct { - A1 *T1 - } - var table []T - var sfunc = func(n int) (s [1]interface{}, s1 *[1]interface{}) { - s1 = &s - for i := 0; i < n; i++ { - var s0 [1]interface{} - s1[0] = &s0 - s1 = &s0 - } - // xdebugf("sfunc s: %v", s) - return - // var s []interface{} - // s = append(s, []interface{}) - // s[0] = append(s[0], []interface{}) - // s[0][0] = append(s[0][0], []interface{}) - // s[0][0][0] = append(s[0][0][0], []interface{}) - // s[0][0][0][0] = append(s[0][0][0][0], []interface{}) - // return s - } - var mfunc = func(n int) (m map[string]interface{}, mlast map[string]interface{}) { - m = make(map[string]interface{}) - mlast = make(map[string]interface{}) - m["A0"] = mlast - for i := 1; i < n; i++ { - m0 := make(map[string]interface{}) - mlast["A"+strconv.FormatInt(int64(i), 10)] = m0 - mlast = m0 - } - // xdebugf("mfunc m: %v", m) - return - } - s, s1 := sfunc(5) - m, _ := mfunc(5) - m99, _ := mfunc(99) - - s1[0] = m - - table = append(table, T{s, 0, false, nil}) - table = append(table, T{s, 256, false, nil}) - table = append(table, T{s, 7, false, errMaxDepthExceeded}) - table = append(table, T{s, 15, false, nil}) - table = append(table, T{m99, 15, true, errMaxDepthExceeded}) - table = append(table, T{m99, 215, true, nil}) - - defer func(n int16, b bool) { - basicHandle(h).MaxDepth = n - testUseMust = b - }(basicHandle(h).MaxDepth, testUseMust) - - testUseMust = false - for i, v := range table { - basicHandle(h).MaxDepth = v.M - b1 := testMarshalErr(v.I, h, t, name+"-maxdepth-enc"+strconv.FormatInt(int64(i), 10)) - // xdebugf("b1: %s", b1) - var err error - if v.S { - var v2 T1 - err = testUnmarshal(&v2, b1, h) - } else { - var v2 interface{} - err = testUnmarshal(&v2, b1, h) - } - if err1, ok := err.(decodeError); ok { - err = err1.codecError - } - var err0 interface{} = err - if err1, ok := err.(codecError); ok { - err0 = err1.err - } - if err0 != v.E { - t.Logf("Unexpected error testing max depth for depth %d: expected %v, received %v", v.M, v.E, err) - t.FailNow() - } - - // decode into something that just triggers swallow - } -} - -func doTestMultipleEncDec(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - // encode a string multiple times. - // decode it multiple times. - // ensure we get the value each time - var s1 = "ugorji" - var s2 = "nwoke" - var s11, s21 string - var buf bytes.Buffer - e := NewEncoder(&buf, h) - e.MustEncode(s1) - e.MustEncode(s2) - d := NewDecoder(&buf, h) - d.MustDecode(&s11) - d.MustDecode(&s21) - testDeepEqualErr(s1, s11, t, name+"-multiple-encode") - testDeepEqualErr(s2, s21, t, name+"-multiple-encode") -} - -func doTestSelfExt(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - var ts TestSelfExtImpl - ts.S = "ugorji" - ts.I = 5678 - ts.B = true - var ts2 TestSelfExtImpl - - bs := testMarshalErr(&ts, h, t, name) - testUnmarshalErr(&ts2, bs, h, t, name) - testDeepEqualErr(&ts, &ts2, t, name) -} - -func doTestBytesEncodedAsArray(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - // Need to test edge case where bytes are encoded as an array - // (not using optimized []byte native format) - - // encode []int8 (or int32 or any numeric type) with all positive numbers - // decode it into []uint8 - var in = make([]int32, 128) - var un = make([]uint8, 128) - for i := range in { - in[i] = int32(i) - un[i] = uint8(i) - } - var out []byte - bs := testMarshalErr(&in, h, t, name) - testUnmarshalErr(&out, bs, h, t, name) - // xdebugf("in: %v", in) - // xdebug2f("out: %v\n", out) - testDeepEqualErr(un, out, t, name) -} - -func doTestStrucEncDec(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - { - var ts1 = newTestStruc(2, testNumRepeatString, false, !testSkipIntf, testMapStringKeyOnly) - var ts2 TestStruc - bs := testMarshalErr(ts1, h, t, name) - testUnmarshalErr(&ts2, bs, h, t, name) - testDeepEqualErr(ts1, &ts2, t, name) - } - // Note: We cannot use TestStrucFlex because it has omitempty values, - // Meaning that sometimes, encoded and decoded will not be same. - // { - // var ts1 = newTestStrucFlex(2, testNumRepeatString, false, !testSkipIntf, testMapStringKeyOnly) - // var ts2 TestStrucFlex - // bs := testMarshalErr(ts1, h, t, name) - // fmt.Printf("\n\n%s\n\n", bs) - // testUnmarshalErr(&ts2, bs, h, t, name) - // testDeepEqualErr(ts1, &ts2, t, name) - // } -} - -func doTestStructKeyType(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - name := h.Name() - - mh, mok := h.(*MsgpackHandle) - - bch, bcok := h.(*BincHandle) - - bh := basicHandle(h) - s2a := bh.StructToArray - bh.StructToArray = false - var mfx bool - if mok { - mfx = mh.NoFixedNum - mh.NoFixedNum = false - } - var bcsym uint8 - if bcok { - bcsym = bch.AsSymbols - bch.AsSymbols = 2 // TODO: should be 0 but binc symbols do not work well - } - defer func() { - bh.StructToArray = s2a - if mok { - mh.NoFixedNum = mfx - } - if bcok { - bch.AsSymbols = bcsym - } - }() - - var bs1, bs2 []byte - - var m = make(map[interface{}]interface{}) - - fn := func(v interface{}) { - bs1 = testMarshalErr(v, h, t, "") - bs2 = testMarshalErr(m, h, t, "") - // if _, ok := h.(*JsonHandle); ok { - // xdebugf("bs1: %s, bs2: %s", bs1, bs2) - // } - // if bcok { - // xdebug2f("-------------") - // xdebugf("v: %#v, m: %#v", v, m) - // xdebugf("bs1: %v", bs1) - // xdebugf("bs2: %v", bs2) - // xdebugf("bs1==bs2: %v", bytes.Equal(bs1, bs2)) - // testDeepEqualErr(bs1, bs2, t, name+"") - // xdebug2f("-------------") - // return - // } - testDeepEqualErr(bs1, bs2, t, name+"") - } - - fnclr := func() { - for k := range m { - delete(m, k) - } - } - - m["F"] = 0 - fn(testStrucKeyTypeT0{}) - fnclr() - - m["FFFF"] = 0 - fn(testStrucKeyTypeT1{}) - fnclr() - - m[int64(-1)] = 0 - fn(testStrucKeyTypeT2{}) - fnclr() - - m[int64(1)] = 0 - fn(testStrucKeyTypeT3{}) - fnclr() - - m[float64(2.5)] = 0 - fn(testStrucKeyTypeT4{}) - fnclr() - -} - -func doTestRawToStringToRawEtc(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // name := h.Name() - - // Tests: - // - RawToString - // - StringToRaw - // - MapValueReset - // - DeleteOnMapValue (skipped - no longer supported) - - bh := basicHandle(h) - // xdebugf("[%s] maptype: %v, slice type: %v", name, bh.MapType, bh.SliceType) - - r2s := bh.RawToString - s2r := bh.StringToRaw - can := bh.Canonical - mvr := bh.MapValueReset - - var wext bool - mh, mok := h.(*MsgpackHandle) - if mok { - wext = mh.WriteExt - } - - _, jok := h.(*JsonHandle) - - defer func() { - bh.RawToString = r2s - bh.StringToRaw = s2r - bh.Canonical = can - bh.MapValueReset = mvr - if mok { - mh.WriteExt = wext - } - }() - - bh.Canonical = false - - var bs1, bs2 []byte - - // encode: StringToRaw - // decode: RawToString - - // compare encoded v1 to encoded v2, while setting StringToRaw to b - fne := func(v1, v2 interface{}, b bool) { - // xdebugf("[%s] fne: StringToRaw: %v, v1: %#v, v2: %#v", name, b, v1, v2) - bh.StringToRaw = b - bs1 = testMarshalErr(v1, h, t, "") - // bs1 = []byte(string(bs1)) - bs2 = testMarshalErr(v2, h, t, "") - // if jok { - // xdebugf("[%s] fne: bh: %#v", name, bh.EncodeOptions) - // xdebugf("[%s] bs1: %s", name, bs1) - // xdebugf("[%s] bs2: %s", name, bs2) - // } - testDeepEqualErr(bs1, bs2, t, "") - } - - // encoded v1, decode naked and compare to v2 - fnd := func(v1, v2 interface{}, bs2r, br2s, bwext bool) { - bh.RawToString = br2s - bh.StringToRaw = bs2r - if mok { - mh.WriteExt = bwext - } - bs1 = testMarshalErr(v1, h, t, "") - var vn interface{} - testUnmarshalErr(&vn, bs1, h, t, "") - testDeepEqualErr(vn, v2, t, "") - } - - sv0 := "value" - bv0 := []byte(sv0) - - sv1 := sv0 - bv1 := []byte(sv1) - - m1 := map[string]*string{"key": &sv1} - m2 := map[string]*[]byte{"key": &bv1} - - // m3 := map[[3]byte]string{[3]byte{'k', 'e', 'y'}: sv0} - m4 := map[[3]byte][]byte{[3]byte{'k', 'e', 'y'}: bv0} - m5 := map[string][]byte{"key": bv0} - // m6 := map[string]string{"key": sv0} - - m7 := map[interface{}]interface{}{"key": sv0} - m8 := map[interface{}]interface{}{"key": bv0} - - // StringToRaw=true - fne(m1, m4, true) - - // StringToRaw=false - // compare encoded m2 to encoded m5 - fne(m2, m5, false) - - // json doesn't work well with StringToRaw and RawToString - // when dealing with interfaces, because it cannot decipher - // that a string should be treated as base64. - if jok { - goto MAP_VALUE_RESET - } - - // if msgpack, always set WriteExt = RawToString - - // StringToRaw=true (RawToString=true) - // encoded m1, decode naked and compare to m5 - fnd(m2, m7, true, true, true) - - // StringToRaw=true (RawToString=false) - // encoded m1, decode naked and compare to m6 - fnd(m1, m8, true, false, false) - - // StringToRaw=false, RawToString=true - // encode m1, decode naked, and compare to m6 - fnd(m2, m7, false, true, true) - -MAP_VALUE_RESET: - // set MapValueReset, and then decode i - sv2 := "value-new" - m9 := map[string]*string{"key": &sv2} - - bs1 = testMarshalErr(m1, h, t, "") - - bh.MapValueReset = false - testUnmarshalErr(&m9, bs1, h, t, "") - // if !(m9["key"] == m1["key"] - testDeepEqualErr(sv2, "value", t, "") - testDeepEqualErr(&sv2, m9["key"], t, "") - - sv2 = "value-new" - m9["key"] = &sv2 - bh.MapValueReset = true - testUnmarshalErr(&m9, bs1, h, t, "") - testDeepEqualErr(sv2, "value-new", t, "") - testDeepEqualErr("value", *(m9["key"]), t, "") - - // t1 = struct { - // key string - // }{ key: sv0 } - // t2 := struct { - // key []byte - // }{ key: bv1 } - -} - -// ----------------- - -func TestJsonDecodeNonStringScalarInStringContext(t *testing.T) { - testOnce.Do(testInitAll) - var b = `{"s.true": "true", "b.true": true, "s.false": "false", "b.false": false, "s.10": "10", "i.10": 10, "i.-10": -10}` - var golden = map[string]string{"s.true": "true", "b.true": "true", "s.false": "false", "b.false": "false", "s.10": "10", "i.10": "10", "i.-10": "-10"} - - var m map[string]string - d := NewDecoderBytes([]byte(b), testJsonH) - d.MustDecode(&m) - if err := deepEqual(golden, m); err == nil { - if testVerbose { - t.Logf("++++ match: decoded: %#v", m) - } - } else { - t.Logf("---- mismatch: %v ==> golden: %#v, decoded: %#v", err, golden, m) - t.FailNow() - } -} - -func TestJsonEncodeIndent(t *testing.T) { - testOnce.Do(testInitAll) - v := TestSimplish{ - Ii: -794, - Ss: `A Man is -after the new line - after new line and tab -`, - } - v2 := v - v.Mm = make(map[string]*TestSimplish) - for i := 0; i < len(v.Ar); i++ { - v3 := v2 - v3.Ii += (i * 4) - v3.Ss = fmt.Sprintf("%d - %s", v3.Ii, v3.Ss) - if i%2 == 0 { - v.Ar[i] = &v3 - } - // v3 = v2 - v.Sl = append(v.Sl, &v3) - v.Mm[strconv.FormatInt(int64(i), 10)] = &v3 - } - oldcan := testJsonH.Canonical - oldIndent := testJsonH.Indent - oldS2A := testJsonH.StructToArray - defer func() { - testJsonH.Canonical = oldcan - testJsonH.Indent = oldIndent - testJsonH.StructToArray = oldS2A - }() - testJsonH.Canonical = true - testJsonH.Indent = -1 - testJsonH.StructToArray = false - var bs []byte - NewEncoderBytes(&bs, testJsonH).MustEncode(&v) - txt1Tab := string(bs) - bs = nil - testJsonH.Indent = 120 - NewEncoderBytes(&bs, testJsonH).MustEncode(&v) - txtSpaces := string(bs) - // fmt.Printf("\n-----------\n%s\n------------\n%s\n-------------\n", txt1Tab, txtSpaces) - - goldenResultTab := `{ - "Ar": [ - { - "Ar": [ - null, - null - ], - "Ii": -794, - "Mm": null, - "Sl": null, - "Ss": "-794 - A Man is\nafter the new line\n\tafter new line and tab\n" - }, - null - ], - "Ii": -794, - "Mm": { - "0": { - "Ar": [ - null, - null - ], - "Ii": -794, - "Mm": null, - "Sl": null, - "Ss": "-794 - A Man is\nafter the new line\n\tafter new line and tab\n" - }, - "1": { - "Ar": [ - null, - null - ], - "Ii": -790, - "Mm": null, - "Sl": null, - "Ss": "-790 - A Man is\nafter the new line\n\tafter new line and tab\n" - } - }, - "Sl": [ - { - "Ar": [ - null, - null - ], - "Ii": -794, - "Mm": null, - "Sl": null, - "Ss": "-794 - A Man is\nafter the new line\n\tafter new line and tab\n" - }, - { - "Ar": [ - null, - null - ], - "Ii": -790, - "Mm": null, - "Sl": null, - "Ss": "-790 - A Man is\nafter the new line\n\tafter new line and tab\n" - } - ], - "Ss": "A Man is\nafter the new line\n\tafter new line and tab\n" -}` - - if txt1Tab != goldenResultTab { - t.Logf("decoded indented with tabs != expected: \nexpected: %s\nencoded: %s", goldenResultTab, txt1Tab) - t.FailNow() - } - if txtSpaces != strings.Replace(goldenResultTab, "\t", strings.Repeat(" ", 120), -1) { - t.Logf("decoded indented with spaces != expected: \nexpected: %s\nencoded: %s", goldenResultTab, txtSpaces) - t.FailNow() - } -} - -func doTestBufioDecReader(t *testing.T, bufsize int) { - testOnce.Do(testInitAll) - bufsizehalf := (bufsize + 1) / 2 - // TODO: add testing when the buffer size is smaller than the string length. - - // try to read 85 bytes in chunks of 7 at a time. - var s = strings.Repeat("01234'56789 ", 5) - // fmt.Printf("s: %s\n", s) - var r = strings.NewReader(s) - var br bufioDecReader - var blist bytesFreelist - br.reset(r, bufsize, &blist) - b, err := ioutil.ReadAll(br.r) - if err != nil { - panic(err) - } - var s2 = string(b) - // fmt.Printf("s==s2: %v, len(s): %v, len(b): %v, len(s2): %v\n", s == s2, len(s), len(b), len(s2)) - if s != s2 { - t.Logf("not equal: \ns: %s\ns2: %s", s, s2) - t.FailNow() - } - // Now, test search functions for skip, readTo and readUntil - // readUntil ', readTo ', skip whitespace. 3 times in a loop, each time compare the token and/or outs - // readUntil: see: 56789 - var out []byte - var token byte - br.reset(strings.NewReader(s), bufsizehalf, &blist) - // println() - for _, v2 := range [...]string{ - `01234'`, - `56789 01234'`, - `56789 01234'`, - `56789 01234'`, - } { - out = br.readUntil('\'', true) - testDeepEqualErr(string(out), v2, t, "-") - // fmt.Printf("readUntil: out: `%s`\n", out) - } - br.reset(strings.NewReader(s), bufsizehalf, &blist) - // println() - for range [4]struct{}{} { - out = br.readTo(&numCharBitset) - testDeepEqualErr(string(out), `01234`, t, "-") - // fmt.Printf("readTo: out: `%s`\n", out) - out = br.readUntil('\'', true) - testDeepEqualErr(string(out), "'", t, "-") - // fmt.Printf("readUntil: out: `%s`\n", out) - out = br.readTo(&numCharBitset) - testDeepEqualErr(string(out), `56789`, t, "-") - // fmt.Printf("readTo: out: `%s`\n", out) - out = br.readUntil('0', true) - testDeepEqualErr(string(out), ` 0`, t, "-") - // fmt.Printf("readUntil: out: `%s`\n", out) - br.unreadn1() - } - br.reset(strings.NewReader(s), bufsizehalf, &blist) - // println() - for range [4]struct{}{} { - out = br.readUntil(' ', true) - testDeepEqualErr(string(out), `01234'56789 `, t, "-") - // fmt.Printf("readUntil: out: |%s|\n", out) - token = br.skipWhitespace() // br.skip(&whitespaceCharBitset) - testDeepEqualErr(token, byte('0'), t, "-") - // fmt.Printf("skip: token: '%c'\n", token) - br.unreadn1() - } - // println() -} - -func doTestPreferArrayOverSlice(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // encode a slice, decode it with PreferArrayOverSlice - // if codecgen, skip the test (as codecgen doesn't work with PreferArrayOverSlice) - if codecgen { - t.Skip() - } - bh := basicHandle(h) - paos := bh.PreferArrayOverSlice - styp := bh.SliceType - defer func() { - bh.PreferArrayOverSlice = paos - bh.SliceType = styp - }() - bh.PreferArrayOverSlice = true - bh.SliceType = reflect.TypeOf(([]bool)(nil)) - - s2 := [4]bool{true, false, true, false} - s := s2[:] - var v interface{} - bs := testMarshalErr(s, h, t, t.Name()) - testUnmarshalErr(&v, bs, h, t, t.Name()) - testDeepEqualErr(s2, v, t, t.Name()) -} - -func doTestZeroCopyBytes(t *testing.T, h Handle) { - testOnce.Do(testInitAll) - // jsonhandle and cborhandle with indefiniteLength do not support inline bytes, so skip them. - if _, ok := h.(*JsonHandle); ok { // if h == testJsonH { - t.Skip() - } - if ch, ok := h.(*CborHandle); ok && ch.IndefiniteLength { - t.Skip() - } - - bh := basicHandle(h) - zc := bh.ZeroCopy - defer func() { - bh.ZeroCopy = zc - }() - bh.ZeroCopy = true - - s := []byte("hello") - var v []byte - bs := testMarshalErr(s, h, t, t.Name()) - - // Note: this test only works for decoding from []byte, so cannot use testUnmarshalErr - NewDecoderBytes(bs, h).MustDecode(&v) - // testUnmarshalErr(&v, bs, h, t, t.Name()) - - // validate that bs and s points into the bs stream - for i := range bs { - if &bs[i] == &v[0] { - return - } - } - - // if not match, then a failure happened. - if len(bs) > 0 && len(v) > 0 { - t.Logf("%s: ZeroCopy=true, but decoded (%p) is not slice of input: (%p)", h.Name(), &v[0], &bs[0]) - } else { - t.Logf("%s: ZeroCopy=true, but decoded OR input slice is empty: %v, %v", h.Name(), v, bs) - } - t.FailNow() -} - -func TestBufioDecReader(t *testing.T) { - testOnce.Do(testInitAll) - doTestBufioDecReader(t, 13) - doTestBufioDecReader(t, 3) - doTestBufioDecReader(t, 5) - doTestBufioDecReader(t, 127) -} - -func TestAtomic(t *testing.T) { - testOnce.Do(testInitAll) - // load, store, load, confirm - if true { - var a atomicTypeInfoSlice - l := a.load() - if l != nil { - t.Logf("atomic fail: %T, expected load return nil, received: %v", a, l) - t.FailNow() - } - l = append(l, rtid2ti{}) - a.store(l) - l = a.load() - if len(l) != 1 { - t.Logf("atomic fail: %T, expected load to have length 1, received: %d", a, len(l)) - t.FailNow() - } - } - if true { - var a atomicRtidFnSlice - l := a.load() - if l != nil { - t.Logf("atomic fail: %T, expected load return nil, received: %v", a, l) - t.FailNow() - } - l = append(l, codecRtidFn{}) - a.store(l) - l = a.load() - if len(l) != 1 { - t.Logf("atomic fail: %T, expected load to have length 1, received: %d", a, len(l)) - t.FailNow() - } - } - if true { - var a atomicClsErr - l := a.load() - if l.errClosed != nil { - t.Logf("atomic fail: %T, expected load return clsErr = nil, received: %v", a, l.errClosed) - t.FailNow() - } - l.errClosed = io.EOF - a.store(l) - l = a.load() - if l.errClosed != io.EOF { - t.Logf("atomic fail: %T, expected clsErr = io.EOF, received: %v", a, l.errClosed) - t.FailNow() - } - } -} - -// ----------- - -func TestJsonLargeInteger(t *testing.T) { - testOnce.Do(testInitAll) - for _, i := range []uint8{'L', 'A', 0} { - for _, j := range []interface{}{ - int64(1 << 60), - -int64(1 << 60), - 0, - 1 << 20, - -(1 << 20), - uint64(1 << 60), - uint(0), - uint(1 << 20), - } { - doTestJsonLargeInteger(t, j, i) - } - } - - oldIAS := testJsonH.IntegerAsString - defer func() { testJsonH.IntegerAsString = oldIAS }() - testJsonH.IntegerAsString = 0 - - type tt struct { - s string - canI, canUi bool - i int64 - ui uint64 - } - - var i int64 - var ui uint64 - var err error - var d *Decoder = NewDecoderBytes(nil, testJsonH) - for _, v := range []tt{ - {"0", true, true, 0, 0}, - {"0000", true, true, 0, 0}, - {"0.00e+2", true, true, 0, 0}, - {"000e-2", true, true, 0, 0}, - {"0.00e-2", true, true, 0, 0}, - - {"9223372036854775807", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"92233720368547758.07e+2", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"922337203685477580700e-2", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"9223372.036854775807E+12", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"9223372036854775807000000000000E-12", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"0.9223372036854775807E+19", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"92233720368547758070000000000000000000E-19", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"0.000009223372036854775807E+24", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - {"9223372036854775807000000000000000000000000E-24", true, true, math.MaxInt64, math.MaxInt64}, // maxint64 - - {"-9223372036854775808", true, false, math.MinInt64, 0}, // minint64 - {"-92233720368547758.08e+2", true, false, math.MinInt64, 0}, // minint64 - {"-922337203685477580800E-2", true, false, math.MinInt64, 0}, // minint64 - {"-9223372.036854775808e+12", true, false, math.MinInt64, 0}, // minint64 - {"-9223372036854775808000000000000E-12", true, false, math.MinInt64, 0}, // minint64 - {"-0.9223372036854775808e+19", true, false, math.MinInt64, 0}, // minint64 - {"-92233720368547758080000000000000000000E-19", true, false, math.MinInt64, 0}, // minint64 - {"-0.000009223372036854775808e+24", true, false, math.MinInt64, 0}, // minint64 - {"-9223372036854775808000000000000000000000000E-24", true, false, math.MinInt64, 0}, // minint64 - - {"18446744073709551615", false, true, 0, math.MaxUint64}, // maxuint64 - {"18446744.073709551615E+12", false, true, 0, math.MaxUint64}, // maxuint64 - {"18446744073709551615000000000000E-12", false, true, 0, math.MaxUint64}, // maxuint64 - {"0.000018446744073709551615E+24", false, true, 0, math.MaxUint64}, // maxuint64 - {"18446744073709551615000000000000000000000000E-24", false, true, 0, math.MaxUint64}, // maxuint64 - - // Add test for limit of uint64 where last digit is 0 - {"18446744073709551610", false, true, 0, math.MaxUint64 - 5}, // maxuint64 - {"18446744.073709551610E+12", false, true, 0, math.MaxUint64 - 5}, // maxuint64 - {"18446744073709551610000000000000E-12", false, true, 0, math.MaxUint64 - 5}, // maxuint64 - {"0.000018446744073709551610E+24", false, true, 0, math.MaxUint64 - 5}, // maxuint64 - {"18446744073709551610000000000000000000000000E-24", false, true, 0, math.MaxUint64 - 5}, // maxuint64 - // {"", true, true}, - } { - if v.s == "" { - continue - } - if true { - d.ResetBytes([]byte(v.s)) - err = d.Decode(&ui) - if (v.canUi && err != nil) || (!v.canUi && err == nil) || (v.canUi && err == nil && v.ui != ui) { - t.Logf("Failing to decode %s (as unsigned): %v", v.s, err) - t.FailNow() - } - } - - if true { - d.ResetBytes([]byte(v.s)) - err = d.Decode(&i) - if (v.canI && err != nil) || (!v.canI && err == nil) || (v.canI && err == nil && v.i != i) { - t.Logf("Failing to decode %s (as signed): %v", v.s, err) - t.FailNow() - } - } - } -} - -func TestJsonInvalidUnicode(t *testing.T) { - testOnce.Do(testInitAll) - // t.Skipf("new json implementation does not handle bad unicode robustly") - var m = map[string]string{ - `"\udc49\u0430abc"`: "\uFFFDabc", - `"\udc49\u0430"`: "\uFFFD", - `"\udc49abc"`: "\uFFFDabc", - `"\udc49"`: "\uFFFD", - `"\udZ49\u0430abc"`: "\uFFFD\u0430abc", - `"\udcG9\u0430"`: "\uFFFD\u0430", - `"\uHc49abc"`: "\uFFFDabc", - `"\uKc49"`: "\uFFFD", - } - - // set testUseMust to true, so we can capture errors - if testUseMust { - testUseMust = false - defer func() { testUseMust = true }() - } - - for k, v := range m { - var s string - - // call testUnmarshal directly, so we can check for EOF - // - // testUnmarshalErr(&s, []byte(k), testJsonH, t, "-") - err := testUnmarshal(&s, []byte(k), testJsonH) - if err != nil { - if err == io.EOF { - continue - } - t.Logf("%s: unmarshal failed: %v", "-", err) - t.FailNow() - } - - if s != v { - t.Logf("not equal: %q, %q", v, s) - t.FailNow() - } - } -} - -func TestMsgpackDecodeMapAndExtSizeMismatch(t *testing.T) { - fn := func(t *testing.T, b []byte, v interface{}) { - if err := NewDecoderBytes(b, testMsgpackH).Decode(v); err != io.EOF && err != io.ErrUnexpectedEOF { - t.Fatalf("expected EOF or ErrUnexpectedEOF, got %v", err) - } - } - - // a map claiming to have 0x10eeeeee KV pairs, but only has 1. - var b = []byte{0xdf, 0x10, 0xee, 0xee, 0xee, 0x1, 0xa1, 0x1} - var m1 map[int]string - var m2 map[int][]byte - fn(t, b, &m1) - fn(t, b, &m2) - - // an extension claiming to have 0x7fffffff bytes, but only has 1. - b = []byte{0xc9, 0x7f, 0xff, 0xff, 0xff, 0xda, 0x1} - var a interface{} - fn(t, b, &a) - - // b = []byte{0x00} - // var s testSelferRecur - // fn(t, b, &s) -} - -func TestMapRangeIndex(t *testing.T) { - // t.Skip() - type T struct { - I int - S string - B bool - M map[int]T - } - - t1 := T{I: 1, B: true, S: "11", M: map[int]T{11: T{I: 11}}} - t2 := T{I: 1, B: true, S: "12", M: map[int]T{12: T{I: 12}}} - - // ------ - - var m1 = map[string]*T{ - "11": &t1, - "12": &t2, - } - var m1c = make(map[string]T) - for k, v := range m1 { - m1c[k] = *v - } - - fnrv := func(r1, r2 reflect.Value) reflect.Value { - if r1.IsValid() { - return r1 - } - return r2 - } - - // var vx reflect.Value - - mt := reflect.TypeOf(m1) - rvk := mapAddressableRV(mt.Key(), mt.Key().Kind()) - rvv := mapAddressableRV(mt.Elem(), mt.Elem().Kind()) - var it mapIter - mapRange(&it, rv4i(m1), rvk, rvv, true) - for it.Next() { - k := fnrv(it.Key(), rvk).Interface().(string) - v := fnrv(it.Value(), rvv).Interface().(*T) - testDeepEqualErr(m1[k], v, t, "map-key-eq-it-key") - if _, ok := m1c[k]; ok { - delete(m1c, k) - } else { - t.Logf("unexpected key in map: %v", k) - t.FailNow() - } - } - it.Done() - testDeepEqualErr(len(m1c), 0, t, "all-keys-not-consumed") - - // ------ - - var m2 = map[*T]T{ - &t1: t1, - &t2: t2, - } - var m2c = make(map[*T]*T) - for k := range m2 { - m2c[k] = k - } - - mt = reflect.TypeOf(m2) - rvk = mapAddressableRV(mt.Key(), mt.Key().Kind()) - rvv = mapAddressableRV(mt.Elem(), mt.Elem().Kind()) - mapRange(&it, rv4i(m2), rvk, rvv, true) - for it.Next() { - k := fnrv(it.Key(), rvk).Interface().(*T) - v := fnrv(it.Value(), rvv).Interface().(T) - testDeepEqualErr(m2[k], v, t, "map-key-eq-it-key") - if _, ok := m2c[k]; ok { - delete(m2c, k) - } else { - t.Logf("unexpected key in map: %v", k) - t.FailNow() - } - } - it.Done() - testDeepEqualErr(len(m2c), 0, t, "all-keys-not-consumed") - - // ---- test mapGet - - fnTestMapIndex := func(mi ...interface{}) { - for _, m0 := range mi { - m := rv4i(m0) - rvv := mapAddressableRV(m.Type().Elem(), m.Type().Elem().Kind()) - for _, k := range m.MapKeys() { - testDeepEqualErr(m.MapIndex(k).Interface(), mapGet(m, k, rvv).Interface(), t, "map-index-eq") - } - } - } - - fnTestMapIndex(m1, m1c, m2, m2c) - - // var s string = "hello" - // var tt = &T{I: 3} - // ttTyp := reflect.TypeOf(tt) - // _, _ = tt, ttTyp - // mv := rv4i(m) - // it := mapRange(mv, rv4i(&s).Elem(), rv4i(&tt).Elem(), true) //ok - // it := mapRange(mv, reflect.New(reflect.TypeOf(s)).Elem(), reflect.New(reflect.TypeOf(T{})).Elem(), true) // ok - // it := mapRange(mv, reflect.New(reflect.TypeOf(s)).Elem(), reflect.New(ttTyp.Elem()), true) // !ok - // it := mapRange(mv, reflect.New(reflect.TypeOf(s)).Elem(), reflect.New(reflect.TypeOf(T{})), true) !ok - // it := mapRange(mv, reflect.New(reflect.TypeOf(s)).Elem(), reflect.New(reflect.TypeOf(T{})).Elem(), true) // ok - - // fmt.Printf("key: %#v\n", it.Key()) - // fmt.Printf("exp: %#v\n", mv.MapIndex(it.Key())) - // fmt.Printf("val: %#v\n", it.Value()) - // testDeepEqualErr(mv.MapIndex(it.Key()), it.Value().Interface() -} - -// ---------- - -func TestBincCodecsTable(t *testing.T) { - testCodecTableOne(t, testBincH) -} - -func TestBincCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testBincH) -} - -func TestBincCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testBincH) -} - -func TestBincStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, testBincH) -} - -func TestBincMammoth(t *testing.T) { - testMammoth(t, testBincH) -} - -func TestSimpleCodecsTable(t *testing.T) { - testCodecTableOne(t, testSimpleH) -} - -func TestSimpleCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testSimpleH) -} - -func TestSimpleCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testSimpleH) -} - -func TestSimpleStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, testSimpleH) -} - -func TestSimpleMammoth(t *testing.T) { - testMammoth(t, testSimpleH) -} - -func TestMsgpackCodecsTable(t *testing.T) { - testCodecTableOne(t, testMsgpackH) -} - -func TestMsgpackCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testMsgpackH) -} - -func TestMsgpackCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testMsgpackH) -} - -func TestMsgpackStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, testMsgpackH) -} - -func TestMsgpackMammoth(t *testing.T) { - testMammoth(t, testMsgpackH) -} - -func TestCborCodecsTable(t *testing.T) { - testCodecTableOne(t, testCborH) -} - -func TestCborCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testCborH) -} - -func TestCborCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testCborH) -} - -func TestCborCodecChan(t *testing.T) { - testCodecChan(t, testCborH) -} - -func TestCborStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, testCborH) -} - -func TestCborMammoth(t *testing.T) { - testMammoth(t, testCborH) -} - -func TestJsonCodecsTable(t *testing.T) { - testCodecTableOne(t, testJsonH) -} - -func TestJsonCodecsMisc(t *testing.T) { - testCodecMiscOne(t, testJsonH) -} - -func TestJsonCodecsEmbeddedPointer(t *testing.T) { - testCodecEmbeddedPointer(t, testJsonH) -} - -func TestJsonCodecChan(t *testing.T) { - testCodecChan(t, testJsonH) -} - -func TestJsonStdEncIntf(t *testing.T) { - doTestStdEncIntf(t, testJsonH) -} - -func TestJsonMammothA(t *testing.T) { - testMammoth(t, testJsonH) -} - -// ----- Raw --------- -func TestJsonRaw(t *testing.T) { - doTestRawValue(t, testJsonH) -} -func TestBincRaw(t *testing.T) { - doTestRawValue(t, testBincH) -} -func TestMsgpackRaw(t *testing.T) { - doTestRawValue(t, testMsgpackH) -} -func TestSimpleRaw(t *testing.T) { - doTestRawValue(t, testSimpleH) -} -func TestCborRaw(t *testing.T) { - doTestRawValue(t, testCborH) -} - -// ----- ALL (framework based) ----- - -func TestAllEncCircularRef(t *testing.T) { - doTestEncCircularRef(t, testCborH) -} - -func TestAllAnonCycle(t *testing.T) { - doTestAnonCycle(t, testCborH) -} - -func TestAllErrWriter(t *testing.T) { - doTestErrWriter(t, testCborH) - doTestErrWriter(t, testJsonH) -} - -// ----- RPC custom ----- - -func TestMsgpackRpcSpec(t *testing.T) { - testCodecRpcOne(t, MsgpackSpecRpc, testMsgpackH, true, 0) -} - -// ----- RPC ----- - -func TestBincRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testBincH, true, 0) -} - -func TestSimpleRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testSimpleH, true, 0) -} - -func TestMsgpackRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testMsgpackH, true, 0) -} - -func TestCborRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testCborH, true, 0) -} - -func TestJsonRpcGo(t *testing.T) { - testCodecRpcOne(t, GoRpc, testJsonH, true, 0) -} - -// ----- OTHERS ----- - -func TestBincMapEncodeForCanonical(t *testing.T) { - t.Skip() // TODO: testing fails??? Need to research - doTestMapEncodeForCanonical(t, testBincH) -} - -func TestSimpleMapEncodeForCanonical(t *testing.T) { - doTestMapEncodeForCanonical(t, testSimpleH) -} - -func TestMsgpackMapEncodeForCanonical(t *testing.T) { - doTestMapEncodeForCanonical(t, testMsgpackH) -} - -func TestCborMapEncodeForCanonical(t *testing.T) { - doTestMapEncodeForCanonical(t, testCborH) -} - -func TestJsonMapEncodeForCanonical(t *testing.T) { - doTestMapEncodeForCanonical(t, testJsonH) -} - -func TestBincUnderlyingType(t *testing.T) { - testCodecUnderlyingType(t, testBincH) -} - -func TestJsonSwallowAndZero(t *testing.T) { - doTestSwallowAndZero(t, testJsonH) -} - -func TestCborSwallowAndZero(t *testing.T) { - doTestSwallowAndZero(t, testCborH) -} - -func TestMsgpackSwallowAndZero(t *testing.T) { - doTestSwallowAndZero(t, testMsgpackH) -} - -func TestBincSwallowAndZero(t *testing.T) { - doTestSwallowAndZero(t, testBincH) -} - -func TestSimpleSwallowAndZero(t *testing.T) { - doTestSwallowAndZero(t, testSimpleH) -} - -func TestJsonRawExt(t *testing.T) { - doTestRawExt(t, testJsonH) -} - -func TestCborRawExt(t *testing.T) { - doTestRawExt(t, testCborH) -} - -func TestMsgpackRawExt(t *testing.T) { - doTestRawExt(t, testMsgpackH) -} - -func TestBincRawExt(t *testing.T) { - doTestRawExt(t, testBincH) -} - -func TestSimpleRawExt(t *testing.T) { - doTestRawExt(t, testSimpleH) -} - -func TestJsonMapStructKey(t *testing.T) { - doTestMapStructKey(t, testJsonH) -} - -func TestCborMapStructKey(t *testing.T) { - doTestMapStructKey(t, testCborH) -} - -func TestMsgpackMapStructKey(t *testing.T) { - doTestMapStructKey(t, testMsgpackH) -} - -func TestBincMapStructKey(t *testing.T) { - doTestMapStructKey(t, testBincH) -} - -func TestSimpleMapStructKey(t *testing.T) { - doTestMapStructKey(t, testSimpleH) -} - -func TestJsonDecodeNilMapValue(t *testing.T) { - doTestDecodeNilMapValue(t, testJsonH) -} - -func TestCborDecodeNilMapValue(t *testing.T) { - doTestDecodeNilMapValue(t, testCborH) -} - -func TestMsgpackDecodeNilMapValue(t *testing.T) { - doTestDecodeNilMapValue(t, testMsgpackH) -} - -func TestBincDecodeNilMapValue(t *testing.T) { - doTestDecodeNilMapValue(t, testBincH) -} - -func TestSimpleDecodeNilMapValue(t *testing.T) { - doTestDecodeNilMapValue(t, testSimpleH) -} - -func TestJsonEmbeddedFieldPrecedence(t *testing.T) { - doTestEmbeddedFieldPrecedence(t, testJsonH) -} - -func TestCborEmbeddedFieldPrecedence(t *testing.T) { - doTestEmbeddedFieldPrecedence(t, testCborH) -} - -func TestMsgpackEmbeddedFieldPrecedence(t *testing.T) { - doTestEmbeddedFieldPrecedence(t, testMsgpackH) -} - -func TestBincEmbeddedFieldPrecedence(t *testing.T) { - doTestEmbeddedFieldPrecedence(t, testBincH) -} - -func TestSimpleEmbeddedFieldPrecedence(t *testing.T) { - doTestEmbeddedFieldPrecedence(t, testSimpleH) -} - -func TestJsonLargeContainerLen(t *testing.T) { - doTestLargeContainerLen(t, testJsonH) -} - -func TestCborLargeContainerLen(t *testing.T) { - doTestLargeContainerLen(t, testCborH) -} - -func TestMsgpackLargeContainerLen(t *testing.T) { - doTestLargeContainerLen(t, testMsgpackH) -} - -func TestBincLargeContainerLen(t *testing.T) { - doTestLargeContainerLen(t, testBincH) -} - -func TestSimpleLargeContainerLen(t *testing.T) { - doTestLargeContainerLen(t, testSimpleH) -} - -func TestJsonMammothMapsAndSlices(t *testing.T) { - doTestMammothMapsAndSlices(t, testJsonH) -} - -func TestCborMammothMapsAndSlices(t *testing.T) { - doTestMammothMapsAndSlices(t, testCborH) -} - -func TestMsgpackMammothMapsAndSlices(t *testing.T) { - old1 := testMsgpackH.WriteExt - defer func() { testMsgpackH.WriteExt = old1 }() - testMsgpackH.WriteExt = true - - doTestMammothMapsAndSlices(t, testMsgpackH) -} - -func TestBincMammothMapsAndSlices(t *testing.T) { - doTestMammothMapsAndSlices(t, testBincH) -} - -func TestSimpleMammothMapsAndSlices(t *testing.T) { - doTestMammothMapsAndSlices(t, testSimpleH) -} - -func TestJsonTime(t *testing.T) { - testTime(t, testJsonH) -} - -func TestCborTime(t *testing.T) { - testTime(t, testCborH) -} - -func TestMsgpackTime(t *testing.T) { - testTime(t, testMsgpackH) -} - -func TestBincTime(t *testing.T) { - testTime(t, testBincH) -} - -func TestSimpleTime(t *testing.T) { - testTime(t, testSimpleH) -} - -func TestJsonUintToInt(t *testing.T) { - testUintToInt(t, testJsonH) -} - -func TestCborUintToInt(t *testing.T) { - testUintToInt(t, testCborH) -} - -func TestMsgpackUintToInt(t *testing.T) { - testUintToInt(t, testMsgpackH) -} - -func TestBincUintToInt(t *testing.T) { - testUintToInt(t, testBincH) -} - -func TestSimpleUintToInt(t *testing.T) { - testUintToInt(t, testSimpleH) -} - -func TestJsonDifferentMapOrSliceType(t *testing.T) { - doTestDifferentMapOrSliceType(t, testJsonH) -} - -func TestCborDifferentMapOrSliceType(t *testing.T) { - doTestDifferentMapOrSliceType(t, testCborH) -} - -func TestMsgpackDifferentMapOrSliceType(t *testing.T) { - doTestDifferentMapOrSliceType(t, testMsgpackH) -} - -func TestBincDifferentMapOrSliceType(t *testing.T) { - doTestDifferentMapOrSliceType(t, testBincH) -} - -func TestSimpleDifferentMapOrSliceType(t *testing.T) { - doTestDifferentMapOrSliceType(t, testSimpleH) -} - -func TestJsonScalars(t *testing.T) { - doTestScalars(t, testJsonH) -} - -func TestCborScalars(t *testing.T) { - doTestScalars(t, testCborH) -} - -func TestMsgpackScalars(t *testing.T) { - doTestScalars(t, testMsgpackH) -} - -func TestBincScalars(t *testing.T) { - doTestScalars(t, testBincH) -} - -func TestSimpleScalars(t *testing.T) { - doTestScalars(t, testSimpleH) -} - -func TestJsonOmitempty(t *testing.T) { - doTestOmitempty(t, testJsonH) -} - -func TestCborOmitempty(t *testing.T) { - doTestOmitempty(t, testCborH) -} - -func TestMsgpackOmitempty(t *testing.T) { - doTestOmitempty(t, testMsgpackH) -} - -func TestBincOmitempty(t *testing.T) { - doTestOmitempty(t, testBincH) -} - -func TestSimpleOmitempty(t *testing.T) { - doTestOmitempty(t, testSimpleH) -} - -func TestJsonIntfMapping(t *testing.T) { - doTestIntfMapping(t, testJsonH) -} - -func TestCborIntfMapping(t *testing.T) { - doTestIntfMapping(t, testCborH) -} - -func TestMsgpackIntfMapping(t *testing.T) { - doTestIntfMapping(t, testMsgpackH) -} - -func TestBincIntfMapping(t *testing.T) { - doTestIntfMapping(t, testBincH) -} - -func TestSimpleIntfMapping(t *testing.T) { - doTestIntfMapping(t, testSimpleH) -} - -func TestJsonMissingFields(t *testing.T) { - doTestMissingFields(t, testJsonH) -} - -func TestCborMissingFields(t *testing.T) { - doTestMissingFields(t, testCborH) -} - -func TestMsgpackMissingFields(t *testing.T) { - doTestMissingFields(t, testMsgpackH) -} - -func TestBincMissingFields(t *testing.T) { - doTestMissingFields(t, testBincH) -} - -func TestSimpleMissingFields(t *testing.T) { - doTestMissingFields(t, testSimpleH) -} - -func TestJsonMaxDepth(t *testing.T) { - doTestMaxDepth(t, testJsonH) -} - -func TestCborMaxDepth(t *testing.T) { - doTestMaxDepth(t, testCborH) -} - -func TestMsgpackMaxDepth(t *testing.T) { - doTestMaxDepth(t, testMsgpackH) -} - -func TestBincMaxDepth(t *testing.T) { - doTestMaxDepth(t, testBincH) -} - -func TestSimpleMaxDepth(t *testing.T) { - doTestMaxDepth(t, testSimpleH) -} - -func TestJsonSelfExt(t *testing.T) { - doTestSelfExt(t, testJsonH) -} - -func TestCborSelfExt(t *testing.T) { - doTestSelfExt(t, testCborH) -} - -func TestMsgpackSelfExt(t *testing.T) { - doTestSelfExt(t, testMsgpackH) -} - -func TestBincSelfExt(t *testing.T) { - doTestSelfExt(t, testBincH) -} - -func TestSimpleSelfExt(t *testing.T) { - doTestSelfExt(t, testSimpleH) -} - -func TestJsonBytesEncodedAsArray(t *testing.T) { - doTestBytesEncodedAsArray(t, testJsonH) -} - -func TestCborBytesEncodedAsArray(t *testing.T) { - doTestBytesEncodedAsArray(t, testCborH) -} - -func TestMsgpackBytesEncodedAsArray(t *testing.T) { - doTestBytesEncodedAsArray(t, testMsgpackH) -} - -func TestBincBytesEncodedAsArray(t *testing.T) { - doTestBytesEncodedAsArray(t, testBincH) -} - -func TestSimpleBytesEncodedAsArray(t *testing.T) { - doTestBytesEncodedAsArray(t, testSimpleH) -} - -func TestJsonStrucEncDec(t *testing.T) { - doTestStrucEncDec(t, testJsonH) -} - -func TestCborStrucEncDec(t *testing.T) { - doTestStrucEncDec(t, testCborH) -} - -func TestMsgpackStrucEncDec(t *testing.T) { - doTestStrucEncDec(t, testMsgpackH) -} - -func TestBincStrucEncDec(t *testing.T) { - doTestStrucEncDec(t, testBincH) -} - -func TestSimpleStrucEncDec(t *testing.T) { - doTestStrucEncDec(t, testSimpleH) -} - -func TestJsonRawToStringToRawEtc(t *testing.T) { - doTestRawToStringToRawEtc(t, testJsonH) -} - -func TestCborRawToStringToRawEtc(t *testing.T) { - doTestRawToStringToRawEtc(t, testCborH) -} - -func TestMsgpackRawToStringToRawEtc(t *testing.T) { - doTestRawToStringToRawEtc(t, testMsgpackH) -} - -func TestBincRawToStringToRawEtc(t *testing.T) { - doTestRawToStringToRawEtc(t, testBincH) -} - -func TestSimpleRawToStringToRawEtc(t *testing.T) { - doTestRawToStringToRawEtc(t, testSimpleH) -} - -func TestJsonStructKeyType(t *testing.T) { - doTestStructKeyType(t, testJsonH) -} - -func TestCborStructKeyType(t *testing.T) { - doTestStructKeyType(t, testCborH) -} - -func TestMsgpackStructKeyType(t *testing.T) { - doTestStructKeyType(t, testMsgpackH) -} - -func TestBincStructKeyType(t *testing.T) { - doTestStructKeyType(t, testBincH) -} - -func TestSimpleStructKeyType(t *testing.T) { - doTestStructKeyType(t, testSimpleH) -} - -func TestJsonPreferArrayOverSlice(t *testing.T) { - doTestPreferArrayOverSlice(t, testJsonH) -} - -func TestCborPreferArrayOverSlice(t *testing.T) { - doTestPreferArrayOverSlice(t, testCborH) -} - -func TestMsgpackPreferArrayOverSlice(t *testing.T) { - doTestPreferArrayOverSlice(t, testMsgpackH) -} - -func TestBincPreferArrayOverSlice(t *testing.T) { - doTestPreferArrayOverSlice(t, testBincH) -} - -func TestSimplePreferArrayOverSlice(t *testing.T) { - doTestPreferArrayOverSlice(t, testSimpleH) -} - -func TestJsonZeroCopyBytes(t *testing.T) { - doTestZeroCopyBytes(t, testJsonH) -} - -func TestCborZeroCopyBytes(t *testing.T) { - doTestZeroCopyBytes(t, testCborH) -} - -func TestMsgpackZeroCopyBytes(t *testing.T) { - doTestZeroCopyBytes(t, testMsgpackH) -} - -func TestBincZeroCopyBytes(t *testing.T) { - doTestZeroCopyBytes(t, testBincH) -} - -func TestSimpleZeroCopyBytes(t *testing.T) { - doTestZeroCopyBytes(t, testSimpleH) -} - -// -------- - -func TestMultipleEncDec(t *testing.T) { - doTestMultipleEncDec(t, testJsonH) -} - -// TODO: -// -// Add Tests for the following: -// - struct tags: on anonymous fields, _struct (all fields), etc -// - chan to encode and decode (with support for codecgen also) -// -// Add negative tests for failure conditions: -// - bad input with large array length prefix -// -// Add tests for decode.go (standalone) -// - UnreadByte: only 2 states (z.ls = 2 and z.ls = 1) (0 --> 2 --> 1) -// - track: z.trb: track, stop track, check -// - PreferArrayOverSlice??? -// - InterfaceReset -// - (chan byte) to decode []byte (with mapbyslice track) -// - decode slice of len 6, 16 into slice of (len 4, cap 8) and (len ) with maxinitlen=6, 8, 16 -// - DeleteOnNilMapValue -// - decnaked: n.l == nil -// - ensureDecodeable (try to decode into a non-decodeable thing e.g. a nil interface{}, -// -// Add tests for encode.go (standalone) -// - nil and 0-len slices and maps for non-fastpath things diff --git a/vendor/github.com/ugorji/go/codec/codecgen.go b/vendor/github.com/ugorji/go/codec/codecgen.go deleted file mode 100644 index cc5ecec6d..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen.go +++ /dev/null @@ -1,13 +0,0 @@ -// +build codecgen generated - -package codec - -// this file is here, to set the codecgen variable to true -// when the build tag codecgen is set. -// -// this allows us do specific things e.g. skip missing fields tests, -// when running in codecgen mode. - -func init() { - codecgen = true -} diff --git a/vendor/github.com/ugorji/go/codec/codecgen/README.md b/vendor/github.com/ugorji/go/codec/codecgen/README.md deleted file mode 100644 index 854b64bfc..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# codecgen tool - -Generate is given a list of *.go files to parse, and an output file (fout), -codecgen will create an output file __file.go__ which -contains `codec.Selfer` implementations for the named types found -in the files parsed. - -Using codecgen is very straightforward. - -**Download and install the tool** - -`go get -u github.com/ugorji/go/codec/codecgen` - -**Run the tool on your files** - -The command line format is: - -`codecgen [options] (-o outfile) (infile ...)` - -```sh -% codecgen -? -Usage of codecgen: - -c="github.com/ugorji/go/codec": codec path - -o="": out file - -r=".*": regex for type name to match - -nr="": regex for type name to exclude - -rt="": tags for go run - -t="": build tag to put in file - -u=false: Use unsafe, e.g. to avoid unnecessary allocation on []byte->string - -x=false: keep temp file - -% codecgen -o values_codecgen.go values.go values2.go moretypedefs.go -``` - -Please see the [blog article](http://ugorji.net/blog/go-codecgen) -for more information on how to use the tool. - diff --git a/vendor/github.com/ugorji/go/codec/codecgen/gen.go b/vendor/github.com/ugorji/go/codec/codecgen/gen.go deleted file mode 100644 index 4f039d0f8..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/gen.go +++ /dev/null @@ -1,383 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// codecgen generates static implementations of the encoder and decoder functions -// for a given type, bypassing reflection, and giving some performance benefits in terms of -// wall and cpu time, and memory usage. -// -// Benchmarks (as of Dec 2018) show that codecgen gives about -// -// - for binary formats (cbor, etc): 25% on encoding and 30% on decoding to/from []byte -// - for text formats (json, etc): 15% on encoding and 25% on decoding to/from []byte -// -// Note that (as of Dec 2018) codecgen completely ignores -// -// - MissingFielder interface -// (if you types implements it, codecgen ignores that) -// - decode option PreferArrayOverSlice -// (we cannot dynamically create non-static arrays without reflection) -// -// In explicit package terms: codecgen generates codec.Selfer implementations for a set of types. -package main - -import ( - "bufio" - "bytes" - "errors" - "flag" - "fmt" - "go/ast" - "go/parser" - "go/token" - "math/rand" - "os" - "os/exec" - "path/filepath" - "regexp" - "strconv" - "strings" - "text/template" - "time" -) - -const genCodecPkg = "codec1978" // keep this in sync with codec.genCodecPkg - -const genFrunMainTmpl = `//+build ignore - -// Code generated - temporary main package for codecgen - DO NOT EDIT. - -package main -{{ if .Types }}import "{{ .ImportPath }}"{{ end }} -func main() { - {{ $.PackageName }}.CodecGenTempWrite{{ .RandString }}() -} -` - -// const genFrunPkgTmpl = `//+build codecgen -const genFrunPkgTmpl = ` - -// Code generated - temporary package for codecgen - DO NOT EDIT. - -package {{ $.PackageName }} - -import ( - {{ if not .CodecPkgFiles }}{{ .CodecPkgName }} "{{ .CodecImportPath }}"{{ end }} - "os" - "reflect" - "bytes" - "strings" - "go/format" -) - -func CodecGenTempWrite{{ .RandString }}() { - os.Remove("{{ .OutFile }}") - fout, err := os.Create("{{ .OutFile }}") - if err != nil { - panic(err) - } - defer fout.Close() - - var typs []reflect.Type - var typ reflect.Type - var numfields int -{{ range $index, $element := .Types }} - var t{{ $index }} {{ . }} -typ = reflect.TypeOf(t{{ $index }}) - typs = append(typs, typ) - if typ.Kind() == reflect.Struct { numfields += typ.NumField() } else { numfields += 1 } -{{ end }} - - // println("initializing {{ .OutFile }}, buf size: {{ .AllFilesSize }}*16", - // {{ .AllFilesSize }}*16, "num fields: ", numfields) - var out = bytes.NewBuffer(make([]byte, 0, numfields*1024)) // {{ .AllFilesSize }}*16 - {{ if not .CodecPkgFiles }}{{ .CodecPkgName }}.{{ end }}Gen(out, - "{{ .BuildTag }}", "{{ .PackageName }}", "{{ .RandString }}", {{ .NoExtensions }}, - {{ if not .CodecPkgFiles }}{{ .CodecPkgName }}.{{ end }}NewTypeInfos(strings.Split("{{ .StructTags }}", ",")), - typs...) - - bout, err := format.Source(out.Bytes()) - // println("... lengths: before formatting: ", len(out.Bytes()), ", after formatting", len(bout)) - if err != nil { - fout.Write(out.Bytes()) - panic(err) - } - fout.Write(bout) -} - -` - -// Generate is given a list of *.go files to parse, and an output file (fout). -// -// It finds all types T in the files, and it creates 2 tmp files (frun). -// - main package file passed to 'go run' -// - package level file which calls *genRunner.Selfer to write Selfer impls for each T. -// We use a package level file so that it can reference unexported types in the package being worked on. -// Tool then executes: "go run __frun__" which creates fout. -// fout contains Codec(En|De)codeSelf implementations for every type T. -// -func Generate(outfile, buildTag, codecPkgPath string, - uid int64, - goRunTag string, st string, - regexName, notRegexName *regexp.Regexp, - deleteTempFile, noExtensions bool, - infiles ...string) (err error) { - // For each file, grab AST, find each type, and write a call to it. - if len(infiles) == 0 { - return - } - if codecPkgPath == "" { - return errors.New("codec package path cannot be blank") - } - if outfile == "" { - return errors.New("outfile cannot be blank") - } - if uid < 0 { - uid = -uid - } else if uid == 0 { - rr := rand.New(rand.NewSource(time.Now().UnixNano())) - uid = 101 + rr.Int63n(9777) - } - // We have to parse dir for package, before opening the temp file for writing (else ImportDir fails). - // Also, ImportDir(...) must take an absolute path. - lastdir := filepath.Dir(outfile) - absdir, err := filepath.Abs(lastdir) - if err != nil { - return - } - importPath, err := pkgPath(absdir) - if err != nil { - return - } - type tmplT struct { - CodecPkgName string - CodecImportPath string - ImportPath string - OutFile string - PackageName string - RandString string - BuildTag string - StructTags string - Types []string - AllFilesSize int64 - CodecPkgFiles bool - NoExtensions bool - } - tv := tmplT{ - CodecPkgName: genCodecPkg, - OutFile: outfile, - CodecImportPath: codecPkgPath, - BuildTag: buildTag, - RandString: strconv.FormatInt(uid, 10), - StructTags: st, - NoExtensions: noExtensions, - } - tv.ImportPath = importPath - if tv.ImportPath == tv.CodecImportPath { - tv.CodecPkgFiles = true - tv.CodecPkgName = "codec" - } else { - // HACK: always handle vendoring. It should be typically on in go 1.6, 1.7 - tv.ImportPath = stripVendor(tv.ImportPath) - } - astfiles := make([]*ast.File, len(infiles)) - var fi os.FileInfo - for i, infile := range infiles { - if filepath.Dir(infile) != lastdir { - err = errors.New("all input files must all be in same directory as output file") - return - } - if fi, err = os.Stat(infile); err != nil { - return - } - tv.AllFilesSize += fi.Size() - - fset := token.NewFileSet() - astfiles[i], err = parser.ParseFile(fset, infile, nil, 0) - if err != nil { - return - } - if i == 0 { - tv.PackageName = astfiles[i].Name.Name - if tv.PackageName == "main" { - // codecgen cannot be run on types in the 'main' package. - // A temporary 'main' package must be created, and should reference the fully built - // package containing the types. - // Also, the temporary main package will conflict with the main package which already has a main method. - err = errors.New("codecgen cannot be run on types in the 'main' package") - return - } - } - } - - // keep track of types with selfer methods - // selferMethods := []string{"CodecEncodeSelf", "CodecDecodeSelf"} - selferEncTyps := make(map[string]bool) - selferDecTyps := make(map[string]bool) - for _, f := range astfiles { - for _, d := range f.Decls { - // if fd, ok := d.(*ast.FuncDecl); ok && fd.Recv != nil && fd.Recv.NumFields() == 1 { - if fd, ok := d.(*ast.FuncDecl); ok && fd.Recv != nil && len(fd.Recv.List) == 1 { - recvType := fd.Recv.List[0].Type - if ptr, ok := recvType.(*ast.StarExpr); ok { - recvType = ptr.X - } - if id, ok := recvType.(*ast.Ident); ok { - switch fd.Name.Name { - case "CodecEncodeSelf": - selferEncTyps[id.Name] = true - case "CodecDecodeSelf": - selferDecTyps[id.Name] = true - } - } - } - } - } - - // now find types - for _, f := range astfiles { - for _, d := range f.Decls { - if gd, ok := d.(*ast.GenDecl); ok { - for _, dd := range gd.Specs { - if td, ok := dd.(*ast.TypeSpec); ok { - // if len(td.Name.Name) == 0 || td.Name.Name[0] > 'Z' || td.Name.Name[0] < 'A' { - if len(td.Name.Name) == 0 { - continue - } - - // only generate for: - // struct: StructType - // primitives (numbers, bool, string): Ident - // map: MapType - // slice, array: ArrayType - // chan: ChanType - // do not generate: - // FuncType, InterfaceType, StarExpr (ptr), etc - // - // We generate for all these types (not just structs), because they may be a field - // in another struct which doesn't have codecgen run on it, and it will be nice - // to take advantage of the fact that the type is a Selfer. - switch td.Type.(type) { - case *ast.StructType, *ast.Ident, *ast.MapType, *ast.ArrayType, *ast.ChanType: - // only add to tv.Types iff - // - it matches per the -r parameter - // - it doesn't match per the -nr parameter - // - it doesn't have any of the Selfer methods in the file - if regexName.FindStringIndex(td.Name.Name) != nil && - notRegexName.FindStringIndex(td.Name.Name) == nil && - !selferEncTyps[td.Name.Name] && - !selferDecTyps[td.Name.Name] { - tv.Types = append(tv.Types, td.Name.Name) - } - } - } - } - } - } - } - - if len(tv.Types) == 0 { - return - } - - // we cannot use ioutil.TempFile, because we cannot guarantee the file suffix (.go). - // Also, we cannot create file in temp directory, - // because go run will not work (as it needs to see the types here). - // Consequently, create the temp file in the current directory, and remove when done. - - // frun, err = ioutil.TempFile("", "codecgen-") - // frunName := filepath.Join(os.TempDir(), "codecgen-"+strconv.FormatInt(time.Now().UnixNano(), 10)+".go") - - frunMainName := filepath.Join(lastdir, "codecgen-main-"+tv.RandString+".generated.go") - frunPkgName := filepath.Join(lastdir, "codecgen-pkg-"+tv.RandString+".generated.go") - - // var frunMain, frunPkg *os.File - if _, err = gen1(frunMainName, genFrunMainTmpl, &tv); err != nil { - return - } - if _, err = gen1(frunPkgName, genFrunPkgTmpl, &tv); err != nil { - return - } - - // remove outfile, so "go run ..." will not think that types in outfile already exist. - os.Remove(outfile) - - // execute go run frun - cmd := exec.Command("go", "run", "-tags", "codecgen.exec safe "+goRunTag, frunMainName) //, frunPkg.Name()) - cmd.Dir = lastdir - var buf bytes.Buffer - cmd.Stdout = &buf - cmd.Stderr = &buf - if err = cmd.Run(); err != nil { - err = fmt.Errorf("error running 'go run %s': %v, console: %s", - frunMainName, err, buf.Bytes()) - return - } - os.Stdout.Write(buf.Bytes()) - - // only delete these files if codecgen ran successfully. - // if unsuccessful, these files are here for diagnosis. - if deleteTempFile { - os.Remove(frunMainName) - os.Remove(frunPkgName) - } - - return -} - -func gen1(frunName, tmplStr string, tv interface{}) (frun *os.File, err error) { - os.Remove(frunName) - if frun, err = os.Create(frunName); err != nil { - return - } - defer frun.Close() - - t := template.New("") - if t, err = t.Parse(tmplStr); err != nil { - return - } - bw := bufio.NewWriter(frun) - if err = t.Execute(bw, tv); err != nil { - bw.Flush() - return - } - if err = bw.Flush(); err != nil { - return - } - return -} - -// copied from ../gen.go (keep in sync). -func stripVendor(s string) string { - // HACK: Misbehaviour occurs in go 1.5. May have to re-visit this later. - // if s contains /vendor/ OR startsWith vendor/, then return everything after it. - const vendorStart = "vendor/" - const vendorInline = "/vendor/" - if i := strings.LastIndex(s, vendorInline); i >= 0 { - s = s[i+len(vendorInline):] - } else if strings.HasPrefix(s, vendorStart) { - s = s[len(vendorStart):] - } - return s -} - -func main() { - o := flag.String("o", "", "out file") - c := flag.String("c", genCodecPath, "codec path") - t := flag.String("t", "", "build tag to put in file") - r := flag.String("r", ".*", "regex for type name to match") - nr := flag.String("nr", "^$", "regex for type name to exclude") - rt := flag.String("rt", "", "tags for go run") - st := flag.String("st", "codec,json", "struct tag keys to introspect") - x := flag.Bool("x", false, "keep temp file") - _ = flag.Bool("u", false, "Allow unsafe use. ***IGNORED*** - kept for backwards compatibility: ") - d := flag.Int64("d", 0, "random identifier for use in generated code") - nx := flag.Bool("nx", false, "do not support extensions - support of extensions may cause extra allocation") - - flag.Parse() - err := Generate(*o, *t, *c, *d, *rt, *st, - regexp.MustCompile(*r), regexp.MustCompile(*nr), !*x, *nx, flag.Args()...) - if err != nil { - fmt.Fprintf(os.Stderr, "codecgen error: %v\n", err) - os.Exit(1) - } -} diff --git a/vendor/github.com/ugorji/go/codec/codecgen/go.mod b/vendor/github.com/ugorji/go/codec/codecgen/go.mod deleted file mode 100644 index a9499d5f9..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/ugorji/go/codec/codecgen - -require ( -github.com/ugorji/go/codec v1.1.7 -) diff --git a/vendor/github.com/ugorji/go/codec/codecgen/goversion_pkgpath_gte_go111.go b/vendor/github.com/ugorji/go/codec/codecgen/goversion_pkgpath_gte_go111.go deleted file mode 100644 index 3f1e7cc9d..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/goversion_pkgpath_gte_go111.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.11 - -package main - -import ( - "fmt" - - "golang.org/x/tools/go/packages" -) - -func pkgPath(dir string) (string, error) { - pkgs, err := packages.Load(&packages.Config{Dir: dir}, ".") - if err != nil { - return "", err - } - if len(pkgs) != 1 { - return "", fmt.Errorf("Could not read package (%d package found)", len(pkgs)) - } - pkg := pkgs[0] - return pkg.PkgPath, nil -} diff --git a/vendor/github.com/ugorji/go/codec/codecgen/goversion_pkgpath_lt_go111.go b/vendor/github.com/ugorji/go/codec/codecgen/goversion_pkgpath_lt_go111.go deleted file mode 100644 index be50035cb..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/goversion_pkgpath_lt_go111.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.11 - -package main - -import ( - "go/build" -) - -func pkgPath(dir string) (string, error) { - pkg, err := build.Default.ImportDir(dir, build.AllowBinary) - if err != nil { - return "", err - } - return pkg.ImportPath, nil -} diff --git a/vendor/github.com/ugorji/go/codec/codecgen/z.go b/vendor/github.com/ugorji/go/codec/codecgen/z.go deleted file mode 100644 index 562a339d8..000000000 --- a/vendor/github.com/ugorji/go/codec/codecgen/z.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package main - -const genCodecPath = "github.com/ugorji/go/codec" diff --git a/vendor/github.com/ugorji/go/codec/decode.go b/vendor/github.com/ugorji/go/codec/decode.go deleted file mode 100644 index a7da0c5ed..000000000 --- a/vendor/github.com/ugorji/go/codec/decode.go +++ /dev/null @@ -1,2039 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "encoding" - "errors" - "fmt" - "io" - "math" - "reflect" - "strconv" - "time" -) - -// Some tagging information for error messages. -const ( - msgBadDesc = "unrecognized descriptor byte" - // msgDecCannotExpandArr = "cannot expand go array from %v to stream length: %v" -) - -const ( - decDefMaxDepth = 1024 // maximum depth - decDefSliceCap = 8 - decDefChanCap = 64 // should be large, as cap cannot be expanded - decScratchByteArrayLen = (6 * 8) // ??? cacheLineSize + - - // decContainerLenUnknown is length returned from Read(Map|Array)Len - // when a format doesn't know apiori. - // For example, json doesn't pre-determine the length of a container (sequence/map). - decContainerLenUnknown = -1 - - // decContainerLenNil is length returned from Read(Map|Array)Len - // when a 'nil' was encountered in the stream. - decContainerLenNil = math.MinInt32 - - // decFailNonEmptyIntf configures whether we error - // when decoding naked into a non-empty interface. - // - // Typically, we cannot decode non-nil stream value into - // nil interface with methods (e.g. io.Reader). - // However, in some scenarios, this should be allowed: - // - MapType - // - SliceType - // - Extensions - // - // Consequently, we should relax this. Put it behind a const flag for now. - decFailNonEmptyIntf = false -) - -var ( - errstrOnlyMapOrArrayCanDecodeIntoStruct = "only encoded map or array can be decoded into a struct" - errstrCannotDecodeIntoNil = "cannot decode into nil" - - // errmsgExpandSliceOverflow = "expand slice: slice overflow" - errmsgExpandSliceCannotChange = "expand slice: cannot change" - - errDecoderNotInitialized = errors.New("Decoder not initialized") - - errDecUnreadByteNothingToRead = errors.New("cannot unread - nothing has been read") - errDecUnreadByteLastByteNotRead = errors.New("cannot unread - last byte has not been read") - errDecUnreadByteUnknown = errors.New("cannot unread - reason unknown") - errMaxDepthExceeded = errors.New("maximum decoding depth exceeded") - - // errBytesDecReaderCannotUnread = errors.New("cannot unread last byte read") -) - -type decDriver interface { - // this will check if the next token is a break. - CheckBreak() bool - - // TryNil tries to decode as nil. - TryNil() bool - - // ContainerType returns one of: Bytes, String, Nil, Slice or Map. - // - // Return unSet if not known. - // - // Note: Implementations MUST fully consume sentinel container types, specifically Nil. - ContainerType() (vt valueType) - - // DecodeNaked will decode primitives (number, bool, string, []byte) and RawExt. - // For maps and arrays, it will not do the decoding in-band, but will signal - // the decoder, so that is done later, by setting the fauxUnion.valueType field. - // - // Note: Numbers are decoded as int64, uint64, float64 only (no smaller sized number types). - // for extensions, DecodeNaked must read the tag and the []byte if it exists. - // if the []byte is not read, then kInterfaceNaked will treat it as a Handle - // that stores the subsequent value in-band, and complete reading the RawExt. - // - // extensions should also use readx to decode them, for efficiency. - // kInterface will extract the detached byte slice if it has to pass it outside its realm. - DecodeNaked() - - DecodeInt64() (i int64) - DecodeUint64() (ui uint64) - - DecodeFloat64() (f float64) - DecodeBool() (b bool) - - // DecodeStringAsBytes returns the bytes representing a string. - // By definition, it will return a view into a scratch buffer. - // - // Note: This can also decode symbols, if supported. - // - // Users should consume it right away and not store it for later use. - DecodeStringAsBytes() (v []byte) - - // DecodeBytes may be called directly, without going through reflection. - // Consequently, it must be designed to handle possible nil. - DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) - // DecodeBytes(bs []byte, isstring, zerocopy bool) (bsOut []byte) - - // DecodeExt will decode into a *RawExt or into an extension. - DecodeExt(v interface{}, xtag uint64, ext Ext) - // decodeExt(verifyTag bool, tag byte) (xtag byte, xbs []byte) - - DecodeTime() (t time.Time) - - // ReadArrayStart will return the length of the array. - // If the format doesn't prefix the length, it returns decContainerLenUnknown. - // If the expected array was a nil in the stream, it returns decContainerLenNil. - ReadArrayStart() int - ReadArrayEnd() - - // ReadMapStart will return the length of the array. - // If the format doesn't prefix the length, it returns decContainerLenUnknown. - // If the expected array was a nil in the stream, it returns decContainerLenNil. - ReadMapStart() int - ReadMapEnd() - - reset() - atEndOfDecode() - // uncacheRead() - - decoder() *Decoder -} - -type decDriverContainerTracker interface { - ReadArrayElem() - ReadMapElemKey() - ReadMapElemValue() -} - -type decodeError struct { - codecError - pos int -} - -func (d decodeError) Error() string { - return fmt.Sprintf("%s decode error [pos %d]: %v", d.name, d.pos, d.err) -} - -type decDriverNoopContainerReader struct{} - -func (x decDriverNoopContainerReader) ReadArrayStart() (v int) { return } -func (x decDriverNoopContainerReader) ReadArrayEnd() {} -func (x decDriverNoopContainerReader) ReadMapStart() (v int) { return } -func (x decDriverNoopContainerReader) ReadMapEnd() {} -func (x decDriverNoopContainerReader) CheckBreak() (v bool) { return } -func (x decDriverNoopContainerReader) atEndOfDecode() {} - -// DecodeOptions captures configuration options during decode. -type DecodeOptions struct { - // MapType specifies type to use during schema-less decoding of a map in the stream. - // If nil (unset), we default to map[string]interface{} iff json handle and MapStringAsKey=true, - // else map[interface{}]interface{}. - MapType reflect.Type - - // SliceType specifies type to use during schema-less decoding of an array in the stream. - // If nil (unset), we default to []interface{} for all formats. - SliceType reflect.Type - - // MaxInitLen defines the maxinum initial length that we "make" a collection - // (string, slice, map, chan). If 0 or negative, we default to a sensible value - // based on the size of an element in the collection. - // - // For example, when decoding, a stream may say that it has 2^64 elements. - // We should not auto-matically provision a slice of that size, to prevent Out-Of-Memory crash. - // Instead, we provision up to MaxInitLen, fill that up, and start appending after that. - MaxInitLen int - - // ReaderBufferSize is the size of the buffer used when reading. - // - // if > 0, we use a smart buffer internally for performance purposes. - ReaderBufferSize int - - // MaxDepth defines the maximum depth when decoding nested - // maps and slices. If 0 or negative, we default to a suitably large number (currently 1024). - MaxDepth int16 - - // If ErrorIfNoField, return an error when decoding a map - // from a codec stream into a struct, and no matching struct field is found. - ErrorIfNoField bool - - // If ErrorIfNoArrayExpand, return an error when decoding a slice/array that cannot be expanded. - // For example, the stream contains an array of 8 items, but you are decoding into a [4]T array, - // or you are decoding into a slice of length 4 which is non-addressable (and so cannot be set). - ErrorIfNoArrayExpand bool - - // If SignedInteger, use the int64 during schema-less decoding of unsigned values (not uint64). - SignedInteger bool - - // MapValueReset controls how we decode into a map value. - // - // By default, we MAY retrieve the mapping for a key, and then decode into that. - // However, especially with big maps, that retrieval may be expensive and unnecessary - // if the stream already contains all that is necessary to recreate the value. - // - // If true, we will never retrieve the previous mapping, - // but rather decode into a new value and set that in the map. - // - // If false, we will retrieve the previous mapping if necessary e.g. - // the previous mapping is a pointer, or is a struct or array with pre-set state, - // or is an interface. - MapValueReset bool - - // SliceElementReset: on decoding a slice, reset the element to a zero value first. - // - // concern: if the slice already contained some garbage, we will decode into that garbage. - SliceElementReset bool - - // InterfaceReset controls how we decode into an interface. - // - // By default, when we see a field that is an interface{...}, - // or a map with interface{...} value, we will attempt decoding into the - // "contained" value. - // - // However, this prevents us from reading a string into an interface{} - // that formerly contained a number. - // - // If true, we will decode into a new "blank" value, and set that in the interface. - // If false, we will decode into whatever is contained in the interface. - InterfaceReset bool - - // InternString controls interning of strings during decoding. - // - // Some handles, e.g. json, typically will read map keys as strings. - // If the set of keys are finite, it may help reduce allocation to - // look them up from a map (than to allocate them afresh). - // - // Note: Handles will be smart when using the intern functionality. - // Every string should not be interned. - // An excellent use-case for interning is struct field names, - // or map keys where key type is string. - InternString bool - - // PreferArrayOverSlice controls whether to decode to an array or a slice. - // - // This only impacts decoding into a nil interface{}. - // - // Consequently, it has no effect on codecgen. - // - // *Note*: This only applies if using go1.5 and above, - // as it requires reflect.ArrayOf support which was absent before go1.5. - PreferArrayOverSlice bool - - // DeleteOnNilMapValue controls how to decode a nil value in the stream. - // - // If true, we will delete the mapping of the key. - // Else, just set the mapping to the zero value of the type. - // - // Deprecated: This does NOTHING and is left behind for compiling compatibility. - // This change is necessitated because 'nil' in a stream now consistently - // means the zero value (ie reset the value to its zero state). - DeleteOnNilMapValue bool - - // RawToString controls how raw bytes in a stream are decoded into a nil interface{}. - // By default, they are decoded as []byte, but can be decoded as string (if configured). - RawToString bool - - // ZeroCopy controls whether decoded values point into the - // input bytes passed into a NewDecoderBytes/ResetBytes(...) call. - // - // To illustrate, if ZeroCopy and decoding from a []byte (not io.Writer), - // then a []byte in the output result may just be a slice of (point into) - // the input bytes. - // - // This optimization prevents unnecessary copying. - // - // However, it is made optional, as the caller MUST ensure that the input parameter - // is not modified after the Decode() happens. - ZeroCopy bool -} - -// ---------------------------------------- - -func (d *Decoder) rawExt(f *codecFnInfo, rv reflect.Value) { - d.d.DecodeExt(rv2i(rv), 0, nil) -} - -func (d *Decoder) ext(f *codecFnInfo, rv reflect.Value) { - d.d.DecodeExt(rv2i(rv), f.xfTag, f.xfFn) -} - -func (d *Decoder) selferUnmarshal(f *codecFnInfo, rv reflect.Value) { - rv2i(rv).(Selfer).CodecDecodeSelf(d) -} - -func (d *Decoder) binaryUnmarshal(f *codecFnInfo, rv reflect.Value) { - bm := rv2i(rv).(encoding.BinaryUnmarshaler) - xbs := d.d.DecodeBytes(nil, true) - if fnerr := bm.UnmarshalBinary(xbs); fnerr != nil { - panic(fnerr) - } -} - -func (d *Decoder) textUnmarshal(f *codecFnInfo, rv reflect.Value) { - tm := rv2i(rv).(encoding.TextUnmarshaler) - fnerr := tm.UnmarshalText(d.d.DecodeStringAsBytes()) - if fnerr != nil { - panic(fnerr) - } -} - -func (d *Decoder) jsonUnmarshal(f *codecFnInfo, rv reflect.Value) { - tm := rv2i(rv).(jsonUnmarshaler) - // bs := d.d.DecodeBytes(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(d.nextValueBytes()) - if fnerr != nil { - panic(fnerr) - } -} - -func (d *Decoder) kErr(f *codecFnInfo, rv reflect.Value) { - d.errorf("no decoding function defined for kind %v", rv.Kind()) -} - -func (d *Decoder) raw(f *codecFnInfo, rv reflect.Value) { - rvSetBytes(rv, d.rawBytes()) -} - -func (d *Decoder) kString(f *codecFnInfo, rv reflect.Value) { - rvSetString(rv, string(d.d.DecodeStringAsBytes())) -} - -func (d *Decoder) kBool(f *codecFnInfo, rv reflect.Value) { - rvSetBool(rv, d.d.DecodeBool()) -} - -func (d *Decoder) kTime(f *codecFnInfo, rv reflect.Value) { - rvSetTime(rv, d.d.DecodeTime()) -} - -func (d *Decoder) kFloat32(f *codecFnInfo, rv reflect.Value) { - rvSetFloat32(rv, d.decodeFloat32()) -} - -func (d *Decoder) kFloat64(f *codecFnInfo, rv reflect.Value) { - rvSetFloat64(rv, d.d.DecodeFloat64()) -} - -func (d *Decoder) kInt(f *codecFnInfo, rv reflect.Value) { - rvSetInt(rv, int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))) -} - -func (d *Decoder) kInt8(f *codecFnInfo, rv reflect.Value) { - rvSetInt8(rv, int8(chkOvf.IntV(d.d.DecodeInt64(), 8))) -} - -func (d *Decoder) kInt16(f *codecFnInfo, rv reflect.Value) { - rvSetInt16(rv, int16(chkOvf.IntV(d.d.DecodeInt64(), 16))) -} - -func (d *Decoder) kInt32(f *codecFnInfo, rv reflect.Value) { - rvSetInt32(rv, int32(chkOvf.IntV(d.d.DecodeInt64(), 32))) -} - -func (d *Decoder) kInt64(f *codecFnInfo, rv reflect.Value) { - rvSetInt64(rv, d.d.DecodeInt64()) -} - -func (d *Decoder) kUint(f *codecFnInfo, rv reflect.Value) { - rvSetUint(rv, uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))) -} - -func (d *Decoder) kUintptr(f *codecFnInfo, rv reflect.Value) { - rvSetUintptr(rv, uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))) -} - -func (d *Decoder) kUint8(f *codecFnInfo, rv reflect.Value) { - rvSetUint8(rv, uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))) -} - -func (d *Decoder) kUint16(f *codecFnInfo, rv reflect.Value) { - rvSetUint16(rv, uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))) -} - -func (d *Decoder) kUint32(f *codecFnInfo, rv reflect.Value) { - rvSetUint32(rv, uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))) -} - -func (d *Decoder) kUint64(f *codecFnInfo, rv reflect.Value) { - rvSetUint64(rv, d.d.DecodeUint64()) -} - -func (d *Decoder) kInterfaceNaked(f *codecFnInfo) (rvn reflect.Value) { - // nil interface: - // use some hieristics to decode it appropriately - // based on the detected next value in the stream. - n := d.naked() - d.d.DecodeNaked() - - // We cannot decode non-nil stream value into nil interface with methods (e.g. io.Reader). - // Howver, it is possible that the user has ways to pass in a type for a given interface - // - MapType - // - SliceType - // - Extensions - // - // Consequently, we should relax this. Put it behind a const flag for now. - if decFailNonEmptyIntf && f.ti.numMeth > 0 { - d.errorf("cannot decode non-nil codec value into nil %v (%v methods)", f.ti.rt, f.ti.numMeth) - return - } - switch n.v { - case valueTypeMap: - // if json, default to a map type with string keys - mtid := d.mtid - if mtid == 0 { - if d.jsms { - mtid = mapStrIntfTypId - } else { - mtid = mapIntfIntfTypId - } - } - if mtid == mapIntfIntfTypId { - var v2 map[interface{}]interface{} - d.decode(&v2) - rvn = rv4i(&v2).Elem() - } else if mtid == mapStrIntfTypId { // for json performance - var v2 map[string]interface{} - d.decode(&v2) - rvn = rv4i(&v2).Elem() - } else { - if d.mtr { - rvn = reflect.New(d.h.MapType) - d.decode(rv2i(rvn)) - rvn = rvn.Elem() - } else { - rvn = rvZeroAddrK(d.h.MapType, reflect.Map) - d.decodeValue(rvn, nil) - } - } - case valueTypeArray: - if d.stid == 0 || d.stid == intfSliceTypId { - var v2 []interface{} - d.decode(&v2) - rvn = rv4i(&v2).Elem() - } else { - if d.str { - rvn = reflect.New(d.h.SliceType) - d.decode(rv2i(rvn)) - rvn = rvn.Elem() - } else { - rvn = rvZeroAddrK(d.h.SliceType, reflect.Slice) - d.decodeValue(rvn, nil) - } - } - if reflectArrayOfSupported && d.h.PreferArrayOverSlice { - rvn = rvGetArray4Slice(rvn) - } - case valueTypeExt: - tag, bytes := n.u, n.l // calling decode below might taint the values - bfn := d.h.getExtForTag(tag) - var re = RawExt{Tag: tag} - if bytes == nil { - // it is one of the InterfaceExt ones: json and cbor. - // most likely cbor, as json decoding never reveals valueTypeExt (no tagging support) - if bfn == nil { - d.decode(&re.Value) - rvn = rv4i(&re).Elem() - } else { - if bfn.ext == SelfExt { - rvn = rvZeroAddrK(bfn.rt, bfn.rt.Kind()) - d.decodeValue(rvn, d.h.fnNoExt(bfn.rt)) - } else { - rvn = reflect.New(bfn.rt) - d.interfaceExtConvertAndDecode(rv2i(rvn), bfn.ext) - rvn = rvn.Elem() - } - } - } else { - // one of the BytesExt ones: binc, msgpack, simple - if bfn == nil { - re.Data = detachZeroCopyBytes(d.bytes, nil, bytes) - rvn = rv4i(&re).Elem() - } else { - rvn = reflect.New(bfn.rt) - if bfn.ext == SelfExt { - d.sideDecode(rv2i(rvn), bytes) - } else { - bfn.ext.ReadExt(rv2i(rvn), bytes) - } - rvn = rvn.Elem() - } - } - case valueTypeNil: - // rvn = reflect.Zero(f.ti.rt) - // no-op - case valueTypeInt: - rvn = n.ri() - case valueTypeUint: - rvn = n.ru() - case valueTypeFloat: - rvn = n.rf() - case valueTypeBool: - rvn = n.rb() - case valueTypeString, valueTypeSymbol: - rvn = n.rs() - case valueTypeBytes: - rvn = n.rl() - case valueTypeTime: - rvn = n.rt() - default: - halt.errorf("kInterfaceNaked: unexpected valueType: %d", n.v) - } - return -} - -func (d *Decoder) kInterface(f *codecFnInfo, rv reflect.Value) { - // Note: - // A consequence of how kInterface works, is that - // if an interface already contains something, we try - // to decode into what was there before. - // We do not replace with a generic value (as got from decodeNaked). - - // every interface passed here MUST be settable. - var rvn reflect.Value - if rvIsNil(rv) || d.h.InterfaceReset { - // check if mapping to a type: if so, initialize it and move on - rvn = d.h.intf2impl(f.ti.rtid) - if rvn.IsValid() { - rv.Set(rvn) - } else { - rvn = d.kInterfaceNaked(f) - // xdebugf("kInterface: %v", rvn) - if rvn.IsValid() { - rv.Set(rvn) - } else if d.h.InterfaceReset { - // reset to zero value based on current type in there. - if rvelem := rv.Elem(); rvelem.IsValid() { - rv.Set(reflect.Zero(rvelem.Type())) - } - } - return - } - } else { - // now we have a non-nil interface value, meaning it contains a type - rvn = rv.Elem() - } - - // Note: interface{} is settable, but underlying type may not be. - // Consequently, we MAY have to create a decodable value out of the underlying value, - // decode into it, and reset the interface itself. - // fmt.Printf(">>>> kInterface: rvn type: %v, rv type: %v\n", rvn.Type(), rv.Type()) - - if isDecodeable(rvn) { - d.decodeValue(rvn, nil) - return - } - - rvn2 := rvZeroAddrK(rvn.Type(), rvn.Kind()) - rvSetDirect(rvn2, rvn) - d.decodeValue(rvn2, nil) - rv.Set(rvn2) -} - -func decStructFieldKey(dd decDriver, keyType valueType, b *[decScratchByteArrayLen]byte) (rvkencname []byte) { - // use if-else-if, not switch (which compiles to binary-search) - // since keyType is typically valueTypeString, branch prediction is pretty good. - - if keyType == valueTypeString { - rvkencname = dd.DecodeStringAsBytes() - } else if keyType == valueTypeInt { - rvkencname = strconv.AppendInt(b[:0], dd.DecodeInt64(), 10) - } else if keyType == valueTypeUint { - rvkencname = strconv.AppendUint(b[:0], dd.DecodeUint64(), 10) - } else if keyType == valueTypeFloat { - rvkencname = strconv.AppendFloat(b[:0], dd.DecodeFloat64(), 'f', -1, 64) - } else { - rvkencname = dd.DecodeStringAsBytes() - } - return -} - -func (d *Decoder) kStruct(f *codecFnInfo, rv reflect.Value) { - sfn := structFieldNode{v: rv, update: true} - ctyp := d.d.ContainerType() - if ctyp == valueTypeNil { - rvSetDirect(rv, f.ti.rv0) - return - } - var mf MissingFielder - if f.ti.isFlag(tiflagMissingFielder) { - mf = rv2i(rv).(MissingFielder) - } else if f.ti.isFlag(tiflagMissingFielderPtr) { - mf = rv2i(rv.Addr()).(MissingFielder) - } - if ctyp == valueTypeMap { - containerLen := d.mapStart() - if containerLen == 0 { - d.mapEnd() - return - } - tisfi := f.ti.sfiSort - hasLen := containerLen >= 0 - - var rvkencname []byte - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - rvkencname = decStructFieldKey(d.d, f.ti.keyType, &d.b) - d.mapElemValue() - if k := f.ti.indexForEncName(rvkencname); k > -1 { - si := tisfi[k] - d.decodeValue(sfn.field(si), nil) - } else if mf != nil { - // store rvkencname in new []byte, as it previously shares Decoder.b, which is used in decode - name2 := rvkencname - rvkencname = make([]byte, len(rvkencname)) - copy(rvkencname, name2) - - var f interface{} - d.decode(&f) - if !mf.CodecMissingField(rvkencname, f) && d.h.ErrorIfNoField { - d.errorf("no matching struct field found when decoding stream map with key: %s ", - stringView(rvkencname)) - } - } else { - d.structFieldNotFound(-1, stringView(rvkencname)) - } - // keepAlive4StringView(rvkencnameB) // not needed, as reference is outside loop - } - d.mapEnd() - } else if ctyp == valueTypeArray { - containerLen := d.arrayStart() - if containerLen == 0 { - d.arrayEnd() - return - } - // Not much gain from doing it two ways for array. - // Arrays are not used as much for structs. - hasLen := containerLen >= 0 - var checkbreak bool - for j, si := range f.ti.sfiSrc { - if hasLen && j == containerLen { - break - } - if !hasLen && d.checkBreak() { - checkbreak = true - break - } - d.arrayElem() - d.decodeValue(sfn.field(si), nil) - } - if (hasLen && containerLen > len(f.ti.sfiSrc)) || (!hasLen && !checkbreak) { - // read remaining values and throw away - for j := len(f.ti.sfiSrc); ; j++ { - if (hasLen && j == containerLen) || (!hasLen && d.checkBreak()) { - break - } - d.arrayElem() - d.structFieldNotFound(j, "") - } - } - d.arrayEnd() - } else { - d.errorstr(errstrOnlyMapOrArrayCanDecodeIntoStruct) - return - } -} - -func (d *Decoder) kSlice(f *codecFnInfo, rv reflect.Value) { - // if f.seq == seqTypeArray { - // xdebugf("decoder.kSlice: %v, %#v", rv.Type(), rv) - // } - - // A slice can be set from a map or array in stream. - // This way, the order can be kept (as order is lost with map). - - // Note: rv is a slice type here - guaranteed - - rtelem0 := f.ti.elem - ctyp := d.d.ContainerType() - if ctyp == valueTypeNil { - if rv.CanSet() { - rvSetDirect(rv, f.ti.rv0) - } - return - } - if ctyp == valueTypeBytes || ctyp == valueTypeString { - // you can only decode bytes or string in the stream into a slice or array of bytes - if !(f.ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { - d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", f.ti.rt) - } - rvbs := rvGetBytes(rv) - bs2 := d.d.DecodeBytes(rvbs, false) - // if rvbs == nil && bs2 != nil || rvbs != nil && bs2 == nil || len(bs2) != len(rvbs) { - if !(len(bs2) > 0 && len(bs2) == len(rvbs) && &bs2[0] == &rvbs[0]) { - if rv.CanSet() { - rvSetBytes(rv, bs2) - } else if len(rvbs) > 0 && len(bs2) > 0 { - copy(rvbs, bs2) - } - } - return - } - - slh, containerLenS := d.decSliceHelperStart() // only expects valueType(Array|Map) - never Nil - - // an array can never return a nil slice. so no need to check f.array here. - if containerLenS == 0 { - if rv.CanSet() { - if rvIsNil(rv) { - rvSetDirect(rv, reflect.MakeSlice(f.ti.rt, 0, 0)) - } else { - rvSetSliceLen(rv, 0) - } - } - slh.End() - return - } - - rtelem0Size := int(rtelem0.Size()) - rtElem0Kind := rtelem0.Kind() - rtelem0Mut := !isImmutableKind(rtElem0Kind) - rtelem := rtelem0 - rtelemkind := rtelem.Kind() - for rtelemkind == reflect.Ptr { - rtelem = rtelem.Elem() - rtelemkind = rtelem.Kind() - } - - var fn *codecFn - - var rv0 = rv - var rvChanged bool - var rvCanset = rv.CanSet() - var rv9 reflect.Value - - rvlen := rvGetSliceLen(rv) - rvcap := rvGetSliceCap(rv) - hasLen := containerLenS > 0 - if hasLen { - if containerLenS > rvcap { - oldRvlenGtZero := rvlen > 0 - rvlen = decInferLen(containerLenS, d.h.MaxInitLen, int(rtelem0.Size())) - if rvlen <= rvcap { - if rvCanset { - rvSetSliceLen(rv, rvlen) - } - } else if rvCanset { - rv = reflect.MakeSlice(f.ti.rt, rvlen, rvlen) - rvcap = rvlen - rvChanged = true - } else { - d.errorf("cannot decode into non-settable slice") - } - if rvChanged && oldRvlenGtZero && rtelem0Mut { // !isImmutableKind(rtelem0.Kind()) { - rvCopySlice(rv, rv0) // only copy up to length NOT cap i.e. rv0.Slice(0, rvcap) - } - } else if containerLenS != rvlen { - rvlen = containerLenS - if rvCanset { - rvSetSliceLen(rv, rvlen) - } - } - } - - // consider creating new element once, and just decoding into it. - var rtelem0Zero reflect.Value - var rtelem0ZeroValid bool - var j int - - for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && f.seq == seqTypeSlice && rvIsNil(rv) { - if hasLen { - rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size) - } else { - rvlen = decDefSliceCap - } - if rvCanset { - rv = reflect.MakeSlice(f.ti.rt, rvlen, rvlen) - rvcap = rvlen - rvChanged = true - } else { - d.errorf("cannot decode into non-settable slice") - } - } - // if indefinite, etc, then expand the slice if necessary - if j >= rvlen { - if f.seq == seqTypeArray { - decArrayCannotExpand(slh, hasLen, rvlen, j, containerLenS) - return - } - slh.ElemContainerState(j) - // rv = reflect.Append(rv, reflect.Zero(rtelem0)) // append logic + varargs - - // expand the slice up to the cap. - // Note that we did, so we have to reset it later. - - if rvlen < rvcap { - if rv.CanSet() { - rvSetSliceLen(rv, rvcap) - } else if rvCanset { - rv = rvSlice(rv, rvcap) - rvChanged = true - } else { - d.errorf(errmsgExpandSliceCannotChange) - return - } - rvlen = rvcap - } else { - if !rvCanset { - d.errorf(errmsgExpandSliceCannotChange) - return - } - // rvcap2 := rvcap - rvcap = growCap(rvcap, rtelem0Size, 1) - // if rvcap < 32 { - // rvcap = 32 - // } - // xdebugf("%v: growing cap from %v to %v (unit size: %v)", rtelem, rvcap2, rvcap, rtelem0Size) - rv9 = reflect.MakeSlice(f.ti.rt, rvcap, rvcap) - rvCopySlice(rv9, rv) - rv = rv9 - rvChanged = true - rvlen = rvcap - } - } else { - slh.ElemContainerState(j) - } - rv9 = rvSliceIndex(rv, j, f.ti) - if d.h.SliceElementReset { - if !rtelem0ZeroValid { - rtelem0ZeroValid = true - rtelem0Zero = reflect.Zero(rtelem0) - } - rv9.Set(rtelem0Zero) - } - - if fn == nil { - fn = d.h.fn(rtelem) - } - d.decodeValue(rv9, fn) - } - if j < rvlen { - if rv.CanSet() { - rvSetSliceLen(rv, j) - } else if rvCanset { - rv = rvSlice(rv, j) - rvChanged = true - } - rvlen = j - } else if j == 0 && rvIsNil(rv) { - if rvCanset { - rv = reflect.MakeSlice(f.ti.rt, 0, 0) - rvChanged = true - } - } - slh.End() - - if rvChanged { // infers rvCanset=true, so it can be reset - rv0.Set(rv) - } - -} - -func (d *Decoder) kSliceForChan(f *codecFnInfo, rv reflect.Value) { - // A slice can be set from a map or array in stream. - // This way, the order can be kept (as order is lost with map). - - if f.ti.chandir&uint8(reflect.SendDir) == 0 { - d.errorf("receive-only channel cannot be decoded") - } - rtelem0 := f.ti.elem - ctyp := d.d.ContainerType() - if ctyp == valueTypeNil { - rvSetDirect(rv, f.ti.rv0) - return - } - if ctyp == valueTypeBytes || ctyp == valueTypeString { - // you can only decode bytes or string in the stream into a slice or array of bytes - if !(f.ti.rtid == uint8SliceTypId || rtelem0.Kind() == reflect.Uint8) { - d.errorf("bytes/string in stream must decode into slice/array of bytes, not %v", f.ti.rt) - } - bs2 := d.d.DecodeBytes(nil, true) - irv := rv2i(rv) - ch, ok := irv.(chan<- byte) - if !ok { - ch = irv.(chan byte) - } - for _, b := range bs2 { - ch <- b - } - return - } - - // only expects valueType(Array|Map - nil handled above) - slh, containerLenS := d.decSliceHelperStart() - - // an array can never return a nil slice. so no need to check f.array here. - if containerLenS == 0 { - if rv.CanSet() && rvIsNil(rv) { - rvSetDirect(rv, reflect.MakeChan(f.ti.rt, 0)) - } - slh.End() - return - } - - rtelem0Size := int(rtelem0.Size()) - rtElem0Kind := rtelem0.Kind() - rtelem0Mut := !isImmutableKind(rtElem0Kind) - rtelem := rtelem0 - rtelemkind := rtelem.Kind() - for rtelemkind == reflect.Ptr { - rtelem = rtelem.Elem() - rtelemkind = rtelem.Kind() - } - - var fn *codecFn - - var rvCanset = rv.CanSet() - var rvChanged bool - var rv0 = rv - var rv9 reflect.Value - - var rvlen int // := rv.Len() - hasLen := containerLenS > 0 - - var j int - - for ; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && rvIsNil(rv) { - if hasLen { - rvlen = decInferLen(containerLenS, d.h.MaxInitLen, rtelem0Size) - } else { - rvlen = decDefChanCap - } - if rvCanset { - rv = reflect.MakeChan(f.ti.rt, rvlen) - rvChanged = true - } else { - d.errorf("cannot decode into non-settable chan") - } - } - slh.ElemContainerState(j) - if rtelem0Mut || !rv9.IsValid() { // || (rtElem0Kind == reflect.Ptr && rvIsNil(rv9)) { - rv9 = rvZeroAddrK(rtelem0, rtElem0Kind) - } - if fn == nil { - fn = d.h.fn(rtelem) - } - d.decodeValue(rv9, fn) - rv.Send(rv9) - } - slh.End() - - if rvChanged { // infers rvCanset=true, so it can be reset - rv0.Set(rv) - } - -} - -func (d *Decoder) kMap(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - rvSetDirect(rv, f.ti.rv0) - return - } - ti := f.ti - if rvIsNil(rv) { - rvlen := decInferLen(containerLen, d.h.MaxInitLen, int(ti.key.Size()+ti.elem.Size())) - rvSetDirect(rv, makeMapReflect(ti.rt, rvlen)) - } - - if containerLen == 0 { - d.mapEnd() - return - } - - ktype, vtype := ti.key, ti.elem - ktypeId := rt2id(ktype) - vtypeKind := vtype.Kind() - ktypeKind := ktype.Kind() - - var vtypeElem reflect.Type - - var keyFn, valFn *codecFn - var ktypeLo, vtypeLo reflect.Type - - for ktypeLo = ktype; ktypeLo.Kind() == reflect.Ptr; ktypeLo = ktypeLo.Elem() { - } - - for vtypeLo = vtype; vtypeLo.Kind() == reflect.Ptr; vtypeLo = vtypeLo.Elem() { - } - - rvvMut := !isImmutableKind(vtypeKind) - - // we do a doMapGet if kind is mutable, and InterfaceReset=true if interface - var doMapGet, doMapSet bool - if !d.h.MapValueReset { - if rvvMut { - if vtypeKind == reflect.Interface { - if !d.h.InterfaceReset { - doMapGet = true - } - } else { - doMapGet = true - } - } - } - - var rvk, rvkn, rvv, rvvn, rvva reflect.Value - var rvvaSet bool - rvkMut := !isImmutableKind(ktype.Kind()) // if ktype is immutable, then re-use the same rvk. - ktypeIsString := ktypeId == stringTypId - ktypeIsIntf := ktypeId == intfTypId - hasLen := containerLen > 0 - var kstrbs []byte - - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - if j == 0 { - if !rvkMut { - rvkn = rvZeroAddrK(ktype, ktypeKind) - } - if !rvvMut { - rvvn = rvZeroAddrK(vtype, vtypeKind) - } - } - - if rvkMut { - rvk = rvZeroAddrK(ktype, ktypeKind) - } else { - rvk = rvkn - } - - d.mapElemKey() - - if ktypeIsString { - kstrbs = d.d.DecodeStringAsBytes() - rvk.SetString(stringView(kstrbs)) // NOTE: if doing an insert, use real string (not stringview) - } else { - if keyFn == nil { - keyFn = d.h.fn(ktypeLo) - } - d.decodeValue(rvk, keyFn) - } - - // special case if interface wrapping a byte array. - if ktypeIsIntf { - if rvk2 := rvk.Elem(); rvk2.IsValid() && rvk2.Type() == uint8SliceTyp { - rvk.Set(rv4i(d.string(rvGetBytes(rvk2)))) - } - // NOTE: consider failing early if map/slice/func - } - - d.mapElemValue() - - doMapSet = true // set to false if u do a get, and its a non-nil pointer - if doMapGet { - if !rvvaSet { - rvva = mapAddressableRV(vtype, vtypeKind) - rvvaSet = true - } - rvv = mapGet(rv, rvk, rvva) // reflect.Value{}) - if vtypeKind == reflect.Ptr { - if rvv.IsValid() && !rvIsNil(rvv) { - doMapSet = false - } else { - if vtypeElem == nil { - vtypeElem = vtype.Elem() - } - rvv = reflect.New(vtypeElem) - } - } else if rvv.IsValid() && vtypeKind == reflect.Interface && !rvIsNil(rvv) { - rvvn = rvZeroAddrK(vtype, vtypeKind) - rvvn.Set(rvv) - rvv = rvvn - } else if rvvMut { - rvv = rvZeroAddrK(vtype, vtypeKind) - } else { - rvv = rvvn - } - } else if rvvMut { - rvv = rvZeroAddrK(vtype, vtypeKind) - } else { - rvv = rvvn - } - - if valFn == nil { - valFn = d.h.fn(vtypeLo) - } - - // We MUST be done with the stringview of the key, BEFORE decoding the value (rvv) - // so that we don't unknowingly reuse the rvk backing buffer during rvv decode. - if doMapSet && ktypeIsString { // set to a real string (not string view) - rvk.SetString(d.string(kstrbs)) - } - d.decodeValue(rvv, valFn) - if doMapSet { - mapSet(rv, rvk, rvv) - } - } - - d.mapEnd() -} - -// Decoder reads and decodes an object from an input stream in a supported format. -// -// Decoder is NOT safe for concurrent use i.e. a Decoder cannot be used -// concurrently in multiple goroutines. -// -// However, as Decoder could be allocation heavy to initialize, a Reset method is provided -// so its state can be reused to decode new input streams repeatedly. -// This is the idiomatic way to use. -type Decoder struct { - panicHdl - - d decDriver - - // cache the mapTypeId and sliceTypeId for faster comparisons - mtid uintptr - stid uintptr - - h *BasicHandle - - blist bytesFreelist - - // ---- cpu cache line boundary? - decRd - - // ---- cpu cache line boundary? - n fauxUnion - - hh Handle - err error - - // ---- cpu cache line boundary? - is map[string]string // used for interning strings - - // ---- writable fields during execution --- *try* to keep in sep cache line - maxdepth int16 - depth int16 - - // Extensions can call Decode() within a current Decode() call. - // We need to know when the top level Decode() call returns, - // so we can decide whether to Release() or not. - calls uint16 // what depth in mustDecode are we in now. - - c containerState - _ [1]byte // padding - - // ---- cpu cache line boundary? - - // b is an always-available scratch buffer used by Decoder and decDrivers. - // By being always-available, it can be used for one-off things without - // having to get from freelist, use, and return back to freelist. - b [decScratchByteArrayLen]byte -} - -// NewDecoder returns a Decoder for decoding a stream of bytes from an io.Reader. -// -// For efficiency, Users are encouraged to configure ReaderBufferSize on the handle -// OR pass in a memory buffered reader (eg bufio.Reader, bytes.Buffer). -func NewDecoder(r io.Reader, h Handle) *Decoder { - d := h.newDecDriver().decoder() - d.Reset(r) - return d -} - -// NewDecoderBytes returns a Decoder which efficiently decodes directly -// from a byte slice with zero copying. -func NewDecoderBytes(in []byte, h Handle) *Decoder { - d := h.newDecDriver().decoder() - d.ResetBytes(in) - return d -} - -func (d *Decoder) r() *decRd { - return &d.decRd -} - -func (d *Decoder) init(h Handle) { - d.bytes = true - d.err = errDecoderNotInitialized - d.h = basicHandle(h) - d.hh = h - d.be = h.isBinary() - // NOTE: do not initialize d.n here. It is lazily initialized in d.naked() - if d.h.InternString { - d.is = make(map[string]string, 32) - } -} - -func (d *Decoder) resetCommon() { - d.d.reset() - d.err = nil - d.depth = 0 - d.calls = 0 - d.maxdepth = d.h.MaxDepth - if d.maxdepth <= 0 { - d.maxdepth = decDefMaxDepth - } - // reset all things which were cached from the Handle, but could change - d.mtid, d.stid = 0, 0 - d.mtr, d.str = false, false - if d.h.MapType != nil { - d.mtid = rt2id(d.h.MapType) - d.mtr = fastpathAV.index(d.mtid) != -1 - } - if d.h.SliceType != nil { - d.stid = rt2id(d.h.SliceType) - d.str = fastpathAV.index(d.stid) != -1 - } -} - -// Reset the Decoder with a new Reader to decode from, -// clearing all state from last run(s). -func (d *Decoder) Reset(r io.Reader) { - if r == nil { - return - } - d.bytes = false - if d.h.ReaderBufferSize > 0 { - if d.bi == nil { - d.bi = new(bufioDecReader) - } - d.bi.reset(r, d.h.ReaderBufferSize, &d.blist) - d.bufio = true - } else { - if d.ri == nil { - d.ri = new(ioDecReader) - } - d.ri.reset(r, &d.blist) - d.bufio = false - } - d.resetCommon() -} - -// ResetBytes resets the Decoder with a new []byte to decode from, -// clearing all state from last run(s). -func (d *Decoder) ResetBytes(in []byte) { - if in == nil { - return - } - d.bufio = false - d.bytes = true - // if d.rb == nil { - // d.rb = new(bytesDecReader) - // } - d.rb.reset(in) - d.resetCommon() -} - -func (d *Decoder) naked() *fauxUnion { - return &d.n -} - -// Decode decodes the stream from reader and stores the result in the -// value pointed to by v. v cannot be a nil pointer. v can also be -// a reflect.Value of a pointer. -// -// Note that a pointer to a nil interface is not a nil pointer. -// If you do not know what type of stream it is, pass in a pointer to a nil interface. -// We will decode and store a value in that nil interface. -// -// Sample usages: -// // Decoding into a non-nil typed value -// var f float32 -// err = codec.NewDecoder(r, handle).Decode(&f) -// -// // Decoding into nil interface -// var v interface{} -// dec := codec.NewDecoder(r, handle) -// err = dec.Decode(&v) -// -// When decoding into a nil interface{}, we will decode into an appropriate value based -// on the contents of the stream: -// - Numbers are decoded as float64, int64 or uint64. -// - Other values are decoded appropriately depending on the type: -// bool, string, []byte, time.Time, etc -// - Extensions are decoded as RawExt (if no ext function registered for the tag) -// Configurations exist on the Handle to override defaults -// (e.g. for MapType, SliceType and how to decode raw bytes). -// -// When decoding into a non-nil interface{} value, the mode of encoding is based on the -// type of the value. When a value is seen: -// - If an extension is registered for it, call that extension function -// - If it implements BinaryUnmarshaler, call its UnmarshalBinary(data []byte) error -// - Else decode it based on its reflect.Kind -// -// There are some special rules when decoding into containers (slice/array/map/struct). -// Decode will typically use the stream contents to UPDATE the container i.e. the values -// in these containers will not be zero'ed before decoding. -// - A map can be decoded from a stream map, by updating matching keys. -// - A slice can be decoded from a stream array, -// by updating the first n elements, where n is length of the stream. -// - A slice can be decoded from a stream map, by decoding as if -// it contains a sequence of key-value pairs. -// - A struct can be decoded from a stream map, by updating matching fields. -// - A struct can be decoded from a stream array, -// by updating fields as they occur in the struct (by index). -// -// This in-place update maintains consistency in the decoding philosophy (i.e. we ALWAYS update -// in place by default). However, the consequence of this is that values in slices or maps -// which are not zero'ed before hand, will have part of the prior values in place after decode -// if the stream doesn't contain an update for those parts. -// -// This in-place update can be disabled by configuring the MapValueReset and SliceElementReset -// decode options available on every handle. -// -// Furthermore, when decoding a stream map or array with length of 0 into a nil map or slice, -// we reset the destination map or slice to a zero-length value. -// -// However, when decoding a stream nil, we reset the destination container -// to its "zero" value (e.g. nil for slice/map, etc). -// -// Note: we allow nil values in the stream anywhere except for map keys. -// A nil value in the encoded stream where a map key is expected is treated as an error. -func (d *Decoder) Decode(v interface{}) (err error) { - // tried to use closure, as runtime optimizes defer with no params. - // This seemed to be causing weird issues (like circular reference found, unexpected panic, etc). - // Also, see https://github.com/golang/go/issues/14939#issuecomment-417836139 - // defer func() { d.deferred(&err) }() - // { x, y := d, &err; defer func() { x.deferred(y) }() } - if d.err != nil { - return d.err - } - if recoverPanicToErr { - defer func() { - if x := recover(); x != nil { - panicValToErr(d, x, &d.err) - if d.err != err { - err = d.err - } - } - }() - } - - // defer d.deferred(&err) - d.mustDecode(v) - return -} - -// MustDecode is like Decode, but panics if unable to Decode. -// This provides insight to the code location that triggered the error. -func (d *Decoder) MustDecode(v interface{}) { - if d.err != nil { - panic(d.err) - } - d.mustDecode(v) -} - -// MustDecode is like Decode, but panics if unable to Decode. -// This provides insight to the code location that triggered the error. -func (d *Decoder) mustDecode(v interface{}) { - // Top-level: v is a pointer and not nil. - - d.calls++ - d.decode(v) - d.calls-- - if d.calls == 0 { - d.d.atEndOfDecode() - } -} - -// Release releases shared (pooled) resources. -// -// It is important to call Release() when done with a Decoder, so those resources -// are released instantly for use by subsequently created Decoders. -// -// By default, Release() is automatically called unless the option ExplicitRelease is set. -// -// Deprecated: Release is a no-op as pooled resources are not used with an Decoder. -// This method is kept for compatibility reasons only. -func (d *Decoder) Release() { -} - -func (d *Decoder) swallow() { - switch d.d.ContainerType() { - case valueTypeNil: - case valueTypeMap: - containerLen := d.mapStart() - hasLen := containerLen >= 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - d.swallow() - d.mapElemValue() - d.swallow() - } - d.mapEnd() - case valueTypeArray: - containerLen := d.arrayStart() - hasLen := containerLen >= 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.arrayElem() - d.swallow() - } - d.arrayEnd() - case valueTypeBytes: - d.d.DecodeBytes(d.b[:], true) - case valueTypeString: - d.d.DecodeStringAsBytes() - default: - // these are all primitives, which we can get from decodeNaked - // if RawExt using Value, complete the processing. - n := d.naked() - d.d.DecodeNaked() - if n.v == valueTypeExt && n.l == nil { - var v2 interface{} - d.decode(&v2) - } - } -} - -func setZero(iv interface{}) { - if iv == nil { - return - } - if _, ok := isNil(iv); ok { - return - } - // var canDecode bool - switch v := iv.(type) { - case *string: - *v = "" - case *bool: - *v = false - case *int: - *v = 0 - case *int8: - *v = 0 - case *int16: - *v = 0 - case *int32: - *v = 0 - case *int64: - *v = 0 - case *uint: - *v = 0 - case *uint8: - *v = 0 - case *uint16: - *v = 0 - case *uint32: - *v = 0 - case *uint64: - *v = 0 - case *float32: - *v = 0 - case *float64: - *v = 0 - case *[]uint8: - *v = nil - case *Raw: - *v = nil - case *time.Time: - *v = time.Time{} - case reflect.Value: - setZeroRV(v) - default: - if !fastpathDecodeSetZeroTypeSwitch(iv) { - setZeroRV(rv4i(iv)) - } - } -} - -func setZeroRV(v reflect.Value) { - // It not decodeable, we do not touch it. - // We considered empty'ing it if not decodeable e.g. - // - if chan, drain it - // - if map, clear it - // - if slice or array, zero all elements up to len - // - // However, we decided instead that we either will set the - // whole value to the zero value, or leave AS IS. - if isDecodeable(v) { - if v.Kind() == reflect.Ptr { - v = v.Elem() - } - if v.CanSet() { - v.Set(reflect.Zero(v.Type())) - } - } -} - -func (d *Decoder) decode(iv interface{}) { - // a switch with only concrete types can be optimized. - // consequently, we deal with nil and interfaces outside the switch. - - if iv == nil { - d.errorstr(errstrCannotDecodeIntoNil) - return - } - - switch v := iv.(type) { - // case nil: - // case Selfer: - case reflect.Value: - d.ensureDecodeable(v) - d.decodeValue(v, nil) - - case *string: - *v = string(d.d.DecodeStringAsBytes()) - case *bool: - *v = d.d.DecodeBool() - case *int: - *v = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - case *int8: - *v = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) - case *int16: - *v = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) - case *int32: - *v = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) - case *int64: - *v = d.d.DecodeInt64() - case *uint: - *v = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - case *uint8: - *v = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - case *uint16: - *v = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) - case *uint32: - *v = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) - case *uint64: - *v = d.d.DecodeUint64() - case *float32: - *v = float32(d.decodeFloat32()) - case *float64: - *v = d.d.DecodeFloat64() - case *[]uint8: - *v = d.d.DecodeBytes(*v, false) - case []uint8: - b := d.d.DecodeBytes(v, false) - if !(len(b) > 0 && len(b) == len(v) && &b[0] == &v[0]) { - copy(v, b) - } - case *time.Time: - *v = d.d.DecodeTime() - case *Raw: - *v = d.rawBytes() - - case *interface{}: - d.decodeValue(rv4i(iv), nil) - - default: - if v, ok := iv.(Selfer); ok { - v.CodecDecodeSelf(d) - } else if !fastpathDecodeTypeSwitch(iv, d) { - v := rv4i(iv) - d.ensureDecodeable(v) - d.decodeValue(v, nil) - } - } -} - -// decodeValue MUST be called by the actual value we want to decode into, -// not its addr or a reference to it. -// -// This way, we know if it is itself a pointer, and can handle nil in -// the stream effectively. -func (d *Decoder) decodeValue(rv reflect.Value, fn *codecFn) { - // If stream is not containing a nil value, then we can deref to the base - // non-pointer value, and decode into that. - var rvp reflect.Value - var rvpValid bool - if rv.Kind() == reflect.Ptr { - if d.d.TryNil() { - if rvelem := rv.Elem(); rvelem.CanSet() { - rvelem.Set(reflect.Zero(rvelem.Type())) - } - return - } - rvpValid = true - for rv.Kind() == reflect.Ptr { - if rvIsNil(rv) { - rvSetDirect(rv, reflect.New(rv.Type().Elem())) - } - rvp = rv - rv = rv.Elem() - } - } - - if fn == nil { - fn = d.h.fn(rv.Type()) - } - if fn.i.addrD { - if rvpValid { - fn.fd(d, &fn.i, rvp) - } else if rv.CanAddr() { - fn.fd(d, &fn.i, rv.Addr()) - } else if !fn.i.addrF { - fn.fd(d, &fn.i, rv) - } else { - d.errorf("cannot decode into a non-pointer value") - } - } else { - fn.fd(d, &fn.i, rv) - } -} - -func (d *Decoder) structFieldNotFound(index int, rvkencname string) { - // NOTE: rvkencname may be a stringView, so don't pass it to another function. - if d.h.ErrorIfNoField { - if index >= 0 { - d.errorf("no matching struct field found when decoding stream array at index %v", index) - return - } else if rvkencname != "" { - d.errorf("no matching struct field found when decoding stream map with key " + rvkencname) - return - } - } - d.swallow() -} - -func (d *Decoder) arrayCannotExpand(sliceLen, streamLen int) { - if d.h.ErrorIfNoArrayExpand { - d.errorf("cannot expand array len during decode from %v to %v", sliceLen, streamLen) - } -} - -func isDecodeable(rv reflect.Value) (canDecode bool) { - switch rv.Kind() { - case reflect.Array: - return rv.CanAddr() - case reflect.Ptr: - if !rvIsNil(rv) { - return true - } - case reflect.Slice, reflect.Chan, reflect.Map: - if !rvIsNil(rv) { - return true - } - } - return -} - -func (d *Decoder) ensureDecodeable(rv reflect.Value) { - // decode can take any reflect.Value that is a inherently addressable i.e. - // - array - // - non-nil chan (we will SEND to it) - // - non-nil slice (we will set its elements) - // - non-nil map (we will put into it) - // - non-nil pointer (we can "update" it) - if isDecodeable(rv) { - return - } - if !rv.IsValid() { - d.errorstr(errstrCannotDecodeIntoNil) - return - } - if !rv.CanInterface() { - d.errorf("cannot decode into a value without an interface: %v", rv) - return - } - rvi := rv2i(rv) - rvk := rv.Kind() - d.errorf("cannot decode into value of kind: %v, type: %T, %#v", rvk, rvi, rvi) -} - -func (d *Decoder) depthIncr() { - d.depth++ - if d.depth >= d.maxdepth { - panic(errMaxDepthExceeded) - } -} - -func (d *Decoder) depthDecr() { - d.depth-- -} - -// Possibly get an interned version of a string -// -// This should mostly be used for map keys, where the key type is string. -// This is because keys of a map/struct are typically reused across many objects. -func (d *Decoder) string(v []byte) (s string) { - if v == nil { - return - } - if d.is == nil { - return string(v) // don't return stringView, as we need a real string here. - } - s, ok := d.is[string(v)] // no allocation here, per go implementation - if !ok { - s = string(v) // new allocation here - d.is[s] = s - } - return -} - -// nextValueBytes returns the next value in the stream as a set of bytes. -func (d *Decoder) nextValueBytes() (bs []byte) { - // d.d.uncacheRead() - if d.js { - d.jsondriver().uncacheRead() - } - d.r().track() - d.swallow() - bs = d.r().stopTrack() - return -} - -func (d *Decoder) rawBytes() (v []byte) { - // ensure that this is not a view into the bytes - // i.e. make new copy always. - bs := d.nextValueBytes() - v = make([]byte, len(bs)) - copy(v, bs) - return -} - -func (d *Decoder) wrapErr(v interface{}, err *error) { - *err = decodeError{codecError: codecError{name: d.hh.Name(), err: v}, pos: d.NumBytesRead()} -} - -// NumBytesRead returns the number of bytes read -func (d *Decoder) NumBytesRead() int { - return int(d.r().numread()) -} - -// decodeFloat32 will delegate to an appropriate DecodeFloat32 implementation (if exists), -// else if will call DecodeFloat64 and ensure the value doesn't overflow. -// -// Note that we return float64 to reduce unnecessary conversions -func (d *Decoder) decodeFloat32() float32 { - if d.js { - return d.jsondriver().DecodeFloat32() // custom implementation for 32-bit - } - return float32(chkOvf.Float32V(d.d.DecodeFloat64())) -} - -// ---- container tracking -// Note: We update the .c after calling the callback. -// This way, the callback can know what the last status was. - -// Note: if you call mapStart and it returns decContainerLenNil, -// then do NOT call mapEnd. - -func (d *Decoder) mapStart() (v int) { - v = d.d.ReadMapStart() - if v != decContainerLenNil { - d.depthIncr() - d.c = containerMapStart - } - return -} - -func (d *Decoder) mapElemKey() { - if d.js { - d.jsondriver().ReadMapElemKey() - } - d.c = containerMapKey -} - -func (d *Decoder) mapElemValue() { - if d.js { - d.jsondriver().ReadMapElemValue() - } - d.c = containerMapValue -} - -func (d *Decoder) mapEnd() { - d.d.ReadMapEnd() - d.depthDecr() - // d.c = containerMapEnd - d.c = 0 -} - -func (d *Decoder) arrayStart() (v int) { - v = d.d.ReadArrayStart() - if v != decContainerLenNil { - d.depthIncr() - d.c = containerArrayStart - } - return -} - -func (d *Decoder) arrayElem() { - if d.js { - d.jsondriver().ReadArrayElem() - } - d.c = containerArrayElem -} - -func (d *Decoder) arrayEnd() { - d.d.ReadArrayEnd() - d.depthDecr() - // d.c = containerArrayEnd - d.c = 0 -} - -func (d *Decoder) interfaceExtConvertAndDecode(v interface{}, ext Ext) { - // var v interface{} = ext.ConvertExt(rv) - // d.d.decode(&v) - // ext.UpdateExt(rv, v) - - // assume v is a pointer: - // - if struct|array, pass as is to ConvertExt - // - else make it non-addressable and pass to ConvertExt - // - make return value from ConvertExt addressable - // - decode into it - // - return the interface for passing into UpdateExt. - // - interface should be a pointer if struct|array, else a value - - var s interface{} - rv := rv4i(v) - rv2 := rv.Elem() - rvk := rv2.Kind() - if rvk == reflect.Struct || rvk == reflect.Array { - s = ext.ConvertExt(v) - } else { - s = ext.ConvertExt(rv2i(rv2)) - } - rv = rv4i(s) - if !rv.CanAddr() { - if rv.Kind() == reflect.Ptr { - rv2 = reflect.New(rv.Type().Elem()) - } else { - rv2 = rvZeroAddrK(rv.Type(), rv.Kind()) - } - rvSetDirect(rv2, rv) - rv = rv2 - } - d.decodeValue(rv, nil) - ext.UpdateExt(v, rv2i(rv)) -} - -func (d *Decoder) sideDecode(v interface{}, bs []byte) { - rv := baseRV(v) - NewDecoderBytes(bs, d.hh).decodeValue(rv, d.h.fnNoExt(rv.Type())) -} - -// func (d *Decoder) bytesInline(clen int, bs []byte, zerocopy bool) []byte { -// if d.bytes && (zerocopy || d.h.ZeroCopy) { -// return d.decRd.rb.readx(uint(clen)) -// } -// if zerocopy && len(bs) == 0 { -// bs = d.b[:] -// } -// return decByteSlice(d.r(), clen, d.h.MaxInitLen, bs) -// } - -// -------------------------------------------------- - -// decSliceHelper assists when decoding into a slice, from a map or an array in the stream. -// A slice can be set from a map or array in stream. This supports the MapBySlice interface. -// -// Note: if IsNil, do not call ElemContainerState. -type decSliceHelper struct { - d *Decoder - ct valueType - Array bool - IsNil bool -} - -func (d *Decoder) decSliceHelperStart() (x decSliceHelper, clen int) { - x.ct = d.d.ContainerType() - x.d = d - switch x.ct { - case valueTypeNil: - x.IsNil = true - case valueTypeArray: - x.Array = true - clen = d.arrayStart() - case valueTypeMap: - clen = d.mapStart() * 2 - default: - d.errorf("only encoded map or array can be decoded into a slice (%d)", x.ct) - } - return -} - -func (x decSliceHelper) End() { - if x.IsNil { - } else if x.Array { - x.d.arrayEnd() - } else { - x.d.mapEnd() - } -} - -func (x decSliceHelper) ElemContainerState(index int) { - // Note: if isnil, clen=0, so we never call into ElemContainerState - - if x.Array { - x.d.arrayElem() - } else { - if index%2 == 0 { - x.d.mapElemKey() - } else { - x.d.mapElemValue() - } - } -} - -func decByteSlice(r *decRd, clen, maxInitLen int, bs []byte) (bsOut []byte) { - if clen == 0 { - return zeroByteSlice - } - if len(bs) == clen { - bsOut = bs - r.readb(bsOut) - } else if cap(bs) >= clen { - bsOut = bs[:clen] - r.readb(bsOut) - } else { - len2 := decInferLen(clen, maxInitLen, 1) - bsOut = make([]byte, len2) - r.readb(bsOut) - for len2 < clen { - len3 := decInferLen(clen-len2, maxInitLen, 1) - bs3 := bsOut - bsOut = make([]byte, len2+len3) - copy(bsOut, bs3) - r.readb(bsOut[len2:]) - len2 += len3 - } - } - return -} - -// detachZeroCopyBytes will copy the in bytes into dest, -// or create a new one if not large enough. -// -// It is used to ensure that the []byte returned is not -// part of the input stream or input stream buffers. -func detachZeroCopyBytes(isBytesReader bool, dest []byte, in []byte) (out []byte) { - if len(in) > 0 { - // if isBytesReader || len(in) <= scratchByteArrayLen { - // if cap(dest) >= len(in) { - // out = dest[:len(in)] - // } else { - // out = make([]byte, len(in)) - // } - // copy(out, in) - // return - // } - if cap(dest) >= len(in) { - out = dest[:len(in)] - } else { - out = make([]byte, len(in)) - } - copy(out, in) - return - } - return in -} - -// decInferLen will infer a sensible length, given the following: -// - clen: length wanted. -// - maxlen: max length to be returned. -// if <= 0, it is unset, and we infer it based on the unit size -// - unit: number of bytes for each element of the collection -func decInferLen(clen, maxlen, unit int) (rvlen int) { - const maxLenIfUnset = 8 // 64 - // handle when maxlen is not set i.e. <= 0 - - // clen==0: use 0 - // maxlen<=0, clen<0: use default - // maxlen> 0, clen<0: use default - // maxlen<=0, clen>0: infer maxlen, and cap on it - // maxlen> 0, clen>0: cap at maxlen - - if clen == 0 { - return - } - if clen < 0 { - if clen == decContainerLenNil { - return 0 - } - return maxLenIfUnset - } - if unit == 0 { - return clen - } - if maxlen <= 0 { - // no maxlen defined. Use maximum of 256K memory, with a floor of 4K items. - // maxlen = 256 * 1024 / unit - // if maxlen < (4 * 1024) { - // maxlen = 4 * 1024 - // } - if unit < (256 / 4) { - maxlen = 256 * 1024 / unit - } else { - maxlen = 4 * 1024 - } - // if maxlen > maxLenIfUnset { - // maxlen = maxLenIfUnset - // } - } - if clen > maxlen { - rvlen = maxlen - } else { - rvlen = clen - } - return -} - -func decReadFull(r io.Reader, bs []byte) (n uint, err error) { - var nn int - for n < uint(len(bs)) && err == nil { - nn, err = r.Read(bs[n:]) - if nn > 0 { - if err == io.EOF { - // leave EOF for next time - err = nil - } - n += uint(nn) - } - } - // do not do this - it serves no purpose - // if n != len(bs) && err == io.EOF { err = io.ErrUnexpectedEOF } - return -} - -func fauxUnionReadRawBytes(dr decDriver, d *Decoder, n *fauxUnion, rawToString bool) { - if rawToString { - n.v = valueTypeString - n.s = string(dr.DecodeBytes(d.b[:], true)) - } else { - n.v = valueTypeBytes - n.l = dr.DecodeBytes(nil, false) - } -} - -func decArrayCannotExpand(slh decSliceHelper, hasLen bool, lenv, j, containerLenS int) { - slh.d.arrayCannotExpand(lenv, j+1) - // drain completely and return - slh.ElemContainerState(j) - slh.d.swallow() - j++ - for ; (hasLen && j < containerLenS) || !(hasLen || slh.d.checkBreak()); j++ { - slh.ElemContainerState(j) - slh.d.swallow() - } - slh.End() -} diff --git a/vendor/github.com/ugorji/go/codec/doc.go b/vendor/github.com/ugorji/go/codec/doc.go deleted file mode 100644 index e987fa6ba..000000000 --- a/vendor/github.com/ugorji/go/codec/doc.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -/* -Package codec provides a -High Performance, Feature-Rich Idiomatic Go 1.4+ codec/encoding library -for binc, msgpack, cbor, json. - -Supported Serialization formats are: - - - msgpack: https://github.com/msgpack/msgpack - - binc: http://github.com/ugorji/binc - - cbor: http://cbor.io http://tools.ietf.org/html/rfc7049 - - json: http://json.org http://tools.ietf.org/html/rfc7159 - - simple: - -This package will carefully use 'package unsafe' for performance reasons in specific places. -You can build without unsafe use by passing the safe or appengine tag -i.e. 'go install -tags=safe ...'. - -For detailed usage information, read the primer at http://ugorji.net/blog/go-codec-primer . - -The idiomatic Go support is as seen in other encoding packages in -the standard library (ie json, xml, gob, etc). - -Rich Feature Set includes: - - - Simple but extremely powerful and feature-rich API - - Support for go 1.4 and above, while selectively using newer APIs for later releases - - Excellent code coverage ( > 90% ) - - Very High Performance. - Our extensive benchmarks show us outperforming Gob, Json, Bson, etc by 2-4X. - - Careful selected use of 'unsafe' for targeted performance gains. - - 100% safe mode supported, where 'unsafe' is not used at all. - - Lock-free (sans mutex) concurrency for scaling to 100's of cores - - In-place updates during decode, with option to zero value in maps and slices prior to decode - - Coerce types where appropriate - e.g. decode an int in the stream into a float, decode numbers from formatted strings, etc - - Corner Cases: - Overflows, nil maps/slices, nil values in streams are handled correctly - - Standard field renaming via tags - - Support for omitting empty fields during an encoding - - Encoding from any value and decoding into pointer to any value - (struct, slice, map, primitives, pointers, interface{}, etc) - - Extensions to support efficient encoding/decoding of any named types - - Support encoding.(Binary|Text)(M|Unm)arshaler interfaces - - Support IsZero() bool to determine if a value is a zero value. - Analogous to time.Time.IsZero() bool. - - Decoding without a schema (into a interface{}). - Includes Options to configure what specific map or slice type to use - when decoding an encoded list or map into a nil interface{} - - Mapping a non-interface type to an interface, so we can decode appropriately - into any interface type with a correctly configured non-interface value. - - Encode a struct as an array, and decode struct from an array in the data stream - - Option to encode struct keys as numbers (instead of strings) - (to support structured streams with fields encoded as numeric codes) - - Comprehensive support for anonymous fields - - Fast (no-reflection) encoding/decoding of common maps and slices - - Code-generation for faster performance, supported in go 1.6+ - - Support binary (e.g. messagepack, cbor) and text (e.g. json) formats - - Support indefinite-length formats to enable true streaming - (for formats which support it e.g. json, cbor) - - Support canonical encoding, where a value is ALWAYS encoded as same sequence of bytes. - This mostly applies to maps, where iteration order is non-deterministic. - - NIL in data stream decoded as zero value - - Never silently skip data when decoding. - User decides whether to return an error or silently skip data when keys or indexes - in the data stream do not map to fields in the struct. - - Detect and error when encoding a cyclic reference (instead of stack overflow shutdown) - - Encode/Decode from/to chan types (for iterative streaming support) - - Drop-in replacement for encoding/json. `json:` key in struct tag supported. - - Provides a RPC Server and Client Codec for net/rpc communication protocol. - - Handle unique idiosyncrasies of codecs e.g. - - For messagepack, configure how ambiguities in handling raw bytes are resolved - - For messagepack, provide rpc server/client codec to support - msgpack-rpc protocol defined at: - https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md - -Extension Support - -Users can register a function to handle the encoding or decoding of -their custom types. - -There are no restrictions on what the custom type can be. Some examples: - - type BisSet []int - type BitSet64 uint64 - type UUID string - type MyStructWithUnexportedFields struct { a int; b bool; c []int; } - type GifImage struct { ... } - -As an illustration, MyStructWithUnexportedFields would normally be -encoded as an empty map because it has no exported fields, while UUID -would be encoded as a string. However, with extension support, you can -encode any of these however you like. - -There is also seamless support provided for registering an extension (with a tag) -but letting the encoding mechanism default to the standard way. - -Custom Encoding and Decoding - -This package maintains symmetry in the encoding and decoding halfs. -We determine how to encode or decode by walking this decision tree - - - is there an extension registered for the type? - - is type a codec.Selfer? - - is format binary, and is type a encoding.BinaryMarshaler and BinaryUnmarshaler? - - is format specifically json, and is type a encoding/json.Marshaler and Unmarshaler? - - is format text-based, and type an encoding.TextMarshaler and TextUnmarshaler? - - else we use a pair of functions based on the "kind" of the type e.g. map, slice, int64, etc - -This symmetry is important to reduce chances of issues happening because the -encoding and decoding sides are out of sync e.g. decoded via very specific -encoding.TextUnmarshaler but encoded via kind-specific generalized mode. - -Consequently, if a type only defines one-half of the symmetry -(e.g. it implements UnmarshalJSON() but not MarshalJSON() ), -then that type doesn't satisfy the check and we will continue walking down the -decision tree. - -RPC - -RPC Client and Server Codecs are implemented, so the codecs can be used -with the standard net/rpc package. - -Usage - -The Handle is SAFE for concurrent READ, but NOT SAFE for concurrent modification. - -The Encoder and Decoder are NOT safe for concurrent use. - -Consequently, the usage model is basically: - - - Create and initialize the Handle before any use. - Once created, DO NOT modify it. - - Multiple Encoders or Decoders can now use the Handle concurrently. - They only read information off the Handle (never write). - - However, each Encoder or Decoder MUST not be used concurrently - - To re-use an Encoder/Decoder, call Reset(...) on it first. - This allows you use state maintained on the Encoder/Decoder. - -Sample usage model: - - // create and configure Handle - var ( - bh codec.BincHandle - mh codec.MsgpackHandle - ch codec.CborHandle - ) - - mh.MapType = reflect.TypeOf(map[string]interface{}(nil)) - - // configure extensions - // e.g. for msgpack, define functions and enable Time support for tag 1 - // mh.SetExt(reflect.TypeOf(time.Time{}), 1, myExt) - - // create and use decoder/encoder - var ( - r io.Reader - w io.Writer - b []byte - h = &bh // or mh to use msgpack - ) - - dec = codec.NewDecoder(r, h) - dec = codec.NewDecoderBytes(b, h) - err = dec.Decode(&v) - - enc = codec.NewEncoder(w, h) - enc = codec.NewEncoderBytes(&b, h) - err = enc.Encode(v) - - //RPC Server - go func() { - for { - conn, err := listener.Accept() - rpcCodec := codec.GoRpc.ServerCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h) - rpc.ServeCodec(rpcCodec) - } - }() - - //RPC Communication (client side) - conn, err = net.Dial("tcp", "localhost:5555") - rpcCodec := codec.GoRpc.ClientCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h) - client := rpc.NewClientWithCodec(rpcCodec) - -Running Tests - -To run tests, use the following: - - go test - -To run the full suite of tests, use the following: - - go test -tags alltests -run Suite - -You can run the tag 'safe' to run tests or build in safe mode. e.g. - - go test -tags safe -run Json - go test -tags "alltests safe" -run Suite - -Running Benchmarks - - cd bench - go test -bench . -benchmem -benchtime 1s - -Please see http://github.com/ugorji/go-codec-bench . - -Caveats - -Struct fields matching the following are ignored during encoding and decoding - - struct tag value set to - - - func, complex numbers, unsafe pointers - - unexported and not embedded - - unexported and embedded and not struct kind - - unexported and embedded pointers (from go1.10) - -Every other field in a struct will be encoded/decoded. - -Embedded fields are encoded as if they exist in the top-level struct, -with some caveats. See Encode documentation. - -*/ -package codec diff --git a/vendor/github.com/ugorji/go/codec/encode.go b/vendor/github.com/ugorji/go/codec/encode.go deleted file mode 100644 index 69d0efcbd..000000000 --- a/vendor/github.com/ugorji/go/codec/encode.go +++ /dev/null @@ -1,1376 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "encoding" - "errors" - "fmt" - "io" - "reflect" - "sort" - "strconv" - "time" -) - -// defEncByteBufSize is the default size of []byte used -// for bufio buffer or []byte (when nil passed) -const defEncByteBufSize = 1 << 10 // 4:16, 6:64, 8:256, 10:1024 - -var errEncoderNotInitialized = errors.New("Encoder not initialized") - -// encDriver abstracts the actual codec (binc vs msgpack, etc) -type encDriver interface { - EncodeNil() - EncodeInt(i int64) - EncodeUint(i uint64) - EncodeBool(b bool) - EncodeFloat32(f float32) - EncodeFloat64(f float64) - EncodeRawExt(re *RawExt) - EncodeExt(v interface{}, xtag uint64, ext Ext) - // EncodeString using cUTF8, honor'ing StringToRaw flag - EncodeString(v string) - EncodeStringBytesRaw(v []byte) - EncodeTime(time.Time) - WriteArrayStart(length int) - WriteArrayEnd() - WriteMapStart(length int) - WriteMapEnd() - - reset() - atEndOfEncode() - encoder() *Encoder -} - -type encDriverContainerTracker interface { - WriteArrayElem() - WriteMapElemKey() - WriteMapElemValue() -} - -type encodeError struct { - codecError -} - -func (e encodeError) Error() string { - return fmt.Sprintf("%s encode error: %v", e.name, e.err) -} - -type encDriverNoopContainerWriter struct{} - -func (encDriverNoopContainerWriter) WriteArrayStart(length int) {} -func (encDriverNoopContainerWriter) WriteArrayEnd() {} -func (encDriverNoopContainerWriter) WriteMapStart(length int) {} -func (encDriverNoopContainerWriter) WriteMapEnd() {} -func (encDriverNoopContainerWriter) atEndOfEncode() {} - -// EncodeOptions captures configuration options during encode. -type EncodeOptions struct { - // WriterBufferSize is the size of the buffer used when writing. - // - // if > 0, we use a smart buffer internally for performance purposes. - WriterBufferSize int - - // ChanRecvTimeout is the timeout used when selecting from a chan. - // - // Configuring this controls how we receive from a chan during the encoding process. - // - If ==0, we only consume the elements currently available in the chan. - // - if <0, we consume until the chan is closed. - // - If >0, we consume until this timeout. - ChanRecvTimeout time.Duration - - // StructToArray specifies to encode a struct as an array, and not as a map - StructToArray bool - - // Canonical representation means that encoding a value will always result in the same - // sequence of bytes. - // - // This only affects maps, as the iteration order for maps is random. - // - // The implementation MAY use the natural sort order for the map keys if possible: - // - // - If there is a natural sort order (ie for number, bool, string or []byte keys), - // then the map keys are first sorted in natural order and then written - // with corresponding map values to the strema. - // - If there is no natural sort order, then the map keys will first be - // encoded into []byte, and then sorted, - // before writing the sorted keys and the corresponding map values to the stream. - // - Canonical bool - - // CheckCircularRef controls whether we check for circular references - // and error fast during an encode. - // - // If enabled, an error is received if a pointer to a struct - // references itself either directly or through one of its fields (iteratively). - // - // This is opt-in, as there may be a performance hit to checking circular references. - CheckCircularRef bool - - // RecursiveEmptyCheck controls whether we descend into interfaces, structs and pointers - // when checking if a value is empty. - // - // Note that this may make OmitEmpty more expensive, as it incurs a lot more reflect calls. - RecursiveEmptyCheck bool - - // Raw controls whether we encode Raw values. - // This is a "dangerous" option and must be explicitly set. - // If set, we blindly encode Raw values as-is, without checking - // if they are a correct representation of a value in that format. - // If unset, we error out. - Raw bool - - // StringToRaw controls how strings are encoded. - // - // As a go string is just an (immutable) sequence of bytes, - // it can be encoded either as raw bytes or as a UTF string. - // - // By default, strings are encoded as UTF-8. - // but can be treated as []byte during an encode. - // - // Note that things which we know (by definition) to be UTF-8 - // are ALWAYS encoded as UTF-8 strings. - // These include encoding.TextMarshaler, time.Format calls, struct field names, etc. - StringToRaw bool - - // // AsSymbols defines what should be encoded as symbols. - // // - // // Encoding as symbols can reduce the encoded size significantly. - // // - // // However, during decoding, each string to be encoded as a symbol must - // // be checked to see if it has been seen before. Consequently, encoding time - // // will increase if using symbols, because string comparisons has a clear cost. - // // - // // Sample values: - // // AsSymbolNone - // // AsSymbolAll - // // AsSymbolMapStringKeys - // // AsSymbolMapStringKeysFlag | AsSymbolStructFieldNameFlag - // AsSymbols AsSymbolFlag -} - -// --------------------------------------------- - -func (e *Encoder) rawExt(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeRawExt(rv2i(rv).(*RawExt)) -} - -func (e *Encoder) ext(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeExt(rv2i(rv), f.xfTag, f.xfFn) -} - -func (e *Encoder) selferMarshal(f *codecFnInfo, rv reflect.Value) { - rv2i(rv).(Selfer).CodecEncodeSelf(e) -} - -func (e *Encoder) binaryMarshal(f *codecFnInfo, rv reflect.Value) { - bs, fnerr := rv2i(rv).(encoding.BinaryMarshaler).MarshalBinary() - e.marshalRaw(bs, fnerr) -} - -func (e *Encoder) textMarshal(f *codecFnInfo, rv reflect.Value) { - bs, fnerr := rv2i(rv).(encoding.TextMarshaler).MarshalText() - e.marshalUtf8(bs, fnerr) -} - -func (e *Encoder) jsonMarshal(f *codecFnInfo, rv reflect.Value) { - bs, fnerr := rv2i(rv).(jsonMarshaler).MarshalJSON() - e.marshalAsis(bs, fnerr) -} - -func (e *Encoder) raw(f *codecFnInfo, rv reflect.Value) { - e.rawBytes(rv2i(rv).(Raw)) -} - -func (e *Encoder) kBool(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeBool(rvGetBool(rv)) -} - -func (e *Encoder) kTime(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeTime(rvGetTime(rv)) -} - -func (e *Encoder) kString(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeString(rvGetString(rv)) -} - -func (e *Encoder) kFloat64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeFloat64(rvGetFloat64(rv)) -} - -func (e *Encoder) kFloat32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeFloat32(rvGetFloat32(rv)) -} - -func (e *Encoder) kInt(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt(rv))) -} - -func (e *Encoder) kInt8(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt8(rv))) -} - -func (e *Encoder) kInt16(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt16(rv))) -} - -func (e *Encoder) kInt32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt32(rv))) -} - -func (e *Encoder) kInt64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeInt(int64(rvGetInt64(rv))) -} - -func (e *Encoder) kUint(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint(rv))) -} - -func (e *Encoder) kUint8(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint8(rv))) -} - -func (e *Encoder) kUint16(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint16(rv))) -} - -func (e *Encoder) kUint32(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint32(rv))) -} - -func (e *Encoder) kUint64(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUint64(rv))) -} - -func (e *Encoder) kUintptr(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeUint(uint64(rvGetUintptr(rv))) -} - -func (e *Encoder) kInvalid(f *codecFnInfo, rv reflect.Value) { - e.e.EncodeNil() -} - -func (e *Encoder) kErr(f *codecFnInfo, rv reflect.Value) { - e.errorf("unsupported kind %s, for %#v", rv.Kind(), rv) -} - -func chanToSlice(rv reflect.Value, rtslice reflect.Type, timeout time.Duration) (rvcs reflect.Value) { - rvcs = reflect.Zero(rtslice) - if timeout < 0 { // consume until close - for { - recv, recvOk := rv.Recv() - if !recvOk { - break - } - rvcs = reflect.Append(rvcs, recv) - } - } else { - cases := make([]reflect.SelectCase, 2) - cases[0] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv} - if timeout == 0 { - cases[1] = reflect.SelectCase{Dir: reflect.SelectDefault} - } else { - tt := time.NewTimer(timeout) - cases[1] = reflect.SelectCase{Dir: reflect.SelectRecv, Chan: rv4i(tt.C)} - } - for { - chosen, recv, recvOk := reflect.Select(cases) - if chosen == 1 || !recvOk { - break - } - rvcs = reflect.Append(rvcs, recv) - } - } - return -} - -func (e *Encoder) kSeqFn(rtelem reflect.Type) (fn *codecFn) { - for rtelem.Kind() == reflect.Ptr { - rtelem = rtelem.Elem() - } - // if kind is reflect.Interface, do not pre-determine the - // encoding type, because preEncodeValue may break it down to - // a concrete type and kInterface will bomb. - if rtelem.Kind() != reflect.Interface { - fn = e.h.fn(rtelem) - } - return -} - -func (e *Encoder) kSliceWMbs(rv reflect.Value, ti *typeInfo) { - var l = rvGetSliceLen(rv) - if l == 0 { - e.mapStart(0) - } else { - if l%2 == 1 { - e.errorf("mapBySlice requires even slice length, but got %v", l) - return - } - e.mapStart(l / 2) - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.encodeValue(rvSliceIndex(rv, j, ti), fn) - } - } - e.mapEnd() -} - -func (e *Encoder) kSliceW(rv reflect.Value, ti *typeInfo) { - var l = rvGetSliceLen(rv) - e.arrayStart(l) - if l > 0 { - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - e.arrayElem() - e.encodeValue(rvSliceIndex(rv, j, ti), fn) - } - } - e.arrayEnd() -} - -func (e *Encoder) kSeqWMbs(rv reflect.Value, ti *typeInfo) { - var l = rv.Len() - if l == 0 { - e.mapStart(0) - } else { - if l%2 == 1 { - e.errorf("mapBySlice requires even slice length, but got %v", l) - return - } - e.mapStart(l / 2) - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.encodeValue(rv.Index(j), fn) - } - } - e.mapEnd() -} - -func (e *Encoder) kSeqW(rv reflect.Value, ti *typeInfo) { - var l = rv.Len() - e.arrayStart(l) - if l > 0 { - fn := e.kSeqFn(ti.elem) - for j := 0; j < l; j++ { - e.arrayElem() - e.encodeValue(rv.Index(j), fn) - } - } - e.arrayEnd() -} - -func (e *Encoder) kChan(f *codecFnInfo, rv reflect.Value) { - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - if f.ti.chandir&uint8(reflect.RecvDir) == 0 { - e.errorf("send-only channel cannot be encoded") - return - } - if !f.ti.mbs && uint8TypId == rt2id(f.ti.elem) { - e.kSliceBytesChan(rv) - return - } - rtslice := reflect.SliceOf(f.ti.elem) - rv = chanToSlice(rv, rtslice, e.h.ChanRecvTimeout) - ti := e.h.getTypeInfo(rt2id(rtslice), rtslice) - if f.ti.mbs { - e.kSliceWMbs(rv, ti) - } else { - e.kSliceW(rv, ti) - } -} - -func (e *Encoder) kSlice(f *codecFnInfo, rv reflect.Value) { - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - if f.ti.mbs { - e.kSliceWMbs(rv, f.ti) - } else { - if f.ti.rtid == uint8SliceTypId || uint8TypId == rt2id(f.ti.elem) { - e.e.EncodeStringBytesRaw(rvGetBytes(rv)) - } else { - e.kSliceW(rv, f.ti) - } - } -} - -func (e *Encoder) kArray(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - e.kSeqWMbs(rv, f.ti) - } else { - if uint8TypId == rt2id(f.ti.elem) { - e.e.EncodeStringBytesRaw(rvGetArrayBytesRO(rv, e.b[:])) - } else { - e.kSeqW(rv, f.ti) - } - } -} - -func (e *Encoder) kSliceBytesChan(rv reflect.Value) { - // do not use range, so that the number of elements encoded - // does not change, and encoding does not hang waiting on someone to close chan. - - // for b := range rv2i(rv).(<-chan byte) { bs = append(bs, b) } - // ch := rv2i(rv).(<-chan byte) // fix error - that this is a chan byte, not a <-chan byte. - - bs := e.b[:0] - irv := rv2i(rv) - ch, ok := irv.(<-chan byte) - if !ok { - ch = irv.(chan byte) - } - -L1: - switch timeout := e.h.ChanRecvTimeout; { - case timeout == 0: // only consume available - for { - select { - case b := <-ch: - bs = append(bs, b) - default: - break L1 - } - } - case timeout > 0: // consume until timeout - tt := time.NewTimer(timeout) - for { - select { - case b := <-ch: - bs = append(bs, b) - case <-tt.C: - // close(tt.C) - break L1 - } - } - default: // consume until close - for b := range ch { - bs = append(bs, b) - } - } - - e.e.EncodeStringBytesRaw(bs) -} - -func (e *Encoder) kStructNoOmitempty(f *codecFnInfo, rv reflect.Value) { - sfn := structFieldNode{v: rv, update: false} - if f.ti.toArray || e.h.StructToArray { // toArray - e.arrayStart(len(f.ti.sfiSrc)) - for _, si := range f.ti.sfiSrc { - e.arrayElem() - e.encodeValue(sfn.field(si), nil) - } - e.arrayEnd() - } else { - e.mapStart(len(f.ti.sfiSort)) - for _, si := range f.ti.sfiSort { - e.mapElemKey() - e.kStructFieldKey(f.ti.keyType, si.encNameAsciiAlphaNum, si.encName) - e.mapElemValue() - e.encodeValue(sfn.field(si), nil) - } - e.mapEnd() - } -} - -func (e *Encoder) kStructFieldKey(keyType valueType, encNameAsciiAlphaNum bool, encName string) { - encStructFieldKey(encName, e.e, e.w(), keyType, encNameAsciiAlphaNum, e.js) -} - -func (e *Encoder) kStruct(f *codecFnInfo, rv reflect.Value) { - var newlen int - toMap := !(f.ti.toArray || e.h.StructToArray) - var mf map[string]interface{} - if f.ti.isFlag(tiflagMissingFielder) { - mf = rv2i(rv).(MissingFielder).CodecMissingFields() - toMap = true - newlen += len(mf) - } else if f.ti.isFlag(tiflagMissingFielderPtr) { - if rv.CanAddr() { - mf = rv2i(rv.Addr()).(MissingFielder).CodecMissingFields() - } else { - // make a new addressable value of same one, and use it - rv2 := reflect.New(rv.Type()) - rvSetDirect(rv2.Elem(), rv) - mf = rv2i(rv2).(MissingFielder).CodecMissingFields() - } - toMap = true - newlen += len(mf) - } - newlen += len(f.ti.sfiSrc) - - var fkvs = e.slist.get(newlen) - - recur := e.h.RecursiveEmptyCheck - sfn := structFieldNode{v: rv, update: false} - - var kv sfiRv - var j int - if toMap { - newlen = 0 - for _, si := range f.ti.sfiSort { // use sorted array - kv.r = sfn.field(si) - if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) { - continue - } - kv.v = si // si.encName - fkvs[newlen] = kv - newlen++ - } - var mflen int - for k, v := range mf { - if k == "" { - delete(mf, k) - continue - } - if f.ti.infoFieldOmitempty && isEmptyValue(rv4i(v), e.h.TypeInfos, recur, recur) { - delete(mf, k) - continue - } - mflen++ - } - // encode it all - e.mapStart(newlen + mflen) - for j = 0; j < newlen; j++ { - kv = fkvs[j] - e.mapElemKey() - e.kStructFieldKey(f.ti.keyType, kv.v.encNameAsciiAlphaNum, kv.v.encName) - e.mapElemValue() - e.encodeValue(kv.r, nil) - } - // now, add the others - for k, v := range mf { - e.mapElemKey() - e.kStructFieldKey(f.ti.keyType, false, k) - e.mapElemValue() - e.encode(v) - } - e.mapEnd() - } else { - newlen = len(f.ti.sfiSrc) - for i, si := range f.ti.sfiSrc { // use unsorted array (to match sequence in struct) - kv.r = sfn.field(si) - // use the zero value. - // if a reference or struct, set to nil (so you do not output too much) - if si.omitEmpty() && isEmptyValue(kv.r, e.h.TypeInfos, recur, recur) { - switch kv.r.Kind() { - case reflect.Struct, reflect.Interface, reflect.Ptr, reflect.Array, reflect.Map, reflect.Slice: - kv.r = reflect.Value{} //encode as nil - } - } - fkvs[i] = kv - } - // encode it all - e.arrayStart(newlen) - for j = 0; j < newlen; j++ { - e.arrayElem() - e.encodeValue(fkvs[j].r, nil) - } - e.arrayEnd() - } - - // do not use defer. Instead, use explicit pool return at end of function. - // defer has a cost we are trying to avoid. - // If there is a panic and these slices are not returned, it is ok. - // spool.end() - e.slist.put(fkvs) -} - -func (e *Encoder) kMap(f *codecFnInfo, rv reflect.Value) { - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - - l := rv.Len() - e.mapStart(l) - if l == 0 { - e.mapEnd() - return - } - - // determine the underlying key and val encFn's for the map. - // This eliminates some work which is done for each loop iteration i.e. - // rv.Type(), ref.ValueOf(rt).Pointer(), then check map/list for fn. - // - // However, if kind is reflect.Interface, do not pre-determine the - // encoding type, because preEncodeValue may break it down to - // a concrete type and kInterface will bomb. - - var keyFn, valFn *codecFn - - ktypeKind := f.ti.key.Kind() - vtypeKind := f.ti.elem.Kind() - - rtval := f.ti.elem - rtvalkind := vtypeKind - for rtvalkind == reflect.Ptr { - rtval = rtval.Elem() - rtvalkind = rtval.Kind() - } - if rtvalkind != reflect.Interface { - valFn = e.h.fn(rtval) - } - - var rvv = mapAddressableRV(f.ti.elem, vtypeKind) - - if e.h.Canonical { - e.kMapCanonical(f.ti.key, f.ti.elem, rv, rvv, valFn) - e.mapEnd() - return - } - - rtkey := f.ti.key - var keyTypeIsString = stringTypId == rt2id(rtkey) // rtkeyid - if !keyTypeIsString { - for rtkey.Kind() == reflect.Ptr { - rtkey = rtkey.Elem() - } - if rtkey.Kind() != reflect.Interface { - keyFn = e.h.fn(rtkey) - } - } - - var rvk = mapAddressableRV(f.ti.key, ktypeKind) - - var it mapIter - mapRange(&it, rv, rvk, rvv, true) - validKV := it.ValidKV() - var vx reflect.Value - for it.Next() { - e.mapElemKey() - if validKV { - vx = it.Key() - } else { - vx = rvk - } - if keyTypeIsString { - e.e.EncodeString(vx.String()) - } else { - e.encodeValue(vx, keyFn) - } - e.mapElemValue() - if validKV { - vx = it.Value() - } else { - vx = rvv - } - e.encodeValue(vx, valFn) - } - it.Done() - - e.mapEnd() -} - -func (e *Encoder) kMapCanonical(rtkey, rtval reflect.Type, rv, rvv reflect.Value, valFn *codecFn) { - // we previously did out-of-band if an extension was registered. - // This is not necessary, as the natural kind is sufficient for ordering. - - mks := rv.MapKeys() - switch rtkey.Kind() { - case reflect.Bool: - mksv := make([]boolRv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = k.Bool() - } - sort.Sort(boolRvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeBool(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - case reflect.String: - mksv := make([]stringRv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = k.String() - } - sort.Sort(stringRvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeString(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint, reflect.Uintptr: - mksv := make([]uint64Rv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = k.Uint() - } - sort.Sort(uint64RvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeUint(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: - mksv := make([]int64Rv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = k.Int() - } - sort.Sort(int64RvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeInt(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - case reflect.Float32: - mksv := make([]float64Rv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = k.Float() - } - sort.Sort(float64RvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeFloat32(float32(mksv[i].v)) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - case reflect.Float64: - mksv := make([]float64Rv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = k.Float() - } - sort.Sort(float64RvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeFloat64(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - case reflect.Struct: - if rtkey == timeTyp { - mksv := make([]timeRv, len(mks)) - for i, k := range mks { - v := &mksv[i] - v.r = k - v.v = rv2i(k).(time.Time) - } - sort.Sort(timeRvSlice(mksv)) - for i := range mksv { - e.mapElemKey() - e.e.EncodeTime(mksv[i].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksv[i].r, rvv), valFn) - } - break - } - fallthrough - default: - // out-of-band - // first encode each key to a []byte first, then sort them, then record - var mksv []byte = e.blist.get(len(mks) * 16)[:0] - e2 := NewEncoderBytes(&mksv, e.hh) - mksbv := make([]bytesRv, len(mks)) - for i, k := range mks { - v := &mksbv[i] - l := len(mksv) - e2.MustEncode(k) - v.r = k - v.v = mksv[l:] - } - sort.Sort(bytesRvSlice(mksbv)) - for j := range mksbv { - e.mapElemKey() - e.encWr.writeb(mksbv[j].v) // e.asis(mksbv[j].v) - e.mapElemValue() - e.encodeValue(mapGet(rv, mksbv[j].r, rvv), valFn) - } - e.blist.put(mksv) - } -} - -// Encoder writes an object to an output stream in a supported format. -// -// Encoder is NOT safe for concurrent use i.e. a Encoder cannot be used -// concurrently in multiple goroutines. -// -// However, as Encoder could be allocation heavy to initialize, a Reset method is provided -// so its state can be reused to decode new input streams repeatedly. -// This is the idiomatic way to use. -type Encoder struct { - panicHdl - - e encDriver - - h *BasicHandle - - // hopefully, reduce derefencing cost by laying the encWriter inside the Encoder - encWr - - // ---- cpu cache line boundary - hh Handle - - blist bytesFreelist - err error - - // ---- cpu cache line boundary - - // ---- writable fields during execution --- *try* to keep in sep cache line - ci set // holds set of addresses found during an encoding (if CheckCircularRef=true) - - slist sfiRvFreelist - - b [(2 * 8)]byte // for encoding chan byte, (non-addressable) [N]byte, etc - - // ---- cpu cache line boundary? -} - -// NewEncoder returns an Encoder for encoding into an io.Writer. -// -// For efficiency, Users are encouraged to configure WriterBufferSize on the handle -// OR pass in a memory buffered writer (eg bufio.Writer, bytes.Buffer). -func NewEncoder(w io.Writer, h Handle) *Encoder { - e := h.newEncDriver().encoder() - e.Reset(w) - return e -} - -// NewEncoderBytes returns an encoder for encoding directly and efficiently -// into a byte slice, using zero-copying to temporary slices. -// -// It will potentially replace the output byte slice pointed to. -// After encoding, the out parameter contains the encoded contents. -func NewEncoderBytes(out *[]byte, h Handle) *Encoder { - e := h.newEncDriver().encoder() - e.ResetBytes(out) - return e -} - -func (e *Encoder) init(h Handle) { - e.err = errEncoderNotInitialized - e.bytes = true - e.hh = h - e.h = basicHandle(h) - e.be = e.hh.isBinary() -} - -func (e *Encoder) w() *encWr { - return &e.encWr -} - -func (e *Encoder) resetCommon() { - e.e.reset() - if e.ci == nil { - // e.ci = (set)(e.cidef[:0]) - } else { - e.ci = e.ci[:0] - } - e.c = 0 - e.err = nil -} - -// Reset resets the Encoder with a new output stream. -// -// This accommodates using the state of the Encoder, -// where it has "cached" information about sub-engines. -func (e *Encoder) Reset(w io.Writer) { - if w == nil { - return - } - e.bytes = false - if e.wf == nil { - e.wf = new(bufioEncWriter) - } - e.wf.reset(w, e.h.WriterBufferSize, &e.blist) - e.resetCommon() -} - -// ResetBytes resets the Encoder with a new destination output []byte. -func (e *Encoder) ResetBytes(out *[]byte) { - if out == nil { - return - } - var in []byte = *out - if in == nil { - in = make([]byte, defEncByteBufSize) - } - e.bytes = true - // if e.wb == nil { - // e.wb = new(bytesEncAppender) - // } - e.wb.reset(in, out) - e.resetCommon() -} - -// Encode writes an object into a stream. -// -// Encoding can be configured via the struct tag for the fields. -// The key (in the struct tags) that we look at is configurable. -// -// By default, we look up the "codec" key in the struct field's tags, -// and fall bak to the "json" key if "codec" is absent. -// That key in struct field's tag value is the key name, -// followed by an optional comma and options. -// -// To set an option on all fields (e.g. omitempty on all fields), you -// can create a field called _struct, and set flags on it. The options -// which can be set on _struct are: -// - omitempty: so all fields are omitted if empty -// - toarray: so struct is encoded as an array -// - int: so struct key names are encoded as signed integers (instead of strings) -// - uint: so struct key names are encoded as unsigned integers (instead of strings) -// - float: so struct key names are encoded as floats (instead of strings) -// More details on these below. -// -// Struct values "usually" encode as maps. Each exported struct field is encoded unless: -// - the field's tag is "-", OR -// - the field is empty (empty or the zero value) and its tag specifies the "omitempty" option. -// -// When encoding as a map, the first string in the tag (before the comma) -// is the map key string to use when encoding. -// ... -// This key is typically encoded as a string. -// However, there are instances where the encoded stream has mapping keys encoded as numbers. -// For example, some cbor streams have keys as integer codes in the stream, but they should map -// to fields in a structured object. Consequently, a struct is the natural representation in code. -// For these, configure the struct to encode/decode the keys as numbers (instead of string). -// This is done with the int,uint or float option on the _struct field (see above). -// -// However, struct values may encode as arrays. This happens when: -// - StructToArray Encode option is set, OR -// - the tag on the _struct field sets the "toarray" option -// Note that omitempty is ignored when encoding struct values as arrays, -// as an entry must be encoded for each field, to maintain its position. -// -// Values with types that implement MapBySlice are encoded as stream maps. -// -// The empty values (for omitempty option) are false, 0, any nil pointer -// or interface value, and any array, slice, map, or string of length zero. -// -// Anonymous fields are encoded inline except: -// - the struct tag specifies a replacement name (first value) -// - the field is of an interface type -// -// Examples: -// -// // NOTE: 'json:' can be used as struct tag key, in place 'codec:' below. -// type MyStruct struct { -// _struct bool `codec:",omitempty"` //set omitempty for every field -// Field1 string `codec:"-"` //skip this field -// Field2 int `codec:"myName"` //Use key "myName" in encode stream -// Field3 int32 `codec:",omitempty"` //use key "Field3". Omit if empty. -// Field4 bool `codec:"f4,omitempty"` //use key "f4". Omit if empty. -// io.Reader //use key "Reader". -// MyStruct `codec:"my1" //use key "my1". -// MyStruct //inline it -// ... -// } -// -// type MyStruct struct { -// _struct bool `codec:",toarray"` //encode struct as an array -// } -// -// type MyStruct struct { -// _struct bool `codec:",uint"` //encode struct with "unsigned integer" keys -// Field1 string `codec:"1"` //encode Field1 key using: EncodeInt(1) -// Field2 string `codec:"2"` //encode Field2 key using: EncodeInt(2) -// } -// -// The mode of encoding is based on the type of the value. When a value is seen: -// - If a Selfer, call its CodecEncodeSelf method -// - If an extension is registered for it, call that extension function -// - If implements encoding.(Binary|Text|JSON)Marshaler, call Marshal(Binary|Text|JSON) method -// - Else encode it based on its reflect.Kind -// -// Note that struct field names and keys in map[string]XXX will be treated as symbols. -// Some formats support symbols (e.g. binc) and will properly encode the string -// only once in the stream, and use a tag to refer to it thereafter. -func (e *Encoder) Encode(v interface{}) (err error) { - // tried to use closure, as runtime optimizes defer with no params. - // This seemed to be causing weird issues (like circular reference found, unexpected panic, etc). - // Also, see https://github.com/golang/go/issues/14939#issuecomment-417836139 - // defer func() { e.deferred(&err) }() } - // { x, y := e, &err; defer func() { x.deferred(y) }() } - - if e.err != nil { - return e.err - } - if recoverPanicToErr { - defer func() { - // if error occurred during encoding, return that error; - // else if error occurred on end'ing (i.e. during flush), return that error. - err = e.w().endErr() - x := recover() - if x == nil { - if e.err != err { - e.err = err - } - } else { - panicValToErr(e, x, &e.err) - if e.err != err { - err = e.err - } - } - }() - } - - // defer e.deferred(&err) - e.mustEncode(v) - return -} - -// MustEncode is like Encode, but panics if unable to Encode. -// This provides insight to the code location that triggered the error. -func (e *Encoder) MustEncode(v interface{}) { - if e.err != nil { - panic(e.err) - } - e.mustEncode(v) -} - -func (e *Encoder) mustEncode(v interface{}) { - e.calls++ - e.encode(v) - e.calls-- - if e.calls == 0 { - e.e.atEndOfEncode() - e.w().end() - } -} - -// Release releases shared (pooled) resources. -// -// It is important to call Release() when done with an Encoder, so those resources -// are released instantly for use by subsequently created Encoders. -// -// Deprecated: Release is a no-op as pooled resources are not used with an Encoder. -// This method is kept for compatibility reasons only. -func (e *Encoder) Release() { -} - -func (e *Encoder) encode(iv interface{}) { - // a switch with only concrete types can be optimized. - // consequently, we deal with nil and interfaces outside the switch. - - if iv == nil { - e.e.EncodeNil() - return - } - - rv, ok := isNil(iv) - if ok { - e.e.EncodeNil() - return - } - - var vself Selfer - - switch v := iv.(type) { - // case nil: - // case Selfer: - case Raw: - e.rawBytes(v) - case reflect.Value: - e.encodeValue(v, nil) - - case string: - e.e.EncodeString(v) - case bool: - e.e.EncodeBool(v) - case int: - e.e.EncodeInt(int64(v)) - case int8: - e.e.EncodeInt(int64(v)) - case int16: - e.e.EncodeInt(int64(v)) - case int32: - e.e.EncodeInt(int64(v)) - case int64: - e.e.EncodeInt(v) - case uint: - e.e.EncodeUint(uint64(v)) - case uint8: - e.e.EncodeUint(uint64(v)) - case uint16: - e.e.EncodeUint(uint64(v)) - case uint32: - e.e.EncodeUint(uint64(v)) - case uint64: - e.e.EncodeUint(v) - case uintptr: - e.e.EncodeUint(uint64(v)) - case float32: - e.e.EncodeFloat32(v) - case float64: - e.e.EncodeFloat64(v) - case time.Time: - e.e.EncodeTime(v) - case []uint8: - e.e.EncodeStringBytesRaw(v) - case *Raw: - e.rawBytes(*v) - case *string: - e.e.EncodeString(*v) - case *bool: - e.e.EncodeBool(*v) - case *int: - e.e.EncodeInt(int64(*v)) - case *int8: - e.e.EncodeInt(int64(*v)) - case *int16: - e.e.EncodeInt(int64(*v)) - case *int32: - e.e.EncodeInt(int64(*v)) - case *int64: - e.e.EncodeInt(*v) - case *uint: - e.e.EncodeUint(uint64(*v)) - case *uint8: - e.e.EncodeUint(uint64(*v)) - case *uint16: - e.e.EncodeUint(uint64(*v)) - case *uint32: - e.e.EncodeUint(uint64(*v)) - case *uint64: - e.e.EncodeUint(*v) - case *uintptr: - e.e.EncodeUint(uint64(*v)) - case *float32: - e.e.EncodeFloat32(*v) - case *float64: - e.e.EncodeFloat64(*v) - case *time.Time: - e.e.EncodeTime(*v) - case *[]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - e.e.EncodeStringBytesRaw(*v) - } - default: - if vself, ok = iv.(Selfer); ok { - vself.CodecEncodeSelf(e) - } else if !fastpathEncodeTypeSwitch(iv, e) { - if !rv.IsValid() { - rv = rv4i(iv) - } - e.encodeValue(rv, nil) - } - } -} - -func (e *Encoder) encodeValue(rv reflect.Value, fn *codecFn) { - // if a valid fn is passed, it MUST BE for the dereferenced type of rv - - // We considered using a uintptr (a pointer) retrievable via rv.UnsafeAddr. - // However, it is possible for the same pointer to point to 2 different types e.g. - // type T struct { tHelper } - // Here, for var v T; &v and &v.tHelper are the same pointer. - // Consequently, we need a tuple of type and pointer, which interface{} natively provides. - var sptr interface{} // uintptr - var rvp reflect.Value - var rvpValid bool -TOP: - switch rv.Kind() { - case reflect.Ptr: - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - rvpValid = true - rvp = rv - rv = rv.Elem() - if e.h.CheckCircularRef && rv.Kind() == reflect.Struct { - sptr = rv2i(rvp) // rv.UnsafeAddr() - break TOP - } - goto TOP - case reflect.Interface: - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - rv = rv.Elem() - goto TOP - case reflect.Slice, reflect.Map: - if rvIsNil(rv) { - e.e.EncodeNil() - return - } - case reflect.Invalid, reflect.Func: - e.e.EncodeNil() - return - } - - if sptr != nil && (&e.ci).add(sptr) { - e.errorf("circular reference found: # %p, %T", sptr, sptr) - } - - var rt reflect.Type - if fn == nil { - rt = rv.Type() - fn = e.h.fn(rt) - } - if fn.i.addrE { - if rvpValid { - fn.fe(e, &fn.i, rvp) - } else if rv.CanAddr() { - fn.fe(e, &fn.i, rv.Addr()) - } else { - if rt == nil { - rt = rv.Type() - } - rv2 := reflect.New(rt) - rvSetDirect(rv2.Elem(), rv) - fn.fe(e, &fn.i, rv2) - } - } else { - fn.fe(e, &fn.i, rv) - } - if sptr != 0 { - (&e.ci).remove(sptr) - } -} - -func (e *Encoder) marshalUtf8(bs []byte, fnerr error) { - if fnerr != nil { - panic(fnerr) - } - if bs == nil { - e.e.EncodeNil() - } else { - e.e.EncodeString(stringView(bs)) - // e.e.EncodeStringEnc(cUTF8, stringView(bs)) - } -} - -func (e *Encoder) marshalAsis(bs []byte, fnerr error) { - if fnerr != nil { - panic(fnerr) - } - if bs == nil { - e.e.EncodeNil() - } else { - e.encWr.writeb(bs) // e.asis(bs) - } -} - -func (e *Encoder) marshalRaw(bs []byte, fnerr error) { - if fnerr != nil { - panic(fnerr) - } - if bs == nil { - e.e.EncodeNil() - } else { - e.e.EncodeStringBytesRaw(bs) - } -} - -func (e *Encoder) rawBytes(vv Raw) { - v := []byte(vv) - if !e.h.Raw { - e.errorf("Raw values cannot be encoded: %v", v) - } - e.encWr.writeb(v) // e.asis(v) -} - -func (e *Encoder) wrapErr(v interface{}, err *error) { - *err = encodeError{codecError{name: e.hh.Name(), err: v}} -} - -// ---- container tracker methods -// Note: We update the .c after calling the callback. -// This way, the callback can know what the last status was. - -func (e *Encoder) mapStart(length int) { - e.e.WriteMapStart(length) - e.c = containerMapStart -} - -func (e *Encoder) mapElemKey() { - if e.js { - e.jsondriver().WriteMapElemKey() - } - e.c = containerMapKey -} - -func (e *Encoder) mapElemValue() { - if e.js { - e.jsondriver().WriteMapElemValue() - } - e.c = containerMapValue -} - -func (e *Encoder) mapEnd() { - e.e.WriteMapEnd() - // e.c = containerMapEnd - e.c = 0 -} - -func (e *Encoder) arrayStart(length int) { - e.e.WriteArrayStart(length) - e.c = containerArrayStart -} - -func (e *Encoder) arrayElem() { - if e.js { - e.jsondriver().WriteArrayElem() - } - e.c = containerArrayElem -} - -func (e *Encoder) arrayEnd() { - e.e.WriteArrayEnd() - e.c = 0 - // e.c = containerArrayEnd -} - -// ---------- - -func (e *Encoder) sideEncode(v interface{}, bs *[]byte) { - rv := baseRV(v) - e2 := NewEncoderBytes(bs, e.hh) - e2.encodeValue(rv, e.h.fnNoExt(rv.Type())) - e2.e.atEndOfEncode() - e2.w().end() -} - -func encStructFieldKey(encName string, ee encDriver, w *encWr, - keyType valueType, encNameAsciiAlphaNum bool, js bool) { - var m must - // use if-else-if, not switch (which compiles to binary-search) - // since keyType is typically valueTypeString, branch prediction is pretty good. - if keyType == valueTypeString { - if js && encNameAsciiAlphaNum { // keyType == valueTypeString - w.writeqstr(encName) - } else { // keyType == valueTypeString - ee.EncodeString(encName) - } - } else if keyType == valueTypeInt { - ee.EncodeInt(m.Int(strconv.ParseInt(encName, 10, 64))) - } else if keyType == valueTypeUint { - ee.EncodeUint(m.Uint(strconv.ParseUint(encName, 10, 64))) - } else if keyType == valueTypeFloat { - ee.EncodeFloat64(m.Float(strconv.ParseFloat(encName, 64))) - } -} diff --git a/vendor/github.com/ugorji/go/codec/fast-path.generated.go b/vendor/github.com/ugorji/go/codec/fast-path.generated.go deleted file mode 100644 index 6c4c652d7..000000000 --- a/vendor/github.com/ugorji/go/codec/fast-path.generated.go +++ /dev/null @@ -1,8938 +0,0 @@ -// +build !notfastpath - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from fast-path.go.tmpl - DO NOT EDIT. - -package codec - -// Fast path functions try to create a fast path encode or decode implementation -// for common maps and slices. -// -// We define the functions and register them in this single file -// so as not to pollute the encode.go and decode.go, and create a dependency in there. -// This file can be omitted without causing a build failure. -// -// The advantage of fast paths is: -// - Many calls bypass reflection altogether -// -// Currently support -// - slice of all builtin types (numeric, bool, string, []byte) -// - maps of builtin types to builtin or interface{} type, EXCEPT FOR -// keys of type uintptr, int8/16/32, uint16/32, float32/64, bool, interface{} -// AND values of type type int8/16/32, uint16/32 -// This should provide adequate "typical" implementations. -// -// Note that fast track decode functions must handle values for which an address cannot be obtained. -// For example: -// m2 := map[string]int{} -// p2 := []interface{}{m2} -// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. -// - -import ( - "reflect" - "sort" -) - -const fastpathEnabled = true - -const fastpathMapBySliceErrMsg = "mapBySlice requires even slice length, but got %v" - -type fastpathT struct{} - -var fastpathTV fastpathT - -type fastpathE struct { - rtid uintptr - rt reflect.Type - encfn func(*Encoder, *codecFnInfo, reflect.Value) - decfn func(*Decoder, *codecFnInfo, reflect.Value) -} - -type fastpathA [81]fastpathE - -func (x *fastpathA) index(rtid uintptr) int { - // use binary search to grab the index (adapted from sort/search.go) - // Note: we use goto (instead of for loop) so this can be inlined. - // h, i, j := 0, 0, len(x) - var h, i uint - var j = uint(len(x)) -LOOP: - if i < j { - h = i + (j-i)/2 - if x[h].rtid < rtid { - i = h + 1 - } else { - j = h - } - goto LOOP - } - if i < uint(len(x)) && x[i].rtid == rtid { - return int(i) - } - return -1 -} - -type fastpathAslice []fastpathE - -func (x fastpathAslice) Len() int { return len(x) } -func (x fastpathAslice) Less(i, j int) bool { return x[uint(i)].rtid < x[uint(j)].rtid } -func (x fastpathAslice) Swap(i, j int) { x[uint(i)], x[uint(j)] = x[uint(j)], x[uint(i)] } - -var fastpathAV fastpathA - -// due to possible initialization loop error, make fastpath in an init() -func init() { - var i uint = 0 - fn := func(v interface{}, - fe func(*Encoder, *codecFnInfo, reflect.Value), - fd func(*Decoder, *codecFnInfo, reflect.Value)) { - xrt := reflect.TypeOf(v) - xptr := rt2id(xrt) - fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} - i++ - } - - fn([]interface{}(nil), (*Encoder).fastpathEncSliceIntfR, (*Decoder).fastpathDecSliceIntfR) - fn([]string(nil), (*Encoder).fastpathEncSliceStringR, (*Decoder).fastpathDecSliceStringR) - fn([][]byte(nil), (*Encoder).fastpathEncSliceBytesR, (*Decoder).fastpathDecSliceBytesR) - fn([]float32(nil), (*Encoder).fastpathEncSliceFloat32R, (*Decoder).fastpathDecSliceFloat32R) - fn([]float64(nil), (*Encoder).fastpathEncSliceFloat64R, (*Decoder).fastpathDecSliceFloat64R) - fn([]uint(nil), (*Encoder).fastpathEncSliceUintR, (*Decoder).fastpathDecSliceUintR) - fn([]uint16(nil), (*Encoder).fastpathEncSliceUint16R, (*Decoder).fastpathDecSliceUint16R) - fn([]uint32(nil), (*Encoder).fastpathEncSliceUint32R, (*Decoder).fastpathDecSliceUint32R) - fn([]uint64(nil), (*Encoder).fastpathEncSliceUint64R, (*Decoder).fastpathDecSliceUint64R) - fn([]int(nil), (*Encoder).fastpathEncSliceIntR, (*Decoder).fastpathDecSliceIntR) - fn([]int8(nil), (*Encoder).fastpathEncSliceInt8R, (*Decoder).fastpathDecSliceInt8R) - fn([]int16(nil), (*Encoder).fastpathEncSliceInt16R, (*Decoder).fastpathDecSliceInt16R) - fn([]int32(nil), (*Encoder).fastpathEncSliceInt32R, (*Decoder).fastpathDecSliceInt32R) - fn([]int64(nil), (*Encoder).fastpathEncSliceInt64R, (*Decoder).fastpathDecSliceInt64R) - fn([]bool(nil), (*Encoder).fastpathEncSliceBoolR, (*Decoder).fastpathDecSliceBoolR) - - fn(map[string]interface{}(nil), (*Encoder).fastpathEncMapStringIntfR, (*Decoder).fastpathDecMapStringIntfR) - fn(map[string]string(nil), (*Encoder).fastpathEncMapStringStringR, (*Decoder).fastpathDecMapStringStringR) - fn(map[string][]byte(nil), (*Encoder).fastpathEncMapStringBytesR, (*Decoder).fastpathDecMapStringBytesR) - fn(map[string]uint(nil), (*Encoder).fastpathEncMapStringUintR, (*Decoder).fastpathDecMapStringUintR) - fn(map[string]uint8(nil), (*Encoder).fastpathEncMapStringUint8R, (*Decoder).fastpathDecMapStringUint8R) - fn(map[string]uint64(nil), (*Encoder).fastpathEncMapStringUint64R, (*Decoder).fastpathDecMapStringUint64R) - fn(map[string]int(nil), (*Encoder).fastpathEncMapStringIntR, (*Decoder).fastpathDecMapStringIntR) - fn(map[string]int64(nil), (*Encoder).fastpathEncMapStringInt64R, (*Decoder).fastpathDecMapStringInt64R) - fn(map[string]float32(nil), (*Encoder).fastpathEncMapStringFloat32R, (*Decoder).fastpathDecMapStringFloat32R) - fn(map[string]float64(nil), (*Encoder).fastpathEncMapStringFloat64R, (*Decoder).fastpathDecMapStringFloat64R) - fn(map[string]bool(nil), (*Encoder).fastpathEncMapStringBoolR, (*Decoder).fastpathDecMapStringBoolR) - fn(map[uint]interface{}(nil), (*Encoder).fastpathEncMapUintIntfR, (*Decoder).fastpathDecMapUintIntfR) - fn(map[uint]string(nil), (*Encoder).fastpathEncMapUintStringR, (*Decoder).fastpathDecMapUintStringR) - fn(map[uint][]byte(nil), (*Encoder).fastpathEncMapUintBytesR, (*Decoder).fastpathDecMapUintBytesR) - fn(map[uint]uint(nil), (*Encoder).fastpathEncMapUintUintR, (*Decoder).fastpathDecMapUintUintR) - fn(map[uint]uint8(nil), (*Encoder).fastpathEncMapUintUint8R, (*Decoder).fastpathDecMapUintUint8R) - fn(map[uint]uint64(nil), (*Encoder).fastpathEncMapUintUint64R, (*Decoder).fastpathDecMapUintUint64R) - fn(map[uint]int(nil), (*Encoder).fastpathEncMapUintIntR, (*Decoder).fastpathDecMapUintIntR) - fn(map[uint]int64(nil), (*Encoder).fastpathEncMapUintInt64R, (*Decoder).fastpathDecMapUintInt64R) - fn(map[uint]float32(nil), (*Encoder).fastpathEncMapUintFloat32R, (*Decoder).fastpathDecMapUintFloat32R) - fn(map[uint]float64(nil), (*Encoder).fastpathEncMapUintFloat64R, (*Decoder).fastpathDecMapUintFloat64R) - fn(map[uint]bool(nil), (*Encoder).fastpathEncMapUintBoolR, (*Decoder).fastpathDecMapUintBoolR) - fn(map[uint8]interface{}(nil), (*Encoder).fastpathEncMapUint8IntfR, (*Decoder).fastpathDecMapUint8IntfR) - fn(map[uint8]string(nil), (*Encoder).fastpathEncMapUint8StringR, (*Decoder).fastpathDecMapUint8StringR) - fn(map[uint8][]byte(nil), (*Encoder).fastpathEncMapUint8BytesR, (*Decoder).fastpathDecMapUint8BytesR) - fn(map[uint8]uint(nil), (*Encoder).fastpathEncMapUint8UintR, (*Decoder).fastpathDecMapUint8UintR) - fn(map[uint8]uint8(nil), (*Encoder).fastpathEncMapUint8Uint8R, (*Decoder).fastpathDecMapUint8Uint8R) - fn(map[uint8]uint64(nil), (*Encoder).fastpathEncMapUint8Uint64R, (*Decoder).fastpathDecMapUint8Uint64R) - fn(map[uint8]int(nil), (*Encoder).fastpathEncMapUint8IntR, (*Decoder).fastpathDecMapUint8IntR) - fn(map[uint8]int64(nil), (*Encoder).fastpathEncMapUint8Int64R, (*Decoder).fastpathDecMapUint8Int64R) - fn(map[uint8]float32(nil), (*Encoder).fastpathEncMapUint8Float32R, (*Decoder).fastpathDecMapUint8Float32R) - fn(map[uint8]float64(nil), (*Encoder).fastpathEncMapUint8Float64R, (*Decoder).fastpathDecMapUint8Float64R) - fn(map[uint8]bool(nil), (*Encoder).fastpathEncMapUint8BoolR, (*Decoder).fastpathDecMapUint8BoolR) - fn(map[uint64]interface{}(nil), (*Encoder).fastpathEncMapUint64IntfR, (*Decoder).fastpathDecMapUint64IntfR) - fn(map[uint64]string(nil), (*Encoder).fastpathEncMapUint64StringR, (*Decoder).fastpathDecMapUint64StringR) - fn(map[uint64][]byte(nil), (*Encoder).fastpathEncMapUint64BytesR, (*Decoder).fastpathDecMapUint64BytesR) - fn(map[uint64]uint(nil), (*Encoder).fastpathEncMapUint64UintR, (*Decoder).fastpathDecMapUint64UintR) - fn(map[uint64]uint8(nil), (*Encoder).fastpathEncMapUint64Uint8R, (*Decoder).fastpathDecMapUint64Uint8R) - fn(map[uint64]uint64(nil), (*Encoder).fastpathEncMapUint64Uint64R, (*Decoder).fastpathDecMapUint64Uint64R) - fn(map[uint64]int(nil), (*Encoder).fastpathEncMapUint64IntR, (*Decoder).fastpathDecMapUint64IntR) - fn(map[uint64]int64(nil), (*Encoder).fastpathEncMapUint64Int64R, (*Decoder).fastpathDecMapUint64Int64R) - fn(map[uint64]float32(nil), (*Encoder).fastpathEncMapUint64Float32R, (*Decoder).fastpathDecMapUint64Float32R) - fn(map[uint64]float64(nil), (*Encoder).fastpathEncMapUint64Float64R, (*Decoder).fastpathDecMapUint64Float64R) - fn(map[uint64]bool(nil), (*Encoder).fastpathEncMapUint64BoolR, (*Decoder).fastpathDecMapUint64BoolR) - fn(map[int]interface{}(nil), (*Encoder).fastpathEncMapIntIntfR, (*Decoder).fastpathDecMapIntIntfR) - fn(map[int]string(nil), (*Encoder).fastpathEncMapIntStringR, (*Decoder).fastpathDecMapIntStringR) - fn(map[int][]byte(nil), (*Encoder).fastpathEncMapIntBytesR, (*Decoder).fastpathDecMapIntBytesR) - fn(map[int]uint(nil), (*Encoder).fastpathEncMapIntUintR, (*Decoder).fastpathDecMapIntUintR) - fn(map[int]uint8(nil), (*Encoder).fastpathEncMapIntUint8R, (*Decoder).fastpathDecMapIntUint8R) - fn(map[int]uint64(nil), (*Encoder).fastpathEncMapIntUint64R, (*Decoder).fastpathDecMapIntUint64R) - fn(map[int]int(nil), (*Encoder).fastpathEncMapIntIntR, (*Decoder).fastpathDecMapIntIntR) - fn(map[int]int64(nil), (*Encoder).fastpathEncMapIntInt64R, (*Decoder).fastpathDecMapIntInt64R) - fn(map[int]float32(nil), (*Encoder).fastpathEncMapIntFloat32R, (*Decoder).fastpathDecMapIntFloat32R) - fn(map[int]float64(nil), (*Encoder).fastpathEncMapIntFloat64R, (*Decoder).fastpathDecMapIntFloat64R) - fn(map[int]bool(nil), (*Encoder).fastpathEncMapIntBoolR, (*Decoder).fastpathDecMapIntBoolR) - fn(map[int64]interface{}(nil), (*Encoder).fastpathEncMapInt64IntfR, (*Decoder).fastpathDecMapInt64IntfR) - fn(map[int64]string(nil), (*Encoder).fastpathEncMapInt64StringR, (*Decoder).fastpathDecMapInt64StringR) - fn(map[int64][]byte(nil), (*Encoder).fastpathEncMapInt64BytesR, (*Decoder).fastpathDecMapInt64BytesR) - fn(map[int64]uint(nil), (*Encoder).fastpathEncMapInt64UintR, (*Decoder).fastpathDecMapInt64UintR) - fn(map[int64]uint8(nil), (*Encoder).fastpathEncMapInt64Uint8R, (*Decoder).fastpathDecMapInt64Uint8R) - fn(map[int64]uint64(nil), (*Encoder).fastpathEncMapInt64Uint64R, (*Decoder).fastpathDecMapInt64Uint64R) - fn(map[int64]int(nil), (*Encoder).fastpathEncMapInt64IntR, (*Decoder).fastpathDecMapInt64IntR) - fn(map[int64]int64(nil), (*Encoder).fastpathEncMapInt64Int64R, (*Decoder).fastpathDecMapInt64Int64R) - fn(map[int64]float32(nil), (*Encoder).fastpathEncMapInt64Float32R, (*Decoder).fastpathDecMapInt64Float32R) - fn(map[int64]float64(nil), (*Encoder).fastpathEncMapInt64Float64R, (*Decoder).fastpathDecMapInt64Float64R) - fn(map[int64]bool(nil), (*Encoder).fastpathEncMapInt64BoolR, (*Decoder).fastpathDecMapInt64BoolR) - - sort.Sort(fastpathAslice(fastpathAV[:])) -} - -// -- encode - -// -- -- fast path type switch -func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { - case []interface{}: - fastpathTV.EncSliceIntfV(v, e) - case *[]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceIntfV(*v, e) - } - case []string: - fastpathTV.EncSliceStringV(v, e) - case *[]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceStringV(*v, e) - } - case [][]byte: - fastpathTV.EncSliceBytesV(v, e) - case *[][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceBytesV(*v, e) - } - case []float32: - fastpathTV.EncSliceFloat32V(v, e) - case *[]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceFloat32V(*v, e) - } - case []float64: - fastpathTV.EncSliceFloat64V(v, e) - case *[]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceFloat64V(*v, e) - } - case []uint: - fastpathTV.EncSliceUintV(v, e) - case *[]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUintV(*v, e) - } - case []uint16: - fastpathTV.EncSliceUint16V(v, e) - case *[]uint16: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUint16V(*v, e) - } - case []uint32: - fastpathTV.EncSliceUint32V(v, e) - case *[]uint32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUint32V(*v, e) - } - case []uint64: - fastpathTV.EncSliceUint64V(v, e) - case *[]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceUint64V(*v, e) - } - case []int: - fastpathTV.EncSliceIntV(v, e) - case *[]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceIntV(*v, e) - } - case []int8: - fastpathTV.EncSliceInt8V(v, e) - case *[]int8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt8V(*v, e) - } - case []int16: - fastpathTV.EncSliceInt16V(v, e) - case *[]int16: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt16V(*v, e) - } - case []int32: - fastpathTV.EncSliceInt32V(v, e) - case *[]int32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt32V(*v, e) - } - case []int64: - fastpathTV.EncSliceInt64V(v, e) - case *[]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceInt64V(*v, e) - } - case []bool: - fastpathTV.EncSliceBoolV(v, e) - case *[]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncSliceBoolV(*v, e) - } - case map[string]interface{}: - fastpathTV.EncMapStringIntfV(v, e) - case *map[string]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringIntfV(*v, e) - } - case map[string]string: - fastpathTV.EncMapStringStringV(v, e) - case *map[string]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringStringV(*v, e) - } - case map[string][]byte: - fastpathTV.EncMapStringBytesV(v, e) - case *map[string][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringBytesV(*v, e) - } - case map[string]uint: - fastpathTV.EncMapStringUintV(v, e) - case *map[string]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringUintV(*v, e) - } - case map[string]uint8: - fastpathTV.EncMapStringUint8V(v, e) - case *map[string]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringUint8V(*v, e) - } - case map[string]uint64: - fastpathTV.EncMapStringUint64V(v, e) - case *map[string]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringUint64V(*v, e) - } - case map[string]int: - fastpathTV.EncMapStringIntV(v, e) - case *map[string]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringIntV(*v, e) - } - case map[string]int64: - fastpathTV.EncMapStringInt64V(v, e) - case *map[string]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringInt64V(*v, e) - } - case map[string]float32: - fastpathTV.EncMapStringFloat32V(v, e) - case *map[string]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringFloat32V(*v, e) - } - case map[string]float64: - fastpathTV.EncMapStringFloat64V(v, e) - case *map[string]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringFloat64V(*v, e) - } - case map[string]bool: - fastpathTV.EncMapStringBoolV(v, e) - case *map[string]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapStringBoolV(*v, e) - } - case map[uint]interface{}: - fastpathTV.EncMapUintIntfV(v, e) - case *map[uint]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintIntfV(*v, e) - } - case map[uint]string: - fastpathTV.EncMapUintStringV(v, e) - case *map[uint]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintStringV(*v, e) - } - case map[uint][]byte: - fastpathTV.EncMapUintBytesV(v, e) - case *map[uint][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintBytesV(*v, e) - } - case map[uint]uint: - fastpathTV.EncMapUintUintV(v, e) - case *map[uint]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintUintV(*v, e) - } - case map[uint]uint8: - fastpathTV.EncMapUintUint8V(v, e) - case *map[uint]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintUint8V(*v, e) - } - case map[uint]uint64: - fastpathTV.EncMapUintUint64V(v, e) - case *map[uint]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintUint64V(*v, e) - } - case map[uint]int: - fastpathTV.EncMapUintIntV(v, e) - case *map[uint]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintIntV(*v, e) - } - case map[uint]int64: - fastpathTV.EncMapUintInt64V(v, e) - case *map[uint]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintInt64V(*v, e) - } - case map[uint]float32: - fastpathTV.EncMapUintFloat32V(v, e) - case *map[uint]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintFloat32V(*v, e) - } - case map[uint]float64: - fastpathTV.EncMapUintFloat64V(v, e) - case *map[uint]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintFloat64V(*v, e) - } - case map[uint]bool: - fastpathTV.EncMapUintBoolV(v, e) - case *map[uint]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUintBoolV(*v, e) - } - case map[uint8]interface{}: - fastpathTV.EncMapUint8IntfV(v, e) - case *map[uint8]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8IntfV(*v, e) - } - case map[uint8]string: - fastpathTV.EncMapUint8StringV(v, e) - case *map[uint8]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8StringV(*v, e) - } - case map[uint8][]byte: - fastpathTV.EncMapUint8BytesV(v, e) - case *map[uint8][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8BytesV(*v, e) - } - case map[uint8]uint: - fastpathTV.EncMapUint8UintV(v, e) - case *map[uint8]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8UintV(*v, e) - } - case map[uint8]uint8: - fastpathTV.EncMapUint8Uint8V(v, e) - case *map[uint8]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Uint8V(*v, e) - } - case map[uint8]uint64: - fastpathTV.EncMapUint8Uint64V(v, e) - case *map[uint8]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Uint64V(*v, e) - } - case map[uint8]int: - fastpathTV.EncMapUint8IntV(v, e) - case *map[uint8]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8IntV(*v, e) - } - case map[uint8]int64: - fastpathTV.EncMapUint8Int64V(v, e) - case *map[uint8]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Int64V(*v, e) - } - case map[uint8]float32: - fastpathTV.EncMapUint8Float32V(v, e) - case *map[uint8]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Float32V(*v, e) - } - case map[uint8]float64: - fastpathTV.EncMapUint8Float64V(v, e) - case *map[uint8]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8Float64V(*v, e) - } - case map[uint8]bool: - fastpathTV.EncMapUint8BoolV(v, e) - case *map[uint8]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint8BoolV(*v, e) - } - case map[uint64]interface{}: - fastpathTV.EncMapUint64IntfV(v, e) - case *map[uint64]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64IntfV(*v, e) - } - case map[uint64]string: - fastpathTV.EncMapUint64StringV(v, e) - case *map[uint64]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64StringV(*v, e) - } - case map[uint64][]byte: - fastpathTV.EncMapUint64BytesV(v, e) - case *map[uint64][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64BytesV(*v, e) - } - case map[uint64]uint: - fastpathTV.EncMapUint64UintV(v, e) - case *map[uint64]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64UintV(*v, e) - } - case map[uint64]uint8: - fastpathTV.EncMapUint64Uint8V(v, e) - case *map[uint64]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Uint8V(*v, e) - } - case map[uint64]uint64: - fastpathTV.EncMapUint64Uint64V(v, e) - case *map[uint64]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Uint64V(*v, e) - } - case map[uint64]int: - fastpathTV.EncMapUint64IntV(v, e) - case *map[uint64]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64IntV(*v, e) - } - case map[uint64]int64: - fastpathTV.EncMapUint64Int64V(v, e) - case *map[uint64]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Int64V(*v, e) - } - case map[uint64]float32: - fastpathTV.EncMapUint64Float32V(v, e) - case *map[uint64]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Float32V(*v, e) - } - case map[uint64]float64: - fastpathTV.EncMapUint64Float64V(v, e) - case *map[uint64]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64Float64V(*v, e) - } - case map[uint64]bool: - fastpathTV.EncMapUint64BoolV(v, e) - case *map[uint64]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapUint64BoolV(*v, e) - } - case map[int]interface{}: - fastpathTV.EncMapIntIntfV(v, e) - case *map[int]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntIntfV(*v, e) - } - case map[int]string: - fastpathTV.EncMapIntStringV(v, e) - case *map[int]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntStringV(*v, e) - } - case map[int][]byte: - fastpathTV.EncMapIntBytesV(v, e) - case *map[int][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntBytesV(*v, e) - } - case map[int]uint: - fastpathTV.EncMapIntUintV(v, e) - case *map[int]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntUintV(*v, e) - } - case map[int]uint8: - fastpathTV.EncMapIntUint8V(v, e) - case *map[int]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntUint8V(*v, e) - } - case map[int]uint64: - fastpathTV.EncMapIntUint64V(v, e) - case *map[int]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntUint64V(*v, e) - } - case map[int]int: - fastpathTV.EncMapIntIntV(v, e) - case *map[int]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntIntV(*v, e) - } - case map[int]int64: - fastpathTV.EncMapIntInt64V(v, e) - case *map[int]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntInt64V(*v, e) - } - case map[int]float32: - fastpathTV.EncMapIntFloat32V(v, e) - case *map[int]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntFloat32V(*v, e) - } - case map[int]float64: - fastpathTV.EncMapIntFloat64V(v, e) - case *map[int]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntFloat64V(*v, e) - } - case map[int]bool: - fastpathTV.EncMapIntBoolV(v, e) - case *map[int]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapIntBoolV(*v, e) - } - case map[int64]interface{}: - fastpathTV.EncMapInt64IntfV(v, e) - case *map[int64]interface{}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64IntfV(*v, e) - } - case map[int64]string: - fastpathTV.EncMapInt64StringV(v, e) - case *map[int64]string: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64StringV(*v, e) - } - case map[int64][]byte: - fastpathTV.EncMapInt64BytesV(v, e) - case *map[int64][]byte: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64BytesV(*v, e) - } - case map[int64]uint: - fastpathTV.EncMapInt64UintV(v, e) - case *map[int64]uint: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64UintV(*v, e) - } - case map[int64]uint8: - fastpathTV.EncMapInt64Uint8V(v, e) - case *map[int64]uint8: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Uint8V(*v, e) - } - case map[int64]uint64: - fastpathTV.EncMapInt64Uint64V(v, e) - case *map[int64]uint64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Uint64V(*v, e) - } - case map[int64]int: - fastpathTV.EncMapInt64IntV(v, e) - case *map[int64]int: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64IntV(*v, e) - } - case map[int64]int64: - fastpathTV.EncMapInt64Int64V(v, e) - case *map[int64]int64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Int64V(*v, e) - } - case map[int64]float32: - fastpathTV.EncMapInt64Float32V(v, e) - case *map[int64]float32: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Float32V(*v, e) - } - case map[int64]float64: - fastpathTV.EncMapInt64Float64V(v, e) - case *map[int64]float64: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64Float64V(*v, e) - } - case map[int64]bool: - fastpathTV.EncMapInt64BoolV(v, e) - case *map[int64]bool: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.EncMapInt64BoolV(*v, e) - } - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false - } - return true -} - -// -- -- fast path functions -func (e *Encoder) fastpathEncSliceIntfR(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceIntfV(rv2i(rv).([]interface{}), e) - } else { - fastpathTV.EncSliceIntfV(rv2i(rv).([]interface{}), e) - } -} -func (fastpathT) EncSliceIntfV(v []interface{}, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.encode(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceIntfV(v []interface{}, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.encode(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceStringR(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceStringV(rv2i(rv).([]string), e) - } else { - fastpathTV.EncSliceStringV(rv2i(rv).([]string), e) - } -} -func (fastpathT) EncSliceStringV(v []string, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeString(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceStringV(v []string, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeString(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceBytesR(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceBytesV(rv2i(rv).([][]byte), e) - } else { - fastpathTV.EncSliceBytesV(rv2i(rv).([][]byte), e) - } -} -func (fastpathT) EncSliceBytesV(v [][]byte, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeStringBytesRaw(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceBytesV(v [][]byte, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeStringBytesRaw(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceFloat32R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceFloat32V(rv2i(rv).([]float32), e) - } else { - fastpathTV.EncSliceFloat32V(rv2i(rv).([]float32), e) - } -} -func (fastpathT) EncSliceFloat32V(v []float32, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeFloat32(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceFloat32V(v []float32, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeFloat32(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceFloat64R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceFloat64V(rv2i(rv).([]float64), e) - } else { - fastpathTV.EncSliceFloat64V(rv2i(rv).([]float64), e) - } -} -func (fastpathT) EncSliceFloat64V(v []float64, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeFloat64(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceFloat64V(v []float64, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeFloat64(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceUintR(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceUintV(rv2i(rv).([]uint), e) - } else { - fastpathTV.EncSliceUintV(rv2i(rv).([]uint), e) - } -} -func (fastpathT) EncSliceUintV(v []uint, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(uint64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceUintV(v []uint, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeUint(uint64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceUint16R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceUint16V(rv2i(rv).([]uint16), e) - } else { - fastpathTV.EncSliceUint16V(rv2i(rv).([]uint16), e) - } -} -func (fastpathT) EncSliceUint16V(v []uint16, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(uint64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceUint16V(v []uint16, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeUint(uint64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceUint32R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceUint32V(rv2i(rv).([]uint32), e) - } else { - fastpathTV.EncSliceUint32V(rv2i(rv).([]uint32), e) - } -} -func (fastpathT) EncSliceUint32V(v []uint32, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(uint64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceUint32V(v []uint32, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeUint(uint64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceUint64R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceUint64V(rv2i(rv).([]uint64), e) - } else { - fastpathTV.EncSliceUint64V(rv2i(rv).([]uint64), e) - } -} -func (fastpathT) EncSliceUint64V(v []uint64, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeUint(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceUint64V(v []uint64, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeUint(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceIntR(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceIntV(rv2i(rv).([]int), e) - } else { - fastpathTV.EncSliceIntV(rv2i(rv).([]int), e) - } -} -func (fastpathT) EncSliceIntV(v []int, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceIntV(v []int, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeInt(int64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceInt8R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceInt8V(rv2i(rv).([]int8), e) - } else { - fastpathTV.EncSliceInt8V(rv2i(rv).([]int8), e) - } -} -func (fastpathT) EncSliceInt8V(v []int8, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceInt8V(v []int8, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeInt(int64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceInt16R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceInt16V(rv2i(rv).([]int16), e) - } else { - fastpathTV.EncSliceInt16V(rv2i(rv).([]int16), e) - } -} -func (fastpathT) EncSliceInt16V(v []int16, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceInt16V(v []int16, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeInt(int64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceInt32R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceInt32V(rv2i(rv).([]int32), e) - } else { - fastpathTV.EncSliceInt32V(rv2i(rv).([]int32), e) - } -} -func (fastpathT) EncSliceInt32V(v []int32, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(int64(v[j])) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceInt32V(v []int32, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeInt(int64(v[j])) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceInt64R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceInt64V(rv2i(rv).([]int64), e) - } else { - fastpathTV.EncSliceInt64V(rv2i(rv).([]int64), e) - } -} -func (fastpathT) EncSliceInt64V(v []int64, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeInt(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceInt64V(v []int64, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeInt(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncSliceBoolR(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.EncAsMapSliceBoolV(rv2i(rv).([]bool), e) - } else { - fastpathTV.EncSliceBoolV(rv2i(rv).([]bool), e) - } -} -func (fastpathT) EncSliceBoolV(v []bool, e *Encoder) { - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - e.e.EncodeBool(v[j]) - } - e.arrayEnd() -} -func (fastpathT) EncAsMapSliceBoolV(v []bool, e *Encoder) { - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - e.e.EncodeBool(v[j]) - } - e.mapEnd() - } -} -func (e *Encoder) fastpathEncMapStringIntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringIntfV(rv2i(rv).(map[string]interface{}), e) -} -func (fastpathT) EncMapStringIntfV(v map[string]interface{}, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.encode(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.encode(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringStringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringStringV(rv2i(rv).(map[string]string), e) -} -func (fastpathT) EncMapStringStringV(v map[string]string, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeString(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeString(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringBytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringBytesV(rv2i(rv).(map[string][]byte), e) -} -func (fastpathT) EncMapStringBytesV(v map[string][]byte, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringUintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringUintV(rv2i(rv).(map[string]uint), e) -} -func (fastpathT) EncMapStringUintV(v map[string]uint, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringUint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringUint8V(rv2i(rv).(map[string]uint8), e) -} -func (fastpathT) EncMapStringUint8V(v map[string]uint8, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringUint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringUint64V(rv2i(rv).(map[string]uint64), e) -} -func (fastpathT) EncMapStringUint64V(v map[string]uint64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeUint(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringIntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringIntV(rv2i(rv).(map[string]int), e) -} -func (fastpathT) EncMapStringIntV(v map[string]int, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringInt64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringInt64V(rv2i(rv).(map[string]int64), e) -} -func (fastpathT) EncMapStringInt64V(v map[string]int64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeInt(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringFloat32V(rv2i(rv).(map[string]float32), e) -} -func (fastpathT) EncMapStringFloat32V(v map[string]float32, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat32(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat32(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringFloat64V(rv2i(rv).(map[string]float64), e) -} -func (fastpathT) EncMapStringFloat64V(v map[string]float64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat64(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeFloat64(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapStringBoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapStringBoolV(rv2i(rv).(map[string]bool), e) -} -func (fastpathT) EncMapStringBoolV(v map[string]bool, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]string, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(stringSlice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeBool(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeString(k2) - e.mapElemValue() - e.e.EncodeBool(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintIntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintIntfV(rv2i(rv).(map[uint]interface{}), e) -} -func (fastpathT) EncMapUintIntfV(v map[uint]interface{}, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.encode(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.encode(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintStringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintStringV(rv2i(rv).(map[uint]string), e) -} -func (fastpathT) EncMapUintStringV(v map[uint]string, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeString(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeString(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintBytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintBytesV(rv2i(rv).(map[uint][]byte), e) -} -func (fastpathT) EncMapUintBytesV(v map[uint][]byte, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintUintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintUintV(rv2i(rv).(map[uint]uint), e) -} -func (fastpathT) EncMapUintUintV(v map[uint]uint, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintUint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintUint8V(rv2i(rv).(map[uint]uint8), e) -} -func (fastpathT) EncMapUintUint8V(v map[uint]uint8, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintUint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintUint64V(rv2i(rv).(map[uint]uint64), e) -} -func (fastpathT) EncMapUintUint64V(v map[uint]uint64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeUint(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintIntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintIntV(rv2i(rv).(map[uint]int), e) -} -func (fastpathT) EncMapUintIntV(v map[uint]int, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeInt(int64(v[uint(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintInt64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintInt64V(rv2i(rv).(map[uint]int64), e) -} -func (fastpathT) EncMapUintInt64V(v map[uint]int64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeInt(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintFloat32V(rv2i(rv).(map[uint]float32), e) -} -func (fastpathT) EncMapUintFloat32V(v map[uint]float32, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeFloat32(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat32(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintFloat64V(rv2i(rv).(map[uint]float64), e) -} -func (fastpathT) EncMapUintFloat64V(v map[uint]float64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeFloat64(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat64(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUintBoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUintBoolV(rv2i(rv).(map[uint]bool), e) -} -func (fastpathT) EncMapUintBoolV(v map[uint]bool, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint(k2))) - e.mapElemValue() - e.e.EncodeBool(v[uint(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeBool(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8IntfV(rv2i(rv).(map[uint8]interface{}), e) -} -func (fastpathT) EncMapUint8IntfV(v map[uint8]interface{}, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.encode(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.encode(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8StringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8StringV(rv2i(rv).(map[uint8]string), e) -} -func (fastpathT) EncMapUint8StringV(v map[uint8]string, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeString(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeString(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8BytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8BytesV(rv2i(rv).(map[uint8][]byte), e) -} -func (fastpathT) EncMapUint8BytesV(v map[uint8][]byte, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8UintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8UintV(rv2i(rv).(map[uint8]uint), e) -} -func (fastpathT) EncMapUint8UintV(v map[uint8]uint, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint8(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Uint8V(rv2i(rv).(map[uint8]uint8), e) -} -func (fastpathT) EncMapUint8Uint8V(v map[uint8]uint8, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[uint8(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Uint64V(rv2i(rv).(map[uint8]uint64), e) -} -func (fastpathT) EncMapUint8Uint64V(v map[uint8]uint64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeUint(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeUint(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8IntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8IntV(rv2i(rv).(map[uint8]int), e) -} -func (fastpathT) EncMapUint8IntV(v map[uint8]int, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeInt(int64(v[uint8(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Int64V(rv2i(rv).(map[uint8]int64), e) -} -func (fastpathT) EncMapUint8Int64V(v map[uint8]int64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeInt(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeInt(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8Float32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Float32V(rv2i(rv).(map[uint8]float32), e) -} -func (fastpathT) EncMapUint8Float32V(v map[uint8]float32, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeFloat32(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat32(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8Float64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8Float64V(rv2i(rv).(map[uint8]float64), e) -} -func (fastpathT) EncMapUint8Float64V(v map[uint8]float64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeFloat64(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeFloat64(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint8BoolV(rv2i(rv).(map[uint8]bool), e) -} -func (fastpathT) EncMapUint8BoolV(v map[uint8]bool, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = uint64(k) - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(uint64(uint8(k2))) - e.mapElemValue() - e.e.EncodeBool(v[uint8(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(uint64(k2)) - e.mapElemValue() - e.e.EncodeBool(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64IntfV(rv2i(rv).(map[uint64]interface{}), e) -} -func (fastpathT) EncMapUint64IntfV(v map[uint64]interface{}, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.encode(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.encode(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64StringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64StringV(rv2i(rv).(map[uint64]string), e) -} -func (fastpathT) EncMapUint64StringV(v map[uint64]string, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeString(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeString(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64BytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64BytesV(rv2i(rv).(map[uint64][]byte), e) -} -func (fastpathT) EncMapUint64BytesV(v map[uint64][]byte, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64UintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64UintV(rv2i(rv).(map[uint64]uint), e) -} -func (fastpathT) EncMapUint64UintV(v map[uint64]uint, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Uint8V(rv2i(rv).(map[uint64]uint8), e) -} -func (fastpathT) EncMapUint64Uint8V(v map[uint64]uint8, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Uint64V(rv2i(rv).(map[uint64]uint64), e) -} -func (fastpathT) EncMapUint64Uint64V(v map[uint64]uint64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeUint(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64IntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64IntV(rv2i(rv).(map[uint64]int), e) -} -func (fastpathT) EncMapUint64IntV(v map[uint64]int, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Int64V(rv2i(rv).(map[uint64]int64), e) -} -func (fastpathT) EncMapUint64Int64V(v map[uint64]int64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeInt(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64Float32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Float32V(rv2i(rv).(map[uint64]float32), e) -} -func (fastpathT) EncMapUint64Float32V(v map[uint64]float32, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat32(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat32(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64Float64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64Float64V(rv2i(rv).(map[uint64]float64), e) -} -func (fastpathT) EncMapUint64Float64V(v map[uint64]float64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat64(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeFloat64(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapUint64BoolV(rv2i(rv).(map[uint64]bool), e) -} -func (fastpathT) EncMapUint64BoolV(v map[uint64]bool, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]uint64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(uint64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeBool(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeUint(k2) - e.mapElemValue() - e.e.EncodeBool(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntIntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntIntfV(rv2i(rv).(map[int]interface{}), e) -} -func (fastpathT) EncMapIntIntfV(v map[int]interface{}, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.encode(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.encode(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntStringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntStringV(rv2i(rv).(map[int]string), e) -} -func (fastpathT) EncMapIntStringV(v map[int]string, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeString(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeString(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntBytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntBytesV(rv2i(rv).(map[int][]byte), e) -} -func (fastpathT) EncMapIntBytesV(v map[int][]byte, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntUintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntUintV(rv2i(rv).(map[int]uint), e) -} -func (fastpathT) EncMapIntUintV(v map[int]uint, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[int(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntUint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntUint8V(rv2i(rv).(map[int]uint8), e) -} -func (fastpathT) EncMapIntUint8V(v map[int]uint8, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeUint(uint64(v[int(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntUint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntUint64V(rv2i(rv).(map[int]uint64), e) -} -func (fastpathT) EncMapIntUint64V(v map[int]uint64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeUint(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeUint(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntIntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntIntV(rv2i(rv).(map[int]int), e) -} -func (fastpathT) EncMapIntIntV(v map[int]int, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeInt(int64(v[int(k2)])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntInt64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntInt64V(rv2i(rv).(map[int]int64), e) -} -func (fastpathT) EncMapIntInt64V(v map[int]int64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeInt(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeInt(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntFloat32V(rv2i(rv).(map[int]float32), e) -} -func (fastpathT) EncMapIntFloat32V(v map[int]float32, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeFloat32(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeFloat32(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntFloat64V(rv2i(rv).(map[int]float64), e) -} -func (fastpathT) EncMapIntFloat64V(v map[int]float64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeFloat64(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeFloat64(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapIntBoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapIntBoolV(rv2i(rv).(map[int]bool), e) -} -func (fastpathT) EncMapIntBoolV(v map[int]bool, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = int64(k) - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(int64(int(k2))) - e.mapElemValue() - e.e.EncodeBool(v[int(k2)]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(int64(k2)) - e.mapElemValue() - e.e.EncodeBool(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64IntfV(rv2i(rv).(map[int64]interface{}), e) -} -func (fastpathT) EncMapInt64IntfV(v map[int64]interface{}, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.encode(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.encode(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64StringR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64StringV(rv2i(rv).(map[int64]string), e) -} -func (fastpathT) EncMapInt64StringV(v map[int64]string, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeString(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeString(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64BytesR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64BytesV(rv2i(rv).(map[int64][]byte), e) -} -func (fastpathT) EncMapInt64BytesV(v map[int64][]byte, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeStringBytesRaw(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64UintR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64UintV(rv2i(rv).(map[int64]uint), e) -} -func (fastpathT) EncMapInt64UintV(v map[int64]uint, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Uint8V(rv2i(rv).(map[int64]uint8), e) -} -func (fastpathT) EncMapInt64Uint8V(v map[int64]uint8, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(uint64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Uint64V(rv2i(rv).(map[int64]uint64), e) -} -func (fastpathT) EncMapInt64Uint64V(v map[int64]uint64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeUint(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64IntR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64IntV(rv2i(rv).(map[int64]int), e) -} -func (fastpathT) EncMapInt64IntV(v map[int64]int, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v[k2])) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(int64(v2)) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Int64V(rv2i(rv).(map[int64]int64), e) -} -func (fastpathT) EncMapInt64Int64V(v map[int64]int64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeInt(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64Float32R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Float32V(rv2i(rv).(map[int64]float32), e) -} -func (fastpathT) EncMapInt64Float32V(v map[int64]float32, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat32(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat32(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64Float64R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64Float64V(rv2i(rv).(map[int64]float64), e) -} -func (fastpathT) EncMapInt64Float64V(v map[int64]float64, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat64(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeFloat64(v2) - } - } - e.mapEnd() -} -func (e *Encoder) fastpathEncMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { - fastpathTV.EncMapInt64BoolV(rv2i(rv).(map[int64]bool), e) -} -func (fastpathT) EncMapInt64BoolV(v map[int64]bool, e *Encoder) { - e.mapStart(len(v)) - if e.h.Canonical { - v2 := make([]int64, len(v)) - var i uint - for k := range v { - v2[i] = k - i++ - } - sort.Sort(int64Slice(v2)) - for _, k2 := range v2 { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeBool(v[k2]) - } - } else { - for k2, v2 := range v { - e.mapElemKey() - e.e.EncodeInt(k2) - e.mapElemValue() - e.e.EncodeBool(v2) - } - } - e.mapEnd() -} - -// -- decode - -// -- -- fast path type switch -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { - var changed bool - var containerLen int - switch v := iv.(type) { - case []interface{}: - fastpathTV.DecSliceIntfN(v, d) - case *[]interface{}: - var v2 []interface{} - if v2, changed = fastpathTV.DecSliceIntfY(*v, d); changed { - *v = v2 - } - case []string: - fastpathTV.DecSliceStringN(v, d) - case *[]string: - var v2 []string - if v2, changed = fastpathTV.DecSliceStringY(*v, d); changed { - *v = v2 - } - case [][]byte: - fastpathTV.DecSliceBytesN(v, d) - case *[][]byte: - var v2 [][]byte - if v2, changed = fastpathTV.DecSliceBytesY(*v, d); changed { - *v = v2 - } - case []float32: - fastpathTV.DecSliceFloat32N(v, d) - case *[]float32: - var v2 []float32 - if v2, changed = fastpathTV.DecSliceFloat32Y(*v, d); changed { - *v = v2 - } - case []float64: - fastpathTV.DecSliceFloat64N(v, d) - case *[]float64: - var v2 []float64 - if v2, changed = fastpathTV.DecSliceFloat64Y(*v, d); changed { - *v = v2 - } - case []uint: - fastpathTV.DecSliceUintN(v, d) - case *[]uint: - var v2 []uint - if v2, changed = fastpathTV.DecSliceUintY(*v, d); changed { - *v = v2 - } - case []uint16: - fastpathTV.DecSliceUint16N(v, d) - case *[]uint16: - var v2 []uint16 - if v2, changed = fastpathTV.DecSliceUint16Y(*v, d); changed { - *v = v2 - } - case []uint32: - fastpathTV.DecSliceUint32N(v, d) - case *[]uint32: - var v2 []uint32 - if v2, changed = fastpathTV.DecSliceUint32Y(*v, d); changed { - *v = v2 - } - case []uint64: - fastpathTV.DecSliceUint64N(v, d) - case *[]uint64: - var v2 []uint64 - if v2, changed = fastpathTV.DecSliceUint64Y(*v, d); changed { - *v = v2 - } - case []int: - fastpathTV.DecSliceIntN(v, d) - case *[]int: - var v2 []int - if v2, changed = fastpathTV.DecSliceIntY(*v, d); changed { - *v = v2 - } - case []int8: - fastpathTV.DecSliceInt8N(v, d) - case *[]int8: - var v2 []int8 - if v2, changed = fastpathTV.DecSliceInt8Y(*v, d); changed { - *v = v2 - } - case []int16: - fastpathTV.DecSliceInt16N(v, d) - case *[]int16: - var v2 []int16 - if v2, changed = fastpathTV.DecSliceInt16Y(*v, d); changed { - *v = v2 - } - case []int32: - fastpathTV.DecSliceInt32N(v, d) - case *[]int32: - var v2 []int32 - if v2, changed = fastpathTV.DecSliceInt32Y(*v, d); changed { - *v = v2 - } - case []int64: - fastpathTV.DecSliceInt64N(v, d) - case *[]int64: - var v2 []int64 - if v2, changed = fastpathTV.DecSliceInt64Y(*v, d); changed { - *v = v2 - } - case []bool: - fastpathTV.DecSliceBoolN(v, d) - case *[]bool: - var v2 []bool - if v2, changed = fastpathTV.DecSliceBoolY(*v, d); changed { - *v = v2 - } - case map[string]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringIntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]interface{}: - fastpathTV.DecMapStringIntfX(v, d) - case map[string]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringStringL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]string: - fastpathTV.DecMapStringStringX(v, d) - case map[string][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringBytesL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string][]byte: - fastpathTV.DecMapStringBytesX(v, d) - case map[string]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringUintL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]uint: - fastpathTV.DecMapStringUintX(v, d) - case map[string]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringUint8L(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]uint8: - fastpathTV.DecMapStringUint8X(v, d) - case map[string]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringUint64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]uint64: - fastpathTV.DecMapStringUint64X(v, d) - case map[string]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringIntL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]int: - fastpathTV.DecMapStringIntX(v, d) - case map[string]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringInt64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]int64: - fastpathTV.DecMapStringInt64X(v, d) - case map[string]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringFloat32L(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]float32: - fastpathTV.DecMapStringFloat32X(v, d) - case map[string]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringFloat64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]float64: - fastpathTV.DecMapStringFloat64X(v, d) - case map[string]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapStringBoolL(v, containerLen, d) - } - d.mapEnd() - } - case *map[string]bool: - fastpathTV.DecMapStringBoolX(v, d) - case map[uint]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintIntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]interface{}: - fastpathTV.DecMapUintIntfX(v, d) - case map[uint]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintStringL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]string: - fastpathTV.DecMapUintStringX(v, d) - case map[uint][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintBytesL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint][]byte: - fastpathTV.DecMapUintBytesX(v, d) - case map[uint]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintUintL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]uint: - fastpathTV.DecMapUintUintX(v, d) - case map[uint]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintUint8L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]uint8: - fastpathTV.DecMapUintUint8X(v, d) - case map[uint]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintUint64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]uint64: - fastpathTV.DecMapUintUint64X(v, d) - case map[uint]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintIntL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]int: - fastpathTV.DecMapUintIntX(v, d) - case map[uint]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintInt64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]int64: - fastpathTV.DecMapUintInt64X(v, d) - case map[uint]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintFloat32L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]float32: - fastpathTV.DecMapUintFloat32X(v, d) - case map[uint]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintFloat64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]float64: - fastpathTV.DecMapUintFloat64X(v, d) - case map[uint]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUintBoolL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint]bool: - fastpathTV.DecMapUintBoolX(v, d) - case map[uint8]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8IntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]interface{}: - fastpathTV.DecMapUint8IntfX(v, d) - case map[uint8]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8StringL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]string: - fastpathTV.DecMapUint8StringX(v, d) - case map[uint8][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8BytesL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8][]byte: - fastpathTV.DecMapUint8BytesX(v, d) - case map[uint8]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8UintL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]uint: - fastpathTV.DecMapUint8UintX(v, d) - case map[uint8]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Uint8L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]uint8: - fastpathTV.DecMapUint8Uint8X(v, d) - case map[uint8]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Uint64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]uint64: - fastpathTV.DecMapUint8Uint64X(v, d) - case map[uint8]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8IntL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]int: - fastpathTV.DecMapUint8IntX(v, d) - case map[uint8]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Int64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]int64: - fastpathTV.DecMapUint8Int64X(v, d) - case map[uint8]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Float32L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]float32: - fastpathTV.DecMapUint8Float32X(v, d) - case map[uint8]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8Float64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]float64: - fastpathTV.DecMapUint8Float64X(v, d) - case map[uint8]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint8BoolL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint8]bool: - fastpathTV.DecMapUint8BoolX(v, d) - case map[uint64]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64IntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]interface{}: - fastpathTV.DecMapUint64IntfX(v, d) - case map[uint64]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64StringL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]string: - fastpathTV.DecMapUint64StringX(v, d) - case map[uint64][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64BytesL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64][]byte: - fastpathTV.DecMapUint64BytesX(v, d) - case map[uint64]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64UintL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]uint: - fastpathTV.DecMapUint64UintX(v, d) - case map[uint64]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Uint8L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]uint8: - fastpathTV.DecMapUint64Uint8X(v, d) - case map[uint64]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Uint64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]uint64: - fastpathTV.DecMapUint64Uint64X(v, d) - case map[uint64]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64IntL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]int: - fastpathTV.DecMapUint64IntX(v, d) - case map[uint64]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Int64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]int64: - fastpathTV.DecMapUint64Int64X(v, d) - case map[uint64]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Float32L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]float32: - fastpathTV.DecMapUint64Float32X(v, d) - case map[uint64]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64Float64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]float64: - fastpathTV.DecMapUint64Float64X(v, d) - case map[uint64]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapUint64BoolL(v, containerLen, d) - } - d.mapEnd() - } - case *map[uint64]bool: - fastpathTV.DecMapUint64BoolX(v, d) - case map[int]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntIntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]interface{}: - fastpathTV.DecMapIntIntfX(v, d) - case map[int]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntStringL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]string: - fastpathTV.DecMapIntStringX(v, d) - case map[int][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntBytesL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int][]byte: - fastpathTV.DecMapIntBytesX(v, d) - case map[int]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntUintL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]uint: - fastpathTV.DecMapIntUintX(v, d) - case map[int]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntUint8L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]uint8: - fastpathTV.DecMapIntUint8X(v, d) - case map[int]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntUint64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]uint64: - fastpathTV.DecMapIntUint64X(v, d) - case map[int]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntIntL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]int: - fastpathTV.DecMapIntIntX(v, d) - case map[int]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntInt64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]int64: - fastpathTV.DecMapIntInt64X(v, d) - case map[int]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntFloat32L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]float32: - fastpathTV.DecMapIntFloat32X(v, d) - case map[int]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntFloat64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]float64: - fastpathTV.DecMapIntFloat64X(v, d) - case map[int]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapIntBoolL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int]bool: - fastpathTV.DecMapIntBoolX(v, d) - case map[int64]interface{}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64IntfL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]interface{}: - fastpathTV.DecMapInt64IntfX(v, d) - case map[int64]string: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64StringL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]string: - fastpathTV.DecMapInt64StringX(v, d) - case map[int64][]byte: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64BytesL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64][]byte: - fastpathTV.DecMapInt64BytesX(v, d) - case map[int64]uint: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64UintL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]uint: - fastpathTV.DecMapInt64UintX(v, d) - case map[int64]uint8: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Uint8L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]uint8: - fastpathTV.DecMapInt64Uint8X(v, d) - case map[int64]uint64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Uint64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]uint64: - fastpathTV.DecMapInt64Uint64X(v, d) - case map[int64]int: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64IntL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]int: - fastpathTV.DecMapInt64IntX(v, d) - case map[int64]int64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Int64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]int64: - fastpathTV.DecMapInt64Int64X(v, d) - case map[int64]float32: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Float32L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]float32: - fastpathTV.DecMapInt64Float32X(v, d) - case map[int64]float64: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64Float64L(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]float64: - fastpathTV.DecMapInt64Float64X(v, d) - case map[int64]bool: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.DecMapInt64BoolL(v, containerLen, d) - } - d.mapEnd() - } - case *map[int64]bool: - fastpathTV.DecMapInt64BoolX(v, d) - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false - } - return true -} - -func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { - switch v := iv.(type) { - case *[]interface{}: - *v = nil - case *[]string: - *v = nil - case *[][]byte: - *v = nil - case *[]float32: - *v = nil - case *[]float64: - *v = nil - case *[]uint: - *v = nil - case *[]uint16: - *v = nil - case *[]uint32: - *v = nil - case *[]uint64: - *v = nil - case *[]int: - *v = nil - case *[]int8: - *v = nil - case *[]int16: - *v = nil - case *[]int32: - *v = nil - case *[]int64: - *v = nil - case *[]bool: - *v = nil - - case *map[string]interface{}: - *v = nil - case *map[string]string: - *v = nil - case *map[string][]byte: - *v = nil - case *map[string]uint: - *v = nil - case *map[string]uint8: - *v = nil - case *map[string]uint64: - *v = nil - case *map[string]int: - *v = nil - case *map[string]int64: - *v = nil - case *map[string]float32: - *v = nil - case *map[string]float64: - *v = nil - case *map[string]bool: - *v = nil - case *map[uint]interface{}: - *v = nil - case *map[uint]string: - *v = nil - case *map[uint][]byte: - *v = nil - case *map[uint]uint: - *v = nil - case *map[uint]uint8: - *v = nil - case *map[uint]uint64: - *v = nil - case *map[uint]int: - *v = nil - case *map[uint]int64: - *v = nil - case *map[uint]float32: - *v = nil - case *map[uint]float64: - *v = nil - case *map[uint]bool: - *v = nil - case *map[uint8]interface{}: - *v = nil - case *map[uint8]string: - *v = nil - case *map[uint8][]byte: - *v = nil - case *map[uint8]uint: - *v = nil - case *map[uint8]uint8: - *v = nil - case *map[uint8]uint64: - *v = nil - case *map[uint8]int: - *v = nil - case *map[uint8]int64: - *v = nil - case *map[uint8]float32: - *v = nil - case *map[uint8]float64: - *v = nil - case *map[uint8]bool: - *v = nil - case *map[uint64]interface{}: - *v = nil - case *map[uint64]string: - *v = nil - case *map[uint64][]byte: - *v = nil - case *map[uint64]uint: - *v = nil - case *map[uint64]uint8: - *v = nil - case *map[uint64]uint64: - *v = nil - case *map[uint64]int: - *v = nil - case *map[uint64]int64: - *v = nil - case *map[uint64]float32: - *v = nil - case *map[uint64]float64: - *v = nil - case *map[uint64]bool: - *v = nil - case *map[int]interface{}: - *v = nil - case *map[int]string: - *v = nil - case *map[int][]byte: - *v = nil - case *map[int]uint: - *v = nil - case *map[int]uint8: - *v = nil - case *map[int]uint64: - *v = nil - case *map[int]int: - *v = nil - case *map[int]int64: - *v = nil - case *map[int]float32: - *v = nil - case *map[int]float64: - *v = nil - case *map[int]bool: - *v = nil - case *map[int64]interface{}: - *v = nil - case *map[int64]string: - *v = nil - case *map[int64][]byte: - *v = nil - case *map[int64]uint: - *v = nil - case *map[int64]uint8: - *v = nil - case *map[int64]uint64: - *v = nil - case *map[int64]int: - *v = nil - case *map[int64]int64: - *v = nil - case *map[int64]float32: - *v = nil - case *map[int64]float64: - *v = nil - case *map[int64]bool: - *v = nil - - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false - } - return true -} - -// -- -- fast path functions - -func (d *Decoder) fastpathDecSliceIntfR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]interface{}) - if v, changed := fastpathTV.DecSliceIntfY(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceIntfN(rv2i(rv).([]interface{}), d) - } -} -func (f fastpathT) DecSliceIntfX(vp *[]interface{}, d *Decoder) { - if v, changed := f.DecSliceIntfY(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceIntfY(v []interface{}, d *Decoder) (_ []interface{}, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []interface{}{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]interface{}, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) - } else { - xlen = 8 - } - v = make([]interface{}, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, nil) - changed = true - } - slh.ElemContainerState(j) - d.decode(&v[uint(j)]) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []interface{}{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceIntfN(v []interface{}, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - d.decode(&v[uint(j)]) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceStringR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]string) - if v, changed := fastpathTV.DecSliceStringY(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceStringN(rv2i(rv).([]string), d) - } -} -func (f fastpathT) DecSliceStringX(vp *[]string, d *Decoder) { - if v, changed := f.DecSliceStringY(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceStringY(v []string, d *Decoder) (_ []string, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []string{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]string, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 16) - } else { - xlen = 8 - } - v = make([]string, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, "") - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = string(d.d.DecodeStringAsBytes()) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []string{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceStringN(v []string, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = string(d.d.DecodeStringAsBytes()) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceBytesR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[][]byte) - if v, changed := fastpathTV.DecSliceBytesY(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceBytesN(rv2i(rv).([][]byte), d) - } -} -func (f fastpathT) DecSliceBytesX(vp *[][]byte, d *Decoder) { - if v, changed := f.DecSliceBytesY(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceBytesY(v [][]byte, d *Decoder) (_ [][]byte, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = [][]byte{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([][]byte, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 24) - } else { - xlen = 8 - } - v = make([][]byte, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, nil) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBytes(nil, false) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = [][]byte{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceBytesN(v [][]byte, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBytes(nil, false) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceFloat32R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]float32) - if v, changed := fastpathTV.DecSliceFloat32Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceFloat32N(rv2i(rv).([]float32), d) - } -} -func (f fastpathT) DecSliceFloat32X(vp *[]float32, d *Decoder) { - if v, changed := f.DecSliceFloat32Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceFloat32Y(v []float32, d *Decoder) (_ []float32, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []float32{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]float32, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - } else { - xlen = 8 - } - v = make([]float32, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = float32(d.decodeFloat32()) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []float32{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceFloat32N(v []float32, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = float32(d.decodeFloat32()) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceFloat64R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]float64) - if v, changed := fastpathTV.DecSliceFloat64Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceFloat64N(rv2i(rv).([]float64), d) - } -} -func (f fastpathT) DecSliceFloat64X(vp *[]float64, d *Decoder) { - if v, changed := f.DecSliceFloat64Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceFloat64Y(v []float64, d *Decoder) (_ []float64, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []float64{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]float64, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]float64, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeFloat64() - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []float64{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceFloat64N(v []float64, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeFloat64() - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceUintR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint) - if v, changed := fastpathTV.DecSliceUintY(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceUintN(rv2i(rv).([]uint), d) - } -} -func (f fastpathT) DecSliceUintX(vp *[]uint, d *Decoder) { - if v, changed := f.DecSliceUintY(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceUintY(v []uint, d *Decoder) (_ []uint, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []uint{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]uint, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]uint, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceUintN(v []uint, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceUint16R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint16) - if v, changed := fastpathTV.DecSliceUint16Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceUint16N(rv2i(rv).([]uint16), d) - } -} -func (f fastpathT) DecSliceUint16X(vp *[]uint16, d *Decoder) { - if v, changed := f.DecSliceUint16Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceUint16Y(v []uint16, d *Decoder) (_ []uint16, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []uint16{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]uint16, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - } else { - xlen = 8 - } - v = make([]uint16, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint16{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceUint16N(v []uint16, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = uint16(chkOvf.UintV(d.d.DecodeUint64(), 16)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceUint32R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint32) - if v, changed := fastpathTV.DecSliceUint32Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceUint32N(rv2i(rv).([]uint32), d) - } -} -func (f fastpathT) DecSliceUint32X(vp *[]uint32, d *Decoder) { - if v, changed := f.DecSliceUint32Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceUint32Y(v []uint32, d *Decoder) (_ []uint32, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []uint32{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]uint32, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - } else { - xlen = 8 - } - v = make([]uint32, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint32{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceUint32N(v []uint32, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = uint32(chkOvf.UintV(d.d.DecodeUint64(), 32)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceUint64R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]uint64) - if v, changed := fastpathTV.DecSliceUint64Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceUint64N(rv2i(rv).([]uint64), d) - } -} -func (f fastpathT) DecSliceUint64X(vp *[]uint64, d *Decoder) { - if v, changed := f.DecSliceUint64Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceUint64Y(v []uint64, d *Decoder) (_ []uint64, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []uint64{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]uint64, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]uint64, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeUint64() - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []uint64{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceUint64N(v []uint64, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeUint64() - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceIntR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int) - if v, changed := fastpathTV.DecSliceIntY(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceIntN(rv2i(rv).([]int), d) - } -} -func (f fastpathT) DecSliceIntX(vp *[]int, d *Decoder) { - if v, changed := f.DecSliceIntY(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceIntY(v []int, d *Decoder) (_ []int, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []int{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]int, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]int, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceIntN(v []int, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceInt8R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int8) - if v, changed := fastpathTV.DecSliceInt8Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceInt8N(rv2i(rv).([]int8), d) - } -} -func (f fastpathT) DecSliceInt8X(vp *[]int8, d *Decoder) { - if v, changed := f.DecSliceInt8Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceInt8Y(v []int8, d *Decoder) (_ []int8, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []int8{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]int8, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - } else { - xlen = 8 - } - v = make([]int8, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int8{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceInt8N(v []int8, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = int8(chkOvf.IntV(d.d.DecodeInt64(), 8)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceInt16R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int16) - if v, changed := fastpathTV.DecSliceInt16Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceInt16N(rv2i(rv).([]int16), d) - } -} -func (f fastpathT) DecSliceInt16X(vp *[]int16, d *Decoder) { - if v, changed := f.DecSliceInt16Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceInt16Y(v []int16, d *Decoder) (_ []int16, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []int16{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]int16, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 2) - } else { - xlen = 8 - } - v = make([]int16, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int16{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceInt16N(v []int16, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = int16(chkOvf.IntV(d.d.DecodeInt64(), 16)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceInt32R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int32) - if v, changed := fastpathTV.DecSliceInt32Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceInt32N(rv2i(rv).([]int32), d) - } -} -func (f fastpathT) DecSliceInt32X(vp *[]int32, d *Decoder) { - if v, changed := f.DecSliceInt32Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceInt32Y(v []int32, d *Decoder) (_ []int32, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []int32{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]int32, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 4) - } else { - xlen = 8 - } - v = make([]int32, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int32{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceInt32N(v []int32, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = int32(chkOvf.IntV(d.d.DecodeInt64(), 32)) - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceInt64R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]int64) - if v, changed := fastpathTV.DecSliceInt64Y(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceInt64N(rv2i(rv).([]int64), d) - } -} -func (f fastpathT) DecSliceInt64X(vp *[]int64, d *Decoder) { - if v, changed := f.DecSliceInt64Y(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceInt64Y(v []int64, d *Decoder) (_ []int64, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []int64{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]int64, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 8) - } else { - xlen = 8 - } - v = make([]int64, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, 0) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeInt64() - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []int64{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceInt64N(v []int64, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeInt64() - } - slh.End() -} - -func (d *Decoder) fastpathDecSliceBoolR(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]bool) - if v, changed := fastpathTV.DecSliceBoolY(*vp, d); changed { - *vp = v - } - } else { - fastpathTV.DecSliceBoolN(rv2i(rv).([]bool), d) - } -} -func (f fastpathT) DecSliceBoolX(vp *[]bool, d *Decoder) { - if v, changed := f.DecSliceBoolY(*vp, d); changed { - *vp = v - } -} -func (fastpathT) DecSliceBoolY(v []bool, d *Decoder) (_ []bool, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { - return - } - return nil, true - } - if containerLenS == 0 { - if v == nil { - v = []bool{} - } else if len(v) != 0 { - v = v[:0] - } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]bool, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, 1) - } else { - xlen = 8 - } - v = make([]bool, uint(xlen)) - changed = true - } - if j >= len(v) { - v = append(v, false) - changed = true - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBool() - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []bool{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) DecSliceBoolN(v []bool, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - v[uint(j)] = d.d.DecodeBool() - } - slh.End() -} -func (d *Decoder) fastpathDecMapStringIntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]interface{})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]interface{}) - if *vp == nil { - *vp = make(map[string]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapStringIntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringIntfL(rv2i(rv).(map[string]interface{}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringIntfX(vp *map[string]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapStringIntfL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringIntfL(v map[string]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk string - var mv interface{} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - d.decode(&mv) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringStringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]string) - if *vp == nil { - *vp = make(map[string]string, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapStringStringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringStringL(rv2i(rv).(map[string]string), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringStringX(vp *map[string]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]string, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapStringStringL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringStringL(v map[string]string, containerLen int, d *Decoder) { - var mk string - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringBytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string][]byte) - if *vp == nil { - *vp = make(map[string][]byte, decInferLen(containerLen, d.h.MaxInitLen, 40)) - } - if containerLen != 0 { - fastpathTV.DecMapStringBytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringBytesL(rv2i(rv).(map[string][]byte), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringBytesX(vp *map[string][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string][]byte, decInferLen(containerLen, d.h.MaxInitLen, 40)) - } - if containerLen != 0 { - f.DecMapStringBytesL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringBytesL(v map[string][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk string - var mv []byte - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - mv = d.d.DecodeBytes(mv, false) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringUintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]uint)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]uint) - if *vp == nil { - *vp = make(map[string]uint, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringUintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringUintL(rv2i(rv).(map[string]uint), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringUintX(vp *map[string]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]uint, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringUintL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringUintL(v map[string]uint, containerLen int, d *Decoder) { - var mk string - var mv uint - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringUint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]uint8)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]uint8) - if *vp == nil { - *vp = make(map[string]uint8, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapStringUint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringUint8L(rv2i(rv).(map[string]uint8), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringUint8X(vp *map[string]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]uint8, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapStringUint8L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringUint8L(v map[string]uint8, containerLen int, d *Decoder) { - var mk string - var mv uint8 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringUint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]uint64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]uint64) - if *vp == nil { - *vp = make(map[string]uint64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringUint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringUint64L(rv2i(rv).(map[string]uint64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringUint64X(vp *map[string]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]uint64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringUint64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringUint64L(v map[string]uint64, containerLen int, d *Decoder) { - var mk string - var mv uint64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeUint64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringIntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]int)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]int) - if *vp == nil { - *vp = make(map[string]int, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringIntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringIntL(rv2i(rv).(map[string]int), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringIntX(vp *map[string]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]int, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringIntL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringIntL(v map[string]int, containerLen int, d *Decoder) { - var mk string - var mv int - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringInt64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]int64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]int64) - if *vp == nil { - *vp = make(map[string]int64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringInt64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringInt64L(rv2i(rv).(map[string]int64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringInt64X(vp *map[string]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]int64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringInt64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringInt64L(v map[string]int64, containerLen int, d *Decoder) { - var mk string - var mv int64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeInt64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringFloat32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]float32)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]float32) - if *vp == nil { - *vp = make(map[string]float32, decInferLen(containerLen, d.h.MaxInitLen, 20)) - } - if containerLen != 0 { - fastpathTV.DecMapStringFloat32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringFloat32L(rv2i(rv).(map[string]float32), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringFloat32X(vp *map[string]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]float32, decInferLen(containerLen, d.h.MaxInitLen, 20)) - } - if containerLen != 0 { - f.DecMapStringFloat32L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringFloat32L(v map[string]float32, containerLen int, d *Decoder) { - var mk string - var mv float32 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = float32(d.decodeFloat32()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringFloat64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]float64) - if *vp == nil { - *vp = make(map[string]float64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapStringFloat64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringFloat64L(rv2i(rv).(map[string]float64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringFloat64X(vp *map[string]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]float64, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapStringFloat64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringFloat64L(v map[string]float64, containerLen int, d *Decoder) { - var mk string - var mv float64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeFloat64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapStringBoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[string]bool)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[string]bool) - if *vp == nil { - *vp = make(map[string]bool, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapStringBoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapStringBoolL(rv2i(rv).(map[string]bool), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapStringBoolX(vp *map[string]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[string]bool, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapStringBoolL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapStringBoolL(v map[string]bool, containerLen int, d *Decoder) { - var mk string - var mv bool - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = string(d.d.DecodeStringAsBytes()) - d.mapElemValue() - mv = d.d.DecodeBool() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintIntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]interface{})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]interface{}) - if *vp == nil { - *vp = make(map[uint]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUintIntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintIntfL(rv2i(rv).(map[uint]interface{}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintIntfX(vp *map[uint]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUintIntfL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintIntfL(v map[uint]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk uint - var mv interface{} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - d.decode(&mv) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintStringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]string) - if *vp == nil { - *vp = make(map[uint]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUintStringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintStringL(rv2i(rv).(map[uint]string), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintStringX(vp *map[uint]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUintStringL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintStringL(v map[uint]string, containerLen int, d *Decoder) { - var mk uint - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintBytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint][]byte) - if *vp == nil { - *vp = make(map[uint][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapUintBytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintBytesL(rv2i(rv).(map[uint][]byte), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintBytesX(vp *map[uint][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapUintBytesL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintBytesL(v map[uint][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk uint - var mv []byte - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - mv = d.d.DecodeBytes(mv, false) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintUintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]uint)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]uint) - if *vp == nil { - *vp = make(map[uint]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintUintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintUintL(rv2i(rv).(map[uint]uint), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintUintX(vp *map[uint]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintUintL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintUintL(v map[uint]uint, containerLen int, d *Decoder) { - var mk uint - var mv uint - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintUint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]uint8)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]uint8) - if *vp == nil { - *vp = make(map[uint]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUintUint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintUint8L(rv2i(rv).(map[uint]uint8), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintUint8X(vp *map[uint]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUintUint8L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintUint8L(v map[uint]uint8, containerLen int, d *Decoder) { - var mk uint - var mv uint8 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintUint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]uint64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]uint64) - if *vp == nil { - *vp = make(map[uint]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintUint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintUint64L(rv2i(rv).(map[uint]uint64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintUint64X(vp *map[uint]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintUint64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintUint64L(v map[uint]uint64, containerLen int, d *Decoder) { - var mk uint - var mv uint64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeUint64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintIntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]int)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]int) - if *vp == nil { - *vp = make(map[uint]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintIntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintIntL(rv2i(rv).(map[uint]int), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintIntX(vp *map[uint]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintIntL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintIntL(v map[uint]int, containerLen int, d *Decoder) { - var mk uint - var mv int - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintInt64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]int64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]int64) - if *vp == nil { - *vp = make(map[uint]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintInt64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintInt64L(rv2i(rv).(map[uint]int64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintInt64X(vp *map[uint]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintInt64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintInt64L(v map[uint]int64, containerLen int, d *Decoder) { - var mk uint - var mv int64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeInt64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintFloat32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]float32)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]float32) - if *vp == nil { - *vp = make(map[uint]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapUintFloat32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintFloat32L(rv2i(rv).(map[uint]float32), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintFloat32X(vp *map[uint]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapUintFloat32L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintFloat32L(v map[uint]float32, containerLen int, d *Decoder) { - var mk uint - var mv float32 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = float32(d.decodeFloat32()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintFloat64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]float64) - if *vp == nil { - *vp = make(map[uint]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUintFloat64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintFloat64L(rv2i(rv).(map[uint]float64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintFloat64X(vp *map[uint]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUintFloat64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintFloat64L(v map[uint]float64, containerLen int, d *Decoder) { - var mk uint - var mv float64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeFloat64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUintBoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint]bool)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint]bool) - if *vp == nil { - *vp = make(map[uint]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUintBoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUintBoolL(rv2i(rv).(map[uint]bool), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUintBoolX(vp *map[uint]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUintBoolL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUintBoolL(v map[uint]bool, containerLen int, d *Decoder) { - var mk uint - var mv bool - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - d.mapElemValue() - mv = d.d.DecodeBool() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8IntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]interface{})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]interface{}) - if *vp == nil { - *vp = make(map[uint8]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8IntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8IntfL(rv2i(rv).(map[uint8]interface{}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8IntfX(vp *map[uint8]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapUint8IntfL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8IntfL(v map[uint8]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk uint8 - var mv interface{} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - d.decode(&mv) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8StringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]string) - if *vp == nil { - *vp = make(map[uint8]string, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8StringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8StringL(rv2i(rv).(map[uint8]string), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8StringX(vp *map[uint8]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]string, decInferLen(containerLen, d.h.MaxInitLen, 17)) - } - if containerLen != 0 { - f.DecMapUint8StringL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8StringL(v map[uint8]string, containerLen int, d *Decoder) { - var mk uint8 - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8BytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8][]byte) - if *vp == nil { - *vp = make(map[uint8][]byte, decInferLen(containerLen, d.h.MaxInitLen, 25)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8BytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8BytesL(rv2i(rv).(map[uint8][]byte), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8BytesX(vp *map[uint8][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8][]byte, decInferLen(containerLen, d.h.MaxInitLen, 25)) - } - if containerLen != 0 { - f.DecMapUint8BytesL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8BytesL(v map[uint8][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk uint8 - var mv []byte - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - mv = d.d.DecodeBytes(mv, false) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8UintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]uint)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]uint) - if *vp == nil { - *vp = make(map[uint8]uint, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8UintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8UintL(rv2i(rv).(map[uint8]uint), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8UintX(vp *map[uint8]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]uint, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8UintL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8UintL(v map[uint8]uint, containerLen int, d *Decoder) { - var mk uint8 - var mv uint - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8Uint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]uint8)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]uint8) - if *vp == nil { - *vp = make(map[uint8]uint8, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Uint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Uint8L(rv2i(rv).(map[uint8]uint8), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8Uint8X(vp *map[uint8]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]uint8, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - f.DecMapUint8Uint8L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8Uint8L(v map[uint8]uint8, containerLen int, d *Decoder) { - var mk uint8 - var mv uint8 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8Uint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]uint64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]uint64) - if *vp == nil { - *vp = make(map[uint8]uint64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Uint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Uint64L(rv2i(rv).(map[uint8]uint64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8Uint64X(vp *map[uint8]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]uint64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8Uint64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8Uint64L(v map[uint8]uint64, containerLen int, d *Decoder) { - var mk uint8 - var mv uint64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeUint64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8IntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]int)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]int) - if *vp == nil { - *vp = make(map[uint8]int, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8IntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8IntL(rv2i(rv).(map[uint8]int), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8IntX(vp *map[uint8]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]int, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8IntL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8IntL(v map[uint8]int, containerLen int, d *Decoder) { - var mk uint8 - var mv int - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8Int64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]int64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]int64) - if *vp == nil { - *vp = make(map[uint8]int64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Int64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Int64L(rv2i(rv).(map[uint8]int64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8Int64X(vp *map[uint8]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]int64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8Int64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8Int64L(v map[uint8]int64, containerLen int, d *Decoder) { - var mk uint8 - var mv int64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeInt64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8Float32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]float32)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]float32) - if *vp == nil { - *vp = make(map[uint8]float32, decInferLen(containerLen, d.h.MaxInitLen, 5)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Float32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Float32L(rv2i(rv).(map[uint8]float32), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8Float32X(vp *map[uint8]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]float32, decInferLen(containerLen, d.h.MaxInitLen, 5)) - } - if containerLen != 0 { - f.DecMapUint8Float32L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8Float32L(v map[uint8]float32, containerLen int, d *Decoder) { - var mk uint8 - var mv float32 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = float32(d.decodeFloat32()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8Float64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]float64) - if *vp == nil { - *vp = make(map[uint8]float64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8Float64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8Float64L(rv2i(rv).(map[uint8]float64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8Float64X(vp *map[uint8]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]float64, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint8Float64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8Float64L(v map[uint8]float64, containerLen int, d *Decoder) { - var mk uint8 - var mv float64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeFloat64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint8BoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint8]bool)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint8]bool) - if *vp == nil { - *vp = make(map[uint8]bool, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - fastpathTV.DecMapUint8BoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint8BoolL(rv2i(rv).(map[uint8]bool), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint8BoolX(vp *map[uint8]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint8]bool, decInferLen(containerLen, d.h.MaxInitLen, 2)) - } - if containerLen != 0 { - f.DecMapUint8BoolL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint8BoolL(v map[uint8]bool, containerLen int, d *Decoder) { - var mk uint8 - var mv bool - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - d.mapElemValue() - mv = d.d.DecodeBool() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64IntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]interface{})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]interface{}) - if *vp == nil { - *vp = make(map[uint64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64IntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64IntfL(rv2i(rv).(map[uint64]interface{}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64IntfX(vp *map[uint64]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUint64IntfL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64IntfL(v map[uint64]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk uint64 - var mv interface{} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - d.decode(&mv) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64StringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]string) - if *vp == nil { - *vp = make(map[uint64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64StringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64StringL(rv2i(rv).(map[uint64]string), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64StringX(vp *map[uint64]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapUint64StringL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64StringL(v map[uint64]string, containerLen int, d *Decoder) { - var mk uint64 - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64BytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64][]byte) - if *vp == nil { - *vp = make(map[uint64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64BytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64BytesL(rv2i(rv).(map[uint64][]byte), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64BytesX(vp *map[uint64][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapUint64BytesL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64BytesL(v map[uint64][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk uint64 - var mv []byte - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - mv = d.d.DecodeBytes(mv, false) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64UintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]uint)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]uint) - if *vp == nil { - *vp = make(map[uint64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64UintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64UintL(rv2i(rv).(map[uint64]uint), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64UintX(vp *map[uint64]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64UintL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64UintL(v map[uint64]uint, containerLen int, d *Decoder) { - var mk uint64 - var mv uint - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64Uint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]uint8)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]uint8) - if *vp == nil { - *vp = make(map[uint64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Uint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Uint8L(rv2i(rv).(map[uint64]uint8), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64Uint8X(vp *map[uint64]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint64Uint8L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64Uint8L(v map[uint64]uint8, containerLen int, d *Decoder) { - var mk uint64 - var mv uint8 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64Uint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]uint64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]uint64) - if *vp == nil { - *vp = make(map[uint64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Uint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Uint64L(rv2i(rv).(map[uint64]uint64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64Uint64X(vp *map[uint64]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64Uint64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64Uint64L(v map[uint64]uint64, containerLen int, d *Decoder) { - var mk uint64 - var mv uint64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeUint64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64IntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]int)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]int) - if *vp == nil { - *vp = make(map[uint64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64IntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64IntL(rv2i(rv).(map[uint64]int), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64IntX(vp *map[uint64]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64IntL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64IntL(v map[uint64]int, containerLen int, d *Decoder) { - var mk uint64 - var mv int - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64Int64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]int64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]int64) - if *vp == nil { - *vp = make(map[uint64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Int64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Int64L(rv2i(rv).(map[uint64]int64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64Int64X(vp *map[uint64]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64Int64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64Int64L(v map[uint64]int64, containerLen int, d *Decoder) { - var mk uint64 - var mv int64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeInt64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64Float32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]float32)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]float32) - if *vp == nil { - *vp = make(map[uint64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Float32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Float32L(rv2i(rv).(map[uint64]float32), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64Float32X(vp *map[uint64]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapUint64Float32L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64Float32L(v map[uint64]float32, containerLen int, d *Decoder) { - var mk uint64 - var mv float32 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = float32(d.decodeFloat32()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64Float64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]float64) - if *vp == nil { - *vp = make(map[uint64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64Float64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64Float64L(rv2i(rv).(map[uint64]float64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64Float64X(vp *map[uint64]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapUint64Float64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64Float64L(v map[uint64]float64, containerLen int, d *Decoder) { - var mk uint64 - var mv float64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeFloat64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapUint64BoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[uint64]bool)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[uint64]bool) - if *vp == nil { - *vp = make(map[uint64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapUint64BoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapUint64BoolL(rv2i(rv).(map[uint64]bool), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapUint64BoolX(vp *map[uint64]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[uint64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapUint64BoolL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapUint64BoolL(v map[uint64]bool, containerLen int, d *Decoder) { - var mk uint64 - var mv bool - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeUint64() - d.mapElemValue() - mv = d.d.DecodeBool() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntIntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]interface{})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]interface{}) - if *vp == nil { - *vp = make(map[int]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapIntIntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntIntfL(rv2i(rv).(map[int]interface{}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntIntfX(vp *map[int]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapIntIntfL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntIntfL(v map[int]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk int - var mv interface{} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - d.decode(&mv) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntStringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]string) - if *vp == nil { - *vp = make(map[int]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapIntStringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntStringL(rv2i(rv).(map[int]string), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntStringX(vp *map[int]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapIntStringL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntStringL(v map[int]string, containerLen int, d *Decoder) { - var mk int - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntBytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int][]byte) - if *vp == nil { - *vp = make(map[int][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapIntBytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntBytesL(rv2i(rv).(map[int][]byte), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntBytesX(vp *map[int][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapIntBytesL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntBytesL(v map[int][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk int - var mv []byte - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - mv = d.d.DecodeBytes(mv, false) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntUintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]uint)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]uint) - if *vp == nil { - *vp = make(map[int]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntUintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntUintL(rv2i(rv).(map[int]uint), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntUintX(vp *map[int]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntUintL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntUintL(v map[int]uint, containerLen int, d *Decoder) { - var mk int - var mv uint - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntUint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]uint8)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]uint8) - if *vp == nil { - *vp = make(map[int]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapIntUint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntUint8L(rv2i(rv).(map[int]uint8), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntUint8X(vp *map[int]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapIntUint8L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntUint8L(v map[int]uint8, containerLen int, d *Decoder) { - var mk int - var mv uint8 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntUint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]uint64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]uint64) - if *vp == nil { - *vp = make(map[int]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntUint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntUint64L(rv2i(rv).(map[int]uint64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntUint64X(vp *map[int]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntUint64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntUint64L(v map[int]uint64, containerLen int, d *Decoder) { - var mk int - var mv uint64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeUint64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntIntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]int)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]int) - if *vp == nil { - *vp = make(map[int]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntIntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntIntL(rv2i(rv).(map[int]int), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntIntX(vp *map[int]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntIntL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntIntL(v map[int]int, containerLen int, d *Decoder) { - var mk int - var mv int - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntInt64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]int64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]int64) - if *vp == nil { - *vp = make(map[int]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntInt64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntInt64L(rv2i(rv).(map[int]int64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntInt64X(vp *map[int]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntInt64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntInt64L(v map[int]int64, containerLen int, d *Decoder) { - var mk int - var mv int64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeInt64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntFloat32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]float32)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]float32) - if *vp == nil { - *vp = make(map[int]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapIntFloat32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntFloat32L(rv2i(rv).(map[int]float32), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntFloat32X(vp *map[int]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapIntFloat32L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntFloat32L(v map[int]float32, containerLen int, d *Decoder) { - var mk int - var mv float32 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = float32(d.decodeFloat32()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntFloat64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]float64) - if *vp == nil { - *vp = make(map[int]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapIntFloat64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntFloat64L(rv2i(rv).(map[int]float64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntFloat64X(vp *map[int]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapIntFloat64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntFloat64L(v map[int]float64, containerLen int, d *Decoder) { - var mk int - var mv float64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeFloat64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapIntBoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int]bool)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int]bool) - if *vp == nil { - *vp = make(map[int]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapIntBoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapIntBoolL(rv2i(rv).(map[int]bool), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapIntBoolX(vp *map[int]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapIntBoolL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapIntBoolL(v map[int]bool, containerLen int, d *Decoder) { - var mk int - var mv bool - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - d.mapElemValue() - mv = d.d.DecodeBool() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64IntfR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]interface{})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]interface{}) - if *vp == nil { - *vp = make(map[int64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64IntfL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64IntfL(rv2i(rv).(map[int64]interface{}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64IntfX(vp *map[int64]interface{}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]interface{}, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapInt64IntfL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64IntfL(v map[int64]interface{}, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - var mk int64 - var mv interface{} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - d.decode(&mv) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64StringR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]string)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]string) - if *vp == nil { - *vp = make(map[int64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64StringL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64StringL(rv2i(rv).(map[int64]string), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64StringX(vp *map[int64]string, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]string, decInferLen(containerLen, d.h.MaxInitLen, 24)) - } - if containerLen != 0 { - f.DecMapInt64StringL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64StringL(v map[int64]string, containerLen int, d *Decoder) { - var mk int64 - var mv string - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = string(d.d.DecodeStringAsBytes()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64BytesR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64][]byte)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64][]byte) - if *vp == nil { - *vp = make(map[int64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64BytesL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64BytesL(rv2i(rv).(map[int64][]byte), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64BytesX(vp *map[int64][]byte, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64][]byte, decInferLen(containerLen, d.h.MaxInitLen, 32)) - } - if containerLen != 0 { - f.DecMapInt64BytesL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64BytesL(v map[int64][]byte, containerLen int, d *Decoder) { - mapGet := v != nil && !d.h.MapValueReset - var mk int64 - var mv []byte - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - if mapGet { - mv = v[mk] - } else { - mv = nil - } - mv = d.d.DecodeBytes(mv, false) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64UintR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]uint)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]uint) - if *vp == nil { - *vp = make(map[int64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64UintL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64UintL(rv2i(rv).(map[int64]uint), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64UintX(vp *map[int64]uint, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]uint, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64UintL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64UintL(v map[int64]uint, containerLen int, d *Decoder) { - var mk int64 - var mv uint - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64Uint8R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]uint8)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]uint8) - if *vp == nil { - *vp = make(map[int64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Uint8L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Uint8L(rv2i(rv).(map[int64]uint8), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64Uint8X(vp *map[int64]uint8, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]uint8, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapInt64Uint8L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64Uint8L(v map[int64]uint8, containerLen int, d *Decoder) { - var mk int64 - var mv uint8 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = uint8(chkOvf.UintV(d.d.DecodeUint64(), 8)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64Uint64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]uint64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]uint64) - if *vp == nil { - *vp = make(map[int64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Uint64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Uint64L(rv2i(rv).(map[int64]uint64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64Uint64X(vp *map[int64]uint64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]uint64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64Uint64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64Uint64L(v map[int64]uint64, containerLen int, d *Decoder) { - var mk int64 - var mv uint64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeUint64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64IntR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]int)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]int) - if *vp == nil { - *vp = make(map[int64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64IntL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64IntL(rv2i(rv).(map[int64]int), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64IntX(vp *map[int64]int, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]int, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64IntL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64IntL(v map[int64]int, containerLen int, d *Decoder) { - var mk int64 - var mv int - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize)) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64Int64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]int64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]int64) - if *vp == nil { - *vp = make(map[int64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Int64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Int64L(rv2i(rv).(map[int64]int64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64Int64X(vp *map[int64]int64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]int64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64Int64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64Int64L(v map[int64]int64, containerLen int, d *Decoder) { - var mk int64 - var mv int64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeInt64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64Float32R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]float32)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]float32) - if *vp == nil { - *vp = make(map[int64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Float32L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Float32L(rv2i(rv).(map[int64]float32), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64Float32X(vp *map[int64]float32, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]float32, decInferLen(containerLen, d.h.MaxInitLen, 12)) - } - if containerLen != 0 { - f.DecMapInt64Float32L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64Float32L(v map[int64]float32, containerLen int, d *Decoder) { - var mk int64 - var mv float32 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = float32(d.decodeFloat32()) - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64Float64R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]float64)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]float64) - if *vp == nil { - *vp = make(map[int64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64Float64L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64Float64L(rv2i(rv).(map[int64]float64), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64Float64X(vp *map[int64]float64, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]float64, decInferLen(containerLen, d.h.MaxInitLen, 16)) - } - if containerLen != 0 { - f.DecMapInt64Float64L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64Float64L(v map[int64]float64, containerLen int, d *Decoder) { - var mk int64 - var mv float64 - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeFloat64() - if v != nil { - v[mk] = mv - } - } -} -func (d *Decoder) fastpathDecMapInt64BoolR(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[int64]bool)) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[int64]bool) - if *vp == nil { - *vp = make(map[int64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - fastpathTV.DecMapInt64BoolL(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.DecMapInt64BoolL(rv2i(rv).(map[int64]bool), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) DecMapInt64BoolX(vp *map[int64]bool, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[int64]bool, decInferLen(containerLen, d.h.MaxInitLen, 9)) - } - if containerLen != 0 { - f.DecMapInt64BoolL(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) DecMapInt64BoolL(v map[int64]bool, containerLen int, d *Decoder) { - var mk int64 - var mv bool - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - mk = d.d.DecodeInt64() - d.mapElemValue() - mv = d.d.DecodeBool() - if v != nil { - v[mk] = mv - } - } -} diff --git a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl b/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl deleted file mode 100644 index 6315ad238..000000000 --- a/vendor/github.com/ugorji/go/codec/fast-path.go.tmpl +++ /dev/null @@ -1,491 +0,0 @@ -// +build !notfastpath - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from fast-path.go.tmpl - DO NOT EDIT. - -package codec - -// Fast path functions try to create a fast path encode or decode implementation -// for common maps and slices. -// -// We define the functions and register them in this single file -// so as not to pollute the encode.go and decode.go, and create a dependency in there. -// This file can be omitted without causing a build failure. -// -// The advantage of fast paths is: -// - Many calls bypass reflection altogether -// -// Currently support -// - slice of all builtin types (numeric, bool, string, []byte) -// - maps of builtin types to builtin or interface{} type, EXCEPT FOR -// keys of type uintptr, int8/16/32, uint16/32, float32/64, bool, interface{} -// AND values of type type int8/16/32, uint16/32 -// This should provide adequate "typical" implementations. -// -// Note that fast track decode functions must handle values for which an address cannot be obtained. -// For example: -// m2 := map[string]int{} -// p2 := []interface{}{m2} -// // decoding into p2 will bomb if fast track functions do not treat like unaddressable. -// - -{{/* -fastpathEncMapStringUint64R (called by fastpath...switch) -EncMapStringUint64V (called by codecgen) - -fastpathEncSliceBoolR: (called by fastpath...switch) (checks f.ti.mbs and calls one of them below) -EncSliceBoolV (also called by codecgen) -EncAsMapSliceBoolV (delegate when mapbyslice=true) - -fastpathDecSliceIntfR (called by fastpath...switch) (calls Y or N below depending on if it can be updated) -DecSliceIntfX (called by codecgen) (calls Y below) -DecSliceIntfY (delegate when slice CAN be updated) -DecSliceIntfN (delegate when slice CANNOT be updated e.g. from array or non-addressable slice) - -fastpathDecMap...R (called by fastpath...switch) (calls L or X? below) -DecMap...X (called by codecgen) -DecMap...L (delegated to by both above) -*/ -}} - -import ( - "reflect" - "sort" -) - -const fastpathEnabled = true - -const fastpathMapBySliceErrMsg = "mapBySlice requires even slice length, but got %v" - -type fastpathT struct {} - -var fastpathTV fastpathT - -type fastpathE struct { - rtid uintptr - rt reflect.Type - encfn func(*Encoder, *codecFnInfo, reflect.Value) - decfn func(*Decoder, *codecFnInfo, reflect.Value) -} - -type fastpathA [{{ .FastpathLen }}]fastpathE - -func (x *fastpathA) index(rtid uintptr) int { - // use binary search to grab the index (adapted from sort/search.go) - // Note: we use goto (instead of for loop) so this can be inlined. - // h, i, j := 0, 0, len(x) - var h, i uint - var j = uint(len(x)) -LOOP: - if i < j { - h = i + (j-i)/2 - if x[h].rtid < rtid { - i = h + 1 - } else { - j = h - } - goto LOOP - } - if i < uint(len(x)) && x[i].rtid == rtid { - return int(i) - } - return -1 -} - -type fastpathAslice []fastpathE - -func (x fastpathAslice) Len() int { return len(x) } -func (x fastpathAslice) Less(i, j int) bool { return x[uint(i)].rtid < x[uint(j)].rtid } -func (x fastpathAslice) Swap(i, j int) { x[uint(i)], x[uint(j)] = x[uint(j)], x[uint(i)] } - -var fastpathAV fastpathA - -// due to possible initialization loop error, make fastpath in an init() -func init() { - var i uint = 0 - fn := func(v interface{}, - fe func(*Encoder, *codecFnInfo, reflect.Value), - fd func(*Decoder, *codecFnInfo, reflect.Value)) { - xrt := reflect.TypeOf(v) - xptr := rt2id(xrt) - fastpathAV[i] = fastpathE{xptr, xrt, fe, fd} - i++ - } - {{/* do not register []uint8 in fast-path */}} - {{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}} - fn([]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R) - {{end}}{{end}}{{end}}{{end}} - - {{range .Values}}{{if not .Primitive}}{{if .MapKey -}} - fn(map[{{ .MapKey }}]{{ .Elem }}(nil), (*Encoder).{{ .MethodNamePfx "fastpathEnc" false }}R, (*Decoder).{{ .MethodNamePfx "fastpathDec" false }}R) - {{end}}{{end}}{{end}} - - sort.Sort(fastpathAslice(fastpathAV[:])) -} - -// -- encode - -// -- -- fast path type switch -func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}} - case []{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) - case *[]{{ .Elem }}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) - } -{{end}}{{end}}{{end}}{{end -}} - -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} - case map[{{ .MapKey }}]{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(v, e) - case *map[{{ .MapKey }}]{{ .Elem }}: - if *v == nil { - e.e.EncodeNil() - } else { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(*v, e) - } -{{end}}{{end}}{{end -}} - - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false - } - return true -} - -// -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}} -func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) { - if f.ti.mbs { - fastpathTV.{{ .MethodNamePfx "EncAsMap" false }}V(rv2i(rv).([]{{ .Elem }}), e) - } else { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).([]{{ .Elem }}), e) - } -} -func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, e *Encoder) { - {{/* if v == nil { e.e.EncodeNil(); return } */ -}} - e.arrayStart(len(v)) - for j := range v { - e.arrayElem() - {{ encmd .Elem "v[j]"}} - } - e.arrayEnd() -} -func (fastpathT) {{ .MethodNamePfx "EncAsMap" false }}V(v []{{ .Elem }}, e *Encoder) { - {{/* if v == nil { e.e.EncodeNil() } else */ -}} - if len(v)%2 == 1 { - e.errorf(fastpathMapBySliceErrMsg, len(v)) - } else { - e.mapStart(len(v) / 2) - for j := range v { - if j%2 == 0 { - e.mapElemKey() - } else { - e.mapElemValue() - } - {{ encmd .Elem "v[j]"}} - } - e.mapEnd() - } -} -{{end}}{{end}}{{end -}} - -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} -func (e *Encoder) {{ .MethodNamePfx "fastpathEnc" false }}R(f *codecFnInfo, rv reflect.Value) { - fastpathTV.{{ .MethodNamePfx "Enc" false }}V(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), e) -} -func (fastpathT) {{ .MethodNamePfx "Enc" false }}V(v map[{{ .MapKey }}]{{ .Elem }}, e *Encoder) { - {{/* if v == nil { e.e.EncodeNil(); return } */ -}} - e.mapStart(len(v)) - if e.h.Canonical { {{/* need to figure out .NoCanonical */}} - {{if eq .MapKey "interface{}"}}{{/* out of band */ -}} - var mksv []byte = make([]byte, 0, len(v)*16) // temporary byte slice for the encoding - e2 := NewEncoderBytes(&mksv, e.hh) - v2 := make([]bytesIntf, len(v)) - var i, l uint {{/* put loop variables outside. seems currently needed for better perf */}} - var vp *bytesIntf - for k2 := range v { - l = uint(len(mksv)) - e2.MustEncode(k2) - vp = &v2[i] - vp.v = mksv[l:] - vp.i = k2 - i++ - } - sort.Sort(bytesIntfSlice(v2)) - for j := range v2 { - e.mapElemKey() - e.asis(v2[j].v) - e.mapElemValue() - e.encode(v[v2[j].i]) - } {{else}}{{ $x := sorttype .MapKey true}}v2 := make([]{{ $x }}, len(v)) - var i uint - for k := range v { - v2[i] = {{if eq $x .MapKey}}k{{else}}{{ $x }}(k){{end}} - i++ - } - sort.Sort({{ sorttype .MapKey false}}(v2)) - for _, k2 := range v2 { - e.mapElemKey() - {{if eq .MapKey "string"}} e.e.EncodeString(k2) {{else}}{{ $y := printf "%s(k2)" .MapKey }}{{if eq $x .MapKey }}{{ $y = "k2" }}{{end}}{{ encmd .MapKey $y }}{{end}} - e.mapElemValue() - {{ $y := printf "v[%s(k2)]" .MapKey }}{{if eq $x .MapKey }}{{ $y = "v[k2]" }}{{end}}{{ encmd .Elem $y }} - } {{end}} - } else { - for k2, v2 := range v { - e.mapElemKey() - {{if eq .MapKey "string"}} e.e.EncodeString(k2) {{else}}{{ encmd .MapKey "k2"}}{{end}} - e.mapElemValue() - {{ encmd .Elem "v2"}} - } - } - e.mapEnd() -} -{{end}}{{end}}{{end -}} - -// -- decode - -// -- -- fast path type switch -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { - var changed bool - var containerLen int - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey }}{{if ne .Elem "uint8" -}} - case []{{ .Elem }}: - fastpathTV.{{ .MethodNamePfx "Dec" false }}N(v, d) - case *[]{{ .Elem }}: - var v2 []{{ .Elem }} - if v2, changed = fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*v, d); changed { - *v = v2 - } -{{end}}{{end}}{{end}}{{end -}} -{{range .Values}}{{if not .Primitive}}{{if .MapKey }}{{/* -// maps only change if nil, and in that case, there's no point copying -*/ -}} - case map[{{ .MapKey }}]{{ .Elem }}: - containerLen = d.mapStart() - if containerLen != decContainerLenNil { - if containerLen != 0 { - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(v, containerLen, d) - } - d.mapEnd() - } - case *map[{{ .MapKey }}]{{ .Elem }}: - {{/* - containerLen = d.mapStart() - if containerLen == 0 { - d.mapEnd() - } else if containerLen == decContainerLenNil { - *v = nil - } else { - if *v == nil { - *v = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})) - } - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(*v, containerLen, d) - } - // consider delegating fully to X - encoding *map is uncommon, so ok to pay small function call cost - */ -}} - fastpathTV.{{ .MethodNamePfx "Dec" false }}X(v, d) -{{end}}{{end}}{{end -}} - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false - } - return true -} - -func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { - switch v := iv.(type) { -{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}} - case *[]{{ .Elem }}: - *v = nil -{{end}}{{end}}{{end}} -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} - case *map[{{ .MapKey }}]{{ .Elem }}: - *v = nil -{{end}}{{end}}{{end}} - default: - _ = v // workaround https://github.com/golang/go/issues/12927 seen in go1.4 - return false - } - return true -} - -// -- -- fast path functions -{{range .Values}}{{if not .Primitive}}{{if not .MapKey -}} -{{/* -Slices can change if they -- did not come from an array -- are addressable (from a ptr) -- are settable (e.g. contained in an interface{}) -*/}} -func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) { - if f.seq != seqTypeArray && rv.Kind() == reflect.Ptr { - vp := rv2i(rv).(*[]{{ .Elem }}) - if v, changed := fastpathTV.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v } - } else { - fastpathTV.{{ .MethodNamePfx "Dec" false }}N(rv2i(rv).([]{{ .Elem }}), d) - } -} -func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *[]{{ .Elem }}, d *Decoder) { - if v, changed := f.{{ .MethodNamePfx "Dec" false }}Y(*vp, d); changed { *vp = v } -} -func (fastpathT) {{ .MethodNamePfx "Dec" false }}Y(v []{{ .Elem }}, d *Decoder) (_ []{{ .Elem }}, changed bool) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - if v == nil { return } - return nil, true - } - if containerLenS == 0 { - if v == nil { v = []{{ .Elem }}{} } else if len(v) != 0 { v = v[:0] } - slh.End() - return v, true - } - hasLen := containerLenS > 0 - var xlen int - if hasLen { - if containerLenS > cap(v) { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) - if xlen <= cap(v) { - v = v[:uint(xlen)] - } else { - v = make([]{{ .Elem }}, uint(xlen)) - } - changed = true - } else if containerLenS != len(v) { - v = v[:containerLenS] - changed = true - } - } - var j int - for j = 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - if j == 0 && len(v) == 0 { - if hasLen { - xlen = decInferLen(containerLenS, d.h.MaxInitLen, {{ .Size }}) - } else { - xlen = 8 - } - v = make([]{{ .Elem }}, uint(xlen)) - changed = true - } - {{/* // if indefinite, etc, then expand the slice if necessary */ -}} - if j >= len(v) { - v = append(v, {{ zerocmd .Elem }}) - changed = true - } - slh.ElemContainerState(j) - {{ if eq .Elem "interface{}" }}d.decode(&v[uint(j)]){{ else }}v[uint(j)] = {{ decmd .Elem }}{{ end }} - } - if j < len(v) { - v = v[:uint(j)] - changed = true - } else if j == 0 && v == nil { - v = []{{ .Elem }}{} - changed = true - } - slh.End() - return v, changed -} -func (fastpathT) {{ .MethodNamePfx "Dec" false }}N(v []{{ .Elem }}, d *Decoder) { - slh, containerLenS := d.decSliceHelperStart() - if slh.IsNil { - return - } - if containerLenS == 0 { - slh.End() - return - } - hasLen := containerLenS > 0 - for j := 0; (hasLen && j < containerLenS) || !(hasLen || d.checkBreak()); j++ { - {{/* // if indefinite, etc, then expand the slice if necessary */ -}} - if j >= len(v) { - decArrayCannotExpand(slh, hasLen, len(v), j, containerLenS) - return - } - slh.ElemContainerState(j) - {{ if eq .Elem "interface{}" -}} - d.decode(&v[uint(j)]) - {{- else -}} - v[uint(j)] = {{ decmd .Elem }} - {{- end }} - } - slh.End() -} -{{end}}{{end}}{{end -}} - -{{range .Values}}{{if not .Primitive}}{{if .MapKey -}} -{{/* -Maps can change if they are -- addressable (from a ptr) -- settable (e.g. contained in an interface{}) -*/ -}} -func (d *Decoder) {{ .MethodNamePfx "fastpathDec" false }}R(f *codecFnInfo, rv reflect.Value) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - if rv.Kind() == reflect.Ptr { - *(rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }})) = nil - } - } else { - if rv.Kind() == reflect.Ptr { - vp, _ := rv2i(rv).(*map[{{ .MapKey }}]{{ .Elem }}) - if *vp == nil { - *vp = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})) - } - if containerLen != 0 { - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(*vp, containerLen, d) - } - } else if containerLen != 0 { - fastpathTV.{{ .MethodNamePfx "Dec" false }}L(rv2i(rv).(map[{{ .MapKey }}]{{ .Elem }}), containerLen, d) - } - d.mapEnd() - } -} -func (f fastpathT) {{ .MethodNamePfx "Dec" false }}X(vp *map[{{ .MapKey }}]{{ .Elem }}, d *Decoder) { - containerLen := d.mapStart() - if containerLen == decContainerLenNil { - *vp = nil - } else { - if *vp == nil { - *vp = make(map[{{ .MapKey }}]{{ .Elem }}, decInferLen(containerLen, d.h.MaxInitLen, {{ .Size }})) - } - if containerLen != 0 { - f.{{ .MethodNamePfx "Dec" false }}L(*vp, containerLen, d) - } - d.mapEnd() - } -} -func (fastpathT) {{ .MethodNamePfx "Dec" false }}L(v map[{{ .MapKey }}]{{ .Elem }}, containerLen int, d *Decoder) { - {{/* No need to check if containerLen == decContainerLenNil, as that is checked by R and L above */ -}} - {{if eq .Elem "interface{}" }}mapGet := v != nil && !d.h.MapValueReset && !d.h.InterfaceReset - {{else if eq .Elem "bytes" "[]byte" }}mapGet := v != nil && !d.h.MapValueReset - {{end -}} - var mk {{ .MapKey }} - var mv {{ .Elem }} - hasLen := containerLen > 0 - for j := 0; (hasLen && j < containerLen) || !(hasLen || d.checkBreak()); j++ { - d.mapElemKey() - {{ if eq .MapKey "interface{}" }}mk = nil - d.decode(&mk) - if bv, bok := mk.([]byte); bok { - mk = d.string(bv) {{/* // maps cannot have []byte as key. switch to string. */}} - }{{ else }}mk = {{ decmd .MapKey }}{{ end }} - d.mapElemValue() - {{ if eq .Elem "interface{}" "[]byte" "bytes" -}} - if mapGet { mv = v[mk] } else { mv = nil } - {{ end -}} - {{ if eq .Elem "interface{}" -}} - d.decode(&mv) - {{ else if eq .Elem "[]byte" "bytes" -}} - mv = d.d.DecodeBytes(mv, false) - {{ else -}} - mv = {{ decmd .Elem }} - {{ end -}} - if v != nil { v[mk] = mv } - } -} -{{end}}{{end}}{{end}} diff --git a/vendor/github.com/ugorji/go/codec/fast-path.not.go b/vendor/github.com/ugorji/go/codec/fast-path.not.go deleted file mode 100644 index 6b6ac1ff2..000000000 --- a/vendor/github.com/ugorji/go/codec/fast-path.not.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build notfastpath - -package codec - -import "reflect" - -const fastpathEnabled = false - -// The generated fast-path code is very large, and adds a few seconds to the build time. -// This causes test execution, execution of small tools which use codec, etc -// to take a long time. -// -// To mitigate, we now support the notfastpath tag. -// This tag disables fastpath during build, allowing for faster build, test execution, -// short-program runs, etc. - -func fastpathDecodeTypeSwitch(iv interface{}, d *Decoder) bool { return false } -func fastpathEncodeTypeSwitch(iv interface{}, e *Encoder) bool { return false } -func fastpathEncodeTypeSwitchSlice(iv interface{}, e *Encoder) bool { return false } -func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool { return false } -func fastpathDecodeSetZeroTypeSwitch(iv interface{}) bool { return false } - -type fastpathT struct{} -type fastpathE struct { - rtid uintptr - rt reflect.Type - encfn func(*Encoder, *codecFnInfo, reflect.Value) - decfn func(*Decoder, *codecFnInfo, reflect.Value) -} -type fastpathA [0]fastpathE - -func (x fastpathA) index(rtid uintptr) int { return -1 } - -var fastpathAV fastpathA -var fastpathTV fastpathT - -// ---- -type TestMammoth2Wrapper struct{} // to allow testMammoth work in notfastpath mode diff --git a/vendor/github.com/ugorji/go/codec/float.go b/vendor/github.com/ugorji/go/codec/float.go deleted file mode 100644 index 0173114fa..000000000 --- a/vendor/github.com/ugorji/go/codec/float.go +++ /dev/null @@ -1,810 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "strconv" -) - -// func parseFloat(b []byte, bitsize int) (f float64, err error) { -// if bitsize == 32 { -// return parseFloat32(b) -// } else { -// return parseFloat64(b) -// } -// } - -func parseFloat32(b []byte) (f float32, err error) { - return parseFloat32_custom(b) - // return parseFloat32_strconv(b) -} - -func parseFloat64(b []byte) (f float64, err error) { - return parseFloat64_custom(b) - // return parseFloat64_strconv(b) -} - -func parseFloat32_strconv(b []byte) (f float32, err error) { - f64, err := strconv.ParseFloat(stringView(b), 32) - f = float32(f64) - return -} - -func parseFloat64_strconv(b []byte) (f float64, err error) { - return strconv.ParseFloat(stringView(b), 64) -} - -// ------ parseFloat custom below -------- - -// We assume that a lot of floating point numbers in json files will be -// those that are handwritten, and with defined precision (in terms of number -// of digits after decimal point), etc. -// -// We further assume that this ones can be written in exact format. -// -// strconv.ParseFloat has some unnecessary overhead which we can do without -// for the common case: -// -// - expensive char-by-char check to see if underscores are in right place -// - testing for and skipping underscores -// - check if the string matches ignorecase +/- inf, +/- infinity, nan -// - support for base 16 (0xFFFF...) -// -// The functions below will try a fast-path for floats which can be decoded -// without any loss of precision, meaning they: -// -// - fits within the significand bits of the 32-bits or 64-bits -// - exponent fits within the exponent value -// - there is no truncation (any extra numbers are all trailing zeros) -// -// To figure out what the values are for maxMantDigits, use this idea below: -// -// 2^23 = 838 8608 (between 10^ 6 and 10^ 7) (significand bits of uint32) -// 2^32 = 42 9496 7296 (between 10^ 9 and 10^10) (full uint32) -// 2^52 = 4503 5996 2737 0496 (between 10^15 and 10^16) (significand bits of uint64) -// 2^64 = 1844 6744 0737 0955 1616 (between 10^19 and 10^20) (full uint64) -// -// Note: we only allow for up to what can comfortably fit into the significand -// ignoring the exponent, and we only try to parse iff significand fits. - -const ( - thousand = 1000 - million = thousand * thousand - billion = thousand * million - trillion = thousand * billion - quadrillion = thousand * trillion - quintillion = thousand * quadrillion -) - -// Exact powers of 10. -var uint64pow10 = [...]uint64{ - 1, 10, 100, - 1 * thousand, 10 * thousand, 100 * thousand, - 1 * million, 10 * million, 100 * million, - 1 * billion, 10 * billion, 100 * billion, - 1 * trillion, 10 * trillion, 100 * trillion, - 1 * quadrillion, 10 * quadrillion, 100 * quadrillion, - 1 * quintillion, 10 * quintillion, -} -var float64pow10 = [...]float64{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, -} -var float32pow10 = [...]float32{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, -} - -type floatinfo struct { - mantbits uint8 - - // expbits uint8 // (unused) - // bias int16 // (unused) - - is32bit bool - exactPow10 int8 // Exact powers of ten are <= 10^N (32: 10, 64: 22) - - exactInts int8 // Exact integers are <= 10^N (for non-float, set to 0) - // maxMantDigits int8 // 10^19 fits in uint64, while 10^9 fits in uint32 - - mantCutoffIsUint64Cutoff bool - - mantCutoff uint64 -} - -// var fi32 = floatinfo{23, 8, -127, 10, 7, 9, fUint32Cutoff} -// var fi64 = floatinfo{52, 11, -1023, 22, 15, 19, fUint64Cutoff} - -// var fi64u = floatinfo{64, 0, -1023, 19, 0, 19, fUint64Cutoff} -// var fi64i = floatinfo{63, 0, -1023, 19, 0, 19, fUint64Cutoff} - -var fi32 = floatinfo{23, true, 10, 7, false, 1<<23 - 1} -var fi64 = floatinfo{52, false, 22, 15, false, 1<<52 - 1} - -var fi64u = floatinfo{0, false, 19, 0, true, fUint64Cutoff} -var fi64i = floatinfo{0, false, 19, 0, true, fUint64Cutoff} - -const fMaxMultiplierForExactPow10_64 = 1e15 -const fMaxMultiplierForExactPow10_32 = 1e7 - -const fUint64Cutoff = (1<<64-1)/10 + 1 -const fUint32Cutoff = (1<<32-1)/10 + 1 - -const fBase = 10 - -func strconvParseErr(b []byte, fn string) error { - return &strconv.NumError{ - Func: fn, - Err: strconv.ErrSyntax, - Num: string(b), - } -} - -func parseFloat32_reader(r readFloatResult) (f float32, fail bool) { - // parseFloatDebug(b, 32, false, exp, trunc, ok) - f = float32(r.mantissa) - if r.exp == 0 { - } else if r.exp < 0 { // int / 10^k - f /= float32pow10[uint8(-r.exp)] - } else { // exp > 0 - if r.exp > fi32.exactPow10 { - f *= float32pow10[r.exp-fi32.exactPow10] - if f > fMaxMultiplierForExactPow10_32 { // exponent too large - outside range - fail = true - return // ok = false - } - f *= float32pow10[fi32.exactPow10] - } else { - f *= float32pow10[uint8(r.exp)] - } - } - if r.neg { - f = -f - } - return -} - -func parseFloat32_custom(b []byte) (f float32, err error) { - r := readFloat(b, fi32) - if r.bad { - return 0, strconvParseErr(b, "ParseFloat") - } - if r.ok { - f, r.bad = parseFloat32_reader(r) - if r.bad { - goto FALLBACK - } - return - } -FALLBACK: - return parseFloat32_strconv(b) -} - -func parseFloat64_reader(r readFloatResult) (f float64, fail bool) { - f = float64(r.mantissa) - if r.exp == 0 { - } else if r.exp < 0 { // int / 10^k - f /= float64pow10[-uint8(r.exp)] - } else { // exp > 0 - if r.exp > fi64.exactPow10 { - f *= float64pow10[r.exp-fi64.exactPow10] - if f > fMaxMultiplierForExactPow10_64 { // exponent too large - outside range - fail = true - return - } - f *= float64pow10[fi64.exactPow10] - } else { - f *= float64pow10[uint8(r.exp)] - } - } - if r.neg { - f = -f - } - return -} - -func parseFloat64_custom(b []byte) (f float64, err error) { - r := readFloat(b, fi64) - if r.bad { - return 0, strconvParseErr(b, "ParseFloat") - } - if r.ok { - f, r.bad = parseFloat64_reader(r) - if r.bad { - goto FALLBACK - } - return - } -FALLBACK: - return parseFloat64_strconv(b) -} - -func parseUint64_simple(b []byte) (n uint64, ok bool) { - var i int - var n1 uint64 - var c uint8 -LOOP: - if i < len(b) { - c = b[i] - // unsigned integers don't overflow well on multiplication, so check cutoff here - // e.g. (maxUint64-5)*10 doesn't overflow well ... - // if n >= fUint64Cutoff || !isDigitChar(b[i]) { // if c < '0' || c > '9' { - if n >= fUint64Cutoff || c < '0' || c > '9' { - return - } else if c == '0' { - n *= fBase - } else { - n1 = n - n = n*fBase + uint64(c-'0') - if n < n1 { - return - } - } - i++ - goto LOOP - } - ok = true - return -} - -// func parseUint64_simple(b []byte) (n uint64, ok bool) { -// var i int -// var n1 uint64 -// LOOP: -// if i < len(b) { -// // unsigned integers don't overflow well on multiplication, so check cutoff here -// // e.g. (maxUint64-5)*10 doesn't overflow well ... -// if n >= fUint64Cutoff || !isDigitChar(b[i]) { // if c < '0' || c > '9' { -// return -// } -// n *= fBase -// n1 = n + uint64(b[i]-'0') -// if n1 < n { -// return -// } -// n = n1 -// i++ -// goto LOOP -// } -// ok = true -// return -// } - -// func parseUint64_simple(b []byte) (n uint64, ok bool) { -// var i int -// var n1 uint64 -// LOOP: -// if i < len(b) { -// // unsigned integers don't overflow well on multiplication, so check cutoff here -// // e.g. (maxUint64-5)*10 doesn't overflow well ... -// if n >= fUint64Cutoff { // if c < '0' || c > '9' { -// return -// } -// n *= fBase -// switch b[i] { -// case '0': -// case '1', '2', '3', '4', '5', '6', '7', '8', '9': -// n1 = n -// n += uint64(b[i] - '0') -// if n < n1 { -// return -// } -// default: -// return -// } -// i++ -// goto LOOP -// } -// ok = true -// return -// } - -// func parseUint64_simple(b []byte) (n uint64, ok bool) { -// var i int -// var n1 uint64 -// LOOP: -// if i < len(b) { -// // unsigned integers don't overflow well on multiplication, so check cutoff here -// // e.g. (maxUint64-5)*10 doesn't overflow well ... -// if n >= fUint64Cutoff { // if c < '0' || c > '9' { -// return -// } -// switch b[i] { -// case '0': -// // n = n<<3 + n<<1 -// n *= 10 -// case '1', '2', '3', '4', '5', '6', '7', '8', '9': -// n1 = n -// // n = n<<3 + n<<1 + uint64(b[i]-'0') -// n = (n * 10) + uint64(b[i]-'0') -// if n < n1 { -// return -// } -// default: -// return -// } -// i++ -// goto LOOP -// } -// ok = true -// return -// } - -func parseUint64_reader(r readFloatResult) (f uint64, fail bool) { - f = r.mantissa - if r.exp == 0 { - } else if r.exp < 0 { // int / 10^k - if f%uint64pow10[uint8(-r.exp)] != 0 { - fail = true - } else { - f /= uint64pow10[uint8(-r.exp)] - } - } else { // exp > 0 - f *= uint64pow10[uint8(r.exp)] - } - return -} - -func parseInt64_reader(r readFloatResult) (v int64, fail bool) { - // xdebugf("parseint64_reader: r: %#v", r) - if r.exp == 0 { - } else if r.exp < 0 { // int / 10^k - if r.mantissa%uint64pow10[uint8(-r.exp)] != 0 { - // fail = true - return 0, true - } - r.mantissa /= uint64pow10[uint8(-r.exp)] - } else { // exp > 0 - r.mantissa *= uint64pow10[uint8(r.exp)] - } - if chkOvf.Uint2Int(r.mantissa, r.neg) { - fail = true - } else if r.neg { - v = -int64(r.mantissa) - } else { - v = int64(r.mantissa) - } - return -} - -// parseNumber will return an integer if only composed of [-]?[0-9]+ -// Else it will return a float. -func parseNumber(b []byte, z *fauxUnion, preferSignedInt bool) (err error) { - var ok, neg bool - var f uint64 - - // var b1 []byte - // if b[0] == '-' { - // neg = true - // b1 = b[1:] - // } else { - // b1 = b - // } - // f, ok = parseUint64_simple(b1) - - if len(b) == 0 { - return - } - - if b[0] == '-' { - neg = true - f, ok = parseUint64_simple(b[1:]) - } else { - f, ok = parseUint64_simple(b) - } - - if ok { - if neg { - z.v = valueTypeInt - if chkOvf.Uint2Int(f, neg) { - return strconvParseErr(b, "ParseInt") - } - z.i = -int64(f) - } else if preferSignedInt { - z.v = valueTypeInt - if chkOvf.Uint2Int(f, neg) { - return strconvParseErr(b, "ParseInt") - } - z.i = int64(f) - } else { - z.v = valueTypeUint - z.u = f - } - return - } - - z.v = valueTypeFloat - z.f, err = parseFloat64_custom(b) - return -} - -type readFloatResult struct { - mantissa uint64 - exp int8 - neg, sawdot, sawexp, trunc, bad bool - ok bool - - _ byte // padding -} - -func readFloat(s []byte, y floatinfo) (r readFloatResult) { - // defer func() { xdebugf("readFloat: %#v", r) }() - - var i uint // uint, so that we eliminate bounds checking - var slen = uint(len(s)) - if slen == 0 { - // read an empty string as the zero value - // r.bad = true - r.ok = true - return - } - - if s[0] == '-' { - r.neg = true - i++ - } - - // we considered punting early if string has length > maxMantDigits, but this doesn't account - // for trailing 0's e.g. 700000000000000000000 can be encoded exactly as it is 7e20 - - var nd, ndMant, dp int8 - var xu uint64 - -LOOP: - for ; i < slen; i++ { - switch s[i] { - case '.': - if r.sawdot { - r.bad = true - return - } - r.sawdot = true - dp = nd - case 'e', 'E': - r.sawexp = true - break LOOP - case '0': - if nd == 0 { - dp-- - continue LOOP - } - nd++ - if r.mantissa < y.mantCutoff { - r.mantissa *= fBase - ndMant++ - } - case '1', '2', '3', '4', '5', '6', '7', '8', '9': - nd++ - if y.mantCutoffIsUint64Cutoff && r.mantissa < fUint64Cutoff { - r.mantissa *= fBase - xu = r.mantissa + uint64(s[i]-'0') - if xu < r.mantissa { - r.trunc = true - return - } - r.mantissa = xu - } else if r.mantissa < y.mantCutoff { - // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(c-'0') - r.mantissa = r.mantissa*fBase + uint64(s[i]-'0') - } else { - r.trunc = true - return - } - ndMant++ - default: - r.bad = true - return - } - } - - if !r.sawdot { - dp = nd - } - - if r.sawexp { - i++ - if i < slen { - var eneg bool - if s[i] == '+' { - i++ - } else if s[i] == '-' { - i++ - eneg = true - } - if i < slen { - // for exact match, exponent is 1 or 2 digits (float64: -22 to 37, float32: -1 to 17). - // exit quick if exponent is more than 2 digits. - if i+2 < slen { - return - } - var e int8 - if s[i] < '0' || s[i] > '9' { // !isDigitChar(s[i]) { // - r.bad = true - return - } - e = int8(s[i] - '0') - i++ - if i < slen { - if s[i] < '0' || s[i] > '9' { // !isDigitChar(s[i]) { // - r.bad = true - return - } - e = e*fBase + int8(s[i]-'0') // (e << 1) + (e << 3) + int8(s[i]-'0') - i++ - } - if eneg { - dp -= e - } else { - dp += e - } - } - } - } - - if r.mantissa != 0 { - r.exp = dp - ndMant - // do not set ok=true for cases we cannot handle - if r.exp < -y.exactPow10 || - r.exp > y.exactInts+y.exactPow10 || - y.mantbits != 0 && r.mantissa>>y.mantbits != 0 { - return - } - } - - r.ok = true - return -} - -/* - -func parseUint64(b []byte) (f uint64, err error) { - if b[0] == '-' { - return 0, strconvParseErr(b, "ParseUint") - } - f, ok := parseUint64_simple(b) - if !ok { - return parseUint64_custom(b) - } - return -} - -func parseInt64(b []byte) (v int64, err error) { - // defer func() { xdebug2f("parseInt64: %s, return: %d, %v", b, v, err) }() - // xdebugf("parseInt64: %s", b) - var ok, neg bool - var f uint64 - var r readFloatResult - - if b[0] == '-' { - neg = true - b = b[1:] - } - - f, ok = parseUint64_simple(b) - // xdebugf("parseuint64_simple: %v, %v", f, ok) - if ok { - if chkOvf.Uint2Int(f, neg) { - goto ERROR - } - if neg { - v = -int64(f) - } else { - v = int64(f) - } - return - } - - r = readFloat(b, fi64i) - // xdebugf("readFloat ok: %v", r.ok) - if r.ok { - r.neg = neg - v, r.bad = parseInt64_reader(r) - if r.bad { - goto ERROR - } - return - } -ERROR: - err = strconvParseErr(b, "ParseInt") - return -} - -func parseUint64_custom(b []byte) (f uint64, err error) { - r := readFloat(b, fi64u) - if r.ok { - f, r.bad = parseUint64_reader(r) - if r.bad { - err = strconvParseErr(b, "ParseUint") - } - return - } - err = strconvParseErr(b, "ParseUint") - return -} - -func parseUint64_simple(b []byte) (n uint64, ok bool) { - for _, c := range b { - if c < '0' || c > '9' { - return - } - // unsigned integers don't overflow well on multiplication, so check cutoff here - // e.g. (maxUint64-5)*10 doesn't overflow well ... - if n >= uint64Cutoff { - return - } - n *= 10 - n1 := n + uint64(c-'0') - if n1 < n { - return - } - n = n1 - } - ok = true - return -} - -func readFloat(s []byte, y floatinfo) (r readFloatResult) { - // defer func() { xdebugf("readFloat: %#v", r) }() - - var i uint // uint, so that we eliminate bounds checking - var slen = uint(len(s)) - if slen == 0 { - // read an empty string as the zero value - // r.bad = true - r.ok = true - return - } - - if s[0] == '-' { - r.neg = true - i++ - } - - // we considered punting early if string has length > maxMantDigits, but this doesn't account - // for trailing 0's e.g. 700000000000000000000 can be encoded exactly as it is 7e20 - - // var mantCutoffIsUint64Cutoff bool - - // var mantCutoff uint64 - // if y.mantbits != 0 { - // mantCutoff = 1<= '1' && c <= '9' { // !(c < '0' || c > '9') { // - nd++ - - if y.mantCutoffIsUint64Cutoff && r.mantissa < fUint64Cutoff { - // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(c-'0') - r.mantissa *= fBase - xu = r.mantissa + uint64(c-'0') - if xu < r.mantissa { - r.trunc = true - return - } - r.mantissa = xu - ndMant++ - } else if r.mantissa < y.mantCutoff { - // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(c-'0') - r.mantissa = r.mantissa*fBase + uint64(c-'0') - ndMant++ - } else { - r.trunc = true - return - } - - // if r.mantissa < y.mantCutoff { - // if y.mantCutoffIsUint64Cutoff { - // // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(c-'0') - // r.mantissa *= fBase - // xu = r.mantissa + uint64(c-'0') - // if xu < r.mantissa { - // r.trunc = true - // return - // } - // r.mantissa = xu - // } else { - // // mantissa = (mantissa << 1) + (mantissa << 3) + uint64(c-'0') - // r.mantissa = r.mantissa*fBase + uint64(c-'0') - // } - // ndMant++ - // } else { - // r.trunc = true - // return - // } - } else { - r.bad = true - return - } - } - - if !r.sawdot { - dp = nd - } - - if r.sawexp { - i++ - if i < slen { - var eneg bool - if s[i] == '+' { - i++ - } else if s[i] == '-' { - i++ - eneg = true - } - if i < slen { - // for exact match, exponent is 1 or 2 digits (float64: -22 to 37, float32: -1 to 17). - // exit quick if exponent is more than 2 digits. - if i+2 < slen { - return - } - var e int8 - if !isDigitChar(s[i]) { // s[i] < '0' || s[i] > '9' { - r.bad = true - return - } - e = int8(s[i] - '0') - i++ - if i < slen { - if !isDigitChar(s[i]) { // s[i] < '0' || s[i] > '9' { - r.bad = true - return - } - e = e*fBase + int8(s[i]-'0') // (e << 1) + (e << 3) + int8(s[i]-'0') - i++ - } - if eneg { - dp -= e - } else { - dp += e - } - } - } - } - - if r.mantissa != 0 { - r.exp = dp - ndMant - // do not set ok=true for cases we cannot handle - if r.exp < -y.exactPow10 || - r.exp > y.exactInts+y.exactPow10 || - y.mantbits != 0 && r.mantissa>>y.mantbits != 0 { - return - } - } - - r.ok = true - return -} - -*/ diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl deleted file mode 100644 index d2caa0b66..000000000 --- a/vendor/github.com/ugorji/go/codec/gen-dec-array.go.tmpl +++ /dev/null @@ -1,90 +0,0 @@ -{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} -{{if not isArray -}} -var {{var "c"}} bool {{/* // changed */}} -_ = {{var "c"}} -if {{var "h"}}.IsNil { - if {{var "v"}} != nil { - {{var "v"}} = nil - {{var "c"}} = true - } -} else {{end -}} -if {{var "l"}} == 0 { - {{if isSlice -}} - if {{var "v"}} == nil { - {{var "v"}} = []{{ .Typ }}{} - {{var "c"}} = true - } else if len({{var "v"}}) != 0 { - {{var "v"}} = {{var "v"}}[:0] - {{var "c"}} = true - } {{else if isChan }}if {{var "v"}} == nil { - {{var "v"}} = make({{ .CTyp }}, 0) - {{var "c"}} = true - } - {{end -}} -} else { - {{var "hl"}} := {{var "l"}} > 0 - var {{var "rl"}} int - _ = {{var "rl"}} - {{if isSlice }} if {{var "hl"}} { - if {{var "l"}} > cap({{var "v"}}) { - {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - if {{var "rl"}} <= cap({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "rl"}}] - } else { - {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}}) - } - {{var "c"}} = true - } else if {{var "l"}} != len({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "l"}}] - {{var "c"}} = true - } - } - {{end -}} - var {{var "j"}} int - {{/* // var {{var "dn"}} bool */ -}} - for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination - {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil { - if {{var "hl"}} { - {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - } else { - {{var "rl"}} = {{if isSlice}}8{{else if isChan}}64{{end}} - } - {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}}) - {{var "c"}} = true - } - {{end -}} - {{var "h"}}.ElemContainerState({{var "j"}}) - {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */ -}} - {{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }} - {{ decLineVar $x -}} - {{var "v"}} <- {{ $x }} - {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */ -}} - var {{var "db"}} bool - if {{var "j"}} >= len({{var "v"}}) { - {{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }}) - {{var "c"}} = true - {{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true - {{end -}} - } - if {{var "db"}} { - z.DecSwallow() - } else { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x -}} - } - {{end -}} - } - {{if isSlice}} if {{var "j"}} < len({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "j"}}] - {{var "c"}} = true - } else if {{var "j"}} == 0 && {{var "v"}} == nil { - {{var "v"}} = make([]{{ .Typ }}, 0) - {{var "c"}} = true - } - {{end -}} -} -{{var "h"}}.End() -{{if not isArray }}if {{var "c"}} { - *{{ .Varname }} = {{var "v"}} -} -{{end -}} diff --git a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl deleted file mode 100644 index 35bda4a16..000000000 --- a/vendor/github.com/ugorji/go/codec/gen-dec-map.go.tmpl +++ /dev/null @@ -1,53 +0,0 @@ -{{var "v"}} := *{{ .Varname }} -{{var "l"}} := z.DecReadMapStart() -if {{var "l"}} == codecSelferDecContainerLenNil{{xs}} { - *{{ .Varname }} = nil -} else { -if {{var "v"}} == nil { - {{var "rl"}} := z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}}) - *{{ .Varname }} = {{var "v"}} -} -var {{var "mk"}} {{ .KTyp }} -var {{var "mv"}} {{ .Typ }} -var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool -if z.DecBasicHandle().MapValueReset { - {{if decElemKindPtr}}{{var "mg"}} = true - {{else if decElemKindIntf}}if !z.DecBasicHandle().InterfaceReset { {{var "mg"}} = true } - {{else if not decElemKindImmutable}}{{var "mg"}} = true - {{end}} } -if {{var "l"}} != 0 { - {{var "hl"}} := {{var "l"}} > 0 - for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { - z.DecReadMapElemKey() - {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}} - {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}} - if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { - {{var "mk"}} = string({{var "bv"}}) - } - {{ end -}} - {{if decElemKindPtr -}} - {{var "ms"}} = true - {{end -}} - if {{var "mg"}} { - {{if decElemKindPtr -}} - {{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] - if {{var "mok"}} { - {{var "ms"}} = false - } - {{else -}} - {{var "mv"}} = {{var "v"}}[{{var "mk"}}] - {{end -}} - } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} - z.DecReadMapElemValue() - {{var "mdn"}} = false - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}} - if {{var "mdn"}} { - if z.DecBasicHandle().DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} } - } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -} // else len==0: TODO: Should we clear map entries? -z.DecReadMapEnd() -} diff --git a/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl deleted file mode 100644 index 4249588a3..000000000 --- a/vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl +++ /dev/null @@ -1,27 +0,0 @@ -{{.Label}}: -switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; { -case timeout{{.Sfx}} == 0: // only consume available - for { - select { - case b{{.Sfx}} := <-{{.Chan}}: - {{ .Slice }} = append({{.Slice}}, b{{.Sfx}}) - default: - break {{.Label}} - } - } -case timeout{{.Sfx}} > 0: // consume until timeout - tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}}) - for { - select { - case b{{.Sfx}} := <-{{.Chan}}: - {{.Slice}} = append({{.Slice}}, b{{.Sfx}}) - case <-tt{{.Sfx}}.C: - // close(tt.C) - break {{.Label}} - } - } -default: // consume until close - for b{{.Sfx}} := range {{.Chan}} { - {{.Slice}} = append({{.Slice}}, b{{.Sfx}}) - } -} diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go b/vendor/github.com/ugorji/go/codec/gen-helper.generated.go deleted file mode 100644 index dc7df3c65..000000000 --- a/vendor/github.com/ugorji/go/codec/gen-helper.generated.go +++ /dev/null @@ -1,273 +0,0 @@ -// comment this out // + build ignore - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from gen-helper.go.tmpl - DO NOT EDIT. - -package codec - -import "encoding" - -// GenVersion is the current version of codecgen. -const GenVersion = 16 - -// 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 continuously and without notice. - -// 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) (ge genHelperEncoder, ee genHelperEncDriver) { - ge = genHelperEncoder{e: e} - ee = genHelperEncDriver{encDriver: e.e} - return -} - -// 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) (gd genHelperDecoder, dd genHelperDecDriver) { - gd = genHelperDecoder{d: d} - dd = genHelperDecDriver{decDriver: d.d} - return -} - -type genHelperEncDriver struct { - encDriver -} - -type genHelperDecDriver struct { - decDriver -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperEncoder struct { - M must - F fastpathT - e *Encoder -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperDecoder struct { - C checkOverflow - F fastpathT - d *Decoder -} - -// 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) IsJSONHandle() bool { - return f.e.js -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncFallback(iv interface{}) { - // f.e.encodeI(iv, false, false) - f.e.encodeValue(rv4i(iv), nil) -} - -// 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.marshalUtf8(bs, fnerr) -} - -// 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.marshalAsis(bs, fnerr) -} - -// 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.marshalRaw(bs, fnerr) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) I2Rtid(v interface{}) uintptr { - return i2rtid(v) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { - return f.e.h.getExt(rtid, true) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) { - f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) WriteStr(s string) { - f.e.w().writestr(s) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() } - -// ---------------- 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) DecScratchArrayBuffer() *[decScratchByteArrayLen]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) { - rv := rv4i(iv) - if chkPtr { - f.d.ensureDecodeable(rv) - } - f.d.decodeValue(rv, nil) -} - -// 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) { - if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil { - halt.errorv(fnerr) - } -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) { - // bs := f.dd.DecodeStringAsBytes() - // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself. - if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil { - halt.errorv(fnerr) - } -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { - if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil { - halt.errorv(fnerr) - } -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() } - -// 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) I2Rtid(v interface{}) uintptr { - return i2rtid(v) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { - return f.d.h.getExt(rtid, true) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) { - f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) { - return decInferLen(clen, maxlen, unit) -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() } diff --git a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl b/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl deleted file mode 100644 index c78a971d9..000000000 --- a/vendor/github.com/ugorji/go/codec/gen-helper.go.tmpl +++ /dev/null @@ -1,243 +0,0 @@ -// comment this out // + build ignore - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from gen-helper.go.tmpl - DO NOT EDIT. - -package codec - -import "encoding" - -// GenVersion is the current version of codecgen. -const GenVersion = {{ .Version }} - -// 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 continuously 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) (ge genHelperEncoder, ee genHelperEncDriver) { - ge = genHelperEncoder{e: e} - ee = genHelperEncDriver{encDriver: e.e} - return -} - -// 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) (gd genHelperDecoder, dd genHelperDecDriver) { - gd = genHelperDecoder{d: d} - dd = genHelperDecDriver{decDriver: d.d} - return -} - -type genHelperEncDriver struct { - encDriver -} - -type genHelperDecDriver struct { - decDriver -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperEncoder struct { - M must - F fastpathT - e *Encoder -} - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -type genHelperDecoder struct { - C checkOverflow - F fastpathT - d *Decoder -} - -// 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) IsJSONHandle() bool { - return f.e.js -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncFallback(iv interface{}) { - // f.e.encodeI(iv, false, false) - f.e.encodeValue(rv4i(iv), nil) -} -// 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.marshalUtf8(bs, fnerr) -} -// 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.marshalAsis(bs, fnerr) -} -// 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.marshalRaw(bs, fnerr) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncRaw(iv Raw) { f.e.rawBytes(iv) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) I2Rtid(v interface{}) uintptr { - return i2rtid(v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { - return f.e.h.getExt(rtid, true) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncExtension(v interface{}, xfFn *extTypeTagFn) { - f.e.e.EncodeExt(v, xfFn.tag, xfFn.ext) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) WriteStr(s string) { - f.e.w().writestr(s) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) BytesView(v string) []byte { return bytesView(v) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapStart(length int) { f.e.mapStart(length) } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapEnd() { f.e.mapEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayStart(length int) { f.e.arrayStart(length) } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayEnd() { f.e.arrayEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteArrayElem() { f.e.arrayElem() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapElemKey() { f.e.mapElemKey() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperEncoder) EncWriteMapElemValue() { f.e.mapElemValue() } - -// ---------------- 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) DecScratchArrayBuffer() *[decScratchByteArrayLen]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) { - rv := rv4i(iv) - if chkPtr { - f.d.ensureDecodeable(rv) - } - f.d.decodeValue(rv, nil) -} -// 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) { - if fnerr := tm.UnmarshalText(f.d.d.DecodeStringAsBytes()); fnerr != nil { - halt.errorv(fnerr) - } -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecJSONUnmarshal(tm jsonUnmarshaler) { - // bs := f.dd.DecodeStringAsBytes() - // grab the bytes to be read, as UnmarshalJSON needs the full JSON so as to unmarshal it itself. - if fnerr := tm.UnmarshalJSON(f.d.nextValueBytes()); fnerr != nil { - halt.errorv(fnerr) - } -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecBinaryUnmarshal(bm encoding.BinaryUnmarshaler) { - if fnerr := bm.UnmarshalBinary(f.d.d.DecodeBytes(nil, true)); fnerr != nil { - halt.errorv(fnerr) - } -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecRaw() []byte { return f.d.rawBytes() } - -// 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) I2Rtid(v interface{}) uintptr { - return i2rtid(v) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) Extension(rtid uintptr) (xfn *extTypeTagFn) { - return f.d.h.getExt(rtid, true) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecExtension(v interface{}, xfFn *extTypeTagFn) { - f.d.d.DecodeExt(v, xfFn.tag, xfFn.ext) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecInferLen(clen, maxlen, unit int) (rvlen int) { - return decInferLen(clen, maxlen, unit) -} -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) StringView(v []byte) string { return stringView(v) } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapStart() int { return f.d.mapStart() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapEnd() { f.d.mapEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayStart() int { return f.d.arrayStart() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayEnd() { f.d.arrayEnd() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadArrayElem() { f.d.arrayElem() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemKey() { f.d.mapElemKey() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecReadMapElemValue() { f.d.mapElemValue() } - -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecDecodeFloat32() float32 { return f.d.decodeFloat32() } -// FOR USE BY CODECGEN ONLY. IT *WILL* CHANGE WITHOUT NOTICE. *DO NOT USE* -func (f genHelperDecoder) DecCheckBreak() bool { return f.d.checkBreak() } - diff --git a/vendor/github.com/ugorji/go/codec/gen.generated.go b/vendor/github.com/ugorji/go/codec/gen.generated.go deleted file mode 100644 index 5aca5a488..000000000 --- a/vendor/github.com/ugorji/go/codec/gen.generated.go +++ /dev/null @@ -1,187 +0,0 @@ -// +build codecgen.exec - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// DO NOT EDIT. THIS FILE IS AUTO-GENERATED FROM gen-dec-(map|array).go.tmpl - -const genDecMapTmpl = ` -{{var "v"}} := *{{ .Varname }} -{{var "l"}} := z.DecReadMapStart() -if {{var "l"}} == codecSelferDecContainerLenNil{{xs}} { - *{{ .Varname }} = nil -} else { -if {{var "v"}} == nil { - {{var "rl"}} := z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - {{var "v"}} = make(map[{{ .KTyp }}]{{ .Typ }}, {{var "rl"}}) - *{{ .Varname }} = {{var "v"}} -} -var {{var "mk"}} {{ .KTyp }} -var {{var "mv"}} {{ .Typ }} -var {{var "mg"}}, {{var "mdn"}} {{if decElemKindPtr}}, {{var "ms"}}, {{var "mok"}}{{end}} bool -if z.DecBasicHandle().MapValueReset { - {{if decElemKindPtr}}{{var "mg"}} = true - {{else if decElemKindIntf}}if !z.DecBasicHandle().InterfaceReset { {{var "mg"}} = true } - {{else if not decElemKindImmutable}}{{var "mg"}} = true - {{end}} } -if {{var "l"}} != 0 { - {{var "hl"}} := {{var "l"}} > 0 - for {{var "j"}} := 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { - z.DecReadMapElemKey() - {{ $x := printf "%vmk%v" .TempVar .Rand }}{{ decLineVarK $x -}} - {{ if eq .KTyp "interface{}" }}{{/* // special case if a byte array. */ -}} - if {{var "bv"}}, {{var "bok"}} := {{var "mk"}}.([]byte); {{var "bok"}} { - {{var "mk"}} = string({{var "bv"}}) - } - {{ end -}} - {{if decElemKindPtr -}} - {{var "ms"}} = true - {{end -}} - if {{var "mg"}} { - {{if decElemKindPtr -}} - {{var "mv"}}, {{var "mok"}} = {{var "v"}}[{{var "mk"}}] - if {{var "mok"}} { - {{var "ms"}} = false - } - {{else -}} - {{var "mv"}} = {{var "v"}}[{{var "mk"}}] - {{end -}} - } {{if not decElemKindImmutable}}else { {{var "mv"}} = {{decElemZero}} }{{end}} - z.DecReadMapElemValue() - {{var "mdn"}} = false - {{ $x := printf "%vmv%v" .TempVar .Rand }}{{ $y := printf "%vmdn%v" .TempVar .Rand }}{{ decLineVar $x $y -}} - if {{var "mdn"}} { - if z.DecBasicHandle().DeleteOnNilMapValue { delete({{var "v"}}, {{var "mk"}}) } else { {{var "v"}}[{{var "mk"}}] = {{decElemZero}} } - } else if {{if decElemKindPtr}} {{var "ms"}} && {{end}} {{var "v"}} != nil { - {{var "v"}}[{{var "mk"}}] = {{var "mv"}} - } -} -} // else len==0: TODO: Should we clear map entries? -z.DecReadMapEnd() -} -` - -const genDecListTmpl = ` -{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }} -{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}} -{{if not isArray -}} -var {{var "c"}} bool {{/* // changed */}} -_ = {{var "c"}} -if {{var "h"}}.IsNil { - if {{var "v"}} != nil { - {{var "v"}} = nil - {{var "c"}} = true - } -} else {{end -}} -if {{var "l"}} == 0 { - {{if isSlice -}} - if {{var "v"}} == nil { - {{var "v"}} = []{{ .Typ }}{} - {{var "c"}} = true - } else if len({{var "v"}}) != 0 { - {{var "v"}} = {{var "v"}}[:0] - {{var "c"}} = true - } {{else if isChan }}if {{var "v"}} == nil { - {{var "v"}} = make({{ .CTyp }}, 0) - {{var "c"}} = true - } - {{end -}} -} else { - {{var "hl"}} := {{var "l"}} > 0 - var {{var "rl"}} int - _ = {{var "rl"}} - {{if isSlice }} if {{var "hl"}} { - if {{var "l"}} > cap({{var "v"}}) { - {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - if {{var "rl"}} <= cap({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "rl"}}] - } else { - {{var "v"}} = make([]{{ .Typ }}, {{var "rl"}}) - } - {{var "c"}} = true - } else if {{var "l"}} != len({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "l"}}] - {{var "c"}} = true - } - } - {{end -}} - var {{var "j"}} int - {{/* // var {{var "dn"}} bool */ -}} - for {{var "j"}} = 0; ({{var "hl"}} && {{var "j"}} < {{var "l"}}) || !({{var "hl"}} || z.DecCheckBreak()); {{var "j"}}++ { // bounds-check-elimination - {{if not isArray}} if {{var "j"}} == 0 && {{var "v"}} == nil { - if {{var "hl"}} { - {{var "rl"}} = z.DecInferLen({{var "l"}}, z.DecBasicHandle().MaxInitLen, {{ .Size }}) - } else { - {{var "rl"}} = {{if isSlice}}8{{else if isChan}}64{{end}} - } - {{var "v"}} = make({{if isSlice}}[]{{ .Typ }}{{else if isChan}}{{.CTyp}}{{end}}, {{var "rl"}}) - {{var "c"}} = true - } - {{end -}} - {{var "h"}}.ElemContainerState({{var "j"}}) - {{/* {{var "dn"}} = r.TryDecodeAsNil() */}}{{/* commented out, as decLineVar handles this already each time */ -}} - {{if isChan}}{{ $x := printf "%[1]vvcx%[2]v" .TempVar .Rand }}var {{$x}} {{ .Typ }} - {{ decLineVar $x -}} - {{var "v"}} <- {{ $x }} - {{else}}{{/* // if indefinite, etc, then expand the slice if necessary */ -}} - var {{var "db"}} bool - if {{var "j"}} >= len({{var "v"}}) { - {{if isSlice }} {{var "v"}} = append({{var "v"}}, {{ zero }}) - {{var "c"}} = true - {{else}} z.DecArrayCannotExpand(len(v), {{var "j"}}+1); {{var "db"}} = true - {{end -}} - } - if {{var "db"}} { - z.DecSwallow() - } else { - {{ $x := printf "%[1]vv%[2]v[%[1]vj%[2]v]" .TempVar .Rand }}{{ decLineVar $x -}} - } - {{end -}} - } - {{if isSlice}} if {{var "j"}} < len({{var "v"}}) { - {{var "v"}} = {{var "v"}}[:{{var "j"}}] - {{var "c"}} = true - } else if {{var "j"}} == 0 && {{var "v"}} == nil { - {{var "v"}} = make([]{{ .Typ }}, 0) - {{var "c"}} = true - } - {{end -}} -} -{{var "h"}}.End() -{{if not isArray }}if {{var "c"}} { - *{{ .Varname }} = {{var "v"}} -} -{{end -}} -` - -const genEncChanTmpl = ` -{{.Label}}: -switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; { -case timeout{{.Sfx}} == 0: // only consume available - for { - select { - case b{{.Sfx}} := <-{{.Chan}}: - {{ .Slice }} = append({{.Slice}}, b{{.Sfx}}) - default: - break {{.Label}} - } - } -case timeout{{.Sfx}} > 0: // consume until timeout - tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}}) - for { - select { - case b{{.Sfx}} := <-{{.Chan}}: - {{.Slice}} = append({{.Slice}}, b{{.Sfx}}) - case <-tt{{.Sfx}}.C: - // close(tt.C) - break {{.Label}} - } - } -default: // consume until close - for b{{.Sfx}} := range {{.Chan}} { - {{.Slice}} = append({{.Slice}}, b{{.Sfx}}) - } -} -` diff --git a/vendor/github.com/ugorji/go/codec/gen.go b/vendor/github.com/ugorji/go/codec/gen.go deleted file mode 100644 index 3573bc32e..000000000 --- a/vendor/github.com/ugorji/go/codec/gen.go +++ /dev/null @@ -1,2339 +0,0 @@ -// +build codecgen.exec - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bytes" - "encoding/base64" - "errors" - "fmt" - "go/format" - "io" - "io/ioutil" - "math/rand" - "reflect" - "regexp" - "sort" - "strconv" - "strings" - "sync" - "text/template" - "time" - "unicode" - "unicode/utf8" -) - -// --------------------------------------------------- -// codecgen supports the full cycle of reflection-based codec: -// - RawExt -// - Raw -// - Extensions -// - (Binary|Text|JSON)(Unm|M)arshal -// - generic by-kind -// -// This means that, for dynamic things, we MUST use reflection to at least get the reflect.Type. -// In those areas, we try to only do reflection or interface-conversion when NECESSARY: -// - Extensions, only if Extensions are configured. -// -// However, codecgen doesn't support the following: -// - Canonical option. (codecgen IGNORES it currently) -// This is just because it has not been implemented. -// - MissingFielder implementation. -// If a type implements MissingFielder, it is completely ignored by codecgen. -// -// During encode/decode, Selfer takes precedence. -// A type implementing Selfer will know how to encode/decode itself statically. -// -// The following field types are supported: -// array: [n]T -// slice: []T -// map: map[K]V -// primitive: [u]int[n], float(32|64), bool, string -// struct -// -// --------------------------------------------------- -// Note that a Selfer cannot call (e|d).(En|De)code on itself, -// as this will cause a circular reference, as (En|De)code will call Selfer methods. -// Any type that implements Selfer must implement completely and not fallback to (En|De)code. -// -// In addition, code in this file manages the generation of fast-path implementations of -// encode/decode of slices/maps of primitive keys/values. -// -// Users MUST re-generate their implementations whenever the code shape changes. -// The generated code will panic if it was generated with a version older than the supporting library. -// --------------------------------------------------- -// -// codec framework is very feature rich. -// When encoding or decoding into an interface, it depends on the runtime type of the interface. -// The type of the interface may be a named type, an extension, etc. -// Consequently, we fallback to runtime codec for encoding/decoding interfaces. -// In addition, we fallback for any value which cannot be guaranteed at runtime. -// This allows us support ANY value, including any named types, specifically those which -// do not implement our interfaces (e.g. Selfer). -// -// This explains some slowness compared to other code generation codecs (e.g. msgp). -// This reduction in speed is only seen when your refers to interfaces, -// e.g. type T struct { A interface{}; B []interface{}; C map[string]interface{} } -// -// codecgen will panic if the file was generated with an old version of the library in use. -// -// Note: -// It was a conscious decision to have gen.go always explicitly call EncodeNil or TryDecodeAsNil. -// This way, there isn't a function call overhead just to see that we should not enter a block of code. -// -// Note: -// codecgen-generated code depends on the variables defined by fast-path.generated.go. -// consequently, you cannot run with tags "codecgen notfastpath". - -// GenVersion is the current version of codecgen. -// -// NOTE: Increment this value each time codecgen changes fundamentally. -// Fundamental changes are: -// - helper methods change (signature change, new ones added, some removed, etc) -// - codecgen command line changes -// -// v1: Initial Version -// v2: -// v3: Changes for Kubernetes: -// changes in signature of some unpublished helper methods and codecgen cmdline arguments. -// v4: Removed separator support from (en|de)cDriver, and refactored codec(gen) -// v5: changes to support faster json decoding. Let encoder/decoder maintain state of collections. -// v6: removed unsafe from gen, and now uses codecgen.exec tag -// v7: -// v8: current - we now maintain compatibility with old generated code. -// v9: skipped -// v10: modified encDriver and decDriver interfaces. -// v11: remove deprecated methods of encDriver and decDriver. -// v12: removed deprecated methods from genHelper and changed container tracking logic -// v13: 20190603 removed DecodeString - use DecodeStringAsBytes instead -// v14: 20190611 refactored nil handling: TryDecodeAsNil -> selective TryNil, etc -// v15: 20190626 encDriver.EncodeString handles StringToRaw flag inside handle -// v16: 20190629 refactoring for v1.1.6 -const genVersion = 16 - -const ( - genCodecPkg = "codec1978" - genTempVarPfx = "yy" - genTopLevelVarName = "x" - - // ignore canBeNil parameter, and always set to true. - // This is because nil can appear anywhere, so we should always check. - genAnythingCanBeNil = true - - // if genUseOneFunctionForDecStructMap, make a single codecDecodeSelferFromMap function; - // else make codecDecodeSelferFromMap{LenPrefix,CheckBreak} so that conditionals - // are not executed a lot. - // - // From testing, it didn't make much difference in runtime, so keep as true (one function only) - genUseOneFunctionForDecStructMap = true - - // genFastpathCanonical configures whether we support Canonical in fast path. - // The savings is not much. - // - // NOTE: This MUST ALWAYS BE TRUE. fast-path.go.tmp doesn't handle it being false. - genFastpathCanonical = true // MUST be true - - // genFastpathTrimTypes configures whether we trim uncommon fastpath types. - genFastpathTrimTypes = true - - // genDecStructArrayInlineLoopCheck configures whether we create a next function - // for each iteration in the loop and call it, or just inline it. - // - // with inlining, we get better performance but about 10% larger files. - genDecStructArrayInlineLoopCheck = true -) - -type genStructMapStyle uint8 - -const ( - genStructMapStyleConsolidated genStructMapStyle = iota - genStructMapStyleLenPrefix - genStructMapStyleCheckBreak -) - -var ( - errGenAllTypesSamePkg = errors.New("All types must be in the same package") - errGenExpectArrayOrMap = errors.New("unexpected type. Expecting array/map/slice") - - genBase64enc = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789__") - genQNameRegex = regexp.MustCompile(`[A-Za-z_.]+`) -) - -type genBuf struct { - buf []byte -} - -func (x *genBuf) s(s string) *genBuf { x.buf = append(x.buf, s...); return x } -func (x *genBuf) b(s []byte) *genBuf { x.buf = append(x.buf, s...); return x } -func (x *genBuf) v() string { return string(x.buf) } -func (x *genBuf) f(s string, args ...interface{}) { x.s(fmt.Sprintf(s, args...)) } -func (x *genBuf) reset() { - if x.buf != nil { - x.buf = x.buf[:0] - } -} - -// genRunner holds some state used during a Gen run. -type genRunner struct { - w io.Writer // output - c uint64 // counter used for generating varsfx - f uint64 // counter used for saying false - - t []reflect.Type // list of types to run selfer on - tc reflect.Type // currently running selfer on this type - te map[uintptr]bool // types for which the encoder has been created - td map[uintptr]bool // types for which the decoder has been created - cp string // codec import path - - im map[string]reflect.Type // imports to add - imn map[string]string // package names of imports to add - imc uint64 // counter for import numbers - - is map[reflect.Type]struct{} // types seen during import search - bp string // base PkgPath, for which we are generating for - - cpfx string // codec package prefix - - tm map[reflect.Type]struct{} // types for which enc/dec must be generated - ts []reflect.Type // types for which enc/dec must be generated - - xs string // top level variable/constant suffix - hn string // fn helper type name - - ti *TypeInfos - // rr *rand.Rand // random generator for file-specific types - - nx bool // no extensions -} - -type genIfClause struct { - hasIf bool -} - -func (g *genIfClause) end(x *genRunner) { - if g.hasIf { - x.line("}") - } -} - -func (g *genIfClause) c(last bool) (v string) { - if last { - if g.hasIf { - v = " } else { " - } - } else if g.hasIf { - v = " } else if " - } else { - v = "if " - g.hasIf = true - } - return -} - -// Gen will write a complete go file containing Selfer implementations for each -// type passed. All the types must be in the same package. -// -// Library users: DO NOT USE IT DIRECTLY. IT WILL CHANGE CONTINUOUSLY WITHOUT NOTICE. -func Gen(w io.Writer, buildTags, pkgName, uid string, noExtensions bool, - ti *TypeInfos, typ ...reflect.Type) { - // All types passed to this method do not have a codec.Selfer method implemented directly. - // codecgen already checks the AST and skips any types that define the codec.Selfer methods. - // Consequently, there's no need to check and trim them if they implement codec.Selfer - - if len(typ) == 0 { - return - } - x := genRunner{ - w: w, - t: typ, - te: make(map[uintptr]bool), - td: make(map[uintptr]bool), - im: make(map[string]reflect.Type), - imn: make(map[string]string), - is: make(map[reflect.Type]struct{}), - tm: make(map[reflect.Type]struct{}), - ts: []reflect.Type{}, - bp: genImportPath(typ[0]), - xs: uid, - ti: ti, - nx: noExtensions, - } - if x.ti == nil { - x.ti = defTypeInfos - } - if x.xs == "" { - rr := rand.New(rand.NewSource(time.Now().UnixNano())) - x.xs = strconv.FormatInt(rr.Int63n(9999), 10) - } - - // gather imports first: - x.cp = genImportPath(reflect.TypeOf(x)) - x.imn[x.cp] = genCodecPkg - for _, t := range typ { - // fmt.Printf("###########: PkgPath: '%v', Name: '%s'\n", genImportPath(t), t.Name()) - if genImportPath(t) != x.bp { - panic(errGenAllTypesSamePkg) - } - x.genRefPkgs(t) - } - x.line("// +build go1.6") - if buildTags != "" { - x.line("// +build " + buildTags) - } - x.line(` - -// Code generated by codecgen - DO NOT EDIT. - -`) - x.line("package " + pkgName) - x.line("") - x.line("import (") - if x.cp != x.bp { - x.cpfx = genCodecPkg + "." - x.linef("%s \"%s\"", genCodecPkg, x.cp) - } - // use a sorted set of im keys, so that we can get consistent output - imKeys := make([]string, 0, len(x.im)) - for k := range x.im { - imKeys = append(imKeys, k) - } - sort.Strings(imKeys) - for _, k := range imKeys { // for k, _ := range x.im { - if k == x.imn[k] { - x.linef("\"%s\"", k) - } else { - x.linef("%s \"%s\"", x.imn[k], k) - } - } - // add required packages - for _, k := range [...]string{"runtime", "errors", "strconv"} { // "reflect", "fmt" - if _, ok := x.im[k]; !ok { - x.line("\"" + k + "\"") - } - } - x.line(")") - x.line("") - - x.line("const (") - x.linef("// ----- content types ----") - x.linef("codecSelferCcUTF8%s = %v", x.xs, int64(cUTF8)) - x.linef("codecSelferCcRAW%s = %v", x.xs, int64(cRAW)) - x.linef("// ----- value types used ----") - for _, vt := range [...]valueType{ - valueTypeArray, valueTypeMap, valueTypeString, - valueTypeInt, valueTypeUint, valueTypeFloat, - valueTypeNil, - } { - x.linef("codecSelferValueType%s%s = %v", vt.String(), x.xs, int64(vt)) - } - - x.linef("codecSelferBitsize%s = uint8(32 << (^uint(0) >> 63))", x.xs) - x.linef("codecSelferDecContainerLenNil%s = %d", x.xs, int64(decContainerLenNil)) - x.line(")") - x.line("var (") - x.line("errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + " = " + "\nerrors.New(`only encoded map or array can be decoded into a struct`)") - x.line(")") - x.line("") - - x.hn = "codecSelfer" + x.xs - x.line("type " + x.hn + " struct{}") - x.line("") - x.linef("func %sFalse() bool { return false }", x.hn) - x.line("") - x.varsfxreset() - x.line("func init() {") - x.linef("if %sGenVersion != %v {", x.cpfx, genVersion) - x.line("_, file, _, _ := runtime.Caller(0)") - x.linef("ver := strconv.FormatInt(int64(%sGenVersion), 10)", x.cpfx) - x.outf(`panic("codecgen version mismatch: current: %v, need " + ver + ". Re-generate file: " + file)`, genVersion) - x.linef("}") - if len(imKeys) > 0 { - x.line("if false { // reference the types, but skip this branch at build/run time") - for _, k := range imKeys { - t := x.im[k] - x.linef("var _ %s.%s", x.imn[k], t.Name()) - } - x.line("} ") // close if false - } - x.line("}") // close init - x.line("") - - // generate rest of type info - for _, t := range typ { - x.tc = t - x.selfer(true) - x.selfer(false) - } - - for _, t := range x.ts { - rtid := rt2id(t) - // generate enc functions for all these slice/map types. - x.varsfxreset() - x.linef("func (x %s) enc%s(v %s%s, e *%sEncoder) {", x.hn, x.genMethodNameT(t), x.arr2str(t, "*"), x.genTypeName(t), x.cpfx) - x.genRequiredMethodVars(true) - switch t.Kind() { - case reflect.Array, reflect.Slice, reflect.Chan: - x.encListFallback("v", t) - case reflect.Map: - x.encMapFallback("v", t) - default: - panic(errGenExpectArrayOrMap) - } - x.line("}") - x.line("") - - // generate dec functions for all these slice/map types. - x.varsfxreset() - x.linef("func (x %s) dec%s(v *%s, d *%sDecoder) {", x.hn, x.genMethodNameT(t), x.genTypeName(t), x.cpfx) - x.genRequiredMethodVars(false) - switch t.Kind() { - case reflect.Array, reflect.Slice, reflect.Chan: - x.decListFallback("v", rtid, t) - case reflect.Map: - x.decMapFallback("v", rtid, t) - default: - panic(errGenExpectArrayOrMap) - } - x.line("}") - x.line("") - } - - x.line("") -} - -func (x *genRunner) checkForSelfer(t reflect.Type, varname string) bool { - // return varname != genTopLevelVarName && t != x.tc - // the only time we checkForSelfer is if we are not at the TOP of the generated code. - return varname != genTopLevelVarName -} - -func (x *genRunner) arr2str(t reflect.Type, s string) string { - if t.Kind() == reflect.Array { - return s - } - return "" -} - -func (x *genRunner) genRequiredMethodVars(encode bool) { - x.line("var h " + x.hn) - if encode { - x.line("z, r := " + x.cpfx + "GenHelperEncoder(e)") - } else { - x.line("z, r := " + x.cpfx + "GenHelperDecoder(d)") - } - x.line("_, _, _ = h, z, r") -} - -func (x *genRunner) genRefPkgs(t reflect.Type) { - if _, ok := x.is[t]; ok { - return - } - x.is[t] = struct{}{} - tpkg, tname := genImportPath(t), t.Name() - if tpkg != "" && tpkg != x.bp && tpkg != x.cp && tname != "" && tname[0] >= 'A' && tname[0] <= 'Z' { - if _, ok := x.im[tpkg]; !ok { - x.im[tpkg] = t - if idx := strings.LastIndex(tpkg, "/"); idx < 0 { - x.imn[tpkg] = tpkg - } else { - x.imc++ - x.imn[tpkg] = "pkg" + strconv.FormatUint(x.imc, 10) + "_" + genGoIdentifier(tpkg[idx+1:], false) - } - } - } - switch t.Kind() { - case reflect.Array, reflect.Slice, reflect.Ptr, reflect.Chan: - x.genRefPkgs(t.Elem()) - case reflect.Map: - x.genRefPkgs(t.Elem()) - x.genRefPkgs(t.Key()) - case reflect.Struct: - for i := 0; i < t.NumField(); i++ { - if fname := t.Field(i).Name; fname != "" && fname[0] >= 'A' && fname[0] <= 'Z' { - x.genRefPkgs(t.Field(i).Type) - } - } - } -} - -// sayFalse will either say "false" or use a function call that returns false. -func (x *genRunner) sayFalse() string { - x.f++ - if x.f%2 == 0 { - return x.hn + "False()" - } - return "false" -} - -func (x *genRunner) varsfx() string { - x.c++ - return strconv.FormatUint(x.c, 10) -} - -func (x *genRunner) varsfxreset() { - x.c = 0 -} - -func (x *genRunner) out(s string) { - _, err := io.WriteString(x.w, s) - if err != nil { - panic(err) - } -} - -func (x *genRunner) outf(s string, params ...interface{}) { - _, err := fmt.Fprintf(x.w, s, params...) - if err != nil { - panic(err) - } -} - -func (x *genRunner) line(s string) { - x.out(s) - if len(s) == 0 || s[len(s)-1] != '\n' { - x.out("\n") - } -} - -func (x *genRunner) lineIf(s string) { - if s != "" { - x.line(s) - } -} - -func (x *genRunner) linef(s string, params ...interface{}) { - x.outf(s, params...) - if len(s) == 0 || s[len(s)-1] != '\n' { - x.out("\n") - } -} - -func (x *genRunner) genTypeName(t reflect.Type) (n string) { - // defer func() { xdebugf(">>>> ####: genTypeName: t: %v, name: '%s'\n", t, n) }() - - // if the type has a PkgPath, which doesn't match the current package, - // then include it. - // We cannot depend on t.String() because it includes current package, - // or t.PkgPath because it includes full import path, - // - var ptrPfx string - for t.Kind() == reflect.Ptr { - ptrPfx += "*" - t = t.Elem() - } - if tn := t.Name(); tn != "" { - return ptrPfx + x.genTypeNamePrim(t) - } - switch t.Kind() { - case reflect.Map: - return ptrPfx + "map[" + x.genTypeName(t.Key()) + "]" + x.genTypeName(t.Elem()) - case reflect.Slice: - return ptrPfx + "[]" + x.genTypeName(t.Elem()) - case reflect.Array: - return ptrPfx + "[" + strconv.FormatInt(int64(t.Len()), 10) + "]" + x.genTypeName(t.Elem()) - case reflect.Chan: - return ptrPfx + t.ChanDir().String() + " " + x.genTypeName(t.Elem()) - default: - if t == intfTyp { - return ptrPfx + "interface{}" - } else { - return ptrPfx + x.genTypeNamePrim(t) - } - } -} - -func (x *genRunner) genTypeNamePrim(t reflect.Type) (n string) { - if t.Name() == "" { - return t.String() - } else if genImportPath(t) == "" || genImportPath(t) == genImportPath(x.tc) { - return t.Name() - } else { - return x.imn[genImportPath(t)] + "." + t.Name() - // return t.String() // best way to get the package name inclusive - } -} - -func (x *genRunner) genZeroValueR(t reflect.Type) string { - // if t is a named type, w - switch t.Kind() { - case reflect.Ptr, reflect.Interface, reflect.Chan, reflect.Func, - reflect.Slice, reflect.Map, reflect.Invalid: - return "nil" - case reflect.Bool: - return "false" - case reflect.String: - return `""` - case reflect.Struct, reflect.Array: - return x.genTypeName(t) + "{}" - default: // all numbers - return "0" - } -} - -func (x *genRunner) genMethodNameT(t reflect.Type) (s string) { - return genMethodNameT(t, x.tc) -} - -func (x *genRunner) selfer(encode bool) { - t := x.tc - t0 := t - // always make decode use a pointer receiver, - // and structs/arrays always use a ptr receiver (encode|decode) - isptr := !encode || t.Kind() == reflect.Array || (t.Kind() == reflect.Struct && t != timeTyp) - x.varsfxreset() - - fnSigPfx := "func (" + genTopLevelVarName + " " - if isptr { - fnSigPfx += "*" - } - fnSigPfx += x.genTypeName(t) - x.out(fnSigPfx) - - if isptr { - t = reflect.PtrTo(t) - } - if encode { - x.line(") CodecEncodeSelf(e *" + x.cpfx + "Encoder) {") - x.genRequiredMethodVars(true) - x.encVar(genTopLevelVarName, t) - } else { - x.line(") CodecDecodeSelf(d *" + x.cpfx + "Decoder) {") - x.genRequiredMethodVars(false) - // do not use decVar, as there is no need to check TryDecodeAsNil - // or way to elegantly handle that, and also setting it to a - // non-nil value doesn't affect the pointer passed. - // x.decVar(genTopLevelVarName, t, false) - x.dec(genTopLevelVarName, t0, true) - } - x.line("}") - x.line("") - - if encode || t0.Kind() != reflect.Struct { - return - } - - // write is containerMap - if genUseOneFunctionForDecStructMap { - x.out(fnSigPfx) - x.line(") codecDecodeSelfFromMap(l int, d *" + x.cpfx + "Decoder) {") - x.genRequiredMethodVars(false) - x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleConsolidated) - x.line("}") - x.line("") - } else { - x.out(fnSigPfx) - x.line(") codecDecodeSelfFromMapLenPrefix(l int, d *" + x.cpfx + "Decoder) {") - x.genRequiredMethodVars(false) - x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleLenPrefix) - x.line("}") - x.line("") - - x.out(fnSigPfx) - x.line(") codecDecodeSelfFromMapCheckBreak(l int, d *" + x.cpfx + "Decoder) {") - x.genRequiredMethodVars(false) - x.decStructMap(genTopLevelVarName, "l", rt2id(t0), t0, genStructMapStyleCheckBreak) - x.line("}") - x.line("") - } - - // write containerArray - x.out(fnSigPfx) - x.line(") codecDecodeSelfFromArray(l int, d *" + x.cpfx + "Decoder) {") - x.genRequiredMethodVars(false) - x.decStructArray(genTopLevelVarName, "l", "return", rt2id(t0), t0) - x.line("}") - x.line("") - -} - -// used for chan, array, slice, map -func (x *genRunner) xtraSM(varname string, t reflect.Type, encode, isptr bool) { - var ptrPfx, addrPfx string - if isptr { - ptrPfx = "*" - } else { - addrPfx = "&" - } - if encode { - x.linef("h.enc%s((%s%s)(%s), e)", x.genMethodNameT(t), ptrPfx, x.genTypeName(t), varname) - } else { - x.linef("h.dec%s((*%s)(%s%s), d)", x.genMethodNameT(t), x.genTypeName(t), addrPfx, varname) - } - x.registerXtraT(t) -} - -func (x *genRunner) registerXtraT(t reflect.Type) { - // recursively register the types - if _, ok := x.tm[t]; ok { - return - } - var tkey reflect.Type - switch t.Kind() { - case reflect.Chan, reflect.Slice, reflect.Array: - case reflect.Map: - tkey = t.Key() - default: - return - } - x.tm[t] = struct{}{} - x.ts = append(x.ts, t) - // check if this refers to any xtra types eg. a slice of array: add the array - x.registerXtraT(t.Elem()) - if tkey != nil { - x.registerXtraT(tkey) - } -} - -// encVar will encode a variable. -// The parameter, t, is the reflect.Type of the variable itself -func (x *genRunner) encVar(varname string, t reflect.Type) { - var checkNil bool - // case reflect.Ptr, reflect.Interface, reflect.Slice, reflect.Map, reflect.Chan: - // do not include checkNil for slice and maps, as we already checkNil below it - switch t.Kind() { - case reflect.Ptr, reflect.Interface, reflect.Chan: - checkNil = true - } - x.encVarChkNil(varname, t, checkNil) -} - -func (x *genRunner) encVarChkNil(varname string, t reflect.Type, checkNil bool) { - if checkNil { - x.linef("if %s == nil { r.EncodeNil() } else {", varname) - } - - switch t.Kind() { - case reflect.Ptr: - telem := t.Elem() - tek := telem.Kind() - if tek == reflect.Array || (tek == reflect.Struct && telem != timeTyp) { - x.enc(varname, genNonPtr(t)) - break - } - i := x.varsfx() - x.line(genTempVarPfx + i + " := *" + varname) - x.enc(genTempVarPfx+i, genNonPtr(t)) - case reflect.Struct, reflect.Array: - if t == timeTyp { - x.enc(varname, t) - break - } - i := x.varsfx() - x.line(genTempVarPfx + i + " := &" + varname) - x.enc(genTempVarPfx+i, t) - default: - x.enc(varname, t) - } - - if checkNil { - x.line("}") - } -} - -// enc will encode a variable (varname) of type t, where t represents T. -// if t is !time.Time and t is of kind reflect.Struct or reflect.Array, varname is of type *T -// (to prevent copying), -// else t is of type T -func (x *genRunner) enc(varname string, t reflect.Type) { - rtid := rt2id(t) - ti2 := x.ti.get(rtid, t) - // We call CodecEncodeSelf if one of the following are honored: - // - the type already implements Selfer, call that - // - the type has a Selfer implementation just created, use that - // - the type is in the list of the ones we will generate for, but it is not currently being generated - - mi := x.varsfx() - // tptr := reflect.PtrTo(t) - tk := t.Kind() - if x.checkForSelfer(t, varname) { - if tk == reflect.Array || - (tk == reflect.Struct && rtid != timeTypId) { // varname is of type *T - // if tptr.Implements(selferTyp) || t.Implements(selferTyp) { - if ti2.isFlag(tiflagSelfer) || ti2.isFlag(tiflagSelferPtr) { - x.line(varname + ".CodecEncodeSelf(e)") - return - } - } else { // varname is of type T - if ti2.isFlag(tiflagSelfer) { - x.line(varname + ".CodecEncodeSelf(e)") - return - } else if ti2.isFlag(tiflagSelferPtr) { - x.linef("%ssf%s := &%s", genTempVarPfx, mi, varname) - x.linef("%ssf%s.CodecEncodeSelf(e)", genTempVarPfx, mi) - return - } - } - - if _, ok := x.te[rtid]; ok { - x.line(varname + ".CodecEncodeSelf(e)") - return - } - } - - inlist := false - for _, t0 := range x.t { - if t == t0 { - inlist = true - if x.checkForSelfer(t, varname) { - x.line(varname + ".CodecEncodeSelf(e)") - return - } - break - } - } - - var rtidAdded bool - if t == x.tc { - x.te[rtid] = true - rtidAdded = true - } - - // check if - // - type is time.Time, RawExt, Raw - // - the type implements (Text|JSON|Binary)(Unm|M)arshal - - var hasIf genIfClause - defer hasIf.end(x) // end if block (if necessary) - - if t == timeTyp { - x.linef("%s !z.EncBasicHandle().TimeNotBuiltin { r.EncodeTime(%s)", hasIf.c(false), varname) - // return - } - if t == rawTyp { - x.linef("%s z.EncRaw(%s)", hasIf.c(true), varname) - return - } - if t == rawExtTyp { - x.linef("%s r.EncodeRawExt(%s)", hasIf.c(true), varname) - return - } - // only check for extensions if extensions are configured, - // and the type is named, and has a packagePath, - // and this is not the CodecEncodeSelf or CodecDecodeSelf method (i.e. it is not a Selfer) - var arrayOrStruct = tk == reflect.Array || tk == reflect.Struct // meaning varname if of type *T - if !x.nx && varname != genTopLevelVarName && genImportPath(t) != "" && t.Name() != "" { - yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi) - x.linef("%s %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.EncExtension(%s, %s) ", - hasIf.c(false), yy, varname, yy, varname, yy) - } - if arrayOrStruct { // varname is of type *T - if ti2.isFlag(tiflagBinaryMarshaler) || ti2.isFlag(tiflagBinaryMarshalerPtr) { - x.linef("%s z.EncBinary() { z.EncBinaryMarshal(%v) ", hasIf.c(false), varname) - } - if ti2.isFlag(tiflagJsonMarshaler) || ti2.isFlag(tiflagJsonMarshalerPtr) { - x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagTextUnmarshaler) || ti2.isFlag(tiflagTextUnmarshalerPtr) { - x.linef("%s !z.EncBinary() { z.EncTextMarshal(%v) ", hasIf.c(false), varname) - } - } else { // varname is of type T - if ti2.isFlag(tiflagBinaryMarshaler) { - x.linef("%s z.EncBinary() { z.EncBinaryMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagBinaryMarshalerPtr) { - x.linef("%s z.EncBinary() { z.EncBinaryMarshal(&%v) ", hasIf.c(false), varname) - } - if ti2.isFlag(tiflagJsonMarshaler) { - x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagJsonMarshalerPtr) { - x.linef("%s !z.EncBinary() && z.IsJSONHandle() { z.EncJSONMarshal(&%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagTextMarshaler) { - x.linef("%s !z.EncBinary() { z.EncTextMarshal(%v) ", hasIf.c(false), varname) - } else if ti2.isFlag(tiflagTextMarshalerPtr) { - x.linef("%s !z.EncBinary() { z.EncTextMarshal(&%v) ", hasIf.c(false), varname) - } - } - x.lineIf(hasIf.c(true)) - - switch t.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - x.line("r.EncodeInt(int64(" + varname + "))") - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - x.line("r.EncodeUint(uint64(" + varname + "))") - case reflect.Float32: - x.line("r.EncodeFloat32(float32(" + varname + "))") - case reflect.Float64: - x.line("r.EncodeFloat64(float64(" + varname + "))") - case reflect.Bool: - x.line("r.EncodeBool(bool(" + varname + "))") - case reflect.String: - x.linef("r.EncodeString(string(%s))", varname) - case reflect.Chan: - x.xtraSM(varname, t, true, false) - // x.encListFallback(varname, rtid, t) - case reflect.Array: - x.xtraSM(varname, t, true, true) - case reflect.Slice: - // if nil, call dedicated function - // if a []uint8, call dedicated function - // if a known fastpath slice, call dedicated function - // else write encode function in-line. - // - if elements are primitives or Selfers, call dedicated function on each member. - // - else call Encoder.encode(XXX) on it. - x.linef("if %s == nil { r.EncodeNil() } else {", varname) - if rtid == uint8SliceTypId { - x.line("r.EncodeStringBytesRaw([]byte(" + varname + "))") - } else if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) - x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)") - } else { - x.xtraSM(varname, t, true, false) - } - x.linef("} // end block: if %s slice == nil", varname) - case reflect.Map: - // if nil, call dedicated function - // if a known fastpath map, call dedicated function - // else write encode function in-line. - // - if elements are primitives or Selfers, call dedicated function on each member. - // - else call Encoder.encode(XXX) on it. - x.linef("if %s == nil { r.EncodeNil() } else {", varname) - if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) - x.line("z.F." + g.MethodNamePfx("Enc", false) + "V(" + varname + ", e)") - } else { - x.xtraSM(varname, t, true, false) - } - x.linef("} // end block: if %s map == nil", varname) - case reflect.Struct: - if !inlist { - delete(x.te, rtid) - x.line("z.EncFallback(" + varname + ")") - break - } - x.encStruct(varname, rtid, t) - default: - if rtidAdded { - delete(x.te, rtid) - } - x.line("z.EncFallback(" + varname + ")") - } -} - -func (x *genRunner) encZero(t reflect.Type) { - switch t.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - x.line("r.EncodeInt(0)") - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - x.line("r.EncodeUint(0)") - case reflect.Float32: - x.line("r.EncodeFloat32(0)") - case reflect.Float64: - x.line("r.EncodeFloat64(0)") - case reflect.Bool: - x.line("r.EncodeBool(false)") - case reflect.String: - x.linef(`r.EncodeString("")`) - default: - x.line("r.EncodeNil()") - } -} - -func (x *genRunner) doEncOmitEmptyLine(t2 reflect.StructField, varname string, buf *genBuf) { - x.f = 0 - x.encOmitEmptyLine(t2, varname, buf) -} - -func (x *genRunner) encOmitEmptyLine(t2 reflect.StructField, varname string, buf *genBuf) { - // smartly check omitEmpty on a struct type, as it may contain uncomparable map/slice/etc. - // also, for maps/slices/arrays, check if len ! 0 (not if == zero value) - varname2 := varname + "." + t2.Name - switch t2.Type.Kind() { - case reflect.Struct: - rtid2 := rt2id(t2.Type) - ti2 := x.ti.get(rtid2, t2.Type) - // fmt.Printf(">>>> structfield: omitempty: type: %s, field: %s\n", t2.Type.Name(), t2.Name) - if ti2.rtid == timeTypId { - buf.s("!(").s(varname2).s(".IsZero())") - break - } - if ti2.isFlag(tiflagIsZeroerPtr) || ti2.isFlag(tiflagIsZeroer) { - buf.s("!(").s(varname2).s(".IsZero())") - break - } - if ti2.isFlag(tiflagComparable) { - buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type)) - break - } - // buf.s("(") - buf.s(x.sayFalse()) // buf.s("false") - for i, n := 0, t2.Type.NumField(); i < n; i++ { - f := t2.Type.Field(i) - if f.PkgPath != "" { // unexported - continue - } - buf.s(" || ") - x.encOmitEmptyLine(f, varname2, buf) - } - //buf.s(")") - case reflect.Bool: - buf.s(varname2) - case reflect.Map, reflect.Slice, reflect.Array, reflect.Chan: - buf.s("len(").s(varname2).s(") != 0") - default: - buf.s(varname2).s(" != ").s(x.genZeroValueR(t2.Type)) - } -} - -func (x *genRunner) encStruct(varname string, rtid uintptr, t reflect.Type) { - // Use knowledge from structfieldinfo (mbs, encodable fields. Ignore omitempty. ) - // replicate code in kStruct i.e. for each field, deref type to non-pointer, and call x.enc on it - - // if t === type currently running selfer on, do for all - ti := x.ti.get(rtid, t) - i := x.varsfx() - sepVarname := genTempVarPfx + "sep" + i - numfieldsvar := genTempVarPfx + "q" + i - ti2arrayvar := genTempVarPfx + "r" + i - struct2arrvar := genTempVarPfx + "2arr" + i - - x.line(sepVarname + " := !z.EncBinary()") - x.linef("%s := z.EncBasicHandle().StructToArray", struct2arrvar) - x.linef("_, _ = %s, %s", sepVarname, struct2arrvar) - x.linef("const %s bool = %v // struct tag has 'toArray'", ti2arrayvar, ti.toArray) - - tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing. - - // var nn int - // due to omitEmpty, we need to calculate the - // number of non-empty things we write out first. - // This is required as we need to pre-determine the size of the container, - // to support length-prefixing. - if ti.anyOmitEmpty { - x.linef("var %s = [%v]bool{ // should field at this index be written?", numfieldsvar, len(tisfi)) - - for j, si := range tisfi { - _ = j - if !si.omitEmpty() { - x.linef("true, // %s", si.fieldName) - continue - } - var t2 reflect.StructField - var omitline genBuf - { - t2typ := t - varname3 := varname - // go through the loop, record the t2 field explicitly, - // and gather the omit line if embedded in pointers. - for ij, ix := range si.is { - if uint8(ij) == si.nis { - break - } - for t2typ.Kind() == reflect.Ptr { - t2typ = t2typ.Elem() - } - t2 = t2typ.Field(int(ix)) - t2typ = t2.Type - varname3 = varname3 + "." + t2.Name - // do not include actual field in the omit line. - // that is done subsequently (right after - below). - if uint8(ij+1) < si.nis && t2typ.Kind() == reflect.Ptr { - omitline.s(varname3).s(" != nil && ") - } - } - } - x.doEncOmitEmptyLine(t2, varname, &omitline) - x.linef("%s, // %s", omitline.v(), si.fieldName) - } - x.line("}") - x.linef("_ = %s", numfieldsvar) - } - - type genFQN struct { - i string - fqname string - nilLine genBuf - nilVar string - canNil bool - sf reflect.StructField - } - - genFQNs := make([]genFQN, len(tisfi)) - for j, si := range tisfi { - q := &genFQNs[j] - q.i = x.varsfx() - q.nilVar = genTempVarPfx + "n" + q.i - q.canNil = false - q.fqname = varname - { - t2typ := t - for ij, ix := range si.is { - if uint8(ij) == si.nis { - break - } - for t2typ.Kind() == reflect.Ptr { - t2typ = t2typ.Elem() - } - q.sf = t2typ.Field(int(ix)) - t2typ = q.sf.Type - q.fqname += "." + q.sf.Name - if t2typ.Kind() == reflect.Ptr { - if !q.canNil { - q.nilLine.f("%s == nil", q.fqname) - q.canNil = true - } else { - q.nilLine.f(" || %s == nil", q.fqname) - } - } - } - } - } - - for j := range genFQNs { - q := &genFQNs[j] - if q.canNil { - x.linef("var %s bool = %s", q.nilVar, q.nilLine.v()) - } - } - - x.linef("if %s || %s {", ti2arrayvar, struct2arrvar) // if ti.toArray - x.linef("z.EncWriteArrayStart(%d)", len(tisfi)) - - for j, si := range tisfi { - q := &genFQNs[j] - // if the type of the field is a Selfer, or one of the ones - if q.canNil { - x.linef("if %s { z.EncWriteArrayElem(); r.EncodeNil() } else { ", q.nilVar) - } - x.linef("z.EncWriteArrayElem()") - if si.omitEmpty() { - x.linef("if %s[%v] {", numfieldsvar, j) - } - x.encVarChkNil(q.fqname, q.sf.Type, false) - if si.omitEmpty() { - x.linef("} else {") - x.encZero(q.sf.Type) - x.linef("}") - } - if q.canNil { - x.line("}") - } - } - - x.line("z.EncWriteArrayEnd()") - x.linef("} else {") // if not ti.toArray - if ti.anyOmitEmpty { - x.linef("var %snn%s int", genTempVarPfx, i) - x.linef("for _, b := range %s { if b { %snn%s++ } }", numfieldsvar, genTempVarPfx, i) - x.linef("z.EncWriteMapStart(%snn%s)", genTempVarPfx, i) - x.linef("%snn%s = %v", genTempVarPfx, i, 0) - } else { - x.linef("z.EncWriteMapStart(%d)", len(tisfi)) - } - - for j, si := range tisfi { - q := &genFQNs[j] - if si.omitEmpty() { - x.linef("if %s[%v] {", numfieldsvar, j) - } - x.linef("z.EncWriteMapElemKey()") - - // emulate EncStructFieldKey - switch ti.keyType { - case valueTypeInt: - x.linef("r.EncodeInt(z.M.Int(strconv.ParseInt(`%s`, 10, 64)))", si.encName) - case valueTypeUint: - x.linef("r.EncodeUint(z.M.Uint(strconv.ParseUint(`%s`, 10, 64)))", si.encName) - case valueTypeFloat: - x.linef("r.EncodeFloat64(z.M.Float(strconv.ParseFloat(`%s`, 64)))", si.encName) - default: // string - if si.encNameAsciiAlphaNum { - x.linef(`if z.IsJSONHandle() { z.WriteStr("\"%s\"") } else { `, si.encName) - } - x.linef("r.EncodeString(`%s`)", si.encName) - if si.encNameAsciiAlphaNum { - x.linef("}") - } - } - x.line("z.EncWriteMapElemValue()") - if q.canNil { - x.line("if " + q.nilVar + " { r.EncodeNil() } else { ") - x.encVarChkNil(q.fqname, q.sf.Type, false) - x.line("}") - } else { - x.encVarChkNil(q.fqname, q.sf.Type, false) - } - if si.omitEmpty() { - x.line("}") - } - } - x.line("z.EncWriteMapEnd()") - x.linef("} ") // end if/else ti.toArray -} - -func (x *genRunner) encListFallback(varname string, t reflect.Type) { - x.linef("if %s == nil { r.EncodeNil(); return }", varname) - elemBytes := t.Elem().Kind() == reflect.Uint8 - if t.AssignableTo(uint8SliceTyp) { - x.linef("r.EncodeStringBytesRaw([]byte(%s))", varname) - return - } - if t.Kind() == reflect.Array && elemBytes { - x.linef("r.EncodeStringBytesRaw(((*[%d]byte)(%s))[:])", t.Len(), varname) - return - } - i := x.varsfx() - if t.Kind() == reflect.Chan { - type ts struct { - Label, Chan, Slice, Sfx string - } - tm, err := template.New("").Parse(genEncChanTmpl) - if err != nil { - panic(err) - } - x.linef("if %s == nil { r.EncodeNil() } else { ", varname) - x.linef("var sch%s []%s", i, x.genTypeName(t.Elem())) - err = tm.Execute(x.w, &ts{"Lsch" + i, varname, "sch" + i, i}) - if err != nil { - panic(err) - } - if elemBytes { - x.linef("r.EncodeStringBytesRaw([]byte(%s))", "sch"+i) - x.line("}") - return - } - varname = "sch" + i - } - - x.line("z.EncWriteArrayStart(len(" + varname + "))") - x.linef("for _, %sv%s := range %s {", genTempVarPfx, i, varname) - x.linef("z.EncWriteArrayElem()") - - x.encVar(genTempVarPfx+"v"+i, t.Elem()) - x.line("}") - x.line("z.EncWriteArrayEnd()") - if t.Kind() == reflect.Chan { - x.line("}") - } -} - -func (x *genRunner) encMapFallback(varname string, t reflect.Type) { - x.linef("if %s == nil { r.EncodeNil(); return }", varname) - // NOTE: Canonical Option is not honored - i := x.varsfx() - x.line("z.EncWriteMapStart(len(" + varname + "))") - x.linef("for %sk%s, %sv%s := range %s {", genTempVarPfx, i, genTempVarPfx, i, varname) - x.linef("z.EncWriteMapElemKey()") - x.encVar(genTempVarPfx+"k"+i, t.Key()) - x.line("z.EncWriteMapElemValue()") - x.encVar(genTempVarPfx+"v"+i, t.Elem()) - x.line("}") - x.line("z.EncWriteMapEnd()") -} - -func (x *genRunner) decVarInitPtr(varname, nilvar string, t reflect.Type, si *structFieldInfo, - newbuf, nilbuf *genBuf) (varname3 string, t2 reflect.StructField) { - //we must accommodate anonymous fields, where the embedded field is a nil pointer in the value. - // t2 = t.FieldByIndex(si.is) - varname3 = varname - t2typ := t - t2kind := t2typ.Kind() - var nilbufed bool - if si != nil { - for ij, ix := range si.is { - if uint8(ij) == si.nis { - break - } - // only one-level pointers can be seen in a type - if t2typ.Kind() == reflect.Ptr { - t2typ = t2typ.Elem() - } - t2 = t2typ.Field(int(ix)) - t2typ = t2.Type - varname3 = varname3 + "." + t2.Name - t2kind = t2typ.Kind() - if t2kind != reflect.Ptr { - continue - } - if newbuf != nil { - if len(newbuf.buf) > 0 { - newbuf.s("\n") - } - newbuf.f("if %s == nil { %s = new(%s) }", varname3, varname3, x.genTypeName(t2typ.Elem())) - } - if nilbuf != nil { - if !nilbufed { - nilbuf.s("if ").s(varname3).s(" != nil") - nilbufed = true - } else { - nilbuf.s(" && ").s(varname3).s(" != nil") - } - } - } - } - if nilbuf != nil { - if nilbufed { - nilbuf.s(" { ").s("// remove the if-true\n") - } - if nilvar != "" { - nilbuf.s(nilvar).s(" = true") - } else if tk := t2typ.Kind(); tk == reflect.Ptr { - if strings.IndexByte(varname3, '.') != -1 || strings.IndexByte(varname3, '[') != -1 { - nilbuf.s(varname3).s(" = nil") - } else { - nilbuf.s("*").s(varname3).s(" = ").s(x.genZeroValueR(t2typ.Elem())) - } - } else { - nilbuf.s(varname3).s(" = ").s(x.genZeroValueR(t2typ)) - } - if nilbufed { - nilbuf.s("}") - } - } - return -} - -// decVar takes a variable called varname, of type t -func (x *genRunner) decVarMain(varname, rand string, t reflect.Type, checkNotNil bool) { - // We only encode as nil if a nillable value. - // This removes some of the wasted checks for TryDecodeAsNil. - // We need to think about this more, to see what happens if omitempty, etc - // cause a nil value to be stored when something is expected. - // This could happen when decoding from a struct encoded as an array. - // For that, decVar should be called with canNil=true, to force true as its value. - var varname2 string - if t.Kind() != reflect.Ptr { - if t.PkgPath() != "" || !x.decTryAssignPrimitive(varname, t, false) { - x.dec(varname, t, false) - } - } else { - if checkNotNil { - x.linef("if %s == nil { %s = new(%s) }", varname, varname, x.genTypeName(t.Elem())) - } - // Ensure we set underlying ptr to a non-nil value (so we can deref to it later). - // There's a chance of a **T in here which is nil. - var ptrPfx string - for t = t.Elem(); t.Kind() == reflect.Ptr; t = t.Elem() { - ptrPfx += "*" - if checkNotNil { - x.linef("if %s%s == nil { %s%s = new(%s)}", ptrPfx, varname, ptrPfx, varname, x.genTypeName(t)) - } - } - // Should we create temp var if a slice/map indexing? No. dec(...) can now handle it. - - if ptrPfx == "" { - x.dec(varname, t, true) - } else { - varname2 = genTempVarPfx + "z" + rand - x.line(varname2 + " := " + ptrPfx + varname) - x.dec(varname2, t, true) - } - } -} - -// decVar takes a variable called varname, of type t -func (x *genRunner) decVar(varname, nilvar string, t reflect.Type, canBeNil, checkNotNil bool) { - - // We only encode as nil if a nillable value. - // This removes some of the wasted checks for TryDecodeAsNil. - // We need to think about this more, to see what happens if omitempty, etc - // cause a nil value to be stored when something is expected. - // This could happen when decoding from a struct encoded as an array. - // For that, decVar should be called with canNil=true, to force true as its value. - - i := x.varsfx() - if t.Kind() == reflect.Ptr { - var buf genBuf - x.decVarInitPtr(varname, nilvar, t, nil, nil, &buf) - x.linef("if r.TryNil() { %s } else {", buf.buf) - x.decVarMain(varname, i, t, checkNotNil) - x.line("} ") - } else { - x.decVarMain(varname, i, t, checkNotNil) - } -} - -// dec will decode a variable (varname) of type t or ptrTo(t) if isptr==true. -// t is always a basetype (i.e. not of kind reflect.Ptr). -func (x *genRunner) dec(varname string, t reflect.Type, isptr bool) { - // assumptions: - // - the varname is to a pointer already. No need to take address of it - // - t is always a baseType T (not a *T, etc). - rtid := rt2id(t) - ti2 := x.ti.get(rtid, t) - if x.checkForSelfer(t, varname) { - if ti2.isFlag(tiflagSelfer) || ti2.isFlag(tiflagSelferPtr) { - x.line(varname + ".CodecDecodeSelf(d)") - return - } - if _, ok := x.td[rtid]; ok { - x.line(varname + ".CodecDecodeSelf(d)") - return - } - } - - inlist := false - for _, t0 := range x.t { - if t == t0 { - inlist = true - if x.checkForSelfer(t, varname) { - x.line(varname + ".CodecDecodeSelf(d)") - return - } - break - } - } - - var rtidAdded bool - if t == x.tc { - x.td[rtid] = true - rtidAdded = true - } - - // check if - // - type is time.Time, Raw, RawExt - // - the type implements (Text|JSON|Binary)(Unm|M)arshal - - mi := x.varsfx() - - var hasIf genIfClause - defer hasIf.end(x) - - var ptrPfx, addrPfx string - if isptr { - ptrPfx = "*" - } else { - addrPfx = "&" - } - if t == timeTyp { - x.linef("%s !z.DecBasicHandle().TimeNotBuiltin { %s%v = r.DecodeTime()", hasIf.c(false), ptrPfx, varname) - // return - } - if t == rawTyp { - x.linef("%s %s%v = z.DecRaw()", hasIf.c(true), ptrPfx, varname) - return - } - - if t == rawExtTyp { - x.linef("%s r.DecodeExt(%s%v, 0, nil)", hasIf.c(true), addrPfx, varname) - return - } - - // only check for extensions if extensions are configured, - // and the type is named, and has a packagePath, - // and this is not the CodecEncodeSelf or CodecDecodeSelf method (i.e. it is not a Selfer) - if !x.nx && varname != genTopLevelVarName && genImportPath(t) != "" && t.Name() != "" { - // first check if extensions are configued, before doing the interface conversion - yy := fmt.Sprintf("%sxt%s", genTempVarPfx, mi) - x.linef("%s %s := z.Extension(z.I2Rtid(%s)); %s != nil { z.DecExtension(%s, %s) ", hasIf.c(false), yy, varname, yy, varname, yy) - } - - if ti2.isFlag(tiflagBinaryUnmarshaler) || ti2.isFlag(tiflagBinaryUnmarshalerPtr) { - x.linef("%s z.DecBinary() { z.DecBinaryUnmarshal(%s%v) ", hasIf.c(false), addrPfx, varname) - } - if ti2.isFlag(tiflagJsonUnmarshaler) || ti2.isFlag(tiflagJsonUnmarshalerPtr) { - x.linef("%s !z.DecBinary() && z.IsJSONHandle() { z.DecJSONUnmarshal(%s%v)", hasIf.c(false), addrPfx, varname) - } else if ti2.isFlag(tiflagTextUnmarshaler) || ti2.isFlag(tiflagTextUnmarshalerPtr) { - x.linef("%s !z.DecBinary() { z.DecTextUnmarshal(%s%v)", hasIf.c(false), addrPfx, varname) - } - - x.lineIf(hasIf.c(true)) - - if x.decTryAssignPrimitive(varname, t, isptr) { - return - } - - switch t.Kind() { - case reflect.Array, reflect.Chan: - x.xtraSM(varname, t, false, isptr) - case reflect.Slice: - // if a []uint8, call dedicated function - // if a known fastpath slice, call dedicated function - // else write encode function in-line. - // - if elements are primitives or Selfers, call dedicated function on each member. - // - else call Encoder.encode(XXX) on it. - if rtid == uint8SliceTypId { - x.linef("%s%s = r.DecodeBytes(%s(%s[]byte)(%s), false)", - ptrPfx, varname, ptrPfx, ptrPfx, varname) - } else if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) - x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname) - } else { - x.xtraSM(varname, t, false, isptr) - // x.decListFallback(varname, rtid, false, t) - } - case reflect.Map: - // if a known fastpath map, call dedicated function - // else write encode function in-line. - // - if elements are primitives or Selfers, call dedicated function on each member. - // - else call Encoder.encode(XXX) on it. - if fastpathAV.index(rtid) != -1 { - g := x.newFastpathGenV(t) - x.linef("z.F.%sX(%s%s, d)", g.MethodNamePfx("Dec", false), addrPfx, varname) - } else { - x.xtraSM(varname, t, false, isptr) - } - case reflect.Struct: - if inlist { - // no need to create temp variable if isptr, or x.F or x[F] - if isptr || strings.IndexByte(varname, '.') != -1 || strings.IndexByte(varname, '[') != -1 { - x.decStruct(varname, rtid, t) - } else { - varname2 := genTempVarPfx + "j" + mi - x.line(varname2 + " := &" + varname) - x.decStruct(varname2, rtid, t) - } - } else { - // delete(x.td, rtid) - x.line("z.DecFallback(" + addrPfx + varname + ", false)") - } - default: - if rtidAdded { - delete(x.te, rtid) - } - x.line("z.DecFallback(" + addrPfx + varname + ", true)") - } -} - -func (x *genRunner) decTryAssignPrimitive(varname string, t reflect.Type, isptr bool) (done bool) { - // This should only be used for exact primitives (ie un-named types). - // Named types may be implementations of Selfer, Unmarshaler, etc. - // They should be handled by dec(...) - - var ptr string - if isptr { - ptr = "*" - } - switch t.Kind() { - case reflect.Int: - x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs) - case reflect.Int8: - x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 8))", ptr, varname, x.genTypeName(t)) - case reflect.Int16: - x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 16))", ptr, varname, x.genTypeName(t)) - case reflect.Int32: - x.linef("%s%s = (%s)(z.C.IntV(r.DecodeInt64(), 32))", ptr, varname, x.genTypeName(t)) - case reflect.Int64: - x.linef("%s%s = (%s)(r.DecodeInt64())", ptr, varname, x.genTypeName(t)) - - case reflect.Uint: - x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs) - case reflect.Uint8: - x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 8))", ptr, varname, x.genTypeName(t)) - case reflect.Uint16: - x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 16))", ptr, varname, x.genTypeName(t)) - case reflect.Uint32: - x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), 32))", ptr, varname, x.genTypeName(t)) - case reflect.Uint64: - x.linef("%s%s = (%s)(r.DecodeUint64())", ptr, varname, x.genTypeName(t)) - case reflect.Uintptr: - x.linef("%s%s = (%s)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize%s))", ptr, varname, x.genTypeName(t), x.xs) - - case reflect.Float32: - x.linef("%s%s = (%s)(z.DecDecodeFloat32())", ptr, varname, x.genTypeName(t)) - case reflect.Float64: - x.linef("%s%s = (%s)(r.DecodeFloat64())", ptr, varname, x.genTypeName(t)) - - case reflect.Bool: - x.linef("%s%s = (%s)(r.DecodeBool())", ptr, varname, x.genTypeName(t)) - case reflect.String: - x.linef("%s%s = (%s)(string(r.DecodeStringAsBytes()))", ptr, varname, x.genTypeName(t)) - default: - return false - } - return true -} - -func (x *genRunner) decListFallback(varname string, rtid uintptr, t reflect.Type) { - if t.AssignableTo(uint8SliceTyp) { - x.line("*" + varname + " = r.DecodeBytes(*((*[]byte)(" + varname + ")), false)") - return - } - if t.Kind() == reflect.Array && t.Elem().Kind() == reflect.Uint8 { - x.linef("r.DecodeBytes( ((*[%d]byte)(%s))[:], true)", t.Len(), varname) - return - } - type tstruc struct { - TempVar string - Sfx string - Rand string - Varname string - CTyp string - Typ string - Immutable bool - Size int - } - telem := t.Elem() - ts := tstruc{genTempVarPfx, x.xs, x.varsfx(), varname, x.genTypeName(t), x.genTypeName(telem), genIsImmutable(telem), int(telem.Size())} - - funcs := make(template.FuncMap) - - funcs["decLineVar"] = func(varname string) string { - x.decVar(varname, "", telem, false, true) - return "" - } - funcs["var"] = func(s string) string { - return ts.TempVar + s + ts.Rand - } - funcs["xs"] = func() string { - return ts.Sfx - } - funcs["zero"] = func() string { - return x.genZeroValueR(telem) - } - funcs["isArray"] = func() bool { - return t.Kind() == reflect.Array - } - funcs["isSlice"] = func() bool { - return t.Kind() == reflect.Slice - } - funcs["isChan"] = func() bool { - return t.Kind() == reflect.Chan - } - tm, err := template.New("").Funcs(funcs).Parse(genDecListTmpl) - if err != nil { - panic(err) - } - if err = tm.Execute(x.w, &ts); err != nil { - panic(err) - } -} - -func (x *genRunner) decMapFallback(varname string, rtid uintptr, t reflect.Type) { - type tstruc struct { - TempVar string - Sfx string - Rand string - Varname string - KTyp string - Typ string - Size int - } - telem := t.Elem() - tkey := t.Key() - ts := tstruc{ - genTempVarPfx, x.xs, x.varsfx(), varname, x.genTypeName(tkey), - x.genTypeName(telem), int(telem.Size() + tkey.Size()), - } - - funcs := make(template.FuncMap) - funcs["decElemZero"] = func() string { - return x.genZeroValueR(telem) - } - funcs["decElemKindImmutable"] = func() bool { - return genIsImmutable(telem) - } - funcs["decElemKindPtr"] = func() bool { - return telem.Kind() == reflect.Ptr - } - funcs["decElemKindIntf"] = func() bool { - return telem.Kind() == reflect.Interface - } - funcs["decLineVarK"] = func(varname string) string { - x.decVar(varname, "", tkey, false, true) - return "" - } - funcs["decLineVar"] = func(varname, decodedNilVarname string) string { - x.decVar(varname, decodedNilVarname, telem, false, true) - return "" - } - funcs["var"] = func(s string) string { - return ts.TempVar + s + ts.Rand - } - funcs["xs"] = func() string { - return ts.Sfx - } - - tm, err := template.New("").Funcs(funcs).Parse(genDecMapTmpl) - if err != nil { - panic(err) - } - if err = tm.Execute(x.w, &ts); err != nil { - panic(err) - } -} - -func (x *genRunner) decStructMapSwitch(kName string, varname string, rtid uintptr, t reflect.Type) { - ti := x.ti.get(rtid, t) - tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing. - x.line("switch (" + kName + ") {") - var newbuf, nilbuf genBuf - for _, si := range tisfi { - x.line("case \"" + si.encName + "\":") - newbuf.reset() - nilbuf.reset() - varname3, t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf) - if len(newbuf.buf) > 0 { - x.linef("if r.TryNil() { %s } else { %s", nilbuf.buf, newbuf.buf) - } - x.decVarMain(varname3, x.varsfx(), t2.Type, false) - if len(newbuf.buf) > 0 { - x.line("}") - } - } - x.line("default:") - // pass the slice here, so that the string will not escape, and maybe save allocation - x.line("z.DecStructFieldNotFound(-1, " + kName + ")") - x.line("} // end switch " + kName) -} - -func (x *genRunner) decStructMap(varname, lenvarname string, rtid uintptr, t reflect.Type, style genStructMapStyle) { - tpfx := genTempVarPfx - ti := x.ti.get(rtid, t) - i := x.varsfx() - kName := tpfx + "s" + i - - switch style { - case genStructMapStyleLenPrefix: - x.linef("for %sj%s := 0; %sj%s < %s; %sj%s++ {", tpfx, i, tpfx, i, lenvarname, tpfx, i) - case genStructMapStyleCheckBreak: - x.linef("for %sj%s := 0; !z.DecCheckBreak(); %sj%s++ {", tpfx, i, tpfx, i) - default: // 0, otherwise. - x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length - x.linef("for %sj%s := 0; ; %sj%s++ {", tpfx, i, tpfx, i) - x.linef("if %shl%s { if %sj%s >= %s { break }", tpfx, i, tpfx, i, lenvarname) - x.line("} else { if z.DecCheckBreak() { break }; }") - } - x.line("z.DecReadMapElemKey()") - - // emulate decstructfieldkey - switch ti.keyType { - case valueTypeInt: - x.linef("%s := z.StringView(strconv.AppendInt(z.DecScratchArrayBuffer()[:0], r.DecodeInt64(), 10))", kName) - case valueTypeUint: - x.linef("%s := z.StringView(strconv.AppendUint(z.DecScratchArrayBuffer()[:0], r.DecodeUint64(), 10))", kName) - case valueTypeFloat: - x.linef("%s := z.StringView(strconv.AppendFloat(z.DecScratchArrayBuffer()[:0], r.DecodeFloat64(), 'f', -1, 64))", kName) - default: // string - x.linef("%s := z.StringView(r.DecodeStringAsBytes())", kName) - } - - x.line("z.DecReadMapElemValue()") - x.decStructMapSwitch(kName, varname, rtid, t) - - x.line("} // end for " + tpfx + "j" + i) -} - -func (x *genRunner) decStructArray(varname, lenvarname, breakString string, rtid uintptr, t reflect.Type) { - tpfx := genTempVarPfx - i := x.varsfx() - ti := x.ti.get(rtid, t) - tisfi := ti.sfiSrc // always use sequence from file. decStruct expects same thing. - x.linef("var %sj%s int", tpfx, i) - x.linef("var %sb%s bool", tpfx, i) // break - x.linef("var %shl%s bool = %s >= 0", tpfx, i, lenvarname) // has length - if !genDecStructArrayInlineLoopCheck { - x.linef("var %sfn%s = func() bool { ", tpfx, i) - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() };", - tpfx, i, tpfx, i, tpfx, i, - tpfx, i, lenvarname, tpfx, i) - x.linef("if %sb%s { z.DecReadArrayEnd(); return true }; return false", tpfx, i) - x.linef("} // end func %sfn%s", tpfx, i) - } - var newbuf, nilbuf genBuf - for _, si := range tisfi { - if genDecStructArrayInlineLoopCheck { - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }", - tpfx, i, tpfx, i, tpfx, i, - tpfx, i, lenvarname, tpfx, i) - x.linef("if %sb%s { z.DecReadArrayEnd(); %s }", tpfx, i, breakString) - } else { - x.linef("if %sfn%s() { %s }", tpfx, i, breakString) - } - x.line("z.DecReadArrayElem()") - newbuf.reset() - nilbuf.reset() - varname3, t2 := x.decVarInitPtr(varname, "", t, si, &newbuf, &nilbuf) - if len(newbuf.buf) > 0 { - x.linef("if r.TryNil() { %s } else { %s", nilbuf.buf, newbuf.buf) - } - x.decVarMain(varname3, x.varsfx(), t2.Type, false) - if len(newbuf.buf) > 0 { - x.line("}") - } - } - // read remaining values and throw away. - x.line("for {") - x.linef("%sj%s++; if %shl%s { %sb%s = %sj%s > %s } else { %sb%s = z.DecCheckBreak() }", - tpfx, i, tpfx, i, tpfx, i, - tpfx, i, lenvarname, tpfx, i) - x.linef("if %sb%s { break }", tpfx, i) - x.line("z.DecReadArrayElem()") - x.linef(`z.DecStructFieldNotFound(%sj%s - 1, "")`, tpfx, i) - x.line("}") -} - -func (x *genRunner) decStruct(varname string, rtid uintptr, t reflect.Type) { - // varname MUST be a ptr, or a struct field or a slice element. - i := x.varsfx() - x.linef("%sct%s := r.ContainerType()", genTempVarPfx, i) - x.linef("if %sct%s == codecSelferValueTypeNil%s {", genTempVarPfx, i, x.xs) - x.linef("*(%s) = %s{}", varname, x.genTypeName(t)) - x.linef("} else if %sct%s == codecSelferValueTypeMap%s {", genTempVarPfx, i, x.xs) - x.line(genTempVarPfx + "l" + i + " := z.DecReadMapStart()") - x.linef("if %sl%s == 0 {", genTempVarPfx, i) - if genUseOneFunctionForDecStructMap { - x.line("} else { ") - x.linef("%s.codecDecodeSelfFromMap(%sl%s, d)", varname, genTempVarPfx, i) - } else { - x.line("} else if " + genTempVarPfx + "l" + i + " > 0 { ") - x.line(varname + ".codecDecodeSelfFromMapLenPrefix(" + genTempVarPfx + "l" + i + ", d)") - x.line("} else {") - x.line(varname + ".codecDecodeSelfFromMapCheckBreak(" + genTempVarPfx + "l" + i + ", d)") - } - x.line("}") - x.line("z.DecReadMapEnd()") - - // else if container is array - x.linef("} else if %sct%s == codecSelferValueTypeArray%s {", genTempVarPfx, i, x.xs) - x.line(genTempVarPfx + "l" + i + " := z.DecReadArrayStart()") - x.linef("if %sl%s != 0 {", genTempVarPfx, i) - x.linef("%s.codecDecodeSelfFromArray(%sl%s, d)", varname, genTempVarPfx, i) - x.line("}") - x.line("z.DecReadArrayEnd()") - // else panic - x.line("} else { ") - x.line("panic(errCodecSelferOnlyMapOrArrayEncodeToStruct" + x.xs + ")") - x.line("} ") -} - -// -------- - -type fastpathGenV struct { - // fastpathGenV is either a primitive (Primitive != "") or a map (MapKey != "") or a slice - MapKey string - Elem string - Primitive string - Size int - NoCanonical bool -} - -func (x *genRunner) newFastpathGenV(t reflect.Type) (v fastpathGenV) { - v.NoCanonical = !genFastpathCanonical - switch t.Kind() { - case reflect.Slice, reflect.Array: - te := t.Elem() - v.Elem = x.genTypeName(te) - v.Size = int(te.Size()) - case reflect.Map: - te, tk := t.Elem(), t.Key() - v.Elem = x.genTypeName(te) - v.MapKey = x.genTypeName(tk) - v.Size = int(te.Size() + tk.Size()) - default: - panic("unexpected type for newFastpathGenV. Requires map or slice type") - } - return -} - -func (x *fastpathGenV) MethodNamePfx(prefix string, prim bool) string { - var name []byte - if prefix != "" { - name = append(name, prefix...) - } - if prim { - name = append(name, genTitleCaseName(x.Primitive)...) - } else { - if x.MapKey == "" { - name = append(name, "Slice"...) - } else { - name = append(name, "Map"...) - name = append(name, genTitleCaseName(x.MapKey)...) - } - name = append(name, genTitleCaseName(x.Elem)...) - } - return string(name) -} - -// genImportPath returns import path of a non-predeclared named typed, or an empty string otherwise. -// -// This handles the misbehaviour that occurs when 1.5-style vendoring is enabled, -// where PkgPath returns the full path, including the vendoring pre-fix that should have been stripped. -// We strip it here. -func genImportPath(t reflect.Type) (s string) { - s = t.PkgPath() - if genCheckVendor { - // HACK: always handle vendoring. It should be typically on in go 1.6, 1.7 - s = genStripVendor(s) - } - return -} - -// A go identifier is (letter|_)[letter|number|_]* -func genGoIdentifier(s string, checkFirstChar bool) string { - b := make([]byte, 0, len(s)) - t := make([]byte, 4) - var n int - for i, r := range s { - if checkFirstChar && i == 0 && !unicode.IsLetter(r) { - b = append(b, '_') - } - // r must be unicode_letter, unicode_digit or _ - if unicode.IsLetter(r) || unicode.IsDigit(r) { - n = utf8.EncodeRune(t, r) - b = append(b, t[:n]...) - } else { - b = append(b, '_') - } - } - return string(b) -} - -func genNonPtr(t reflect.Type) reflect.Type { - for t.Kind() == reflect.Ptr { - t = t.Elem() - } - return t -} - -func genTitleCaseName(s string) string { - switch s { - case "interface{}", "interface {}": - return "Intf" - case "[]byte", "[]uint8", "bytes": - return "Bytes" - default: - return strings.ToUpper(s[0:1]) + s[1:] - } -} - -func genMethodNameT(t reflect.Type, tRef reflect.Type) (n string) { - var ptrPfx string - for t.Kind() == reflect.Ptr { - ptrPfx += "Ptrto" - t = t.Elem() - } - tstr := t.String() - if tn := t.Name(); tn != "" { - if tRef != nil && genImportPath(t) == genImportPath(tRef) { - return ptrPfx + tn - } else { - if genQNameRegex.MatchString(tstr) { - return ptrPfx + strings.Replace(tstr, ".", "_", 1000) - } else { - return ptrPfx + genCustomTypeName(tstr) - } - } - } - switch t.Kind() { - case reflect.Map: - return ptrPfx + "Map" + genMethodNameT(t.Key(), tRef) + genMethodNameT(t.Elem(), tRef) - case reflect.Slice: - return ptrPfx + "Slice" + genMethodNameT(t.Elem(), tRef) - case reflect.Array: - return ptrPfx + "Array" + strconv.FormatInt(int64(t.Len()), 10) + genMethodNameT(t.Elem(), tRef) - case reflect.Chan: - var cx string - switch t.ChanDir() { - case reflect.SendDir: - cx = "ChanSend" - case reflect.RecvDir: - cx = "ChanRecv" - default: - cx = "Chan" - } - return ptrPfx + cx + genMethodNameT(t.Elem(), tRef) - default: - if t == intfTyp { - return ptrPfx + "Interface" - } else { - if tRef != nil && genImportPath(t) == genImportPath(tRef) { - if t.Name() != "" { - return ptrPfx + t.Name() - } else { - return ptrPfx + genCustomTypeName(tstr) - } - } else { - // best way to get the package name inclusive - // return ptrPfx + strings.Replace(tstr, ".", "_", 1000) - // return ptrPfx + genBase64enc.EncodeToString([]byte(tstr)) - if t.Name() != "" && genQNameRegex.MatchString(tstr) { - return ptrPfx + strings.Replace(tstr, ".", "_", 1000) - } else { - return ptrPfx + genCustomTypeName(tstr) - } - } - } - } -} - -// genCustomNameForType base64encodes the t.String() value in such a way -// that it can be used within a function name. -func genCustomTypeName(tstr string) string { - len2 := genBase64enc.EncodedLen(len(tstr)) - bufx := make([]byte, len2) - genBase64enc.Encode(bufx, []byte(tstr)) - for i := len2 - 1; i >= 0; i-- { - if bufx[i] == '=' { - len2-- - } else { - break - } - } - return string(bufx[:len2]) -} - -func genIsImmutable(t reflect.Type) (v bool) { - return isImmutableKind(t.Kind()) -} - -type genInternal struct { - Version int - Values []fastpathGenV -} - -func (x genInternal) FastpathLen() (l int) { - for _, v := range x.Values { - if v.Primitive == "" && !(v.MapKey == "" && v.Elem == "uint8") { - l++ - } - } - return -} - -func genInternalZeroValue(s string) string { - switch s { - case "interface{}", "interface {}": - return "nil" - case "[]byte", "[]uint8", "bytes": - return "nil" - case "bool": - return "false" - case "string": - return `""` - default: - return "0" - } -} - -var genInternalNonZeroValueIdx [6]uint64 -var genInternalNonZeroValueStrs = [...][6]string{ - {`"string-is-an-interface-1"`, "true", `"some-string-1"`, `[]byte("some-string-1")`, "11.1", "111"}, - {`"string-is-an-interface-2"`, "false", `"some-string-2"`, `[]byte("some-string-2")`, "22.2", "77"}, - {`"string-is-an-interface-3"`, "true", `"some-string-3"`, `[]byte("some-string-3")`, "33.3e3", "127"}, -} - -// Note: last numbers must be in range: 0-127 (as they may be put into a int8, uint8, etc) - -func genInternalNonZeroValue(s string) string { - var i int - switch s { - case "interface{}", "interface {}": - i = 0 - case "bool": - i = 1 - case "string": - i = 2 - case "bytes", "[]byte", "[]uint8": - i = 3 - case "float32", "float64", "float", "double": - i = 4 - default: - i = 5 - } - genInternalNonZeroValueIdx[i]++ - idx := genInternalNonZeroValueIdx[i] - slen := uint64(len(genInternalNonZeroValueStrs)) - return genInternalNonZeroValueStrs[idx%slen][i] // return string, to remove ambiguity -} - -func genInternalEncCommandAsString(s string, vname string) string { - switch s { - case "uint64": - return "e.e.EncodeUint(" + vname + ")" - case "uint", "uint8", "uint16", "uint32": - return "e.e.EncodeUint(uint64(" + vname + "))" - case "int64": - return "e.e.EncodeInt(" + vname + ")" - case "int", "int8", "int16", "int32": - return "e.e.EncodeInt(int64(" + vname + "))" - case "[]byte", "[]uint8", "bytes": - return "e.e.EncodeStringBytesRaw(" + vname + ")" - case "string": - return "e.e.EncodeString(" + vname + ")" - case "float32": - return "e.e.EncodeFloat32(" + vname + ")" - case "float64": - return "e.e.EncodeFloat64(" + vname + ")" - case "bool": - return "e.e.EncodeBool(" + vname + ")" - // case "symbol": - // return "e.e.EncodeSymbol(" + vname + ")" - default: - return "e.encode(" + vname + ")" - } -} - -func genInternalDecCommandAsString(s string) string { - switch s { - case "uint": - return "uint(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))" - case "uint8": - return "uint8(chkOvf.UintV(d.d.DecodeUint64(), 8))" - case "uint16": - return "uint16(chkOvf.UintV(d.d.DecodeUint64(), 16))" - case "uint32": - return "uint32(chkOvf.UintV(d.d.DecodeUint64(), 32))" - case "uint64": - return "d.d.DecodeUint64()" - case "uintptr": - return "uintptr(chkOvf.UintV(d.d.DecodeUint64(), uintBitsize))" - case "int": - return "int(chkOvf.IntV(d.d.DecodeInt64(), intBitsize))" - case "int8": - return "int8(chkOvf.IntV(d.d.DecodeInt64(), 8))" - case "int16": - return "int16(chkOvf.IntV(d.d.DecodeInt64(), 16))" - case "int32": - return "int32(chkOvf.IntV(d.d.DecodeInt64(), 32))" - case "int64": - return "d.d.DecodeInt64()" - - case "string": - return "string(d.d.DecodeStringAsBytes())" - case "[]byte", "[]uint8", "bytes": - return "d.d.DecodeBytes(nil, false)" - case "float32": - return "float32(d.decodeFloat32())" - case "float64": - return "d.d.DecodeFloat64()" - case "bool": - return "d.d.DecodeBool()" - default: - panic(errors.New("gen internal: unknown type for decode: " + s)) - } -} - -func genInternalSortType(s string, elem bool) string { - for _, v := range [...]string{ - "int", - "uint", - "float", - "bool", - "string", - "bytes", "[]uint8", "[]byte", - } { - if v == "[]byte" || v == "[]uint8" { - v = "bytes" - } - if strings.HasPrefix(s, v) { - if v == "int" || v == "uint" || v == "float" { - v += "64" - } - if elem { - return v - } - return v + "Slice" - } - } - panic("sorttype: unexpected type: " + s) -} - -func genStripVendor(s string) string { - // HACK: Misbehaviour occurs in go 1.5. May have to re-visit this later. - // if s contains /vendor/ OR startsWith vendor/, then return everything after it. - const vendorStart = "vendor/" - const vendorInline = "/vendor/" - if i := strings.LastIndex(s, vendorInline); i >= 0 { - s = s[i+len(vendorInline):] - } else if strings.HasPrefix(s, vendorStart) { - s = s[len(vendorStart):] - } - return s -} - -// var genInternalMu sync.Mutex -var genInternalV = genInternal{Version: genVersion} -var genInternalTmplFuncs template.FuncMap -var genInternalOnce sync.Once - -func genInternalInit() { - wordSizeBytes := int(intBitsize) / 8 - - typesizes := map[string]int{ - "interface{}": 2 * wordSizeBytes, - "string": 2 * wordSizeBytes, - "[]byte": 3 * wordSizeBytes, - "uint": 1 * wordSizeBytes, - "uint8": 1, - "uint16": 2, - "uint32": 4, - "uint64": 8, - "uintptr": 1 * wordSizeBytes, - "int": 1 * wordSizeBytes, - "int8": 1, - "int16": 2, - "int32": 4, - "int64": 8, - "float32": 4, - "float64": 8, - "bool": 1, - } - - // keep as slice, so it is in specific iteration order. - // Initial order was uint64, string, interface{}, int, int64, ... - - var types = [...]string{ - "interface{}", - "string", - "[]byte", - "float32", - "float64", - "uint", - "uint8", - "uint16", - "uint32", - "uint64", - "uintptr", - "int", - "int8", - "int16", - "int32", - "int64", - "bool", - } - - var primitivetypes, slicetypes, mapkeytypes, mapvaltypes []string - - primitivetypes = types[:] - slicetypes = types[:] - mapkeytypes = types[:] - mapvaltypes = types[:] - - if genFastpathTrimTypes { - slicetypes = []string{ - "interface{}", - "string", - "[]byte", - "float32", - "float64", - "uint", - // "uint8", // no need for fastpath of []uint8, as it is handled specially - "uint16", - "uint32", - "uint64", - // "uintptr", - "int", - "int8", - "int16", - "int32", - "int64", - "bool", - } - - mapkeytypes = []string{ - //"interface{}", - "string", - //"[]byte", - //"float32", - //"float64", - "uint", - "uint8", - //"uint16", - //"uint32", - "uint64", - //"uintptr", - "int", - //"int8", - //"int16", - //"int32", - "int64", - // "bool", - } - - mapvaltypes = []string{ - "interface{}", - "string", - "[]byte", - "uint", - "uint8", - //"uint16", - //"uint32", - "uint64", - // "uintptr", - "int", - //"int8", - //"int16", - //"int32", - "int64", - "float32", - "float64", - "bool", - } - } - - // var mapkeytypes [len(&types) - 1]string // skip bool - // copy(mapkeytypes[:], types[:]) - - // var mb []byte - // mb = append(mb, '|') - // for _, s := range mapkeytypes { - // mb = append(mb, s...) - // mb = append(mb, '|') - // } - // var mapkeytypestr = string(mb) - - var gt = genInternal{Version: genVersion} - - // For each slice or map type, there must be a (symmetrical) Encode and Decode fast-path function - - for _, s := range primitivetypes { - gt.Values = append(gt.Values, - fastpathGenV{Primitive: s, Size: typesizes[s], NoCanonical: !genFastpathCanonical}) - } - for _, s := range slicetypes { - // if s != "uint8" { // do not generate fast path for slice of bytes. Treat specially already. - // gt.Values = append(gt.Values, fastpathGenV{Elem: s, Size: typesizes[s]}) - // } - gt.Values = append(gt.Values, - fastpathGenV{Elem: s, Size: typesizes[s], NoCanonical: !genFastpathCanonical}) - } - for _, s := range mapkeytypes { - // if _, ok := typesizes[s]; !ok { - // if strings.Contains(mapkeytypestr, "|"+s+"|") { - // gt.Values = append(gt.Values, fastpathGenV{MapKey: s, Elem: s, Size: 2 * typesizes[s]}) - // } - for _, ms := range mapvaltypes { - gt.Values = append(gt.Values, - fastpathGenV{MapKey: s, Elem: ms, Size: typesizes[s] + typesizes[ms], NoCanonical: !genFastpathCanonical}) - } - } - - funcs := make(template.FuncMap) - // funcs["haspfx"] = strings.HasPrefix - funcs["encmd"] = genInternalEncCommandAsString - funcs["decmd"] = genInternalDecCommandAsString - funcs["zerocmd"] = genInternalZeroValue - funcs["nonzerocmd"] = genInternalNonZeroValue - funcs["hasprefix"] = strings.HasPrefix - funcs["sorttype"] = genInternalSortType - - genInternalV = gt - genInternalTmplFuncs = funcs -} - -// genInternalGoFile is used to generate source files from templates. -// It is run by the program author alone. -// Unfortunately, it has to be exported so that it can be called from a command line tool. -// *** DO NOT USE *** -func genInternalGoFile(r io.Reader, w io.Writer) (err error) { - genInternalOnce.Do(genInternalInit) - - gt := genInternalV - - t := template.New("").Funcs(genInternalTmplFuncs) - - tmplstr, err := ioutil.ReadAll(r) - if err != nil { - return - } - - if t, err = t.Parse(string(tmplstr)); err != nil { - return - } - - var out bytes.Buffer - err = t.Execute(&out, gt) - if err != nil { - return - } - - bout, err := format.Source(out.Bytes()) - if err != nil { - w.Write(out.Bytes()) // write out if error, so we can still see. - // w.Write(bout) // write out if error, as much as possible, so we can still see. - return - } - w.Write(bout) - return -} diff --git a/vendor/github.com/ugorji/go/codec/go.mod b/vendor/github.com/ugorji/go/codec/go.mod deleted file mode 100644 index b4760da40..000000000 --- a/vendor/github.com/ugorji/go/codec/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/ugorji/go/codec - -require ( -github.com/ugorji/go v1.1.7 -) diff --git a/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go b/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go deleted file mode 100644 index 9ddbe2059..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.5 - -package codec - -import "reflect" - -const reflectArrayOfSupported = true - -func reflectArrayOf(count int, elem reflect.Type) reflect.Type { - return reflect.ArrayOf(count, elem) -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go deleted file mode 100644 index c5fcd6697..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.5 - -package codec - -import "reflect" - -const reflectArrayOfSupported = false - -func reflectArrayOf(count int, elem reflect.Type) reflect.Type { - panic("codec: reflect.ArrayOf unsupported in this go version") -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go b/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go deleted file mode 100644 index a35359887..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.5 - -package codec - -import "time" - -func fmtTime(t time.Time, b []byte) []byte { - return t.AppendFormat(b, time.RFC3339Nano) -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go deleted file mode 100644 index 41700c321..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.5 - -package codec - -import "time" - -func fmtTime(t time.Time, b []byte) []byte { - s := t.Format(time.RFC3339Nano) - b = b[:len(s)] - copy(b, s) - return b -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go b/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go deleted file mode 100644 index 31e01b645..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.9 - -package codec - -import "reflect" - -func makeMapReflect(t reflect.Type, size int) reflect.Value { - // if size < 0 { - // return reflect.MakeMapWithSize(t, 4) - // } - return reflect.MakeMapWithSize(t, size) -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go b/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go deleted file mode 100644 index cde4cd372..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.9 - -package codec - -import "reflect" - -func makeMapReflect(t reflect.Type, size int) reflect.Value { - return reflect.MakeMap(t) -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go b/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go deleted file mode 100644 index 2a4914974..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_maprange_gte_go112.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.12 -// +build safe appengine - -package codec - -import "reflect" - -type mapIter struct { - t *reflect.MapIter - m reflect.Value - values bool -} - -func (t *mapIter) ValidKV() (r bool) { - return true -} - -func (t *mapIter) Next() (r bool) { - return t.t.Next() -} - -func (t *mapIter) Key() reflect.Value { - return t.t.Key() -} - -func (t *mapIter) Value() (r reflect.Value) { - if t.values { - return t.t.Value() - } - return -} - -func (t *mapIter) Done() {} - -func mapRange(t *mapIter, m, k, v reflect.Value, values bool) { - *t = mapIter{ - m: m, - t: m.MapRange(), - values: values, - } -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go b/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go deleted file mode 100644 index 161d02b08..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_maprange_lt_go112.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.7 -// +build !go1.12 -// +build safe appengine - -package codec - -import "reflect" - -type mapIter struct { - m reflect.Value - keys []reflect.Value - j int - values bool -} - -func (t *mapIter) ValidKV() (r bool) { - return true -} - -func (t *mapIter) Next() (r bool) { - t.j++ - return t.j < len(t.keys) -} - -func (t *mapIter) Key() reflect.Value { - return t.keys[t.j] -} - -func (t *mapIter) Value() (r reflect.Value) { - if t.values { - return t.m.MapIndex(t.keys[t.j]) - } - return -} - -func (t *mapIter) Done() {} - -func mapRange(t *mapIter, m, k, v reflect.Value, values bool) { - *t = mapIter{ - m: m, - keys: m.MapKeys(), - values: values, - j: -1, - } -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go deleted file mode 100644 index 794133a3c..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.10 - -package codec - -const allowSetUnexportedEmbeddedPtr = false diff --git a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go b/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go deleted file mode 100644 index fd92ede35..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.10 - -package codec - -const allowSetUnexportedEmbeddedPtr = true diff --git a/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go b/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go deleted file mode 100644 index 8debfa613..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.4 - -package codec - -// This codec package will only work for go1.4 and above. -// This is for the following reasons: -// - go 1.4 was released in 2014 -// - go runtime is written fully in go -// - interface only holds pointers -// - reflect.Value is stabilized as 3 words - -func init() { - panic("codec: go 1.3 and below are not supported") -} diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go deleted file mode 100644 index 0f1bb01e5..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.5,!go1.6 - -package codec - -import "os" - -var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go deleted file mode 100644 index 2fb4b057d..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.6,!go1.7 - -package codec - -import "os" - -var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0" diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go deleted file mode 100644 index c5b815505..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build go1.7 - -package codec - -const genCheckVendor = true diff --git a/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go b/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go deleted file mode 100644 index 837cf240b..000000000 --- a/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build !go1.5 - -package codec - -var genCheckVendor = false diff --git a/vendor/github.com/ugorji/go/codec/helper.go b/vendor/github.com/ugorji/go/codec/helper.go deleted file mode 100644 index 02e643615..000000000 --- a/vendor/github.com/ugorji/go/codec/helper.go +++ /dev/null @@ -1,2815 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// Contains code shared by both encode and decode. - -// Some shared ideas around encoding/decoding -// ------------------------------------------ -// -// If an interface{} is passed, we first do a type assertion to see if it is -// a primitive type or a map/slice of primitive types, and use a fastpath to handle it. -// -// If we start with a reflect.Value, we are already in reflect.Value land and -// will try to grab the function for the underlying Type and directly call that function. -// This is more performant than calling reflect.Value.Interface(). -// -// This still helps us bypass many layers of reflection, and give best performance. -// -// Containers -// ------------ -// Containers in the stream are either associative arrays (key-value pairs) or -// regular arrays (indexed by incrementing integers). -// -// Some streams support indefinite-length containers, and use a breaking -// byte-sequence to denote that the container has come to an end. -// -// Some streams also are text-based, and use explicit separators to denote the -// end/beginning of different values. -// -// Philosophy -// ------------ -// On decode, this codec will update containers appropriately: -// - If struct, update fields from stream into fields of struct. -// If field in stream not found in struct, handle appropriately (based on option). -// If a struct field has no corresponding value in the stream, leave it AS IS. -// If nil in stream, set value to nil/zero value. -// - If map, update map from stream. -// If the stream value is NIL, set the map to nil. -// - if slice, try to update up to length of array in stream. -// if container len is less than stream array length, -// and container cannot be expanded, handled (based on option). -// This means you can decode 4-element stream array into 1-element array. -// -// ------------------------------------ -// On encode, user can specify omitEmpty. This means that the value will be omitted -// if the zero value. The problem may occur during decode, where omitted values do not affect -// the value being decoded into. This means that if decoding into a struct with an -// int field with current value=5, and the field is omitted in the stream, then after -// decoding, the value will still be 5 (not 0). -// omitEmpty only works if you guarantee that you always decode into zero-values. -// -// ------------------------------------ -// We could have truncated a map to remove keys not available in the stream, -// or set values in the struct which are not in the stream to their zero values. -// We decided against it because there is no efficient way to do it. -// We may introduce it as an option later. -// However, that will require enabling it for both runtime and code generation modes. -// -// To support truncate, we need to do 2 passes over the container: -// map -// - first collect all keys (e.g. in k1) -// - for each key in stream, mark k1 that the key should not be removed -// - after updating map, do second pass and call delete for all keys in k1 which are not marked -// struct: -// - for each field, track the *typeInfo s1 -// - iterate through all s1, and for each one not marked, set value to zero -// - this involves checking the possible anonymous fields which are nil ptrs. -// too much work. -// -// ------------------------------------------ -// Error Handling is done within the library using panic. -// -// This way, the code doesn't have to keep checking if an error has happened, -// and we don't have to keep sending the error value along with each call -// or storing it in the En|Decoder and checking it constantly along the way. -// -// We considered storing the error is En|Decoder. -// - once it has its err field set, it cannot be used again. -// - panicing will be optional, controlled by const flag. -// - code should always check error first and return early. -// -// We eventually decided against it as it makes the code clumsier to always -// check for these error conditions. -// -// ------------------------------------------ -// We use sync.Pool only for the aid of long-lived objects shared across multiple goroutines. -// Encoder, Decoder, enc|decDriver, reader|writer, etc do not fall into this bucket. -// -// Also, GC is much better now, eliminating some of the reasons to use a shared pool structure. -// Instead, the short-lived objects use free-lists that live as long as the object exists. -// -// ------------------------------------------ -// Performance is affected by the following: -// - Bounds Checking -// - Inlining -// - Pointer chasing -// This package tries hard to manage the performance impact of these. -// -// ------------------------------------------ -// To alleviate performance due to pointer-chasing: -// - Prefer non-pointer values in a struct field -// - Refer to these directly within helper classes -// e.g. json.go refers directly to d.d.decRd -// -// We made the changes to embed En/Decoder in en/decDriver, -// but we had to explicitly reference the fields as opposed to using a function -// to get the better performance that we were looking for. -// For example, we explicitly call d.d.decRd.fn() instead of d.d.r().fn(). -// -// ------------------------------------------ -// Bounds Checking -// - Allow bytesDecReader to incur "bounds check error", and -// recover that as an io.EOF. -// This allows the bounds check branch to always be taken by the branch predictor, -// giving better performance (in theory), while ensuring that the code is shorter. -// -// ------------------------------------------ -// Escape Analysis -// - Prefer to return non-pointers if the value is used right away. -// Newly allocated values returned as pointers will be heap-allocated as they escape. -// -// Prefer functions and methods that -// - take no parameters and -// - return no results and -// - do not allocate. -// These are optimized by the runtime. -// For example, in json, we have dedicated functions for ReadMapElemKey, etc -// which do not delegate to readDelim, as readDelim takes a parameter. -// The difference in runtime was as much as 5%. - -import ( - "bytes" - "encoding" - "encoding/binary" - "errors" - "fmt" - "io" - "math" - "reflect" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" - "unicode/utf8" -) - -const ( - // rvNLen is the length of the array for readn or writen calls - rwNLen = 7 - - // scratchByteArrayLen = 64 - // initCollectionCap = 16 // 32 is defensive. 16 is preferred. - - // Support encoding.(Binary|Text)(Unm|M)arshaler. - // This constant flag will enable or disable it. - supportMarshalInterfaces = true - - // for debugging, set this to false, to catch panic traces. - // Note that this will always cause rpc tests to fail, since they need io.EOF sent via panic. - recoverPanicToErr = true - - // arrayCacheLen is the length of the cache used in encoder or decoder for - // allowing zero-alloc initialization. - // arrayCacheLen = 8 - - // size of the cacheline: defaulting to value for archs: amd64, arm64, 386 - // should use "runtime/internal/sys".CacheLineSize, but that is not exposed. - cacheLineSize = 64 - - wordSizeBits = 32 << (^uint(0) >> 63) // strconv.IntSize - wordSize = wordSizeBits / 8 - - // so structFieldInfo fits into 8 bytes - maxLevelsEmbedding = 14 - - // xdebug controls whether xdebugf prints any output - xdebug = true -) - -var ( - oneByteArr [1]byte - zeroByteSlice = oneByteArr[:0:0] - - codecgen bool - - halt panicHdl - - refBitset bitset32 - isnilBitset bitset32 - scalarBitset bitset32 - - digitCharBitset bitset256 - numCharBitset bitset256 - whitespaceCharBitset bitset256 - - numCharWithExpBitset64 bitset64 - numCharNoExpBitset64 bitset64 - whitespaceCharBitset64 bitset64 -) - -var ( - errMapTypeNotMapKind = errors.New("MapType MUST be of Map Kind") - errSliceTypeNotSliceKind = errors.New("SliceType MUST be of Slice Kind") -) - -var pool4tiload = sync.Pool{New: func() interface{} { return new(typeInfoLoadArray) }} - -func init() { - refBitset = refBitset. - set(byte(reflect.Map)). - set(byte(reflect.Ptr)). - set(byte(reflect.Func)). - set(byte(reflect.Chan)). - set(byte(reflect.UnsafePointer)) - - isnilBitset = isnilBitset. - set(byte(reflect.Map)). - set(byte(reflect.Ptr)). - set(byte(reflect.Func)). - set(byte(reflect.Chan)). - set(byte(reflect.UnsafePointer)). - set(byte(reflect.Interface)). - set(byte(reflect.Slice)) - - scalarBitset = scalarBitset. - set(byte(reflect.Bool)). - set(byte(reflect.Int)). - set(byte(reflect.Int8)). - set(byte(reflect.Int16)). - set(byte(reflect.Int32)). - set(byte(reflect.Int64)). - set(byte(reflect.Uint)). - set(byte(reflect.Uint8)). - set(byte(reflect.Uint16)). - set(byte(reflect.Uint32)). - set(byte(reflect.Uint64)). - set(byte(reflect.Uintptr)). - set(byte(reflect.Float32)). - set(byte(reflect.Float64)). - set(byte(reflect.Complex64)). - set(byte(reflect.Complex128)). - set(byte(reflect.String)) - - var i byte - for i = 0; i <= utf8.RuneSelf; i++ { - switch i { - case ' ', '\t', '\r', '\n': - whitespaceCharBitset.set(i) - whitespaceCharBitset64 = whitespaceCharBitset64.set(i) - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - digitCharBitset.set(i) - numCharBitset.set(i) - numCharWithExpBitset64 = numCharWithExpBitset64.set(i - 42) - numCharNoExpBitset64 = numCharNoExpBitset64.set(i) - case '.', '+', '-': - numCharBitset.set(i) - numCharWithExpBitset64 = numCharWithExpBitset64.set(i - 42) - numCharNoExpBitset64 = numCharNoExpBitset64.set(i) - case 'e', 'E': - numCharBitset.set(i) - numCharWithExpBitset64 = numCharWithExpBitset64.set(i - 42) - } - } - -} - -type handleFlag uint8 - -const ( - initedHandleFlag handleFlag = 1 << iota - binaryHandleFlag - jsonHandleFlag -) - -type clsErr struct { - closed bool // is it closed? - errClosed error // error on closing -} - -type charEncoding uint8 - -const ( - _ charEncoding = iota // make 0 unset - cUTF8 - cUTF16LE - cUTF16BE - cUTF32LE - cUTF32BE - // Deprecated: not a true char encoding value - cRAW charEncoding = 255 -) - -// valueType is the stream type -type valueType uint8 - -const ( - valueTypeUnset valueType = iota - valueTypeNil - valueTypeInt - valueTypeUint - valueTypeFloat - valueTypeBool - valueTypeString - valueTypeSymbol - valueTypeBytes - valueTypeMap - valueTypeArray - valueTypeTime - valueTypeExt - - // valueTypeInvalid = 0xff -) - -var valueTypeStrings = [...]string{ - "Unset", - "Nil", - "Int", - "Uint", - "Float", - "Bool", - "String", - "Symbol", - "Bytes", - "Map", - "Array", - "Timestamp", - "Ext", -} - -func (x valueType) String() string { - if int(x) < len(valueTypeStrings) { - return valueTypeStrings[x] - } - return strconv.FormatInt(int64(x), 10) -} - -type seqType uint8 - -const ( - _ seqType = iota - seqTypeArray - seqTypeSlice - seqTypeChan -) - -// note that containerMapStart and containerArraySend are not sent. -// This is because the ReadXXXStart and EncodeXXXStart already does these. -type containerState uint8 - -const ( - _ containerState = iota - - containerMapStart - containerMapKey - containerMapValue - containerMapEnd - containerArrayStart - containerArrayElem - containerArrayEnd -) - -// do not recurse if a containing type refers to an embedded type -// which refers back to its containing type (via a pointer). -// The second time this back-reference happens, break out, -// so as not to cause an infinite loop. -const rgetMaxRecursion = 2 - -// Anecdotally, we believe most types have <= 12 fields. -// - even Java's PMD rules set TooManyFields threshold to 15. -// However, go has embedded fields, which should be regarded as -// top level, allowing structs to possibly double or triple. -// In addition, we don't want to keep creating transient arrays, -// especially for the sfi index tracking, and the evtypes tracking. -// -// So - try to keep typeInfoLoadArray within 2K bytes -const ( - typeInfoLoadArraySfisLen = 16 - typeInfoLoadArraySfiidxLen = 8 * 112 - typeInfoLoadArrayEtypesLen = 12 - typeInfoLoadArrayBLen = 8 * 4 -) - -// fauxUnion is used to keep track of the primitives decoded. -// -// Without it, we would have to decode each primitive and wrap it -// in an interface{}, causing an allocation. -// In this model, the primitives are decoded in a "pseudo-atomic" fashion, -// so we can rest assured that no other decoding happens while these -// primitives are being decoded. -// -// maps and arrays are not handled by this mechanism. -type fauxUnion struct { - // r RawExt // used for RawExt, uint, []byte. - - // primitives below - u uint64 - i int64 - f float64 - l []byte - s string - - // ---- cpu cache line boundary? - t time.Time - b bool - - // state - v valueType -} - -// typeInfoLoad is a transient object used while loading up a typeInfo. -type typeInfoLoad struct { - etypes []uintptr - sfis []structFieldInfo -} - -// typeInfoLoadArray is a cache object used to efficiently load up a typeInfo without -// much allocation. -type typeInfoLoadArray struct { - sfis [typeInfoLoadArraySfisLen]structFieldInfo - sfiidx [typeInfoLoadArraySfiidxLen]byte - etypes [typeInfoLoadArrayEtypesLen]uintptr - b [typeInfoLoadArrayBLen]byte // scratch - used for struct field names -} - -// mirror json.Marshaler and json.Unmarshaler here, -// so we don't import the encoding/json package - -type jsonMarshaler interface { - MarshalJSON() ([]byte, error) -} -type jsonUnmarshaler interface { - UnmarshalJSON([]byte) error -} - -type isZeroer interface { - IsZero() bool -} - -type codecError struct { - name string - err interface{} -} - -func (e codecError) Cause() error { - switch xerr := e.err.(type) { - case nil: - return nil - case error: - return xerr - case string: - return errors.New(xerr) - case fmt.Stringer: - return errors.New(xerr.String()) - default: - return fmt.Errorf("%v", e.err) - } -} - -func (e codecError) Error() string { - return fmt.Sprintf("%s error: %v", e.name, e.err) -} - -var ( - bigen = binary.BigEndian - structInfoFieldName = "_struct" - - mapStrIntfTyp = reflect.TypeOf(map[string]interface{}(nil)) - mapIntfIntfTyp = reflect.TypeOf(map[interface{}]interface{}(nil)) - intfSliceTyp = reflect.TypeOf([]interface{}(nil)) - intfTyp = intfSliceTyp.Elem() - - reflectValTyp = reflect.TypeOf((*reflect.Value)(nil)).Elem() - - stringTyp = reflect.TypeOf("") - timeTyp = reflect.TypeOf(time.Time{}) - rawExtTyp = reflect.TypeOf(RawExt{}) - rawTyp = reflect.TypeOf(Raw{}) - uintptrTyp = reflect.TypeOf(uintptr(0)) - uint8Typ = reflect.TypeOf(uint8(0)) - uint8SliceTyp = reflect.TypeOf([]uint8(nil)) - uintTyp = reflect.TypeOf(uint(0)) - intTyp = reflect.TypeOf(int(0)) - - mapBySliceTyp = reflect.TypeOf((*MapBySlice)(nil)).Elem() - - binaryMarshalerTyp = reflect.TypeOf((*encoding.BinaryMarshaler)(nil)).Elem() - binaryUnmarshalerTyp = reflect.TypeOf((*encoding.BinaryUnmarshaler)(nil)).Elem() - - textMarshalerTyp = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() - textUnmarshalerTyp = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() - - jsonMarshalerTyp = reflect.TypeOf((*jsonMarshaler)(nil)).Elem() - jsonUnmarshalerTyp = reflect.TypeOf((*jsonUnmarshaler)(nil)).Elem() - - selferTyp = reflect.TypeOf((*Selfer)(nil)).Elem() - missingFielderTyp = reflect.TypeOf((*MissingFielder)(nil)).Elem() - iszeroTyp = reflect.TypeOf((*isZeroer)(nil)).Elem() - - uint8TypId = rt2id(uint8Typ) - uint8SliceTypId = rt2id(uint8SliceTyp) - rawExtTypId = rt2id(rawExtTyp) - rawTypId = rt2id(rawTyp) - intfTypId = rt2id(intfTyp) - timeTypId = rt2id(timeTyp) - stringTypId = rt2id(stringTyp) - - mapStrIntfTypId = rt2id(mapStrIntfTyp) - mapIntfIntfTypId = rt2id(mapIntfIntfTyp) - intfSliceTypId = rt2id(intfSliceTyp) - // mapBySliceTypId = rt2id(mapBySliceTyp) - - intBitsize = uint8(intTyp.Bits()) - uintBitsize = uint8(uintTyp.Bits()) - - // bsAll0x00 = []byte{0, 0, 0, 0, 0, 0, 0, 0} - bsAll0xff = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff} - - chkOvf checkOverflow - - errNoFieldNameToStructFieldInfo = errors.New("no field name passed to parseStructFieldInfo") -) - -var defTypeInfos = NewTypeInfos([]string{"codec", "json"}) - -var immutableKindsSet = [32]bool{ - // reflect.Invalid: , - reflect.Bool: true, - reflect.Int: true, - reflect.Int8: true, - reflect.Int16: true, - reflect.Int32: true, - reflect.Int64: true, - reflect.Uint: true, - reflect.Uint8: true, - reflect.Uint16: true, - reflect.Uint32: true, - reflect.Uint64: true, - reflect.Uintptr: true, - reflect.Float32: true, - reflect.Float64: true, - reflect.Complex64: true, - reflect.Complex128: true, - // reflect.Array - // reflect.Chan - // reflect.Func: true, - // reflect.Interface - // reflect.Map - // reflect.Ptr - // reflect.Slice - reflect.String: true, - // reflect.Struct - // reflect.UnsafePointer -} - -// SelfExt is a sentinel extension signifying that types -// registered with it SHOULD be encoded and decoded -// based on the native mode of the format. -// -// This allows users to define a tag for an extension, -// but signify that the types should be encoded/decoded as the native encoding. -// This way, users need not also define how to encode or decode the extension. -var SelfExt = &extFailWrapper{} - -// Selfer defines methods by which a value can encode or decode itself. -// -// Any type which implements Selfer will be able to encode or decode itself. -// Consequently, during (en|de)code, this takes precedence over -// (text|binary)(M|Unm)arshal or extension support. -// -// By definition, it is not allowed for a Selfer to directly call Encode or Decode on itself. -// If that is done, Encode/Decode will rightfully fail with a Stack Overflow style error. -// For example, the snippet below will cause such an error. -// type testSelferRecur struct{} -// func (s *testSelferRecur) CodecEncodeSelf(e *Encoder) { e.MustEncode(s) } -// func (s *testSelferRecur) CodecDecodeSelf(d *Decoder) { d.MustDecode(s) } -// -// Note: *the first set of bytes of any value MUST NOT represent nil in the format*. -// This is because, during each decode, we first check the the next set of bytes -// represent nil, and if so, we just set the value to nil. -type Selfer interface { - CodecEncodeSelf(*Encoder) - CodecDecodeSelf(*Decoder) -} - -// MissingFielder defines the interface allowing structs to internally decode or encode -// values which do not map to struct fields. -// -// We expect that this interface is bound to a pointer type (so the mutation function works). -// -// A use-case is if a version of a type unexports a field, but you want compatibility between -// both versions during encoding and decoding. -// -// Note that the interface is completely ignored during codecgen. -type MissingFielder interface { - // CodecMissingField is called to set a missing field and value pair. - // - // It returns true if the missing field was set on the struct. - CodecMissingField(field []byte, value interface{}) bool - - // CodecMissingFields returns the set of fields which are not struct fields - CodecMissingFields() map[string]interface{} -} - -// MapBySlice is a tag interface that denotes wrapped slice should encode as a map in the stream. -// The slice contains a sequence of key-value pairs. -// This affords storing a map in a specific sequence in the stream. -// -// Example usage: -// type T1 []string // or []int or []Point or any other "slice" type -// func (_ T1) MapBySlice{} // T1 now implements MapBySlice, and will be encoded as a map -// type T2 struct { KeyValues T1 } -// -// var kvs = []string{"one", "1", "two", "2", "three", "3"} -// var v2 = T2{ KeyValues: T1(kvs) } -// // v2 will be encoded like the map: {"KeyValues": {"one": "1", "two": "2", "three": "3"} } -// -// The support of MapBySlice affords the following: -// - A slice type which implements MapBySlice will be encoded as a map -// - A slice can be decoded from a map in the stream -// - It MUST be a slice type (not a pointer receiver) that implements MapBySlice -type MapBySlice interface { - MapBySlice() -} - -// BasicHandle encapsulates the common options and extension functions. -// -// Deprecated: DO NOT USE DIRECTLY. EXPORTED FOR GODOC BENEFIT. WILL BE REMOVED. -type BasicHandle struct { - // BasicHandle is always a part of a different type. - // It doesn't have to fit into it own cache lines. - - // TypeInfos is used to get the type info for any type. - // - // If not configured, the default TypeInfos is used, which uses struct tag keys: codec, json - TypeInfos *TypeInfos - - // Note: BasicHandle is not comparable, due to these slices here (extHandle, intf2impls). - // If *[]T is used instead, this becomes comparable, at the cost of extra indirection. - // Thses slices are used all the time, so keep as slices (not pointers). - - extHandle - - rtidFns atomicRtidFnSlice - rtidFnsNoExt atomicRtidFnSlice - - // ---- cache line - - DecodeOptions - - // ---- cache line - - EncodeOptions - - intf2impls - - mu sync.Mutex - inited uint32 // holds if inited, and also handle flags (binary encoding, json handler, etc) - - RPCOptions - - // TimeNotBuiltin configures whether time.Time should be treated as a builtin type. - // - // All Handlers should know how to encode/decode time.Time as part of the core - // format specification, or as a standard extension defined by the format. - // - // However, users can elect to handle time.Time as a custom extension, or via the - // standard library's encoding.Binary(M|Unm)arshaler or Text(M|Unm)arshaler interface. - // To elect this behavior, users can set TimeNotBuiltin=true. - // - // Note: Setting TimeNotBuiltin=true can be used to enable the legacy behavior - // (for Cbor and Msgpack), where time.Time was not a builtin supported type. - // - // Note: DO NOT CHANGE AFTER FIRST USE. - // - // Once a Handle has been used, do not modify this option. - // It will lead to unexpected behaviour during encoding and decoding. - TimeNotBuiltin bool - - // ExplicitRelease configures whether Release() is implicitly called after an encode or - // decode call. - // - // If you will hold onto an Encoder or Decoder for re-use, by calling Reset(...) - // on it or calling (Must)Encode repeatedly into a given []byte or io.Writer, - // then you do not want it to be implicitly closed after each Encode/Decode call. - // Doing so will unnecessarily return resources to the shared pool, only for you to - // grab them right after again to do another Encode/Decode call. - // - // Instead, you configure ExplicitRelease=true, and you explicitly call Release() when - // you are truly done. - // - // As an alternative, you can explicitly set a finalizer - so its resources - // are returned to the shared pool before it is garbage-collected. Do it as below: - // runtime.SetFinalizer(e, (*Encoder).Release) - // runtime.SetFinalizer(d, (*Decoder).Release) - // - // Deprecated: This is not longer used as pools are only used for long-lived objects - // which are shared across goroutines. - // Setting this value has no effect. It is maintained for backward compatibility. - ExplicitRelease bool - - // ---- cache line -} - -// basicHandle returns an initialized BasicHandle from the Handle. -func basicHandle(hh Handle) (x *BasicHandle) { - x = hh.getBasicHandle() - // ** We need to simulate once.Do, to ensure no data race within the block. - // ** Consequently, below would not work. - // if atomic.CompareAndSwapUint32(&x.inited, 0, 1) { - // x.be = hh.isBinary() - // _, x.js = hh.(*JsonHandle) - // x.n = hh.Name()[0] - // } - - // simulate once.Do using our own stored flag and mutex as a CompareAndSwap - // is not sufficient, since a race condition can occur within init(Handle) function. - // init is made noinline, so that this function can be inlined by its caller. - if atomic.LoadUint32(&x.inited) == 0 { - x.init(hh) - } - return -} - -func (x *BasicHandle) isJs() bool { - return handleFlag(x.inited)&jsonHandleFlag != 0 -} - -func (x *BasicHandle) isBe() bool { - return handleFlag(x.inited)&binaryHandleFlag != 0 -} - -//go:noinline -func (x *BasicHandle) init(hh Handle) { - // make it uninlineable, as it is called at most once - x.mu.Lock() - if x.inited == 0 { - var f = initedHandleFlag - if hh.isBinary() { - f |= binaryHandleFlag - } - if _, b := hh.(*JsonHandle); b { - f |= jsonHandleFlag - } - atomic.StoreUint32(&x.inited, uint32(f)) - // ensure MapType and SliceType are of correct type - if x.MapType != nil && x.MapType.Kind() != reflect.Map { - panic(errMapTypeNotMapKind) - } - if x.SliceType != nil && x.SliceType.Kind() != reflect.Slice { - panic(errSliceTypeNotSliceKind) - } - } - x.mu.Unlock() -} - -func (x *BasicHandle) getBasicHandle() *BasicHandle { - return x -} - -func (x *BasicHandle) getTypeInfo(rtid uintptr, rt reflect.Type) (pti *typeInfo) { - if x.TypeInfos == nil { - return defTypeInfos.get(rtid, rt) - } - return x.TypeInfos.get(rtid, rt) -} - -func findFn(s []codecRtidFn, rtid uintptr) (i uint, fn *codecFn) { - // binary search. adapted from sort/search.go. - // Note: we use goto (instead of for loop) so this can be inlined. - - // h, i, j := 0, 0, len(s) - var h uint // var h, i uint - var j = uint(len(s)) -LOOP: - if i < j { - h = i + (j-i)/2 - if s[h].rtid < rtid { - i = h + 1 - } else { - j = h - } - goto LOOP - } - if i < uint(len(s)) && s[i].rtid == rtid { - fn = s[i].fn - } - return -} - -func (x *BasicHandle) fn(rt reflect.Type) (fn *codecFn) { - return x.fnVia(rt, &x.rtidFns, true) -} - -func (x *BasicHandle) fnNoExt(rt reflect.Type) (fn *codecFn) { - return x.fnVia(rt, &x.rtidFnsNoExt, false) -} - -func (x *BasicHandle) fnVia(rt reflect.Type, fs *atomicRtidFnSlice, checkExt bool) (fn *codecFn) { - rtid := rt2id(rt) - sp := fs.load() - if sp != nil { - if _, fn = findFn(sp, rtid); fn != nil { - return - } - } - fn = x.fnLoad(rt, rtid, checkExt) - x.mu.Lock() - var sp2 []codecRtidFn - sp = fs.load() - if sp == nil { - sp2 = []codecRtidFn{{rtid, fn}} - fs.store(sp2) - } else { - idx, fn2 := findFn(sp, rtid) - if fn2 == nil { - sp2 = make([]codecRtidFn, len(sp)+1) - copy(sp2, sp[:idx]) - copy(sp2[idx+1:], sp[idx:]) - sp2[idx] = codecRtidFn{rtid, fn} - fs.store(sp2) - } - } - x.mu.Unlock() - return -} - -func (x *BasicHandle) fnLoad(rt reflect.Type, rtid uintptr, checkExt bool) (fn *codecFn) { - fn = new(codecFn) - fi := &(fn.i) - ti := x.getTypeInfo(rtid, rt) - fi.ti = ti - - rk := reflect.Kind(ti.kind) - - // anything can be an extension except the built-in ones: time, raw and rawext - - if rtid == timeTypId && !x.TimeNotBuiltin { - fn.fe = (*Encoder).kTime - fn.fd = (*Decoder).kTime - } else if rtid == rawTypId { - fn.fe = (*Encoder).raw - fn.fd = (*Decoder).raw - } else if rtid == rawExtTypId { - fn.fe = (*Encoder).rawExt - fn.fd = (*Decoder).rawExt - fi.addrF = true - fi.addrD = true - fi.addrE = true - } else if xfFn := x.getExt(rtid, checkExt); xfFn != nil { - fi.xfTag, fi.xfFn = xfFn.tag, xfFn.ext - fn.fe = (*Encoder).ext - fn.fd = (*Decoder).ext - fi.addrF = true - fi.addrD = true - if rk == reflect.Struct || rk == reflect.Array { - fi.addrE = true - } - } else if ti.isFlag(tiflagSelfer) || ti.isFlag(tiflagSelferPtr) { - fn.fe = (*Encoder).selferMarshal - fn.fd = (*Decoder).selferUnmarshal - fi.addrF = true - fi.addrD = ti.isFlag(tiflagSelferPtr) - fi.addrE = ti.isFlag(tiflagSelferPtr) - } else if supportMarshalInterfaces && x.isBe() && - (ti.isFlag(tiflagBinaryMarshaler) || ti.isFlag(tiflagBinaryMarshalerPtr)) && - (ti.isFlag(tiflagBinaryUnmarshaler) || ti.isFlag(tiflagBinaryUnmarshalerPtr)) { - fn.fe = (*Encoder).binaryMarshal - fn.fd = (*Decoder).binaryUnmarshal - fi.addrF = true - fi.addrD = ti.isFlag(tiflagBinaryUnmarshalerPtr) - fi.addrE = ti.isFlag(tiflagBinaryMarshalerPtr) - } else if supportMarshalInterfaces && !x.isBe() && x.isJs() && - (ti.isFlag(tiflagJsonMarshaler) || ti.isFlag(tiflagJsonMarshalerPtr)) && - (ti.isFlag(tiflagJsonUnmarshaler) || ti.isFlag(tiflagJsonUnmarshalerPtr)) { - //If JSON, we should check JSONMarshal before textMarshal - fn.fe = (*Encoder).jsonMarshal - fn.fd = (*Decoder).jsonUnmarshal - fi.addrF = true - fi.addrD = ti.isFlag(tiflagJsonUnmarshalerPtr) - fi.addrE = ti.isFlag(tiflagJsonMarshalerPtr) - } else if supportMarshalInterfaces && !x.isBe() && - (ti.isFlag(tiflagTextMarshaler) || ti.isFlag(tiflagTextMarshalerPtr)) && - (ti.isFlag(tiflagTextUnmarshaler) || ti.isFlag(tiflagTextUnmarshalerPtr)) { - fn.fe = (*Encoder).textMarshal - fn.fd = (*Decoder).textUnmarshal - fi.addrF = true - fi.addrD = ti.isFlag(tiflagTextUnmarshalerPtr) - fi.addrE = ti.isFlag(tiflagTextMarshalerPtr) - } else { - if fastpathEnabled && (rk == reflect.Map || rk == reflect.Slice) { - if ti.pkgpath == "" { // un-named slice or map - if idx := fastpathAV.index(rtid); idx != -1 { - fn.fe = fastpathAV[idx].encfn - fn.fd = fastpathAV[idx].decfn - fi.addrD = true - fi.addrF = false - } - } else { - // use mapping for underlying type if there - var rtu reflect.Type - if rk == reflect.Map { - rtu = reflect.MapOf(ti.key, ti.elem) - } else { - rtu = reflect.SliceOf(ti.elem) - } - rtuid := rt2id(rtu) - if idx := fastpathAV.index(rtuid); idx != -1 { - xfnf := fastpathAV[idx].encfn - xrt := fastpathAV[idx].rt - fn.fe = func(e *Encoder, xf *codecFnInfo, xrv reflect.Value) { - xfnf(e, xf, rvConvert(xrv, xrt)) - } - fi.addrD = true - fi.addrF = false // meaning it can be an address(ptr) or a value - xfnf2 := fastpathAV[idx].decfn - xptr2rt := reflect.PtrTo(xrt) - fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) { - if xrv.Kind() == reflect.Ptr { - xfnf2(d, xf, rvConvert(xrv, xptr2rt)) - } else { - xfnf2(d, xf, rvConvert(xrv, xrt)) - } - } - } - } - } - if fn.fe == nil && fn.fd == nil { - switch rk { - case reflect.Bool: - fn.fe = (*Encoder).kBool - fn.fd = (*Decoder).kBool - case reflect.String: - // Do not use different functions based on StringToRaw option, - // as that will statically set the function for a string type, - // and if the Handle is modified thereafter, behaviour is non-deterministic. - // i.e. DO NOT DO: - // if x.StringToRaw { - // fn.fe = (*Encoder).kStringToRaw - // } else { - // fn.fe = (*Encoder).kStringEnc - // } - - fn.fe = (*Encoder).kString - fn.fd = (*Decoder).kString - case reflect.Int: - fn.fd = (*Decoder).kInt - fn.fe = (*Encoder).kInt - case reflect.Int8: - fn.fe = (*Encoder).kInt8 - fn.fd = (*Decoder).kInt8 - case reflect.Int16: - fn.fe = (*Encoder).kInt16 - fn.fd = (*Decoder).kInt16 - case reflect.Int32: - fn.fe = (*Encoder).kInt32 - fn.fd = (*Decoder).kInt32 - case reflect.Int64: - fn.fe = (*Encoder).kInt64 - fn.fd = (*Decoder).kInt64 - case reflect.Uint: - fn.fd = (*Decoder).kUint - fn.fe = (*Encoder).kUint - case reflect.Uint8: - fn.fe = (*Encoder).kUint8 - fn.fd = (*Decoder).kUint8 - case reflect.Uint16: - fn.fe = (*Encoder).kUint16 - fn.fd = (*Decoder).kUint16 - case reflect.Uint32: - fn.fe = (*Encoder).kUint32 - fn.fd = (*Decoder).kUint32 - case reflect.Uint64: - fn.fe = (*Encoder).kUint64 - fn.fd = (*Decoder).kUint64 - case reflect.Uintptr: - fn.fe = (*Encoder).kUintptr - fn.fd = (*Decoder).kUintptr - case reflect.Float32: - fn.fe = (*Encoder).kFloat32 - fn.fd = (*Decoder).kFloat32 - case reflect.Float64: - fn.fe = (*Encoder).kFloat64 - fn.fd = (*Decoder).kFloat64 - case reflect.Invalid: - fn.fe = (*Encoder).kInvalid - fn.fd = (*Decoder).kErr - case reflect.Chan: - fi.seq = seqTypeChan - fn.fe = (*Encoder).kChan - fn.fd = (*Decoder).kSliceForChan - case reflect.Slice: - fi.seq = seqTypeSlice - fn.fe = (*Encoder).kSlice - fn.fd = (*Decoder).kSlice - case reflect.Array: - fi.seq = seqTypeArray - fn.fe = (*Encoder).kArray - fi.addrF = false - fi.addrD = false - rt2 := reflect.SliceOf(ti.elem) - fn.fd = func(d *Decoder, xf *codecFnInfo, xrv reflect.Value) { - // call fnVia directly, so fn(...) is not recursive, and can be inlined - d.h.fnVia(rt2, &x.rtidFns, true).fd(d, xf, rvGetSlice4Array(xrv, rt2)) - } - case reflect.Struct: - if ti.anyOmitEmpty || - ti.isFlag(tiflagMissingFielder) || - ti.isFlag(tiflagMissingFielderPtr) { - fn.fe = (*Encoder).kStruct - } else { - fn.fe = (*Encoder).kStructNoOmitempty - } - fn.fd = (*Decoder).kStruct - case reflect.Map: - fn.fe = (*Encoder).kMap - fn.fd = (*Decoder).kMap - case reflect.Interface: - // encode: reflect.Interface are handled already by preEncodeValue - fn.fd = (*Decoder).kInterface - fn.fe = (*Encoder).kErr - default: - // reflect.Ptr and reflect.Interface are handled already by preEncodeValue - fn.fe = (*Encoder).kErr - fn.fd = (*Decoder).kErr - } - } - } - return -} - -// Handle defines a specific encoding format. It also stores any runtime state -// used during an Encoding or Decoding session e.g. stored state about Types, etc. -// -// Once a handle is configured, it can be shared across multiple Encoders and Decoders. -// -// Note that a Handle is NOT safe for concurrent modification. -// -// A Handle also should not be modified after it is configured and has -// been used at least once. This is because stored state may be out of sync with the -// new configuration, and a data race can occur when multiple goroutines access it. -// i.e. multiple Encoders or Decoders in different goroutines. -// -// Consequently, the typical usage model is that a Handle is pre-configured -// before first time use, and not modified while in use. -// Such a pre-configured Handle is safe for concurrent access. -type Handle interface { - Name() string - // return the basic handle. It may not have been inited. - // Prefer to use basicHandle() helper function that ensures it has been inited. - getBasicHandle() *BasicHandle - newEncDriver() encDriver - newDecDriver() decDriver - isBinary() bool -} - -// Raw represents raw formatted bytes. -// We "blindly" store it during encode and retrieve the raw bytes during decode. -// Note: it is dangerous during encode, so we may gate the behaviour -// behind an Encode flag which must be explicitly set. -type Raw []byte - -// RawExt represents raw unprocessed extension data. -// Some codecs will decode extension data as a *RawExt -// if there is no registered extension for the tag. -// -// Only one of Data or Value is nil. -// If Data is nil, then the content of the RawExt is in the Value. -type RawExt struct { - Tag uint64 - // Data is the []byte which represents the raw ext. If nil, ext is exposed in Value. - // Data is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of types - Data []byte - // Value represents the extension, if Data is nil. - // Value is used by codecs (e.g. cbor, json) which leverage the format to do - // custom serialization of the types. - Value interface{} -} - -// BytesExt handles custom (de)serialization of types to/from []byte. -// It is used by codecs (e.g. binc, msgpack, simple) which do custom serialization of the types. -type BytesExt interface { - // WriteExt converts a value to a []byte. - // - // Note: v is a pointer iff the registered extension type is a struct or array kind. - WriteExt(v interface{}) []byte - - // ReadExt updates a value from a []byte. - // - // Note: dst is always a pointer kind to the registered extension type. - ReadExt(dst interface{}, src []byte) -} - -// InterfaceExt handles custom (de)serialization of types to/from another interface{} value. -// The Encoder or Decoder will then handle the further (de)serialization of that known type. -// -// It is used by codecs (e.g. cbor, json) which use the format to do custom serialization of types. -type InterfaceExt interface { - // ConvertExt converts a value into a simpler interface for easy encoding - // e.g. convert time.Time to int64. - // - // Note: v is a pointer iff the registered extension type is a struct or array kind. - ConvertExt(v interface{}) interface{} - - // UpdateExt updates a value from a simpler interface for easy decoding - // e.g. convert int64 to time.Time. - // - // Note: dst is always a pointer kind to the registered extension type. - UpdateExt(dst interface{}, src interface{}) -} - -// Ext handles custom (de)serialization of custom types / extensions. -type Ext interface { - BytesExt - InterfaceExt -} - -// addExtWrapper is a wrapper implementation to support former AddExt exported method. -type addExtWrapper struct { - encFn func(reflect.Value) ([]byte, error) - decFn func(reflect.Value, []byte) error -} - -func (x addExtWrapper) WriteExt(v interface{}) []byte { - bs, err := x.encFn(rv4i(v)) - if err != nil { - panic(err) - } - return bs -} - -func (x addExtWrapper) ReadExt(v interface{}, bs []byte) { - if err := x.decFn(rv4i(v), bs); err != nil { - panic(err) - } -} - -func (x addExtWrapper) ConvertExt(v interface{}) interface{} { - return x.WriteExt(v) -} - -func (x addExtWrapper) UpdateExt(dest interface{}, v interface{}) { - x.ReadExt(dest, v.([]byte)) -} - -type bytesExtFailer struct{} - -func (bytesExtFailer) WriteExt(v interface{}) []byte { - halt.errorstr("BytesExt.WriteExt is not supported") - return nil -} -func (bytesExtFailer) ReadExt(v interface{}, bs []byte) { - halt.errorstr("BytesExt.ReadExt is not supported") -} - -type interfaceExtFailer struct{} - -func (interfaceExtFailer) ConvertExt(v interface{}) interface{} { - halt.errorstr("InterfaceExt.ConvertExt is not supported") - return nil -} -func (interfaceExtFailer) UpdateExt(dest interface{}, v interface{}) { - halt.errorstr("InterfaceExt.UpdateExt is not supported") -} - -type bytesExtWrapper struct { - interfaceExtFailer - BytesExt -} - -type interfaceExtWrapper struct { - bytesExtFailer - InterfaceExt -} - -type extFailWrapper struct { - bytesExtFailer - interfaceExtFailer -} - -type binaryEncodingType struct{} - -func (binaryEncodingType) isBinary() bool { return true } - -type textEncodingType struct{} - -func (textEncodingType) isBinary() bool { return false } - -// noBuiltInTypes is embedded into many types which do not support builtins -// e.g. msgpack, simple, cbor. - -type noBuiltInTypes struct{} - -func (noBuiltInTypes) EncodeBuiltin(rt uintptr, v interface{}) {} -func (noBuiltInTypes) DecodeBuiltin(rt uintptr, v interface{}) {} - -// bigenHelper. -// Users must already slice the x completely, because we will not reslice. -type bigenHelper struct { - x []byte // must be correctly sliced to appropriate len. slicing is a cost. - w *encWr -} - -func (z bigenHelper) writeUint16(v uint16) { - bigen.PutUint16(z.x, v) - z.w.writeb(z.x) -} - -func (z bigenHelper) writeUint32(v uint32) { - bigen.PutUint32(z.x, v) - z.w.writeb(z.x) -} - -func (z bigenHelper) writeUint64(v uint64) { - bigen.PutUint64(z.x, v) - z.w.writeb(z.x) -} - -type extTypeTagFn struct { - rtid uintptr - rtidptr uintptr - rt reflect.Type - tag uint64 - ext Ext - // _ [1]uint64 // padding -} - -type extHandle []extTypeTagFn - -// AddExt registes an encode and decode function for a reflect.Type. -// To deregister an Ext, call AddExt with nil encfn and/or nil decfn. -// -// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead. -func (o *extHandle) AddExt(rt reflect.Type, tag byte, - encfn func(reflect.Value) ([]byte, error), - decfn func(reflect.Value, []byte) error) (err error) { - if encfn == nil || decfn == nil { - return o.SetExt(rt, uint64(tag), nil) - } - return o.SetExt(rt, uint64(tag), addExtWrapper{encfn, decfn}) -} - -// SetExt will set the extension for a tag and reflect.Type. -// Note that the type must be a named type, and specifically not a pointer or Interface. -// An error is returned if that is not honored. -// To Deregister an ext, call SetExt with nil Ext. -// -// Deprecated: Use SetBytesExt or SetInterfaceExt on the Handle instead. -func (o *extHandle) SetExt(rt reflect.Type, tag uint64, ext Ext) (err error) { - // o is a pointer, because we may need to initialize it - // We EXPECT *o is a pointer to a non-nil extHandle. - - rk := rt.Kind() - for rk == reflect.Ptr { - rt = rt.Elem() - rk = rt.Kind() - } - - if rt.PkgPath() == "" || rk == reflect.Interface { // || rk == reflect.Ptr { - return fmt.Errorf("codec.Handle.SetExt: Takes named type, not a pointer or interface: %v", rt) - } - - rtid := rt2id(rt) - switch rtid { - case timeTypId, rawTypId, rawExtTypId: - // all natively supported type, so cannot have an extension. - // However, we do not return an error for these, as we do not document that. - // Instead, we silently treat as a no-op, and return. - return - } - o2 := *o - for i := range o2 { - v := &o2[i] - if v.rtid == rtid { - v.tag, v.ext = tag, ext - return - } - } - rtidptr := rt2id(reflect.PtrTo(rt)) - *o = append(o2, extTypeTagFn{rtid, rtidptr, rt, tag, ext}) // , [1]uint64{}}) - return -} - -func (o extHandle) getExt(rtid uintptr, check bool) (v *extTypeTagFn) { - if !check { - return - } - for i := range o { - v = &o[i] - if v.rtid == rtid || v.rtidptr == rtid { - return - } - } - return nil -} - -func (o extHandle) getExtForTag(tag uint64) (v *extTypeTagFn) { - for i := range o { - v = &o[i] - if v.tag == tag { - return - } - } - return nil -} - -type intf2impl struct { - rtid uintptr // for intf - impl reflect.Type - // _ [1]uint64 // padding // not-needed, as *intf2impl is never returned. -} - -type intf2impls []intf2impl - -// Intf2Impl maps an interface to an implementing type. -// This allows us support infering the concrete type -// and populating it when passed an interface. -// e.g. var v io.Reader can be decoded as a bytes.Buffer, etc. -// -// Passing a nil impl will clear the mapping. -func (o *intf2impls) Intf2Impl(intf, impl reflect.Type) (err error) { - if impl != nil && !impl.Implements(intf) { - return fmt.Errorf("Intf2Impl: %v does not implement %v", impl, intf) - } - rtid := rt2id(intf) - o2 := *o - for i := range o2 { - v := &o2[i] - if v.rtid == rtid { - v.impl = impl - return - } - } - *o = append(o2, intf2impl{rtid, impl}) - return -} - -func (o intf2impls) intf2impl(rtid uintptr) (rv reflect.Value) { - for i := range o { - v := &o[i] - if v.rtid == rtid { - if v.impl == nil { - return - } - vkind := v.impl.Kind() - if vkind == reflect.Ptr { - return reflect.New(v.impl.Elem()) - } - return rvZeroAddrK(v.impl, vkind) - } - } - return -} - -type structFieldInfoFlag uint8 - -const ( - _ structFieldInfoFlag = 1 << iota - structFieldInfoFlagReady - structFieldInfoFlagOmitEmpty -) - -func (x *structFieldInfoFlag) flagSet(f structFieldInfoFlag) { - *x = *x | f -} - -func (x *structFieldInfoFlag) flagClr(f structFieldInfoFlag) { - *x = *x &^ f -} - -func (x structFieldInfoFlag) flagGet(f structFieldInfoFlag) bool { - return x&f != 0 -} - -func (x structFieldInfoFlag) omitEmpty() bool { - return x.flagGet(structFieldInfoFlagOmitEmpty) -} - -func (x structFieldInfoFlag) ready() bool { - return x.flagGet(structFieldInfoFlagReady) -} - -type structFieldInfo struct { - encName string // encode name - fieldName string // field name - - is [maxLevelsEmbedding]uint16 // (recursive/embedded) field index in struct - nis uint8 // num levels of embedding. if 1, then it's not embedded. - - encNameAsciiAlphaNum bool // the encName only contains ascii alphabet and numbers - structFieldInfoFlag - // _ [1]byte // padding -} - -// func (si *structFieldInfo) setToZeroValue(v reflect.Value) { -// if v, valid := si.field(v, false); valid { -// v.Set(reflect.Zero(v.Type())) -// } -// } - -// rv returns the field of the struct. -// If anonymous, it returns an Invalid -func (si *structFieldInfo) field(v reflect.Value, update bool) (rv2 reflect.Value, valid bool) { - // replicate FieldByIndex - for i, x := range si.is { - if uint8(i) == si.nis { - break - } - if v, valid = baseStructRv(v, update); !valid { - return - } - v = v.Field(int(x)) - } - - return v, true -} - -func parseStructInfo(stag string) (toArray, omitEmpty bool, keytype valueType) { - keytype = valueTypeString // default - if stag == "" { - return - } - for i, s := range strings.Split(stag, ",") { - if i == 0 { - } else { - switch s { - case "omitempty": - omitEmpty = true - case "toarray": - toArray = true - case "int": - keytype = valueTypeInt - case "uint": - keytype = valueTypeUint - case "float": - keytype = valueTypeFloat - // case "bool": - // keytype = valueTypeBool - case "string": - keytype = valueTypeString - } - } - } - return -} - -func (si *structFieldInfo) parseTag(stag string) { - // if fname == "" { - // panic(errNoFieldNameToStructFieldInfo) - // } - - if stag == "" { - return - } - for i, s := range strings.Split(stag, ",") { - if i == 0 { - if s != "" { - si.encName = s - } - } else { - switch s { - case "omitempty": - si.flagSet(structFieldInfoFlagOmitEmpty) - } - } - } -} - -type sfiSortedByEncName []*structFieldInfo - -func (p sfiSortedByEncName) Len() int { return len(p) } -func (p sfiSortedByEncName) Less(i, j int) bool { return p[uint(i)].encName < p[uint(j)].encName } -func (p sfiSortedByEncName) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } - -const structFieldNodeNumToCache = 4 - -type structFieldNodeCache struct { - rv [structFieldNodeNumToCache]reflect.Value - idx [structFieldNodeNumToCache]uint32 - num uint8 -} - -func (x *structFieldNodeCache) get(key uint32) (fv reflect.Value, valid bool) { - for i, k := range &x.idx { - if uint8(i) == x.num { - return // break - } - if key == k { - return x.rv[i], true - } - } - return -} - -func (x *structFieldNodeCache) tryAdd(fv reflect.Value, key uint32) { - if x.num < structFieldNodeNumToCache { - x.rv[x.num] = fv - x.idx[x.num] = key - x.num++ - return - } -} - -type structFieldNode struct { - v reflect.Value - cache2 structFieldNodeCache - cache3 structFieldNodeCache - update bool -} - -func (x *structFieldNode) field(si *structFieldInfo) (fv reflect.Value) { - // return si.fieldval(x.v, x.update) - - // Note: we only cache if nis=2 or nis=3 i.e. up to 2 levels of embedding - // This mostly saves us time on the repeated calls to v.Elem, v.Field, etc. - var valid bool - switch si.nis { - case 1: - fv = x.v.Field(int(si.is[0])) - case 2: - if fv, valid = x.cache2.get(uint32(si.is[0])); valid { - fv = fv.Field(int(si.is[1])) - return - } - fv = x.v.Field(int(si.is[0])) - if fv, valid = baseStructRv(fv, x.update); !valid { - return - } - x.cache2.tryAdd(fv, uint32(si.is[0])) - fv = fv.Field(int(si.is[1])) - case 3: - var key uint32 = uint32(si.is[0])<<16 | uint32(si.is[1]) - if fv, valid = x.cache3.get(key); valid { - fv = fv.Field(int(si.is[2])) - return - } - fv = x.v.Field(int(si.is[0])) - if fv, valid = baseStructRv(fv, x.update); !valid { - return - } - fv = fv.Field(int(si.is[1])) - if fv, valid = baseStructRv(fv, x.update); !valid { - return - } - x.cache3.tryAdd(fv, key) - fv = fv.Field(int(si.is[2])) - default: - fv, _ = si.field(x.v, x.update) - } - return -} - -func baseStructRv(v reflect.Value, update bool) (v2 reflect.Value, valid bool) { - for v.Kind() == reflect.Ptr { - if rvIsNil(v) { - if !update { - return - } - rvSetDirect(v, reflect.New(v.Type().Elem())) - } - v = v.Elem() - } - return v, true -} - -type tiflag uint32 - -const ( - _ tiflag = 1 << iota - - tiflagComparable - - tiflagIsZeroer - tiflagIsZeroerPtr - - tiflagBinaryMarshaler - tiflagBinaryMarshalerPtr - - tiflagBinaryUnmarshaler - tiflagBinaryUnmarshalerPtr - - tiflagTextMarshaler - tiflagTextMarshalerPtr - - tiflagTextUnmarshaler - tiflagTextUnmarshalerPtr - - tiflagJsonMarshaler - tiflagJsonMarshalerPtr - - tiflagJsonUnmarshaler - tiflagJsonUnmarshalerPtr - - tiflagSelfer - tiflagSelferPtr - - tiflagMissingFielder - tiflagMissingFielderPtr -) - -// typeInfo keeps static (non-changing readonly)information -// about each (non-ptr) type referenced in the encode/decode sequence. -// -// During an encode/decode sequence, we work as below: -// - If base is a built in type, en/decode base value -// - If base is registered as an extension, en/decode base value -// - If type is binary(M/Unm)arshaler, call Binary(M/Unm)arshal method -// - If type is text(M/Unm)arshaler, call Text(M/Unm)arshal method -// - Else decode appropriately based on the reflect.Kind -type typeInfo struct { - rt reflect.Type - elem reflect.Type - pkgpath string - - rtid uintptr - - numMeth uint16 // number of methods - kind uint8 - chandir uint8 - - anyOmitEmpty bool // true if a struct, and any of the fields are tagged "omitempty" - toArray bool // whether this (struct) type should be encoded as an array - keyType valueType // if struct, how is the field name stored in a stream? default is string - mbs bool // base type (T or *T) is a MapBySlice - - // ---- cpu cache line boundary? - sfiSort []*structFieldInfo // sorted. Used when enc/dec struct to map. - sfiSrc []*structFieldInfo // unsorted. Used when enc/dec struct to array. - - key reflect.Type - - // ---- cpu cache line boundary? - // sfis []structFieldInfo // all sfi, in src order, as created. - sfiNamesSort []byte // all names, with indexes into the sfiSort - - // rv0 is the zero value for the type. - // It is mostly beneficial for all non-reference kinds - // i.e. all but map/chan/func/ptr/unsafe.pointer - // so beneficial for intXX, bool, slices, structs, etc - rv0 reflect.Value - - elemsize uintptr - - // other flags, with individual bits representing if set. - flags tiflag - - infoFieldOmitempty bool - - elemkind uint8 - _ [2]byte // padding - // _ [1]uint64 // padding -} - -func (ti *typeInfo) isFlag(f tiflag) bool { - return ti.flags&f != 0 -} - -func (ti *typeInfo) flag(when bool, f tiflag) *typeInfo { - if when { - ti.flags |= f - } - return ti -} - -func (ti *typeInfo) indexForEncName(name []byte) (index int16) { - var sn []byte - if len(name)+2 <= 32 { - var buf [32]byte // should not escape to heap - sn = buf[:len(name)+2] - } else { - sn = make([]byte, len(name)+2) - } - copy(sn[1:], name) - sn[0], sn[len(sn)-1] = tiSep2(name), 0xff - j := bytes.Index(ti.sfiNamesSort, sn) - if j < 0 { - return -1 - } - index = int16(uint16(ti.sfiNamesSort[j+len(sn)+1]) | uint16(ti.sfiNamesSort[j+len(sn)])<<8) - return -} - -type rtid2ti struct { - rtid uintptr - ti *typeInfo -} - -// TypeInfos caches typeInfo for each type on first inspection. -// -// It is configured with a set of tag keys, which are used to get -// configuration for the type. -type TypeInfos struct { - // infos: formerly map[uintptr]*typeInfo, now *[]rtid2ti, 2 words expected - infos atomicTypeInfoSlice - mu sync.Mutex - _ uint64 // padding (cache-aligned) - tags []string - _ uint64 // padding (cache-aligned) -} - -// NewTypeInfos creates a TypeInfos given a set of struct tags keys. -// -// This allows users customize the struct tag keys which contain configuration -// of their types. -func NewTypeInfos(tags []string) *TypeInfos { - return &TypeInfos{tags: tags} -} - -func (x *TypeInfos) structTag(t reflect.StructTag) (s string) { - // check for tags: codec, json, in that order. - // this allows seamless support for many configured structs. - for _, x := range x.tags { - s = t.Get(x) - if s != "" { - return s - } - } - return -} - -func findTypeInfo(s []rtid2ti, rtid uintptr) (i uint, ti *typeInfo) { - // binary search. adapted from sort/search.go. - // Note: we use goto (instead of for loop) so this can be inlined. - - // h, i, j := 0, 0, len(s) - var h uint // var h, i uint - var j = uint(len(s)) -LOOP: - if i < j { - h = i + (j-i)/2 - if s[h].rtid < rtid { - i = h + 1 - } else { - j = h - } - goto LOOP - } - if i < uint(len(s)) && s[i].rtid == rtid { - ti = s[i].ti - } - return -} - -func (x *TypeInfos) get(rtid uintptr, rt reflect.Type) (pti *typeInfo) { - sp := x.infos.load() - if sp != nil { - _, pti = findTypeInfo(sp, rtid) - if pti != nil { - return - } - } - - rk := rt.Kind() - - if rk == reflect.Ptr { // || (rk == reflect.Interface && rtid != intfTypId) { - halt.errorf("invalid kind passed to TypeInfos.get: %v - %v", rk, rt) - } - - // do not hold lock while computing this. - // it may lead to duplication, but that's ok. - ti := typeInfo{ - rt: rt, - rtid: rtid, - kind: uint8(rk), - pkgpath: rt.PkgPath(), - keyType: valueTypeString, // default it - so it's never 0 - } - ti.rv0 = reflect.Zero(rt) - - ti.numMeth = uint16(rt.NumMethod()) - - var b1, b2 bool - b1, b2 = implIntf(rt, binaryMarshalerTyp) - ti.flag(b1, tiflagBinaryMarshaler).flag(b2, tiflagBinaryMarshalerPtr) - b1, b2 = implIntf(rt, binaryUnmarshalerTyp) - ti.flag(b1, tiflagBinaryUnmarshaler).flag(b2, tiflagBinaryUnmarshalerPtr) - b1, b2 = implIntf(rt, textMarshalerTyp) - ti.flag(b1, tiflagTextMarshaler).flag(b2, tiflagTextMarshalerPtr) - b1, b2 = implIntf(rt, textUnmarshalerTyp) - ti.flag(b1, tiflagTextUnmarshaler).flag(b2, tiflagTextUnmarshalerPtr) - b1, b2 = implIntf(rt, jsonMarshalerTyp) - ti.flag(b1, tiflagJsonMarshaler).flag(b2, tiflagJsonMarshalerPtr) - b1, b2 = implIntf(rt, jsonUnmarshalerTyp) - ti.flag(b1, tiflagJsonUnmarshaler).flag(b2, tiflagJsonUnmarshalerPtr) - b1, b2 = implIntf(rt, selferTyp) - ti.flag(b1, tiflagSelfer).flag(b2, tiflagSelferPtr) - b1, b2 = implIntf(rt, missingFielderTyp) - ti.flag(b1, tiflagMissingFielder).flag(b2, tiflagMissingFielderPtr) - b1, b2 = implIntf(rt, iszeroTyp) - ti.flag(b1, tiflagIsZeroer).flag(b2, tiflagIsZeroerPtr) - b1 = rt.Comparable() - ti.flag(b1, tiflagComparable) - - switch rk { - case reflect.Struct: - var omitEmpty bool - if f, ok := rt.FieldByName(structInfoFieldName); ok { - ti.toArray, omitEmpty, ti.keyType = parseStructInfo(x.structTag(f.Tag)) - ti.infoFieldOmitempty = omitEmpty - } else { - ti.keyType = valueTypeString - } - pp, pi := &pool4tiload, pool4tiload.Get() // pool.tiLoad() - pv := pi.(*typeInfoLoadArray) - pv.etypes[0] = ti.rtid - // vv := typeInfoLoad{pv.fNames[:0], pv.encNames[:0], pv.etypes[:1], pv.sfis[:0]} - vv := typeInfoLoad{pv.etypes[:1], pv.sfis[:0]} - x.rget(rt, rtid, omitEmpty, nil, &vv) - ti.sfiSrc, ti.sfiSort, ti.sfiNamesSort, ti.anyOmitEmpty = rgetResolveSFI(rt, vv.sfis, pv) - pp.Put(pi) - case reflect.Map: - ti.elem = rt.Elem() - ti.key = rt.Key() - case reflect.Slice: - ti.mbs, _ = implIntf(rt, mapBySliceTyp) - ti.elem = rt.Elem() - ti.elemsize = ti.elem.Size() - ti.elemkind = uint8(ti.elem.Kind()) - case reflect.Chan: - ti.elem = rt.Elem() - ti.chandir = uint8(rt.ChanDir()) - case reflect.Array: - ti.elem = rt.Elem() - ti.elemsize = ti.elem.Size() - ti.elemkind = uint8(ti.elem.Kind()) - case reflect.Ptr: - ti.elem = rt.Elem() - } - - x.mu.Lock() - sp = x.infos.load() - var sp2 []rtid2ti - if sp == nil { - pti = &ti - sp2 = []rtid2ti{{rtid, pti}} - x.infos.store(sp2) - } else { - var idx uint - idx, pti = findTypeInfo(sp, rtid) - if pti == nil { - pti = &ti - sp2 = make([]rtid2ti, len(sp)+1) - copy(sp2, sp[:idx]) - copy(sp2[idx+1:], sp[idx:]) - sp2[idx] = rtid2ti{rtid, pti} - x.infos.store(sp2) - } - } - x.mu.Unlock() - return -} - -func (x *TypeInfos) rget(rt reflect.Type, rtid uintptr, omitEmpty bool, - indexstack []uint16, pv *typeInfoLoad) { - // Read up fields and store how to access the value. - // - // It uses go's rules for message selectors, - // which say that the field with the shallowest depth is selected. - // - // Note: we consciously use slices, not a map, to simulate a set. - // Typically, types have < 16 fields, - // and iteration using equals is faster than maps there - flen := rt.NumField() - if flen > (1< %v fields are not supported - has %v fields", - (1<= 0; i-- { // bounds-check elimination - b := si.encName[i] - if (b >= '0' && b <= '9') || (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z') { - continue - } - si.encNameAsciiAlphaNum = false - break - } - si.fieldName = f.Name - si.flagSet(structFieldInfoFlagReady) - - if len(indexstack) > maxLevelsEmbedding-1 { - halt.errorf("codec: only supports up to %v depth of embedding - type has %v depth", - maxLevelsEmbedding-1, len(indexstack)) - } - si.nis = uint8(len(indexstack)) + 1 - copy(si.is[:], indexstack) - si.is[len(indexstack)] = j - - if omitEmpty { - si.flagSet(structFieldInfoFlagOmitEmpty) - } - pv.sfis = append(pv.sfis, si) - } -} - -func tiSep(name string) uint8 { - // (xn[0]%64) // (between 192-255 - outside ascii BMP) - // Tried the following before settling on correct implementation: - // return 0xfe - (name[0] & 63) - // return 0xfe - (name[0] & 63) - uint8(len(name)) - // return 0xfe - (name[0] & 63) - uint8(len(name)&63) - // return ((0xfe - (name[0] & 63)) & 0xf8) | (uint8(len(name) & 0x07)) - - return 0xfe - (name[0] & 63) - uint8(len(name)&63) -} - -func tiSep2(name []byte) uint8 { - return 0xfe - (name[0] & 63) - uint8(len(name)&63) -} - -// resolves the struct field info got from a call to rget. -// Returns a trimmed, unsorted and sorted []*structFieldInfo. -func rgetResolveSFI(rt reflect.Type, x []structFieldInfo, pv *typeInfoLoadArray) ( - y, z []*structFieldInfo, ss []byte, anyOmitEmpty bool) { - sa := pv.sfiidx[:0] - sn := pv.b[:] - n := len(x) - - var xn string - var ui uint16 - var sep byte - - for i := range x { - ui = uint16(i) - xn = x[i].encName // fieldName or encName? use encName for now. - if len(xn)+2 > cap(sn) { - sn = make([]byte, len(xn)+2) - } else { - sn = sn[:len(xn)+2] - } - // use a custom sep, so that misses are less frequent, - // since the sep (first char in search) is as unique as first char in field name. - sep = tiSep(xn) - sn[0], sn[len(sn)-1] = sep, 0xff - copy(sn[1:], xn) - j := bytes.Index(sa, sn) - if j == -1 { - sa = append(sa, sep) - sa = append(sa, xn...) - sa = append(sa, 0xff, byte(ui>>8), byte(ui)) - } else { - index := uint16(sa[j+len(sn)+1]) | uint16(sa[j+len(sn)])<<8 - // one of them must be cleared (reset to nil), - // and the index updated appropriately - i2clear := ui // index to be cleared - if x[i].nis < x[index].nis { // this one is shallower - // update the index to point to this later one. - sa[j+len(sn)], sa[j+len(sn)+1] = byte(ui>>8), byte(ui) - // clear the earlier one, as this later one is shallower. - i2clear = index - } - if x[i2clear].ready() { - x[i2clear].flagClr(structFieldInfoFlagReady) - n-- - } - } - } - - var w []structFieldInfo - sharingArray := len(x) <= typeInfoLoadArraySfisLen // sharing array with typeInfoLoadArray - if sharingArray { - w = make([]structFieldInfo, n) - } - - // remove all the nils (non-ready) - y = make([]*structFieldInfo, n) - n = 0 - var sslen int - for i := range x { - if !x[i].ready() { - continue - } - if !anyOmitEmpty && x[i].omitEmpty() { - anyOmitEmpty = true - } - if sharingArray { - w[n] = x[i] - y[n] = &w[n] - } else { - y[n] = &x[i] - } - sslen = sslen + len(x[i].encName) + 4 - n++ - } - if n != len(y) { - halt.errorf("failure reading struct %v - expecting %d of %d valid fields, got %d", - rt, len(y), len(x), n) - } - - z = make([]*structFieldInfo, len(y)) - copy(z, y) - sort.Sort(sfiSortedByEncName(z)) - - sharingArray = len(sa) <= typeInfoLoadArraySfiidxLen - if sharingArray { - ss = make([]byte, 0, sslen) - } else { - ss = sa[:0] // reuse the newly made sa array if necessary - } - for i := range z { - xn = z[i].encName - sep = tiSep(xn) - ui = uint16(i) - ss = append(ss, sep) - ss = append(ss, xn...) - ss = append(ss, 0xff, byte(ui>>8), byte(ui)) - } - return -} - -func implIntf(rt, iTyp reflect.Type) (base bool, indir bool) { - return rt.Implements(iTyp), reflect.PtrTo(rt).Implements(iTyp) -} - -// isEmptyStruct is only called from isEmptyValue, and checks if a struct is empty: -// - does it implement IsZero() bool -// - is it comparable, and can i compare directly using == -// - if checkStruct, then walk through the encodable fields -// and check if they are empty or not. -func isEmptyStruct(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool { - // v is a struct kind - no need to check again. - // We only check isZero on a struct kind, to reduce the amount of times - // that we lookup the rtid and typeInfo for each type as we walk the tree. - - vt := v.Type() - rtid := rt2id(vt) - if tinfos == nil { - tinfos = defTypeInfos - } - ti := tinfos.get(rtid, vt) - if ti.rtid == timeTypId { - return rv2i(v).(time.Time).IsZero() - } - if ti.isFlag(tiflagIsZeroerPtr) && v.CanAddr() { - return rv2i(v.Addr()).(isZeroer).IsZero() - } - if ti.isFlag(tiflagIsZeroer) { - return rv2i(v).(isZeroer).IsZero() - } - if ti.isFlag(tiflagComparable) { - return rv2i(v) == rv2i(reflect.Zero(vt)) - } - if !checkStruct { - return false - } - // We only care about what we can encode/decode, - // so that is what we use to check omitEmpty. - for _, si := range ti.sfiSrc { - sfv, valid := si.field(v, false) - if valid && !isEmptyValue(sfv, tinfos, deref, checkStruct) { - return false - } - } - return true -} - -// func roundFloat(x float64) float64 { -// t := math.Trunc(x) -// if math.Abs(x-t) >= 0.5 { -// return t + math.Copysign(1, x) -// } -// return t -// } - -func panicToErr(h errDecorator, err *error) { - // Note: This method MUST be called directly from defer i.e. defer panicToErr ... - // else it seems the recover is not fully handled - if recoverPanicToErr { - if x := recover(); x != nil { - // fmt.Printf("panic'ing with: %v\n", x) - // debug.PrintStack() - panicValToErr(h, x, err) - } - } -} - -func isSliceBoundsError(s string) bool { - return strings.Contains(s, "index out of range") || - strings.Contains(s, "slice bounds out of range") -} - -func panicValToErr(h errDecorator, v interface{}, err *error) { - d, dok := h.(*Decoder) - switch xerr := v.(type) { - case nil: - case error: - switch xerr { - case nil: - case io.EOF, io.ErrUnexpectedEOF, errEncoderNotInitialized, errDecoderNotInitialized: - // treat as special (bubble up) - *err = xerr - default: - if dok && d.bytes && isSliceBoundsError(xerr.Error()) { - *err = io.EOF - } else { - h.wrapErr(xerr, err) - } - } - case string: - if xerr != "" { - if dok && d.bytes && isSliceBoundsError(xerr) { - *err = io.EOF - } else { - h.wrapErr(xerr, err) - } - } - case fmt.Stringer: - if xerr != nil { - h.wrapErr(xerr, err) - } - default: - h.wrapErr(v, err) - } -} - -func isImmutableKind(k reflect.Kind) (v bool) { - // return immutableKindsSet[k] - // since we know reflect.Kind is in range 0..31, then use the k%32 == k constraint - return immutableKindsSet[k%reflect.Kind(len(immutableKindsSet))] // bounds-check-elimination -} - -func usableByteSlice(bs []byte, slen int) []byte { - if cap(bs) >= slen { - if bs == nil { - return []byte{} - } - return bs[:slen] - } - return make([]byte, slen) -} - -// ---- - -type codecFnInfo struct { - ti *typeInfo - xfFn Ext - xfTag uint64 - seq seqType - addrD bool - addrF bool // if addrD, this says whether decode function can take a value or a ptr - addrE bool -} - -// codecFn encapsulates the captured variables and the encode function. -// This way, we only do some calculations one times, and pass to the -// code block that should be called (encapsulated in a function) -// instead of executing the checks every time. -type codecFn struct { - i codecFnInfo - fe func(*Encoder, *codecFnInfo, reflect.Value) - fd func(*Decoder, *codecFnInfo, reflect.Value) - _ [1]uint64 // padding (cache-aligned) -} - -type codecRtidFn struct { - rtid uintptr - fn *codecFn -} - -func makeExt(ext interface{}) Ext { - if ext == nil { - return &extFailWrapper{} - } - switch t := ext.(type) { - case nil: - return &extFailWrapper{} - case Ext: - return t - case BytesExt: - return &bytesExtWrapper{BytesExt: t} - case InterfaceExt: - return &interfaceExtWrapper{InterfaceExt: t} - } - return &extFailWrapper{} -} - -func baseRV(v interface{}) (rv reflect.Value) { - for rv = rv4i(v); rv.Kind() == reflect.Ptr; rv = rv.Elem() { - } - return -} - -// ---- - -// these "checkOverflow" functions must be inlinable, and not call anybody. -// Overflow means that the value cannot be represented without wrapping/overflow. -// Overflow=false does not mean that the value can be represented without losing precision -// (especially for floating point). - -type checkOverflow struct{} - -// func (checkOverflow) Float16(f float64) (overflow bool) { -// halt.errorf("unimplemented") -// if f < 0 { -// f = -f -// } -// return math.MaxFloat32 < f && f <= math.MaxFloat64 -// } - -func (checkOverflow) Float32(v float64) (overflow bool) { - if v < 0 { - v = -v - } - return math.MaxFloat32 < v && v <= math.MaxFloat64 -} -func (checkOverflow) Uint(v uint64, bitsize uint8) (overflow bool) { - // if bitsize == 0 || bitsize >= 64 || v == 0 { - // if v == 0 { - // return - // } - // if trunc := (v << (64 - bitsize)) >> (64 - bitsize); v != trunc { - if v != 0 && v != (v<<(64-bitsize))>>(64-bitsize) { - overflow = true - } - return -} -func (checkOverflow) Int(v int64, bitsize uint8) (overflow bool) { - // if bitsize == 0 || bitsize >= 64 || v == 0 { - // if v == 0 { - // return - // } - // if trunc := (v << (64 - bitsize)) >> (64 - bitsize); v != trunc { - // overflow = true - // } - if v != 0 && v != (v<<(64-bitsize))>>(64-bitsize) { - overflow = true - } - return -} - -func (checkOverflow) Uint2Int(v uint64, neg bool) (overflow bool) { - return (neg && v > 1<<63) || (!neg && v >= 1<<63) -} - -func (checkOverflow) SignedInt(v uint64) (overflow bool) { - //e.g. -127 to 128 for int8 - pos := (v >> 63) == 0 - ui2 := v & 0x7fffffffffffffff - if pos { - if ui2 > math.MaxInt64 { - overflow = true - } - } else { - if ui2 > math.MaxInt64-1 { - overflow = true - } - } - return -} - -func (x checkOverflow) Float32V(v float64) float64 { - if x.Float32(v) { - halt.errorf("float32 overflow: %v", v) - } - return v -} -func (x checkOverflow) UintV(v uint64, bitsize uint8) uint64 { - if x.Uint(v, bitsize) { - halt.errorf("uint64 overflow: %v", v) - } - return v -} -func (x checkOverflow) IntV(v int64, bitsize uint8) int64 { - if x.Int(v, bitsize) { - halt.errorf("int64 overflow: %v", v) - } - return v -} -func (x checkOverflow) SignedIntV(v uint64) int64 { - if x.SignedInt(v) { - halt.errorf("uint64 to int64 overflow: %v", v) - } - return int64(v) -} - -// ------------------ FLOATING POINT ----------------- - -func isNaN64(f float64) bool { return f != f } -func isNaN32(f float32) bool { return f != f } -func abs32(f float32) float32 { - return math.Float32frombits(math.Float32bits(f) &^ (1 << 31)) -} - -// Per go spec, floats are represented in memory as -// IEEE single or double precision floating point values. -// -// We also looked at the source for stdlib math/modf.go, -// reviewed https://github.com/chewxy/math32 -// and read wikipedia documents describing the formats. -// -// It became clear that we could easily look at the bits to determine -// whether any fraction exists. -// -// This is all we need for now. - -func noFrac64(f float64) (v bool) { - x := math.Float64bits(f) - e := uint64(x>>52)&0x7FF - 1023 // uint(x>>shift)&mask - bias - // clear top 12+e bits, the integer part; if the rest is 0, then no fraction. - if e < 52 { - // return x&((1<<64-1)>>(12+e)) == 0 - return x<<(12+e) == 0 - } - return -} - -func noFrac32(f float32) (v bool) { - x := math.Float32bits(f) - e := uint32(x>>23)&0xFF - 127 // uint(x>>shift)&mask - bias - // clear top 9+e bits, the integer part; if the rest is 0, then no fraction. - if e < 23 { - // return x&((1<<32-1)>>(9+e)) == 0 - return x<<(9+e) == 0 - } - return -} - -func isWhitespaceChar(v byte) bool { - // these are in order of speed below ... - - return v < 33 - // return v < 33 && whitespaceCharBitset64.isset(v) - // return v < 33 && (v == ' ' || v == '\n' || v == '\t' || v == '\r') - // return v == ' ' || v == '\n' || v == '\t' || v == '\r' - // return whitespaceCharBitset.isset(v) -} - -func isNumberChar(v byte) bool { - // these are in order of speed below ... - - return numCharBitset.isset(v) - // return v < 64 && numCharNoExpBitset64.isset(v) || v == 'e' || v == 'E' - // return v > 42 && v < 102 && numCharWithExpBitset64.isset(v-42) -} - -func isDigitChar(v byte) bool { - // these are in order of speed below ... - - return digitCharBitset.isset(v) - // return v >= '0' && v <= '9' -} - -// func noFrac(f float64) bool { -// _, frac := math.Modf(float64(f)) -// return frac == 0 -// } - -// ----------------------- - -type ioFlusher interface { - Flush() error -} - -type ioPeeker interface { - Peek(int) ([]byte, error) -} - -type ioBuffered interface { - Buffered() int -} - -// ----------------------- - -type sfiRv struct { - v *structFieldInfo - r reflect.Value -} - -// ----------------- - -type set []interface{} - -func (s *set) add(v interface{}) (exists bool) { - // e.ci is always nil, or len >= 1 - x := *s - - if x == nil { - x = make([]interface{}, 1, 8) - x[0] = v - *s = x - return - } - // typically, length will be 1. make this perform. - if len(x) == 1 { - if j := x[0]; j == 0 { - x[0] = v - } else if j == v { - exists = true - } else { - x = append(x, v) - *s = x - } - return - } - // check if it exists - for _, j := range x { - if j == v { - exists = true - return - } - } - // try to replace a "deleted" slot - for i, j := range x { - if j == 0 { - x[i] = v - return - } - } - // if unable to replace deleted slot, just append it. - x = append(x, v) - *s = x - return -} - -func (s *set) remove(v interface{}) (exists bool) { - x := *s - if len(x) == 0 { - return - } - if len(x) == 1 { - if x[0] == v { - x[0] = 0 - } - return - } - for i, j := range x { - if j == v { - exists = true - x[i] = 0 // set it to 0, as way to delete it. - // copy(x[i:], x[i+1:]) - // x = x[:len(x)-1] - return - } - } - return -} - -// ------ - -// bitset types are better than [256]bool, because they permit the whole -// bitset array being on a single cache line and use less memory. -// -// Also, since pos is a byte (0-255), there's no bounds checks on indexing (cheap). -// -// We previously had bitset128 [16]byte, and bitset32 [4]byte, but those introduces -// bounds checking, so we discarded them, and everyone uses bitset256. -// -// given x > 0 and n > 0 and x is exactly 2^n, then pos/x === pos>>n AND pos%x === pos&(x-1). -// consequently, pos/32 === pos>>5, pos/16 === pos>>4, pos/8 === pos>>3, pos%8 == pos&7 - -// type bitset256 [32]byte - -// func (x *bitset256) set(pos byte) { -// x[pos>>3] |= (1 << (pos & 7)) -// } -// func (x *bitset256) check(pos byte) uint8 { -// return x[pos>>3] & (1 << (pos & 7)) -// } -// func (x *bitset256) isset(pos byte) bool { -// return x.check(pos) != 0 -// // return x[pos>>3]&(1<<(pos&7)) != 0 -// } -// func (x *bitset256) isnotset(pos byte) bool { -// return x.check(pos) == 0 -// } - -// type bitset256 [4]uint64 - -// func (x *bitset256) set(pos byte) { -// x[pos>>6] |= (1 << (pos & 63)) -// } -// func (x *bitset256) check(pos byte) uint64 { -// return x[pos>>6] & (1 << (pos & 63)) -// } -// func (x *bitset256) isset(pos byte) bool { -// return x.check(pos) != 0 -// } -// func (x *bitset256) isnotset(pos byte) bool { -// return x.check(pos) == 0 -// } - -type bitset256 [256]bool - -func (x *bitset256) set(pos byte) { - x[pos] = true -} -func (x *bitset256) isset(pos byte) bool { - return x[pos] -} -func (x *bitset256) isnotset(pos byte) bool { - return !x[pos] -} - -type bitset32 uint32 - -func (x bitset32) set(pos byte) bitset32 { - return x | (1 << pos) -} -func (x bitset32) check(pos byte) uint32 { - return uint32(x) & (1 << pos) -} -func (x bitset32) isset(pos byte) bool { - return x.check(pos) != 0 -} -func (x bitset32) isnotset(pos byte) bool { - return x.check(pos) == 0 -} - -type bitset64 uint64 - -func (x bitset64) set(pos byte) bitset64 { - return x | (1 << pos) -} -func (x bitset64) check(pos byte) uint64 { - return uint64(x) & (1 << pos) -} -func (x bitset64) isset(pos byte) bool { - return x.check(pos) != 0 -} -func (x bitset64) isnotset(pos byte) bool { - return x.check(pos) == 0 -} - -// func (x *bitset256) unset(pos byte) { -// x[pos>>3] &^= (1 << (pos & 7)) -// } - -// type bit2set256 [64]byte - -// func (x *bit2set256) set(pos byte, v1, v2 bool) { -// var pos2 uint8 = (pos & 3) << 1 // returning 0, 2, 4 or 6 -// if v1 { -// x[pos>>2] |= 1 << (pos2 + 1) -// } -// if v2 { -// x[pos>>2] |= 1 << pos2 -// } -// } -// func (x *bit2set256) get(pos byte) uint8 { -// var pos2 uint8 = (pos & 3) << 1 // returning 0, 2, 4 or 6 -// return x[pos>>2] << (6 - pos2) >> 6 // 11000000 -> 00000011 -// } - -// ------------ - -type panicHdl struct{} - -func (panicHdl) errorv(err error) { - if err != nil { - panic(err) - } -} - -func (panicHdl) errorstr(message string) { - if message != "" { - panic(message) - } -} - -func (panicHdl) errorf(format string, params ...interface{}) { - if len(params) != 0 { - panic(fmt.Sprintf(format, params...)) - } - if len(params) == 0 { - panic(format) - } - panic("undefined error") -} - -// ---------------------------------------------------- - -type errDecorator interface { - wrapErr(in interface{}, out *error) -} - -type errDecoratorDef struct{} - -func (errDecoratorDef) wrapErr(v interface{}, e *error) { *e = fmt.Errorf("%v", v) } - -// ---------------------------------------------------- - -type must struct{} - -func (must) String(s string, err error) string { - if err != nil { - halt.errorv(err) - } - return s -} -func (must) Int(s int64, err error) int64 { - if err != nil { - halt.errorv(err) - } - return s -} -func (must) Uint(s uint64, err error) uint64 { - if err != nil { - halt.errorv(err) - } - return s -} -func (must) Float(s float64, err error) float64 { - if err != nil { - halt.errorv(err) - } - return s -} - -// ------------------- - -func freelistCapacity(length int) (capacity int) { - for capacity = 8; capacity < length; capacity *= 2 { - } - return -} - -type bytesFreelist [][]byte - -func (x *bytesFreelist) get(length int) (out []byte) { - var j int = -1 - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) >= length && (j == -1 || cap((*x)[j]) > cap((*x)[i])) { - j = i - } - } - if j == -1 { - return make([]byte, length, freelistCapacity(length)) - } - out = (*x)[j][:length] - (*x)[j] = nil - for i := 0; i < len(out); i++ { - out[i] = 0 - } - return -} - -func (x *bytesFreelist) put(v []byte) { - if len(v) == 0 { - return - } - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) == 0 { - (*x)[i] = v - return - } - } - *x = append(*x, v) -} - -func (x *bytesFreelist) check(v []byte, length int) (out []byte) { - if cap(v) < length { - x.put(v) - return x.get(length) - } - return v[:length] -} - -// ------------------------- - -type sfiRvFreelist [][]sfiRv - -func (x *sfiRvFreelist) get(length int) (out []sfiRv) { - var j int = -1 - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) >= length && (j == -1 || cap((*x)[j]) > cap((*x)[i])) { - j = i - } - } - if j == -1 { - return make([]sfiRv, length, freelistCapacity(length)) - } - out = (*x)[j][:length] - (*x)[j] = nil - for i := 0; i < len(out); i++ { - out[i] = sfiRv{} - } - return -} - -func (x *sfiRvFreelist) put(v []sfiRv) { - for i := 0; i < len(*x); i++ { - if cap((*x)[i]) == 0 { - (*x)[i] = v - return - } - } - *x = append(*x, v) -} - -// ----------- - -// xdebugf printf. the message in red on the terminal. -// Use it in place of fmt.Printf (which it calls internally) -func xdebugf(pattern string, args ...interface{}) { - xdebugAnyf("31", pattern, args...) -} - -// xdebug2f printf. the message in blue on the terminal. -// Use it in place of fmt.Printf (which it calls internally) -func xdebug2f(pattern string, args ...interface{}) { - xdebugAnyf("34", pattern, args...) -} - -func xdebugAnyf(colorcode, pattern string, args ...interface{}) { - if !xdebug { - return - } - var delim string - if len(pattern) > 0 && pattern[len(pattern)-1] != '\n' { - delim = "\n" - } - fmt.Printf("\033[1;"+colorcode+"m"+pattern+delim+"\033[0m", args...) - // os.Stderr.Flush() -} - -// register these here, so that staticcheck stops barfing -var _ = xdebug2f -var _ = xdebugf -var _ = isNaN32 diff --git a/vendor/github.com/ugorji/go/codec/helper.s b/vendor/github.com/ugorji/go/codec/helper.s deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/github.com/ugorji/go/codec/helper_internal.go b/vendor/github.com/ugorji/go/codec/helper_internal.go deleted file mode 100644 index 5a6ebb9ef..000000000 --- a/vendor/github.com/ugorji/go/codec/helper_internal.go +++ /dev/null @@ -1,119 +0,0 @@ -// 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. - -package codec - -// All non-std package dependencies live in this file, -// so porting to different environment is easy (just update functions). - -func pruneSignExt(v []byte, pos bool) (n int) { - if len(v) < 2 { - } else if pos && v[0] == 0 { - for ; v[n] == 0 && n+1 < len(v) && (v[n+1]&(1<<7) == 0); n++ { - } - } else if !pos && v[0] == 0xff { - for ; v[n] == 0xff && n+1 < len(v) && (v[n+1]&(1<<7) != 0); n++ { - } - } - return -} - -// validate that this function is correct ... -// culled from OGRE (Object-Oriented Graphics Rendering Engine) -// function: halfToFloatI (http://stderr.org/doc/ogre-doc/api/OgreBitwise_8h-source.html) -func halfFloatToFloatBits(yy uint16) (d uint32) { - y := uint32(yy) - s := (y >> 15) & 0x01 - e := (y >> 10) & 0x1f - m := y & 0x03ff - - if e == 0 { - if m == 0 { // plu or minus 0 - return s << 31 - } - // Denormalized number -- renormalize it - for (m & 0x00000400) == 0 { - m <<= 1 - e -= 1 - } - e += 1 - const zz uint32 = 0x0400 - m &= ^zz - } else if e == 31 { - if m == 0 { // Inf - return (s << 31) | 0x7f800000 - } - return (s << 31) | 0x7f800000 | (m << 13) // NaN - } - e = e + (127 - 15) - m = m << 13 - return (s << 31) | (e << 23) | m -} - -// GrowCap will return a new capacity for a slice, given the following: -// - oldCap: current capacity -// - unit: in-memory size of an element -// - num: number of elements to add -func growCap(oldCap, unit, num int) (newCap int) { - // appendslice logic (if cap < 1024, *2, else *1.25): - // leads to many copy calls, especially when copying bytes. - // bytes.Buffer model (2*cap + n): much better for bytes. - // smarter way is to take the byte-size of the appended element(type) into account - - // maintain 2 thresholds: - // t1: if cap <= t1, newcap = 2x - // t2: if cap <= t2, newcap = 1.5x - // else newcap = 1.25x - // - // t1, t2 >= 1024 always. - // This means that, if unit size >= 16, then always do 2x or 1.25x (ie t1, t2, t3 are all same) - // - // With this, appending for bytes increase by: - // 100% up to 4K - // 75% up to 16K - // 25% beyond that - - // unit can be 0 e.g. for struct{}{}; handle that appropriately - if unit <= 0 { - if uint64(^uint(0)) == ^uint64(0) { // 64-bit - var maxInt64 uint64 = 1<<63 - 1 // prevent failure with overflow int on 32-bit (386) - return int(maxInt64) // math.MaxInt64 - } - return 1<<31 - 1 // math.MaxInt32 - } - - // handle if num < 0, cap=0, etc. - - var t1, t2 int // thresholds - if unit <= 4 { - t1, t2 = 4*1024, 16*1024 - } else if unit <= 16 { - t1, t2 = unit*1*1024, unit*4*1024 - } else { - t1, t2 = 1024, 1024 - } - - if oldCap <= 0 { - newCap = 2 - } else if oldCap <= t1 { // [0,t1] - newCap = oldCap * 8 / 4 - } else if oldCap <= t2 { // (t1,t2] - newCap = oldCap * 6 / 4 - } else { // (t2,infinity] - newCap = oldCap * 5 / 4 - } - - if num > 0 && newCap < num+oldCap { - newCap = num + oldCap - } - - // ensure newCap takes multiples of a cache line (size is a multiple of 64) - t1 = newCap * unit - t2 = t1 % 64 - if t2 != 0 { - t1 += 64 - t2 - newCap = t1 / unit - } - - return -} diff --git a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go deleted file mode 100644 index 8c611b60d..000000000 --- a/vendor/github.com/ugorji/go/codec/helper_not_unsafe.go +++ /dev/null @@ -1,409 +0,0 @@ -// +build !go1.7 safe appengine - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "reflect" - "sync/atomic" - "time" -) - -const safeMode = true - -// stringView returns a view of the []byte as a string. -// In unsafe mode, it doesn't incur allocation and copying caused by conversion. -// In regular safe mode, it is an allocation and copy. -// -// Usage: Always maintain a reference to v while result of this call is in use, -// and call keepAlive4BytesView(v) at point where done with view. -func stringView(v []byte) string { - return string(v) -} - -// bytesView returns a view of the string as a []byte. -// In unsafe mode, it doesn't incur allocation and copying caused by conversion. -// In regular safe mode, it is an allocation and copy. -// -// Usage: Always maintain a reference to v while result of this call is in use, -// and call keepAlive4BytesView(v) at point where done with view. -func bytesView(v string) []byte { - return []byte(v) -} - -// isNil says whether the value v is nil. -// This applies to references like map/ptr/unsafepointer/chan/func, -// and non-reference values like interface/slice. -func isNil(v interface{}) (rv reflect.Value, isnil bool) { - rv = rv4i(v) - if isnilBitset.isset(byte(rv.Kind())) { - isnil = rv.IsNil() - } - return -} - -func rv4i(i interface{}) reflect.Value { - return reflect.ValueOf(i) -} - -func rv2i(rv reflect.Value) interface{} { - return rv.Interface() -} - -func rvIsNil(rv reflect.Value) bool { - return rv.IsNil() -} - -func rvSetSliceLen(rv reflect.Value, length int) { - rv.SetLen(length) -} - -func rvZeroAddrK(t reflect.Type, k reflect.Kind) reflect.Value { - return reflect.New(t).Elem() -} - -func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) { - return v.Convert(t) -} - -func rt2id(rt reflect.Type) uintptr { - return rv4i(rt).Pointer() -} - -func i2rtid(i interface{}) uintptr { - return rv4i(reflect.TypeOf(i)).Pointer() -} - -// -------------------------- - -func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool { - switch v.Kind() { - case reflect.Invalid: - return true - case reflect.Array, reflect.Map, reflect.Slice, reflect.String: - return v.Len() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Interface, reflect.Ptr: - if deref { - if v.IsNil() { - return true - } - return isEmptyValue(v.Elem(), tinfos, deref, checkStruct) - } - return v.IsNil() - case reflect.Struct: - return isEmptyStruct(v, tinfos, deref, checkStruct) - } - return false -} - -// -------------------------- -type atomicClsErr struct { - v atomic.Value -} - -func (x *atomicClsErr) load() (e clsErr) { - if i := x.v.Load(); i != nil { - e = i.(clsErr) - } - return -} - -func (x *atomicClsErr) store(p clsErr) { - x.v.Store(p) -} - -// -------------------------- -type atomicTypeInfoSlice struct { // expected to be 2 words - v atomic.Value -} - -func (x *atomicTypeInfoSlice) load() (e []rtid2ti) { - if i := x.v.Load(); i != nil { - e = i.([]rtid2ti) - } - return -} - -func (x *atomicTypeInfoSlice) store(p []rtid2ti) { - x.v.Store(p) -} - -// -------------------------- -type atomicRtidFnSlice struct { // expected to be 2 words - v atomic.Value -} - -func (x *atomicRtidFnSlice) load() (e []codecRtidFn) { - if i := x.v.Load(); i != nil { - e = i.([]codecRtidFn) - } - return -} - -func (x *atomicRtidFnSlice) store(p []codecRtidFn) { - x.v.Store(p) -} - -// -------------------------- -func (n *fauxUnion) ru() reflect.Value { - return rv4i(&n.u).Elem() -} -func (n *fauxUnion) ri() reflect.Value { - return rv4i(&n.i).Elem() -} -func (n *fauxUnion) rf() reflect.Value { - return rv4i(&n.f).Elem() -} -func (n *fauxUnion) rl() reflect.Value { - return rv4i(&n.l).Elem() -} -func (n *fauxUnion) rs() reflect.Value { - return rv4i(&n.s).Elem() -} -func (n *fauxUnion) rt() reflect.Value { - return rv4i(&n.t).Elem() -} -func (n *fauxUnion) rb() reflect.Value { - return rv4i(&n.b).Elem() -} - -// -------------------------- -func rvSetBytes(rv reflect.Value, v []byte) { - rv.SetBytes(v) -} - -func rvSetString(rv reflect.Value, v string) { - rv.SetString(v) -} - -func rvSetBool(rv reflect.Value, v bool) { - rv.SetBool(v) -} - -func rvSetTime(rv reflect.Value, v time.Time) { - rv.Set(rv4i(v)) -} - -func rvSetFloat32(rv reflect.Value, v float32) { - rv.SetFloat(float64(v)) -} - -func rvSetFloat64(rv reflect.Value, v float64) { - rv.SetFloat(v) -} - -func rvSetInt(rv reflect.Value, v int) { - rv.SetInt(int64(v)) -} - -func rvSetInt8(rv reflect.Value, v int8) { - rv.SetInt(int64(v)) -} - -func rvSetInt16(rv reflect.Value, v int16) { - rv.SetInt(int64(v)) -} - -func rvSetInt32(rv reflect.Value, v int32) { - rv.SetInt(int64(v)) -} - -func rvSetInt64(rv reflect.Value, v int64) { - rv.SetInt(v) -} - -func rvSetUint(rv reflect.Value, v uint) { - rv.SetUint(uint64(v)) -} - -func rvSetUintptr(rv reflect.Value, v uintptr) { - rv.SetUint(uint64(v)) -} - -func rvSetUint8(rv reflect.Value, v uint8) { - rv.SetUint(uint64(v)) -} - -func rvSetUint16(rv reflect.Value, v uint16) { - rv.SetUint(uint64(v)) -} - -func rvSetUint32(rv reflect.Value, v uint32) { - rv.SetUint(uint64(v)) -} - -func rvSetUint64(rv reflect.Value, v uint64) { - rv.SetUint(v) -} - -// ---------------- - -// rvSetDirect is rv.Set for all kinds except reflect.Interface -func rvSetDirect(rv reflect.Value, v reflect.Value) { - rv.Set(v) -} - -// rvSlice returns a slice of the slice of lenth -func rvSlice(rv reflect.Value, length int) reflect.Value { - return rv.Slice(0, length) -} - -// ---------------- - -func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) reflect.Value { - return rv.Index(i) -} - -func rvGetSliceLen(rv reflect.Value) int { - return rv.Len() -} - -func rvGetSliceCap(rv reflect.Value) int { - return rv.Cap() -} - -func rvGetArrayBytesRO(rv reflect.Value, scratch []byte) (bs []byte) { - l := rv.Len() - if rv.CanAddr() { - return rvGetBytes(rv.Slice(0, l)) - } - - if l <= cap(scratch) { - bs = scratch[:l] - } else { - bs = make([]byte, l) - } - reflect.Copy(rv4i(bs), rv) - return -} - -func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) { - v = rvZeroAddrK(reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem()), reflect.Array) - reflect.Copy(v, rv) - return -} - -func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) { - return rv.Slice(0, rv.Len()) -} - -func rvCopySlice(dest, src reflect.Value) { - reflect.Copy(dest, src) -} - -// ------------ - -func rvGetBool(rv reflect.Value) bool { - return rv.Bool() -} - -func rvGetBytes(rv reflect.Value) []byte { - return rv.Bytes() -} - -func rvGetTime(rv reflect.Value) time.Time { - return rv2i(rv).(time.Time) -} - -func rvGetString(rv reflect.Value) string { - return rv.String() -} - -func rvGetFloat64(rv reflect.Value) float64 { - return rv.Float() -} - -func rvGetFloat32(rv reflect.Value) float32 { - return float32(rv.Float()) -} - -func rvGetInt(rv reflect.Value) int { - return int(rv.Int()) -} - -func rvGetInt8(rv reflect.Value) int8 { - return int8(rv.Int()) -} - -func rvGetInt16(rv reflect.Value) int16 { - return int16(rv.Int()) -} - -func rvGetInt32(rv reflect.Value) int32 { - return int32(rv.Int()) -} - -func rvGetInt64(rv reflect.Value) int64 { - return rv.Int() -} - -func rvGetUint(rv reflect.Value) uint { - return uint(rv.Uint()) -} - -func rvGetUint8(rv reflect.Value) uint8 { - return uint8(rv.Uint()) -} - -func rvGetUint16(rv reflect.Value) uint16 { - return uint16(rv.Uint()) -} - -func rvGetUint32(rv reflect.Value) uint32 { - return uint32(rv.Uint()) -} - -func rvGetUint64(rv reflect.Value) uint64 { - return rv.Uint() -} - -func rvGetUintptr(rv reflect.Value) uintptr { - return uintptr(rv.Uint()) -} - -// ------------ map range and map indexing ---------- - -func mapGet(m, k, v reflect.Value) (vv reflect.Value) { - return m.MapIndex(k) -} - -func mapSet(m, k, v reflect.Value) { - m.SetMapIndex(k, v) -} - -func mapDelete(m, k reflect.Value) { - m.SetMapIndex(k, reflect.Value{}) -} - -// return an addressable reflect value that can be used in mapRange and mapGet operations. -// -// all calls to mapGet or mapRange will call here to get an addressable reflect.Value. -func mapAddressableRV(t reflect.Type, k reflect.Kind) (r reflect.Value) { - return // reflect.New(t).Elem() -} - -// ---------- ENCODER optimized --------------- - -func (e *Encoder) jsondriver() *jsonEncDriver { - return e.e.(*jsonEncDriver) -} - -// ---------- DECODER optimized --------------- - -func (d *Decoder) checkBreak() bool { - return d.d.CheckBreak() -} - -func (d *Decoder) jsondriver() *jsonDecDriver { - return d.d.(*jsonDecDriver) -} diff --git a/vendor/github.com/ugorji/go/codec/helper_test.go b/vendor/github.com/ugorji/go/codec/helper_test.go deleted file mode 100644 index fe2879ec8..000000000 --- a/vendor/github.com/ugorji/go/codec/helper_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// 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. - -package codec - -// All non-std package dependencies related to testing live in this file, -// so porting to different environment is easy (just update functions). - -import ( - "errors" - "reflect" -) - -// --- these functions are used by both benchmarks and tests - -var errDeepEqualNotMatch = errors.New("Not Match") - -func deepEqual(v1, v2 interface{}) (err error) { - if !reflect.DeepEqual(v1, v2) { - err = errDeepEqualNotMatch - } - return -} - -func approxDataSize(rv reflect.Value) (sum int) { - switch rk := rv.Kind(); rk { - case reflect.Invalid: - case reflect.Ptr, reflect.Interface: - sum += int(rv.Type().Size()) - sum += approxDataSize(rv.Elem()) - case reflect.Slice: - sum += int(rv.Type().Size()) - for j := 0; j < rv.Len(); j++ { - sum += approxDataSize(rv.Index(j)) - } - case reflect.String: - sum += int(rv.Type().Size()) - sum += rv.Len() - case reflect.Map: - sum += int(rv.Type().Size()) - for _, mk := range rv.MapKeys() { - sum += approxDataSize(mk) - sum += approxDataSize(rv.MapIndex(mk)) - } - case reflect.Struct: - //struct size already includes the full data size. - //sum += int(rv.Type().Size()) - for j := 0; j < rv.NumField(); j++ { - sum += approxDataSize(rv.Field(j)) - } - default: - //pure value types - sum += int(rv.Type().Size()) - } - return -} diff --git a/vendor/github.com/ugorji/go/codec/helper_unsafe.go b/vendor/github.com/ugorji/go/codec/helper_unsafe.go deleted file mode 100644 index 10ff66ef0..000000000 --- a/vendor/github.com/ugorji/go/codec/helper_unsafe.go +++ /dev/null @@ -1,867 +0,0 @@ -// +build !safe -// +build !appengine -// +build go1.7 - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "reflect" - "sync/atomic" - "time" - "unsafe" -) - -// This file has unsafe variants of some helper methods. -// NOTE: See helper_not_unsafe.go for the usage information. - -// For reflect.Value code, we decided to do the following: -// - if we know the kind, we can elide conditional checks for -// - SetXXX (Int, Uint, String, Bool, etc) -// - SetLen -// -// We can also optimize -// - IsNil - -const safeMode = false - -// keep in sync with GO_ROOT/src/reflect/value.go -const ( - unsafeFlagIndir = 1 << 7 - unsafeFlagAddr = 1 << 8 - unsafeFlagKindMask = (1 << 5) - 1 // 5 bits for 27 kinds (up to 31) - // unsafeTypeKindDirectIface = 1 << 5 -) - -type unsafeString struct { - Data unsafe.Pointer - Len int -} - -type unsafeSlice struct { - Data unsafe.Pointer - Len int - Cap int -} - -type unsafeIntf struct { - typ unsafe.Pointer - word unsafe.Pointer -} - -type unsafeReflectValue struct { - typ unsafe.Pointer - ptr unsafe.Pointer - flag uintptr -} - -func stringView(v []byte) string { - if len(v) == 0 { - return "" - } - bx := (*unsafeSlice)(unsafe.Pointer(&v)) - return *(*string)(unsafe.Pointer(&unsafeString{bx.Data, bx.Len})) -} - -func bytesView(v string) []byte { - if len(v) == 0 { - return zeroByteSlice - } - sx := (*unsafeString)(unsafe.Pointer(&v)) - return *(*[]byte)(unsafe.Pointer(&unsafeSlice{sx.Data, sx.Len, sx.Len})) -} - -// // isNilRef says whether the interface is a nil reference or not. -// // -// // A reference here is a pointer-sized reference i.e. map, ptr, chan, func, unsafepointer. -// // It is optional to extend this to also check if slices or interfaces are nil also. -// // -// // NOTE: There is no global way of checking if an interface is nil. -// // For true references (map, ptr, func, chan), you can just look -// // at the word of the interface. -// // However, for slices, you have to dereference -// // the word, and get a pointer to the 3-word interface value. -// func isNilRef(v interface{}) (rv reflect.Value, isnil bool) { -// isnil = ((*unsafeIntf)(unsafe.Pointer(&v))).word == nil -// return -// } - -func isNil(v interface{}) (rv reflect.Value, isnil bool) { - var ui = (*unsafeIntf)(unsafe.Pointer(&v)) - if ui.word == nil { - isnil = true - return - } - rv = rv4i(v) // reflect.value is cheap and inline'able - tk := rv.Kind() - isnil = (tk == reflect.Interface || tk == reflect.Slice) && *(*unsafe.Pointer)(ui.word) == nil - return -} - -func rv2ptr(urv *unsafeReflectValue) (ptr unsafe.Pointer) { - // true references (map, func, chan, ptr - NOT slice) may be double-referenced? as flagIndir - if refBitset.isset(byte(urv.flag&unsafeFlagKindMask)) && urv.flag&unsafeFlagIndir != 0 { - ptr = *(*unsafe.Pointer)(urv.ptr) - } else { - ptr = urv.ptr - } - return -} - -func rv4i(i interface{}) (rv reflect.Value) { - // Unfortunately, we cannot get the "kind" of the interface directly here. - // We need the 'rtype', whose structure changes in different go versions. - // Finally, it's not clear that there is benefit to reimplementing it, - // as the "escapes(i)" is not clearly expensive since we want i to exist on the heap. - - return reflect.ValueOf(i) -} - -func rv2i(rv reflect.Value) interface{} { - // We tap into implememtation details from - // the source go stdlib reflect/value.go, and trims the implementation. - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*interface{})(unsafe.Pointer(&unsafeIntf{typ: urv.typ, word: rv2ptr(urv)})) -} - -func rvIsNil(rv reflect.Value) bool { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - if urv.flag&unsafeFlagIndir != 0 { - return *(*unsafe.Pointer)(urv.ptr) == nil - } - return urv.ptr == nil -} - -func rvSetSliceLen(rv reflect.Value, length int) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - (*unsafeString)(urv.ptr).Len = length -} - -func rvZeroAddrK(t reflect.Type, k reflect.Kind) (rv reflect.Value) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - urv.flag = uintptr(k) | unsafeFlagIndir | unsafeFlagAddr - urv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word - urv.ptr = unsafe_New(urv.typ) - return -} - -func rvConvert(v reflect.Value, t reflect.Type) (rv reflect.Value) { - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *urv = *uv - urv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word - return -} - -func rt2id(rt reflect.Type) uintptr { - return uintptr(((*unsafeIntf)(unsafe.Pointer(&rt))).word) -} - -func i2rtid(i interface{}) uintptr { - return uintptr(((*unsafeIntf)(unsafe.Pointer(&i))).typ) -} - -// -------------------------- - -func isEmptyValue(v reflect.Value, tinfos *TypeInfos, deref, checkStruct bool) bool { - urv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - if urv.flag == 0 { - return true - } - switch v.Kind() { - case reflect.Invalid: - return true - case reflect.String: - return (*unsafeString)(urv.ptr).Len == 0 - case reflect.Slice: - return (*unsafeSlice)(urv.ptr).Len == 0 - case reflect.Bool: - return !*(*bool)(urv.ptr) - case reflect.Int: - return *(*int)(urv.ptr) == 0 - case reflect.Int8: - return *(*int8)(urv.ptr) == 0 - case reflect.Int16: - return *(*int16)(urv.ptr) == 0 - case reflect.Int32: - return *(*int32)(urv.ptr) == 0 - case reflect.Int64: - return *(*int64)(urv.ptr) == 0 - case reflect.Uint: - return *(*uint)(urv.ptr) == 0 - case reflect.Uint8: - return *(*uint8)(urv.ptr) == 0 - case reflect.Uint16: - return *(*uint16)(urv.ptr) == 0 - case reflect.Uint32: - return *(*uint32)(urv.ptr) == 0 - case reflect.Uint64: - return *(*uint64)(urv.ptr) == 0 - case reflect.Uintptr: - return *(*uintptr)(urv.ptr) == 0 - case reflect.Float32: - return *(*float32)(urv.ptr) == 0 - case reflect.Float64: - return *(*float64)(urv.ptr) == 0 - case reflect.Interface: - isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil - if deref { - if isnil { - return true - } - return isEmptyValue(v.Elem(), tinfos, deref, checkStruct) - } - return isnil - case reflect.Ptr: - // isnil := urv.ptr == nil // (not sufficient, as a pointer value encodes the type) - isnil := urv.ptr == nil || *(*unsafe.Pointer)(urv.ptr) == nil - if deref { - if isnil { - return true - } - return isEmptyValue(v.Elem(), tinfos, deref, checkStruct) - } - return isnil - case reflect.Struct: - return isEmptyStruct(v, tinfos, deref, checkStruct) - case reflect.Map, reflect.Array, reflect.Chan: - return v.Len() == 0 - } - return false -} - -// -------------------------- - -// atomicXXX is expected to be 2 words (for symmetry with atomic.Value) -// -// Note that we do not atomically load/store length and data pointer separately, -// as this could lead to some races. Instead, we atomically load/store cappedSlice. -// -// Note: with atomic.(Load|Store)Pointer, we MUST work with an unsafe.Pointer directly. - -// ---------------------- -type atomicTypeInfoSlice struct { - v unsafe.Pointer // *[]rtid2ti - _ uint64 // padding (atomicXXX expected to be 2 words) -} - -func (x *atomicTypeInfoSlice) load() (s []rtid2ti) { - x2 := atomic.LoadPointer(&x.v) - if x2 != nil { - s = *(*[]rtid2ti)(x2) - } - return -} - -func (x *atomicTypeInfoSlice) store(p []rtid2ti) { - atomic.StorePointer(&x.v, unsafe.Pointer(&p)) -} - -// -------------------------- -type atomicRtidFnSlice struct { - v unsafe.Pointer // *[]codecRtidFn - _ uint64 // padding (atomicXXX expected to be 2 words) (make 1 word so JsonHandle fits) -} - -func (x *atomicRtidFnSlice) load() (s []codecRtidFn) { - x2 := atomic.LoadPointer(&x.v) - if x2 != nil { - s = *(*[]codecRtidFn)(x2) - } - return -} - -func (x *atomicRtidFnSlice) store(p []codecRtidFn) { - atomic.StorePointer(&x.v, unsafe.Pointer(&p)) -} - -// -------------------------- -type atomicClsErr struct { - v unsafe.Pointer // *clsErr - _ uint64 // padding (atomicXXX expected to be 2 words) -} - -func (x *atomicClsErr) load() (e clsErr) { - x2 := (*clsErr)(atomic.LoadPointer(&x.v)) - if x2 != nil { - e = *x2 - } - return -} - -func (x *atomicClsErr) store(p clsErr) { - atomic.StorePointer(&x.v, unsafe.Pointer(&p)) -} - -// -------------------------- - -// to create a reflect.Value for each member field of fauxUnion, -// we first create a global fauxUnion, and create reflect.Value -// for them all. -// This way, we have the flags and type in the reflect.Value. -// Then, when a reflect.Value is called, we just copy it, -// update the ptr to the fauxUnion's, and return it. - -type unsafeDecNakedWrapper struct { - fauxUnion - ru, ri, rf, rl, rs, rb, rt reflect.Value // mapping to the primitives above -} - -func (n *unsafeDecNakedWrapper) init() { - n.ru = rv4i(&n.u).Elem() - n.ri = rv4i(&n.i).Elem() - n.rf = rv4i(&n.f).Elem() - n.rl = rv4i(&n.l).Elem() - n.rs = rv4i(&n.s).Elem() - n.rt = rv4i(&n.t).Elem() - n.rb = rv4i(&n.b).Elem() - // n.rr[] = rv4i(&n.) -} - -var defUnsafeDecNakedWrapper unsafeDecNakedWrapper - -func init() { - defUnsafeDecNakedWrapper.init() -} - -func (n *fauxUnion) ru() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.ru - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.u) - return -} -func (n *fauxUnion) ri() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.ri - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.i) - return -} -func (n *fauxUnion) rf() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.rf - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.f) - return -} -func (n *fauxUnion) rl() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.rl - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.l) - return -} -func (n *fauxUnion) rs() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.rs - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.s) - return -} -func (n *fauxUnion) rt() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.rt - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.t) - return -} -func (n *fauxUnion) rb() (v reflect.Value) { - v = defUnsafeDecNakedWrapper.rb - ((*unsafeReflectValue)(unsafe.Pointer(&v))).ptr = unsafe.Pointer(&n.b) - return -} - -// -------------------------- -func rvSetBytes(rv reflect.Value, v []byte) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*[]byte)(urv.ptr) = v -} - -func rvSetString(rv reflect.Value, v string) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*string)(urv.ptr) = v -} - -func rvSetBool(rv reflect.Value, v bool) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*bool)(urv.ptr) = v -} - -func rvSetTime(rv reflect.Value, v time.Time) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*time.Time)(urv.ptr) = v -} - -func rvSetFloat32(rv reflect.Value, v float32) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*float32)(urv.ptr) = v -} - -func rvSetFloat64(rv reflect.Value, v float64) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*float64)(urv.ptr) = v -} - -func rvSetInt(rv reflect.Value, v int) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int)(urv.ptr) = v -} - -func rvSetInt8(rv reflect.Value, v int8) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int8)(urv.ptr) = v -} - -func rvSetInt16(rv reflect.Value, v int16) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int16)(urv.ptr) = v -} - -func rvSetInt32(rv reflect.Value, v int32) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int32)(urv.ptr) = v -} - -func rvSetInt64(rv reflect.Value, v int64) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*int64)(urv.ptr) = v -} - -func rvSetUint(rv reflect.Value, v uint) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint)(urv.ptr) = v -} - -func rvSetUintptr(rv reflect.Value, v uintptr) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uintptr)(urv.ptr) = v -} - -func rvSetUint8(rv reflect.Value, v uint8) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint8)(urv.ptr) = v -} - -func rvSetUint16(rv reflect.Value, v uint16) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint16)(urv.ptr) = v -} - -func rvSetUint32(rv reflect.Value, v uint32) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint32)(urv.ptr) = v -} - -func rvSetUint64(rv reflect.Value, v uint64) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - *(*uint64)(urv.ptr) = v -} - -// ---------------- - -// rvSetDirect is rv.Set for all kinds except reflect.Interface -func rvSetDirect(rv reflect.Value, v reflect.Value) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - if uv.flag&unsafeFlagIndir == 0 { - *(*unsafe.Pointer)(urv.ptr) = uv.ptr - } else { - typedmemmove(urv.typ, urv.ptr, uv.ptr) - } -} - -// rvSlice returns a slice of the slice of lenth -func rvSlice(rv reflect.Value, length int) (v reflect.Value) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - *uv = *urv - var x []unsafe.Pointer - uv.ptr = unsafe.Pointer(&x) - *(*unsafeSlice)(uv.ptr) = *(*unsafeSlice)(urv.ptr) - (*unsafeSlice)(uv.ptr).Len = length - return -} - -// ------------ - -func rvSliceIndex(rv reflect.Value, i int, ti *typeInfo) (v reflect.Value) { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - uv.ptr = unsafe.Pointer(uintptr(((*unsafeSlice)(urv.ptr)).Data) + (ti.elemsize * uintptr(i))) - uv.typ = ((*unsafeIntf)(unsafe.Pointer(&ti.elem))).word - uv.flag = uintptr(ti.elemkind) | unsafeFlagIndir | unsafeFlagAddr - return -} - -func rvGetSliceLen(rv reflect.Value) int { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return (*unsafeSlice)(urv.ptr).Len -} - -func rvGetSliceCap(rv reflect.Value) int { - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return (*unsafeSlice)(urv.ptr).Cap -} - -func rvGetArrayBytesRO(rv reflect.Value, scratch []byte) (bs []byte) { - l := rv.Len() - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - bx := (*unsafeSlice)(unsafe.Pointer(&bs)) - bx.Data = urv.ptr - bx.Len, bx.Cap = l, l - return -} - -func rvGetArray4Slice(rv reflect.Value) (v reflect.Value) { - // It is possible that this slice is based off an array with a larger - // len that we want (where array len == slice cap). - // However, it is ok to create an array type that is a subset of the full - // e.g. full slice is based off a *[16]byte, but we can create a *[4]byte - // off of it. That is ok. - // - // Consequently, we use rvGetSliceLen, not rvGetSliceCap. - - t := reflectArrayOf(rvGetSliceLen(rv), rv.Type().Elem()) - // v = rvZeroAddrK(t, reflect.Array) - - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - uv.flag = uintptr(reflect.Array) | unsafeFlagIndir | unsafeFlagAddr - uv.typ = ((*unsafeIntf)(unsafe.Pointer(&t))).word - - urv := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - uv.ptr = *(*unsafe.Pointer)(urv.ptr) // slice rv has a ptr to the slice. - - return -} - -func rvGetSlice4Array(rv reflect.Value, tslice reflect.Type) (v reflect.Value) { - uv := (*unsafeReflectValue)(unsafe.Pointer(&v)) - - var x []unsafe.Pointer - - uv.ptr = unsafe.Pointer(&x) - uv.typ = ((*unsafeIntf)(unsafe.Pointer(&tslice))).word - uv.flag = unsafeFlagIndir | uintptr(reflect.Slice) - - s := (*unsafeSlice)(uv.ptr) - s.Data = ((*unsafeReflectValue)(unsafe.Pointer(&rv))).ptr - s.Len = rv.Len() - s.Cap = s.Len - return -} - -func rvCopySlice(dest, src reflect.Value) { - t := dest.Type().Elem() - urv := (*unsafeReflectValue)(unsafe.Pointer(&dest)) - destPtr := urv.ptr - urv = (*unsafeReflectValue)(unsafe.Pointer(&src)) - typedslicecopy((*unsafeIntf)(unsafe.Pointer(&t)).word, - *(*unsafeSlice)(destPtr), *(*unsafeSlice)(urv.ptr)) -} - -// ------------ - -func rvGetBool(rv reflect.Value) bool { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*bool)(v.ptr) -} - -func rvGetBytes(rv reflect.Value) []byte { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*[]byte)(v.ptr) -} - -func rvGetTime(rv reflect.Value) time.Time { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*time.Time)(v.ptr) -} - -func rvGetString(rv reflect.Value) string { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*string)(v.ptr) -} - -func rvGetFloat64(rv reflect.Value) float64 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*float64)(v.ptr) -} - -func rvGetFloat32(rv reflect.Value) float32 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*float32)(v.ptr) -} - -func rvGetInt(rv reflect.Value) int { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int)(v.ptr) -} - -func rvGetInt8(rv reflect.Value) int8 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int8)(v.ptr) -} - -func rvGetInt16(rv reflect.Value) int16 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int16)(v.ptr) -} - -func rvGetInt32(rv reflect.Value) int32 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int32)(v.ptr) -} - -func rvGetInt64(rv reflect.Value) int64 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*int64)(v.ptr) -} - -func rvGetUint(rv reflect.Value) uint { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint)(v.ptr) -} - -func rvGetUint8(rv reflect.Value) uint8 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint8)(v.ptr) -} - -func rvGetUint16(rv reflect.Value) uint16 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint16)(v.ptr) -} - -func rvGetUint32(rv reflect.Value) uint32 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint32)(v.ptr) -} - -func rvGetUint64(rv reflect.Value) uint64 { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uint64)(v.ptr) -} - -func rvGetUintptr(rv reflect.Value) uintptr { - v := (*unsafeReflectValue)(unsafe.Pointer(&rv)) - return *(*uintptr)(v.ptr) -} - -// ------------ map range and map indexing ---------- - -// regular calls to map via reflection: MapKeys, MapIndex, MapRange/MapIter etc -// will always allocate for each map key or value. -// -// It is more performant to provide a value that the map entry is set into, -// and that elides the allocation. - -// unsafeMapHashIter -// -// go 1.4+ has runtime/hashmap.go or runtime/map.go which has a -// hIter struct with the first 2 values being key and value -// of the current iteration. -// -// This *hIter is passed to mapiterinit, mapiternext, mapiterkey, mapiterelem. -// We bypass the reflect wrapper functions and just use the *hIter directly. -// -// Though *hIter has many fields, we only care about the first 2. -type unsafeMapHashIter struct { - key, value unsafe.Pointer - // other fields are ignored -} - -type mapIter struct { - unsafeMapIter -} - -type unsafeMapIter struct { - it *unsafeMapHashIter - // k, v reflect.Value - mtyp, ktyp, vtyp unsafe.Pointer - mptr, kptr, vptr unsafe.Pointer - kisref, visref bool - mapvalues bool - done bool - started bool - // _ [2]uint64 // padding (cache-aligned) -} - -func (t *unsafeMapIter) ValidKV() (r bool) { - return false -} - -func (t *unsafeMapIter) Next() (r bool) { - if t == nil || t.done { - return - } - if t.started { - mapiternext((unsafe.Pointer)(t.it)) - } else { - t.started = true - } - - t.done = t.it.key == nil - if t.done { - return - } - unsafeMapSet(t.kptr, t.ktyp, t.it.key, t.kisref) - if t.mapvalues { - unsafeMapSet(t.vptr, t.vtyp, t.it.value, t.visref) - } - return true -} - -func (t *unsafeMapIter) Key() (r reflect.Value) { - return -} - -func (t *unsafeMapIter) Value() (r reflect.Value) { - return -} - -func (t *unsafeMapIter) Done() { -} - -func unsafeMapSet(p, ptyp, p2 unsafe.Pointer, isref bool) { - if isref { - *(*unsafe.Pointer)(p) = *(*unsafe.Pointer)(p2) // p2 - } else { - typedmemmove(ptyp, p, p2) // *(*unsafe.Pointer)(p2)) // p2) - } -} - -func unsafeMapKVPtr(urv *unsafeReflectValue) unsafe.Pointer { - if urv.flag&unsafeFlagIndir == 0 { - return unsafe.Pointer(&urv.ptr) - } - return urv.ptr -} - -func mapRange(t *mapIter, m, k, v reflect.Value, mapvalues bool) { - if rvIsNil(m) { - t.done = true - return - } - t.done = false - t.started = false - t.mapvalues = mapvalues - - var urv *unsafeReflectValue - - urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) - t.mtyp = urv.typ - t.mptr = rv2ptr(urv) - - t.it = (*unsafeMapHashIter)(mapiterinit(t.mtyp, t.mptr)) - - urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) - t.ktyp = urv.typ - t.kptr = urv.ptr - t.kisref = refBitset.isset(byte(k.Kind())) - - if mapvalues { - urv = (*unsafeReflectValue)(unsafe.Pointer(&v)) - t.vtyp = urv.typ - t.vptr = urv.ptr - t.visref = refBitset.isset(byte(v.Kind())) - } else { - t.vtyp = nil - t.vptr = nil - } -} - -func mapGet(m, k, v reflect.Value) (vv reflect.Value) { - var urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) - var kptr = unsafeMapKVPtr(urv) - - urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) - - vvptr := mapaccess(urv.typ, rv2ptr(urv), kptr) - if vvptr == nil { - return - } - // vvptr = *(*unsafe.Pointer)(vvptr) - - urv = (*unsafeReflectValue)(unsafe.Pointer(&v)) - - unsafeMapSet(urv.ptr, urv.typ, vvptr, refBitset.isset(byte(v.Kind()))) - return v -} - -func mapSet(m, k, v reflect.Value) { - var urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) - var kptr = unsafeMapKVPtr(urv) - urv = (*unsafeReflectValue)(unsafe.Pointer(&v)) - var vptr = unsafeMapKVPtr(urv) - urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) - mapassign(urv.typ, rv2ptr(urv), kptr, vptr) -} - -// func mapDelete(m, k reflect.Value) { -// var urv = (*unsafeReflectValue)(unsafe.Pointer(&k)) -// var kptr = unsafeMapKVPtr(urv) -// urv = (*unsafeReflectValue)(unsafe.Pointer(&m)) -// mapdelete(urv.typ, rv2ptr(urv), kptr) -// } - -// return an addressable reflect value that can be used in mapRange and mapGet operations. -// -// all calls to mapGet or mapRange will call here to get an addressable reflect.Value. -func mapAddressableRV(t reflect.Type, k reflect.Kind) (r reflect.Value) { - // return reflect.New(t).Elem() - return rvZeroAddrK(t, k) -} - -//go:linkname mapiterinit reflect.mapiterinit -//go:noescape -func mapiterinit(typ unsafe.Pointer, it unsafe.Pointer) (key unsafe.Pointer) - -//go:linkname mapiternext reflect.mapiternext -//go:noescape -func mapiternext(it unsafe.Pointer) (key unsafe.Pointer) - -//go:linkname mapaccess reflect.mapaccess -//go:noescape -func mapaccess(typ unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) (val unsafe.Pointer) - -//go:linkname mapassign reflect.mapassign -//go:noescape -func mapassign(typ unsafe.Pointer, m unsafe.Pointer, key, val unsafe.Pointer) - -//go:linkname mapdelete reflect.mapdelete -//go:noescape -func mapdelete(typ unsafe.Pointer, m unsafe.Pointer, key unsafe.Pointer) - -//go:linkname typedmemmove reflect.typedmemmove -//go:noescape -func typedmemmove(typ unsafe.Pointer, dst, src unsafe.Pointer) - -//go:linkname unsafe_New reflect.unsafe_New -//go:noescape -func unsafe_New(typ unsafe.Pointer) unsafe.Pointer - -//go:linkname typedslicecopy reflect.typedslicecopy -//go:noescape -func typedslicecopy(elemType unsafe.Pointer, dst, src unsafeSlice) int - -// ---------- ENCODER optimized --------------- - -func (e *Encoder) jsondriver() *jsonEncDriver { - return (*jsonEncDriver)((*unsafeIntf)(unsafe.Pointer(&e.e)).word) -} - -// ---------- DECODER optimized --------------- - -func (d *Decoder) checkBreak() bool { - // jsonDecDriver.CheckBreak() CANNOT be inlined. - // Consequently, there's no benefit in incurring the cost of this - // wrapping function checkBreak. - // - // It is faster to just call the interface method directly. - - // if d.js { - // return d.jsondriver().CheckBreak() - // } - // if d.cbor { - // return d.cbordriver().CheckBreak() - // } - return d.d.CheckBreak() -} - -func (d *Decoder) jsondriver() *jsonDecDriver { - return (*jsonDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).word) -} - -// func (d *Decoder) cbordriver() *cborDecDriver { -// return (*cborDecDriver)((*unsafeIntf)(unsafe.Pointer(&d.d)).word) -// } diff --git a/vendor/github.com/ugorji/go/codec/json.go b/vendor/github.com/ugorji/go/codec/json.go deleted file mode 100644 index 6d21cd7c8..000000000 --- a/vendor/github.com/ugorji/go/codec/json.go +++ /dev/null @@ -1,1530 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// By default, this json support uses base64 encoding for bytes, because you cannot -// store and read any arbitrary string in json (only unicode). -// However, the user can configre how to encode/decode bytes. -// -// This library specifically supports UTF-8 for encoding and decoding only. -// -// Note that the library will happily encode/decode things which are not valid -// json e.g. a map[int64]string. We do it for consistency. With valid json, -// we will encode and decode appropriately. -// Users can specify their map type if necessary to force it. -// -// Note: -// - we cannot use strconv.Quote and strconv.Unquote because json quotes/unquotes differently. -// We implement it here. - -import ( - "bytes" - "encoding/base64" - "math" - "strconv" - "time" - "unicode" - "unicode/utf16" - "unicode/utf8" -) - -//-------------------------------- - -var jsonLiterals = [...]byte{ - '"', 't', 'r', 'u', 'e', '"', - '"', 'f', 'a', 'l', 's', 'e', '"', - '"', 'n', 'u', 'l', 'l', '"', -} - -const ( - jsonLitTrueQ = 0 - jsonLitTrue = 1 - jsonLitFalseQ = 6 - jsonLitFalse = 7 - jsonLitNullQ = 13 - jsonLitNull = 14 -) - -var ( - // jsonLiteralTrueQ = jsonLiterals[jsonLitTrueQ : jsonLitTrueQ+6] - // jsonLiteralFalseQ = jsonLiterals[jsonLitFalseQ : jsonLitFalseQ+7] - // jsonLiteralNullQ = jsonLiterals[jsonLitNullQ : jsonLitNullQ+6] - - jsonLiteralTrue = jsonLiterals[jsonLitTrue : jsonLitTrue+4] - jsonLiteralFalse = jsonLiterals[jsonLitFalse : jsonLitFalse+5] - jsonLiteralNull = jsonLiterals[jsonLitNull : jsonLitNull+4] - - // these are used, after consuming the first char - jsonLiteral4True = jsonLiterals[jsonLitTrue+1 : jsonLitTrue+4] - jsonLiteral4False = jsonLiterals[jsonLitFalse+1 : jsonLitFalse+5] - jsonLiteral4Null = jsonLiterals[jsonLitNull+1 : jsonLitNull+4] -) - -const ( - jsonU4Chk2 = '0' - jsonU4Chk1 = 'a' - 10 - jsonU4Chk0 = 'A' - 10 - - // jsonScratchArrayLen = cacheLineSize + 32 // 96 -) - -const ( - // If !jsonValidateSymbols, decoding will be faster, by skipping some checks: - // - If we see first character of null, false or true, - // do not validate subsequent characters. - // - e.g. if we see a n, assume null and skip next 3 characters, - // and do not validate they are ull. - // P.S. Do not expect a significant decoding boost from this. - jsonValidateSymbols = true - - jsonSpacesOrTabsLen = 128 - - jsonAlwaysReturnInternString = false -) - -var ( - // jsonTabs and jsonSpaces are used as caches for indents - jsonTabs, jsonSpaces [jsonSpacesOrTabsLen]byte - - jsonCharHtmlSafeSet bitset256 - jsonCharSafeSet bitset256 -) - -func init() { - var i byte - for i = 0; i < jsonSpacesOrTabsLen; i++ { - jsonSpaces[i] = ' ' - jsonTabs[i] = '\t' - } - - // populate the safe values as true: note: ASCII control characters are (0-31) - // jsonCharSafeSet: all true except (0-31) " \ - // jsonCharHtmlSafeSet: all true except (0-31) " \ < > & - for i = 32; i < utf8.RuneSelf; i++ { - switch i { - case '"', '\\': - case '<', '>', '&': - jsonCharSafeSet.set(i) // = true - default: - jsonCharSafeSet.set(i) - jsonCharHtmlSafeSet.set(i) - } - } -} - -// ---------------- - -type jsonEncDriver struct { - noBuiltInTypes - h *JsonHandle - - se interfaceExtWrapper - - // ---- cpu cache line boundary? - di int8 // indent per: if negative, use tabs - d bool // indenting? - dl uint16 // indent level - ks bool // map key as string - is byte // integer as string - - typical bool - - s *bitset256 // safe set for characters (taking h.HTMLAsIs into consideration) - - // scratch: encode time, numbers, etc. Note: leave 1 byte for containerState - b [cacheLineSize + 24]byte // buffer for encoding numbers and time - - e Encoder -} - -func (e *jsonEncDriver) encoder() *Encoder { return &e.e } - -func (e *jsonEncDriver) writeIndent() { - e.e.encWr.writen1('\n') - x := int(e.di) * int(e.dl) - if e.di < 0 { - x = -x - for x > jsonSpacesOrTabsLen { - e.e.encWr.writeb(jsonTabs[:]) - x -= jsonSpacesOrTabsLen - } - e.e.encWr.writeb(jsonTabs[:x]) - } else { - for x > jsonSpacesOrTabsLen { - e.e.encWr.writeb(jsonSpaces[:]) - x -= jsonSpacesOrTabsLen - } - e.e.encWr.writeb(jsonSpaces[:x]) - } -} - -func (e *jsonEncDriver) WriteArrayElem() { - if e.e.c != containerArrayStart { - e.e.encWr.writen1(',') - } - if e.d { - e.writeIndent() - } -} - -func (e *jsonEncDriver) WriteMapElemKey() { - if e.e.c != containerMapStart { - e.e.encWr.writen1(',') - } - if e.d { - e.writeIndent() - } -} - -func (e *jsonEncDriver) WriteMapElemValue() { - if e.d { - e.e.encWr.writen2(':', ' ') - } else { - e.e.encWr.writen1(':') - } -} - -func (e *jsonEncDriver) EncodeNil() { - // We always encode nil as just null (never in quotes) - // This allows us to easily decode if a nil in the json stream - // ie if initial token is n. - - // e.e.encWr.writeb(jsonLiteralNull) - e.e.encWr.writen([rwNLen]byte{'n', 'u', 'l', 'l'}, 4) -} - -func (e *jsonEncDriver) EncodeTime(t time.Time) { - // Do NOT use MarshalJSON, as it allocates internally. - // instead, we call AppendFormat directly, using our scratch buffer (e.b) - - if t.IsZero() { - e.EncodeNil() - } else { - e.b[0] = '"' - b := fmtTime(t, e.b[1:1]) - e.b[len(b)+1] = '"' - e.e.encWr.writeb(e.b[:len(b)+2]) - } -} - -func (e *jsonEncDriver) EncodeExt(rv interface{}, xtag uint64, ext Ext) { - if ext == SelfExt { - rv2 := baseRV(rv) - e.e.encodeValue(rv2, e.h.fnNoExt(rv2.Type())) - } else if v := ext.ConvertExt(rv); v == nil { - e.EncodeNil() - } else { - e.e.encode(v) - } -} - -func (e *jsonEncDriver) EncodeRawExt(re *RawExt) { - // only encodes re.Value (never re.Data) - if re.Value == nil { - e.EncodeNil() - } else { - e.e.encode(re.Value) - } -} - -func (e *jsonEncDriver) EncodeBool(b bool) { - // Use writen with an array instead of writeb with a slice - // i.e. in place of e.e.encWr.writeb(jsonLiteralTrueQ) - // OR jsonLiteralTrue, jsonLiteralFalse, jsonLiteralFalseQ, etc - - if e.ks && e.e.c == containerMapKey { - if b { - e.e.encWr.writen([rwNLen]byte{'"', 't', 'r', 'u', 'e', '"'}, 6) - } else { - e.e.encWr.writen([rwNLen]byte{'"', 'f', 'a', 'l', 's', 'e', '"'}, 7) - } - } else { - if b { - e.e.encWr.writen([rwNLen]byte{'t', 'r', 'u', 'e'}, 4) - } else { - e.e.encWr.writen([rwNLen]byte{'f', 'a', 'l', 's', 'e'}, 5) - } - } -} - -func (e *jsonEncDriver) encodeFloat(f float64, bitsize, fmt byte, prec int8) { - var blen uint - if e.ks && e.e.c == containerMapKey { - blen = 2 + uint(len(strconv.AppendFloat(e.b[1:1], f, fmt, int(prec), int(bitsize)))) - // _ = e.b[:blen] - e.b[0] = '"' - e.b[blen-1] = '"' - e.e.encWr.writeb(e.b[:blen]) - } else { - e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, int(prec), int(bitsize))) - } -} - -func (e *jsonEncDriver) EncodeFloat64(f float64) { - fmt, prec := jsonFloatStrconvFmtPrec64(f) - e.encodeFloat(f, 64, fmt, prec) -} - -func (e *jsonEncDriver) EncodeFloat32(f float32) { - fmt, prec := jsonFloatStrconvFmtPrec32(f) - e.encodeFloat(float64(f), 32, fmt, prec) -} - -func (e *jsonEncDriver) EncodeInt(v int64) { - if e.is == 'A' || e.is == 'L' && (v > 1<<53 || v < -(1<<53)) || - (e.ks && e.e.c == containerMapKey) { - blen := 2 + len(strconv.AppendInt(e.b[1:1], v, 10)) - e.b[0] = '"' - e.b[blen-1] = '"' - e.e.encWr.writeb(e.b[:blen]) - return - } - e.e.encWr.writeb(strconv.AppendInt(e.b[:0], v, 10)) -} - -func (e *jsonEncDriver) EncodeUint(v uint64) { - if e.is == 'A' || e.is == 'L' && v > 1<<53 || (e.ks && e.e.c == containerMapKey) { - blen := 2 + len(strconv.AppendUint(e.b[1:1], v, 10)) - e.b[0] = '"' - e.b[blen-1] = '"' - e.e.encWr.writeb(e.b[:blen]) - return - } - e.e.encWr.writeb(strconv.AppendUint(e.b[:0], v, 10)) -} - -func (e *jsonEncDriver) EncodeString(v string) { - if e.h.StringToRaw { - e.EncodeStringBytesRaw(bytesView(v)) - return - } - e.quoteStr(v) -} - -func (e *jsonEncDriver) EncodeStringBytesRaw(v []byte) { - // if encoding raw bytes and RawBytesExt is configured, use it to encode - if v == nil { - e.EncodeNil() - return - } - if e.se.InterfaceExt != nil { - e.EncodeExt(v, 0, &e.se) - return - } - - slen := base64.StdEncoding.EncodedLen(len(v)) + 2 - var bs []byte - if len(e.b) < slen { - bs = e.e.blist.get(slen) - } else { - bs = e.b[:slen] - } - bs[0] = '"' - base64.StdEncoding.Encode(bs[1:], v) - bs[len(bs)-1] = '"' - e.e.encWr.writeb(bs) - if len(e.b) < slen { - e.e.blist.put(bs) - } -} - -// indent is done as below: -// - newline and indent are added before each mapKey or arrayElem -// - newline and indent are added before each ending, -// except there was no entry (so we can have {} or []) - -func (e *jsonEncDriver) WriteArrayStart(length int) { - if e.d { - e.dl++ - } - e.e.encWr.writen1('[') -} - -func (e *jsonEncDriver) WriteArrayEnd() { - if e.d { - e.dl-- - e.writeIndent() - } - e.e.encWr.writen1(']') -} - -func (e *jsonEncDriver) WriteMapStart(length int) { - if e.d { - e.dl++ - } - e.e.encWr.writen1('{') -} - -func (e *jsonEncDriver) WriteMapEnd() { - if e.d { - e.dl-- - if e.e.c != containerMapStart { - e.writeIndent() - } - } - e.e.encWr.writen1('}') -} - -func (e *jsonEncDriver) quoteStr(s string) { - // adapted from std pkg encoding/json - const hex = "0123456789abcdef" - w := e.e.w() - w.writen1('"') - var i, start uint - for i < uint(len(s)) { - // encode all bytes < 0x20 (except \r, \n). - // also encode < > & to prevent security holes when served to some browsers. - - // We optimize for ascii, by assumining that most characters are in the BMP - // and natively consumed by json without much computation. - - // if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' { - // if (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) { - if e.s.isset(s[i]) { - i++ - continue - } - // b := s[i] - if s[i] < utf8.RuneSelf { - if start < i { - w.writestr(s[start:i]) - } - switch s[i] { - case '\\', '"': - w.writen2('\\', s[i]) - case '\n': - w.writen2('\\', 'n') - case '\r': - w.writen2('\\', 'r') - case '\b': - w.writen2('\\', 'b') - case '\f': - w.writen2('\\', 'f') - case '\t': - w.writen2('\\', 't') - default: - w.writestr(`\u00`) - w.writen2(hex[s[i]>>4], hex[s[i]&0xF]) - } - i++ - start = i - continue - } - c, size := utf8.DecodeRuneInString(s[i:]) - if c == utf8.RuneError { - if size == 1 { - if start < i { - w.writestr(s[start:i]) - } - w.writestr(`\ufffd`) - i++ - start = i - } - continue - } - // U+2028 is LINE SEPARATOR. U+2029 is PARAGRAPH SEPARATOR. - // Both technically valid JSON, but bomb on JSONP, so fix here unconditionally. - if c == '\u2028' || c == '\u2029' { - if start < i { - w.writestr(s[start:i]) - } - w.writestr(`\u202`) - w.writen1(hex[c&0xF]) - i += uint(size) - start = i - continue - } - i += uint(size) - } - if start < uint(len(s)) { - w.writestr(s[start:]) - } - w.writen1('"') -} - -func (e *jsonEncDriver) atEndOfEncode() { - if e.h.TermWhitespace { - if e.e.c == 0 { // scalar written, output space - e.e.encWr.writen1(' ') - } else { // container written, output new-line - e.e.encWr.writen1('\n') - } - } -} - -// ---------- - -type jsonDecDriver struct { - noBuiltInTypes - h *JsonHandle - - tok uint8 // used to store the token read right after skipWhiteSpace - fnil bool // found null - _ [2]byte // padding - bstr [4]byte // scratch used for string \UXXX parsing - - buf []byte - se interfaceExtWrapper - - _ uint64 // padding - - // ---- cpu cache line boundary? - - d Decoder -} - -func (d *jsonDecDriver) decoder() *Decoder { - return &d.d -} - -func (d *jsonDecDriver) uncacheRead() { - if d.tok != 0 { - d.d.decRd.unreadn1() - d.tok = 0 - } -} - -func (d *jsonDecDriver) ReadMapStart() int { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return decContainerLenNil - } - if d.tok != '{' { - d.d.errorf("read map - expect char '%c' but got char '%c'", '{', d.tok) - } - d.tok = 0 - return decContainerLenUnknown -} - -func (d *jsonDecDriver) ReadArrayStart() int { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return decContainerLenNil - } - if d.tok != '[' { - d.d.errorf("read array - expect char '%c' but got char '%c'", '[', d.tok) - } - d.tok = 0 - return decContainerLenUnknown -} - -func (d *jsonDecDriver) CheckBreak() bool { - d.advance() - return d.tok == '}' || d.tok == ']' -} - -func (d *jsonDecDriver) ReadArrayElem() { - const xc uint8 = ',' - if d.d.c != containerArrayStart { - d.advance() - if d.tok != xc { - d.readDelimError(xc) - } - d.tok = 0 - } -} - -func (d *jsonDecDriver) ReadArrayEnd() { - const xc uint8 = ']' - d.advance() - if d.tok != xc { - d.readDelimError(xc) - } - d.tok = 0 -} - -func (d *jsonDecDriver) ReadMapElemKey() { - const xc uint8 = ',' - if d.d.c != containerMapStart { - d.advance() - if d.tok != xc { - d.readDelimError(xc) - } - d.tok = 0 - } -} - -func (d *jsonDecDriver) ReadMapElemValue() { - const xc uint8 = ':' - d.advance() - if d.tok != xc { - d.readDelimError(xc) - } - d.tok = 0 -} - -func (d *jsonDecDriver) ReadMapEnd() { - const xc uint8 = '}' - d.advance() - if d.tok != xc { - d.readDelimError(xc) - } - d.tok = 0 -} - -// func (d *jsonDecDriver) readDelim(xc uint8) { -// d.advance() -// if d.tok != xc { -// d.readDelimError(xc) -// } -// d.tok = 0 -// } - -func (d *jsonDecDriver) readDelimError(xc uint8) { - d.d.errorf("read json delimiter - expect char '%c' but got char '%c'", xc, d.tok) -} - -func (d *jsonDecDriver) readLit4True() { - bs := d.d.decRd.readn(3) - d.tok = 0 - if jsonValidateSymbols && bs != [rwNLen]byte{'r', 'u', 'e'} { // !Equal jsonLiteral4True - d.d.errorf("expecting %s: got %s", jsonLiteral4True, bs) - } -} - -func (d *jsonDecDriver) readLit4False() { - bs := d.d.decRd.readn(4) - d.tok = 0 - if jsonValidateSymbols && bs != [rwNLen]byte{'a', 'l', 's', 'e'} { // !Equal jsonLiteral4False - d.d.errorf("expecting %s: got %s", jsonLiteral4False, bs) - } -} - -func (d *jsonDecDriver) readLit4Null() { - bs := d.d.decRd.readn(3) // readx(3) - d.tok = 0 - if jsonValidateSymbols && bs != [rwNLen]byte{'u', 'l', 'l'} { // !Equal jsonLiteral4Null - d.d.errorf("expecting %s: got %s", jsonLiteral4Null, bs) - } - d.fnil = true -} - -func (d *jsonDecDriver) advance() { - if d.tok == 0 { - d.fnil = false - d.tok = d.d.decRd.skipWhitespace() // skip(&whitespaceCharBitset) - } -} - -func (d *jsonDecDriver) TryNil() bool { - d.advance() - // we shouldn't try to see if quoted "null" was here, right? - // only the plain string: `null` denotes a nil (ie not quotes) - if d.tok == 'n' { - d.readLit4Null() - return true - } - return false -} - -// func (d *jsonDecDriver) Nil() bool { -// return d.fnil -// } - -func (d *jsonDecDriver) DecodeBool() (v bool) { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return - } - fquot := d.d.c == containerMapKey && d.tok == '"' - if fquot { - d.tok = d.d.decRd.readn1() - } - switch d.tok { - case 'f': - d.readLit4False() - // v = false - case 't': - d.readLit4True() - v = true - default: - d.d.errorf("decode bool: got first char %c", d.tok) - // v = false // "unreachable" - } - if fquot { - d.d.decRd.readn1() - } - return -} - -func (d *jsonDecDriver) DecodeTime() (t time.Time) { - // read string, and pass the string into json.unmarshal - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return - } - bs := d.readUnescapedString() - t, err := time.Parse(time.RFC3339, stringView(bs)) - if err != nil { - d.d.errorv(err) - } - return -} - -func (d *jsonDecDriver) ContainerType() (vt valueType) { - // check container type by checking the first char - d.advance() - - // optimize this, so we don't do 4 checks but do one computation. - // return jsonContainerSet[d.tok] - - // ContainerType is mostly called for Map and Array, - // so this conditional is good enough (max 2 checks typically) - if d.tok == '{' { - return valueTypeMap - } else if d.tok == '[' { - return valueTypeArray - } else if d.tok == 'n' { - d.readLit4Null() - return valueTypeNil - } else if d.tok == '"' { - return valueTypeString - } - return valueTypeUnset -} - -func (d *jsonDecDriver) decNumBytes() (bs []byte) { - d.advance() - if d.tok == '"' { - bs = d.d.decRd.readUntil('"', false) - } else if d.tok == 'n' { - d.readLit4Null() - } else { - bs = d.d.decRd.readNumberWithLastByte() - } - d.tok = 0 - return -} - -func (d *jsonDecDriver) DecodeUint64() (u uint64) { - bs := d.decNumBytes() - if len(bs) == 0 { - return - } - if bs[0] == '-' { - d.d.errorf("negative number cannot be decoded as uint64") - } - var r readFloatResult - u, r.ok = parseUint64_simple(bs) - if r.ok { - return - } - - r = readFloat(bs, fi64u) - if r.ok { - u, r.bad = parseUint64_reader(r) - if r.bad { - d.d.errorv(strconvParseErr(bs, "ParseUint")) - } - return - } - d.d.errorv(strconvParseErr(bs, "ParseUint")) - return -} - -// func (d *jsonDecDriver) DecodeInt64() (i int64) { -// bs := d.decNumBytes() -// if len(bs) == 0 { -// return -// } -// i, err := parseInt64(bs) -// if err != nil { -// d.d.errorv(err) -// } -// return -// } - -func (d *jsonDecDriver) DecodeInt64() (v int64) { - b := d.decNumBytes() - if len(b) == 0 { - return - } - - var r readFloatResult - var neg bool - - if b[0] == '-' { - neg = true - b = b[1:] - } - - r.mantissa, r.ok = parseUint64_simple(b) - // xdebugf("parseuint64_simple: %v, %v", f, ok) - if r.ok { - if chkOvf.Uint2Int(r.mantissa, neg) { - d.d.errorf("overflow decoding number from %s", b) - } - if neg { - v = -int64(r.mantissa) - } else { - v = int64(r.mantissa) - } - return - } - - r = readFloat(b, fi64i) - // xdebugf("readFloat ok: %v", r.ok) - if r.ok { - r.neg = neg - v, r.bad = parseInt64_reader(r) - if r.bad { - d.d.errorv(strconvParseErr(b, "ParseInt")) - } - return - } - d.d.errorv(strconvParseErr(b, "ParseInt")) - return -} - -func (d *jsonDecDriver) DecodeFloat64() (f float64) { - var err error - bs := d.decNumBytes() - if len(bs) == 0 { - return - } - f, err = parseFloat64(bs) - if err != nil { - d.d.errorv(err) - } - return -} - -func (d *jsonDecDriver) DecodeFloat32() (f float32) { - var err error - bs := d.decNumBytes() - if len(bs) == 0 { - return - } - f, err = parseFloat32(bs) - if err != nil { - d.d.errorv(err) - } - return -} - -func (d *jsonDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - d.advance() - if d.tok == 'n' { - d.readLit4Null() - return - } - if ext == nil { - re := rv.(*RawExt) - re.Tag = xtag - d.d.decode(&re.Value) - } else if ext == SelfExt { - rv2 := baseRV(rv) - d.d.decodeValue(rv2, d.h.fnNoExt(rv2.Type())) - } else { - d.d.interfaceExtConvertAndDecode(rv, ext) - } -} - -func (d *jsonDecDriver) decBytesFromArray(bs []byte) []byte { - if bs == nil { - bs = []byte{} - } else { - bs = bs[:0] - } - d.tok = 0 - bs = append(bs, uint8(d.DecodeUint64())) - d.tok = d.d.decRd.skipWhitespace() // skip(&whitespaceCharBitset) - for d.tok != ']' { - if d.tok != ',' { - d.d.errorf("read array element - expect char '%c' but got char '%c'", ',', d.tok) - } - d.tok = 0 - bs = append(bs, uint8(chkOvf.UintV(d.DecodeUint64(), 8))) - d.tok = d.d.decRd.skipWhitespace() // skip(&whitespaceCharBitset) - } - d.tok = 0 - return bs -} - -func (d *jsonDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - // if decoding into raw bytes, and the RawBytesExt is configured, use it to decode. - if d.se.InterfaceExt != nil { - bsOut = bs - d.DecodeExt(&bsOut, 0, &d.se) - return - } - d.advance() - // check if an "array" of uint8's (see ContainerType for how to infer if an array) - if d.tok == '[' { - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - return d.decBytesFromArray(bs) - } - - // base64 encodes []byte{} as "", and we encode nil []byte as null. - // Consequently, base64 should decode null as a nil []byte, and "" as an empty []byte{}. - // appendStringAsBytes returns a zero-len slice for both, so as not to reset d.buf. - // However, it sets a fnil field to true, so we can check if a null was found. - - if d.tok == 'n' { - d.readLit4Null() - return nil - } - - bs1 := d.readUnescapedString() - slen := base64.StdEncoding.DecodedLen(len(bs1)) - if slen == 0 { - bsOut = []byte{} - } else if slen <= cap(bs) { - bsOut = bs[:slen] - } else if zerocopy { - d.buf = d.d.blist.check(d.buf, slen) - bsOut = d.buf - } else { - bsOut = make([]byte, slen) - } - slen2, err := base64.StdEncoding.Decode(bsOut, bs1) - if err != nil { - d.d.errorf("error decoding base64 binary '%s': %v", bs1, err) - return nil - } - if slen != slen2 { - bsOut = bsOut[:slen2] - } - return -} - -func (d *jsonDecDriver) DecodeStringAsBytes() (s []byte) { - d.advance() - - // common case - if d.tok == '"' { - d.appendStringAsBytes() - return d.buf - } - // d.d.errorf("expect char '%c' but got char '%c'", '"', d.tok) - - // handle non-string scalar: null, true, false or a number - switch d.tok { - case 'n': - d.readLit4Null() - return nil // []byte{} - case 'f': - d.readLit4False() - return jsonLiteralFalse - case 't': - d.readLit4True() - return jsonLiteralTrue - } - - // try to parse a valid number - d.tok = 0 - return d.d.decRd.readNumberWithLastByte() -} - -func (d *jsonDecDriver) readUnescapedString() (bs []byte) { - if d.tok != '"' { - d.d.errorf("expecting string starting with '\"'; got '%c'", d.tok) - return - } - - bs = d.d.decRd.readUntil('"', false) - d.tok = 0 - return -} - -func (d *jsonDecDriver) appendStringAsBytes() { - if d.buf != nil { - d.buf = d.buf[:0] - } - d.tok = 0 - - var c uint8 - for { - c = d.d.decRd.readn1() - - if c == '"' { - break - } - if c != '\\' { - d.buf = append(d.buf, c) - continue - } - - c = d.d.decRd.readn1() - - switch c { - case '"', '\\', '/', '\'': - d.buf = append(d.buf, c) - case 'b': - d.buf = append(d.buf, '\b') - case 'f': - d.buf = append(d.buf, '\f') - case 'n': - d.buf = append(d.buf, '\n') - case 'r': - d.buf = append(d.buf, '\r') - case 't': - d.buf = append(d.buf, '\t') - case 'u': - d.appendStringAsBytesSlashU() - default: - d.d.errorf("unsupported escaped value: %c", c) - } - } -} - -func (d *jsonDecDriver) appendStringAsBytesSlashU() { - var r rune - var rr uint32 - var j uint - var c byte - var cs [7]byte - cs = d.d.decRd.readn(4) - for _, c = range cs[:4] { // bounds-check-elimination - // best to use explicit if-else - // - not a table, etc which involve memory loads, array lookup with bounds checks, etc - if c >= '0' && c <= '9' { - rr = rr*16 + uint32(c-jsonU4Chk2) - } else if c >= 'a' && c <= 'f' { - rr = rr*16 + uint32(c-jsonU4Chk1) - } else if c >= 'A' && c <= 'F' { - rr = rr*16 + uint32(c-jsonU4Chk0) - } else { - r = unicode.ReplacementChar - goto encode_rune - } - } - r = rune(rr) - if utf16.IsSurrogate(r) { - cs = d.d.decRd.readn(6) - if cs[0] == '\\' && cs[1] == 'u' { - var rr1 uint32 - for j = 2; j < 6; j++ { - c = cs[j] - if c >= '0' && c <= '9' { - rr = rr*16 + uint32(c-jsonU4Chk2) - } else if c >= 'a' && c <= 'f' { - rr = rr*16 + uint32(c-jsonU4Chk1) - } else if c >= 'A' && c <= 'F' { - rr = rr*16 + uint32(c-jsonU4Chk0) - } else { - r = unicode.ReplacementChar - goto encode_rune - } - } - r = utf16.DecodeRune(r, rune(rr1)) - goto encode_rune - } - r = unicode.ReplacementChar - } -encode_rune: - w2 := utf8.EncodeRune(d.bstr[:], r) - d.buf = append(d.buf, d.bstr[:w2]...) -} - -func (d *jsonDecDriver) nakedNum(z *fauxUnion, bs []byte) (err error) { - // const cutoff = uint64(1 << uint(64-1)) - - if len(bs) == 0 { - if d.h.PreferFloat { - z.v = valueTypeFloat - z.f = 0 - } else if d.h.SignedInteger { - z.v = valueTypeInt - z.i = 0 - } else { - z.v = valueTypeUint - z.u = 0 - } - return - } - if d.h.PreferFloat { - z.v = valueTypeFloat - z.f, err = parseFloat64(bs) - } else { - err = parseNumber(bs, z, d.h.SignedInteger) - } - return -} - -func (d *jsonDecDriver) sliceToString(bs []byte) string { - if d.d.is != nil && (jsonAlwaysReturnInternString || d.d.c == containerMapKey) { - return d.d.string(bs) - } - return string(bs) -} - -func (d *jsonDecDriver) DecodeNaked() { - z := d.d.naked() - - d.advance() - var bs []byte - switch d.tok { - case 'n': - d.readLit4Null() - z.v = valueTypeNil - case 'f': - d.readLit4False() - z.v = valueTypeBool - z.b = false - case 't': - d.readLit4True() - z.v = valueTypeBool - z.b = true - case '{': - z.v = valueTypeMap // don't consume. kInterfaceNaked will call ReadMapStart - case '[': - z.v = valueTypeArray // don't consume. kInterfaceNaked will call ReadArrayStart - case '"': - // if a string, and MapKeyAsString, then try to decode it as a nil, bool or number first - d.appendStringAsBytes() - bs = d.buf - if len(bs) > 0 && d.d.c == containerMapKey && d.h.MapKeyAsString { - if bytes.Equal(bs, jsonLiteralNull) { - z.v = valueTypeNil - } else if bytes.Equal(bs, jsonLiteralTrue) { - z.v = valueTypeBool - z.b = true - } else if bytes.Equal(bs, jsonLiteralFalse) { - z.v = valueTypeBool - z.b = false - } else { - // check if a number: float, int or uint - if err := d.nakedNum(z, bs); err != nil { - z.v = valueTypeString - z.s = d.sliceToString(bs) - } - } - } else { - z.v = valueTypeString - z.s = d.sliceToString(bs) - } - default: // number - bs = d.d.decRd.readNumberWithLastByte() - d.tok = 0 - if len(bs) == 0 { - d.d.errorf("decode number from empty string") - return - } - if err := d.nakedNum(z, bs); err != nil { - d.d.errorf("decode number from %s: %v", bs, err) - return - } - } -} - -//---------------------- - -// JsonHandle is a handle for JSON encoding format. -// -// Json is comprehensively supported: -// - decodes numbers into interface{} as int, uint or float64 -// based on how the number looks and some config parameters e.g. PreferFloat, SignedInt, etc. -// - decode integers from float formatted numbers e.g. 1.27e+8 -// - decode any json value (numbers, bool, etc) from quoted strings -// - configurable way to encode/decode []byte . -// by default, encodes and decodes []byte using base64 Std Encoding -// - UTF-8 support for encoding and decoding -// -// It has better performance than the json library in the standard library, -// by leveraging the performance improvements of the codec library. -// -// In addition, it doesn't read more bytes than necessary during a decode, which allows -// reading multiple values from a stream containing json and non-json content. -// For example, a user can read a json value, then a cbor value, then a msgpack value, -// all from the same stream in sequence. -// -// Note that, when decoding quoted strings, invalid UTF-8 or invalid UTF-16 surrogate pairs are -// not treated as an error. Instead, they are replaced by the Unicode replacement character U+FFFD. -type JsonHandle struct { - textEncodingType - BasicHandle - - // Indent indicates how a value is encoded. - // - If positive, indent by that number of spaces. - // - If negative, indent by that number of tabs. - Indent int8 - - // IntegerAsString controls how integers (signed and unsigned) are encoded. - // - // Per the JSON Spec, JSON numbers are 64-bit floating point numbers. - // Consequently, integers > 2^53 cannot be represented as a JSON number without losing precision. - // This can be mitigated by configuring how to encode integers. - // - // IntegerAsString interpretes the following values: - // - if 'L', then encode integers > 2^53 as a json string. - // - if 'A', then encode all integers as a json string - // containing the exact integer representation as a decimal. - // - else encode all integers as a json number (default) - IntegerAsString byte - - // HTMLCharsAsIs controls how to encode some special characters to html: < > & - // - // By default, we encode them as \uXXX - // to prevent security holes when served from some browsers. - HTMLCharsAsIs bool - - // PreferFloat says that we will default to decoding a number as a float. - // If not set, we will examine the characters of the number and decode as an - // integer type if it doesn't have any of the characters [.eE]. - PreferFloat bool - - // TermWhitespace says that we add a whitespace character - // at the end of an encoding. - // - // The whitespace is important, especially if using numbers in a context - // where multiple items are written to a stream. - TermWhitespace bool - - // MapKeyAsString says to encode all map keys as strings. - // - // Use this to enforce strict json output. - // The only caveat is that nil value is ALWAYS written as null (never as "null") - MapKeyAsString bool - - // _ uint64 // padding (cache line) - - // Note: below, we store hardly-used items - // e.g. RawBytesExt (which is already cached in the (en|de)cDriver). - - // RawBytesExt, if configured, is used to encode and decode raw bytes in a custom way. - // If not configured, raw bytes are encoded to/from base64 text. - RawBytesExt InterfaceExt - - _ [5]uint64 // padding (cache line) -} - -// Name returns the name of the handle: json -func (h *JsonHandle) Name() string { return "json" } - -// func (h *JsonHandle) hasElemSeparators() bool { return true } -func (h *JsonHandle) typical() bool { - return h.Indent == 0 && !h.MapKeyAsString && h.IntegerAsString != 'A' && h.IntegerAsString != 'L' -} - -func (h *JsonHandle) newEncDriver() encDriver { - var e = &jsonEncDriver{h: h} - e.e.e = e - e.e.js = true - e.e.init(h) - e.reset() - return e -} - -func (h *JsonHandle) newDecDriver() decDriver { - var d = &jsonDecDriver{h: h} - d.d.d = d - d.d.js = true - d.d.jsms = h.MapKeyAsString - d.d.init(h) - d.reset() - return d -} - -func (e *jsonEncDriver) reset() { - // (htmlasis && jsonCharSafeSet.isset(b)) || jsonCharHtmlSafeSet.isset(b) - e.typical = e.h.typical() - if e.h.HTMLCharsAsIs { - e.s = &jsonCharSafeSet - } else { - e.s = &jsonCharHtmlSafeSet - } - e.se.InterfaceExt = e.h.RawBytesExt - e.d, e.dl, e.di = false, 0, 0 - if e.h.Indent != 0 { - e.d = true - e.di = int8(e.h.Indent) - } - e.ks = e.h.MapKeyAsString - e.is = e.h.IntegerAsString -} - -func (d *jsonDecDriver) reset() { - d.se.InterfaceExt = d.h.RawBytesExt - d.buf = d.d.blist.check(d.buf, 256)[:0] - d.tok = 0 - d.fnil = false -} - -func (d *jsonDecDriver) atEndOfDecode() {} - -func jsonFloatStrconvFmtPrec64(f float64) (fmt byte, prec int8) { - fmt = 'f' - prec = -1 - var abs = math.Abs(f) - if abs == 0 || abs == 1 { - prec = 1 - } else if abs < 1e-6 || abs >= 1e21 { - fmt = 'e' - } else if noFrac64(abs) { // _, frac := math.Modf(abs); frac == 0 { - prec = 1 - } - return -} - -func jsonFloatStrconvFmtPrec32(f float32) (fmt byte, prec int8) { - fmt = 'f' - prec = -1 - var abs = abs32(f) - if abs == 0 || abs == 1 { - prec = 1 - } else if abs < 1e-6 || abs >= 1e21 { - fmt = 'e' - } else if noFrac32(abs) { // _, frac := math.Modf(abs); frac == 0 { - prec = 1 - } - return -} - -var _ decDriverContainerTracker = (*jsonDecDriver)(nil) -var _ encDriverContainerTracker = (*jsonEncDriver)(nil) -var _ decDriver = (*jsonDecDriver)(nil) - -var _ encDriver = (*jsonEncDriver)(nil) - -// ---------------- - -/* -type jsonEncDriverTypical jsonEncDriver - -func (e *jsonEncDriverTypical) WriteArrayStart(length int) { - e.e.encWr.writen1('[') -} - -func (e *jsonEncDriverTypical) WriteArrayElem() { - if e.e.c != containerArrayStart { - e.e.encWr.writen1(',') - } -} - -func (e *jsonEncDriverTypical) WriteArrayEnd() { - e.e.encWr.writen1(']') -} - -func (e *jsonEncDriverTypical) WriteMapStart(length int) { - e.e.encWr.writen1('{') -} - -func (e *jsonEncDriverTypical) WriteMapElemKey() { - if e.e.c != containerMapStart { - e.e.encWr.writen1(',') - } -} - -func (e *jsonEncDriverTypical) WriteMapElemValue() { - e.e.encWr.writen1(':') -} - -func (e *jsonEncDriverTypical) WriteMapEnd() { - e.e.encWr.writen1('}') -} - -func (e *jsonEncDriverTypical) EncodeBool(b bool) { - if b { - // e.e.encWr.writeb(jsonLiteralTrue) - e.e.encWr.writen([rwNLen]byte{'t', 'r', 'u', 'e'}, 4) - } else { - // e.e.encWr.writeb(jsonLiteralFalse) - e.e.encWr.writen([rwNLen]byte{'f', 'a', 'l', 's', 'e'}, 5) - } -} - -func (e *jsonEncDriverTypical) EncodeInt(v int64) { - e.e.encWr.writeb(strconv.AppendInt(e.b[:0], v, 10)) -} - -func (e *jsonEncDriverTypical) EncodeUint(v uint64) { - e.e.encWr.writeb(strconv.AppendUint(e.b[:0], v, 10)) -} - -func (e *jsonEncDriverTypical) EncodeFloat64(f float64) { - fmt, prec := jsonFloatStrconvFmtPrec64(f) - e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, int(prec), 64)) - // e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, jsonFloatStrconvFmtPrec64(f), 64)) -} - -func (e *jsonEncDriverTypical) EncodeFloat32(f float32) { - fmt, prec := jsonFloatStrconvFmtPrec32(f) - e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], float64(f), fmt, int(prec), 32)) -} - -// func (e *jsonEncDriverTypical) encodeFloat(f float64, bitsize uint8) { -// fmt, prec := jsonFloatStrconvFmtPrec(f, bitsize == 32) -// e.e.encWr.writeb(strconv.AppendFloat(e.b[:0], f, fmt, prec, int(bitsize))) -// } - -// func (e *jsonEncDriverTypical) atEndOfEncode() { -// if e.tw { -// e.e.encWr.writen1(' ') -// } -// } - -*/ - -/* -func (d *jsonDecDriver) appendStringAsBytes() (bs []byte) { - if d.buf != nil { - d.buf = d.buf[:0] - } - d.tok = 0 - - // append on each byte seen can be expensive, so we just - // keep track of where we last read a contiguous set of - // non-special bytes (using cursor variable), - // and when we see a special byte - // e.g. end-of-slice, " or \, - // we will append the full range into the v slice before proceeding - - var cs = d.d.decRd.readUntil('"', true) - var c uint8 - var i, cursor uint - for { - if i >= uint(len(cs)) { - d.buf = append(d.buf, cs[cursor:]...) - cs = d.d.decRd.readUntil('"', true) - i, cursor = 0, 0 - continue // this continue helps elide the cs[i] below - } - c = cs[i] - if c == '"' { - break - } - if c != '\\' { - i++ - continue - } - - d.buf = append(d.buf, cs[cursor:i]...) - i++ - if i >= uint(len(cs)) { - d.d.errorf("need at least 1 more bytes for \\ escape sequence") - return // bounds-check elimination - } - c = cs[i] - switch c { - case '"', '\\', '/', '\'': - d.buf = append(d.buf, c) - case 'b': - d.buf = append(d.buf, '\b') - case 'f': - d.buf = append(d.buf, '\f') - case 'n': - d.buf = append(d.buf, '\n') - case 'r': - d.buf = append(d.buf, '\r') - case 't': - d.buf = append(d.buf, '\t') - case 'u': - i = d.appendStringAsBytesSlashU(cs, i) - default: - d.d.errorf("unsupported escaped value: %c", c) - } - i++ - cursor = i - } - if len(cs) > 0 { - if len(d.buf) > 0 && cursor < uint(len(cs)) { - d.buf = append(d.buf, cs[cursor:i]...) - } else { - // if bytes, just return the cs got from readUntil. - // do not do it for io, especially bufio, as the buffer is needed for other things - cs = cs[:i] - if d.d.bytes { - return cs - } - d.buf = d.d.blist.check(d.buf, len(cs)) - copy(d.buf, cs) - } - } - return d.buf -} - -func (d *jsonDecDriver) appendStringAsBytesSlashU(cs []byte, i uint) uint { - var r rune - var rr uint32 - var j uint - var c byte - if uint(len(cs)) < i+4 { - d.d.errorf("need at least 4 more bytes for unicode sequence") - return 0 // bounds-check elimination - } - for _, c = range cs[i+1 : i+5] { // bounds-check-elimination - // best to use explicit if-else - // - not a table, etc which involve memory loads, array lookup with bounds checks, etc - if c >= '0' && c <= '9' { - rr = rr*16 + uint32(c-jsonU4Chk2) - } else if c >= 'a' && c <= 'f' { - rr = rr*16 + uint32(c-jsonU4Chk1) - } else if c >= 'A' && c <= 'F' { - rr = rr*16 + uint32(c-jsonU4Chk0) - } else { - r = unicode.ReplacementChar - i += 4 - goto encode_rune - } - } - r = rune(rr) - i += 4 - if utf16.IsSurrogate(r) { - if len(cs) >= int(i+6) { - var cx = cs[i+1:][:6:6] // [:6] affords bounds-check-elimination - //var cx [6]byte - //copy(cx[:], cs[i+1:]) - if cx[0] == '\\' && cx[1] == 'u' { - i += 2 - var rr1 uint32 - for j = 2; j < 6; j++ { - c = cx[j] - if c >= '0' && c <= '9' { - rr = rr*16 + uint32(c-jsonU4Chk2) - } else if c >= 'a' && c <= 'f' { - rr = rr*16 + uint32(c-jsonU4Chk1) - } else if c >= 'A' && c <= 'F' { - rr = rr*16 + uint32(c-jsonU4Chk0) - } else { - r = unicode.ReplacementChar - i += 4 - goto encode_rune - } - } - r = utf16.DecodeRune(r, rune(rr1)) - i += 4 - goto encode_rune - } - } - r = unicode.ReplacementChar - } -encode_rune: - w2 := utf8.EncodeRune(d.bstr[:], r) - d.buf = append(d.buf, d.bstr[:w2]...) - return i -} - -*/ - -/* -// jsonFloatStrconvFmtPrec ... -// -// ensure that every float has an 'e' or '.' in it,/ for easy differentiation from integers. -// this is better/faster than checking if encoded value has [e.] and appending if needed. - -// func jsonFloatStrconvFmtPrec(f float64, bits32 bool) (fmt byte, prec int) { -// fmt = 'f' -// prec = -1 -// var abs = math.Abs(f) -// if abs == 0 || abs == 1 { -// prec = 1 -// } else if !bits32 && (abs < 1e-6 || abs >= 1e21) || -// bits32 && (float32(abs) < 1e-6 || float32(abs) >= 1e21) { -// fmt = 'e' -// } else if _, frac := math.Modf(abs); frac == 0 { -// // ensure that floats have a .0 at the end, for easy identification as floats -// prec = 1 -// } -// return -// } - -*/ diff --git a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl deleted file mode 100644 index ba55b396f..000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from mammoth-test.go.tmpl - DO NOT EDIT. - -package codec - -import "testing" -import "fmt" - -// TestMammoth has all the different paths optimized in fast-path -// It has all the primitives, slices and maps. -// -// For each of those types, it has a pointer and a non-pointer field. - -func init() { _ = fmt.Printf } // so we can include fmt as needed - -type TestMammoth struct { - -{{range .Values }}{{if .Primitive -}} -{{ .MethodNamePfx "F" true }} {{ .Primitive }} -{{ .MethodNamePfx "Fptr" true }} *{{ .Primitive }} -{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if not .MapKey -}} -{{ .MethodNamePfx "F" false }} []{{ .Elem }} -{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }} -{{end}}{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if .MapKey -}} -{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }} -{{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }} -{{end}}{{end}}{{end}} - -} - -{{range .Values }}{{if not .Primitive }}{{if not .MapKey -}} -type {{ .MethodNamePfx "typMbs" false }} []{{ .Elem }} -func (_ {{ .MethodNamePfx "typMbs" false }}) MapBySlice() { } -{{end}}{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if .MapKey -}} -type {{ .MethodNamePfx "typMap" false }} map[{{ .MapKey }}]{{ .Elem }} -{{end}}{{end}}{{end}} - -func doTestMammothSlices(t *testing.T, h Handle) { -{{range $i, $e := .Values }}{{if not .Primitive }}{{if not .MapKey -}} - var v{{$i}}va [8]{{ .Elem }} - for _, v := range [][]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .Elem }}, {{ zerocmd .Elem }}, {{ zerocmd .Elem }}, {{ nonzerocmd .Elem }} } } { - {{/* - // fmt.Printf(">>>> running mammoth slice v{{$i}}: %v\n", v) - // - encode value to some []byte - // - decode into a length-wise-equal []byte - // - check if equal to initial slice - // - encode ptr to the value - // - check if encode bytes are same - // - decode into ptrs to: nil, then 1-elem slice, equal-length, then large len slice - // - decode into non-addressable slice of equal length, then larger len - // - for each decode, compare elem-by-elem to the original slice - // - - // - rinse and repeat for a MapBySlice version - // - - */ -}} - var v{{$i}}v1, v{{$i}}v2 []{{ .Elem }} - var bs{{$i}} []byte - v{{$i}}v1 = v - bs{{$i}} = testMarshalErr(v{{$i}}v1, h, t, "enc-slice-v{{$i}}") - if v != nil { - if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) } - testUnmarshalErr(v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}") - if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) } - testUnmarshalErr(rv4i(v{{$i}}v2), bs{{$i}}, h, t, "dec-slice-v{{$i}}-noaddr") // non-addressable value - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-noaddr") - } - // ... - bs{{$i}} = testMarshalErr(&v{{$i}}v1, h, t, "enc-slice-v{{$i}}-p") - v{{$i}}v2 = nil - testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p") - v{{$i}}va = [8]{{ .Elem }}{} // clear the array - v{{$i}}v2 = v{{$i}}va[:1:1] - testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-1") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-1") - v{{$i}}va = [8]{{ .Elem }}{} // clear the array - v{{$i}}v2 = v{{$i}}va[:len(v{{$i}}v1):len(v{{$i}}v1)] - testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-len") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-len") - v{{$i}}va = [8]{{ .Elem }}{} // clear the array - v{{$i}}v2 = v{{$i}}va[:] - testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-cap") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-slice-v{{$i}}-p-cap") - if len(v{{$i}}v1) > 1 { - v{{$i}}va = [8]{{ .Elem }}{} // clear the array - testUnmarshalErr((&v{{$i}}va)[:len(v{{$i}}v1)], bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-len-noaddr") - testDeepEqualErr(v{{$i}}v1, v{{$i}}va[:len(v{{$i}}v1)], t, "equal-slice-v{{$i}}-p-len-noaddr") - v{{$i}}va = [8]{{ .Elem }}{} // clear the array - testUnmarshalErr((&v{{$i}}va)[:], bs{{$i}}, h, t, "dec-slice-v{{$i}}-p-cap-noaddr") - testDeepEqualErr(v{{$i}}v1, v{{$i}}va[:len(v{{$i}}v1)], t, "equal-slice-v{{$i}}-p-cap-noaddr") - } - // ... - var v{{$i}}v3, v{{$i}}v4 {{ .MethodNamePfx "typMbs" false }} - v{{$i}}v2 = nil - if v != nil { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) } - v{{$i}}v3 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v1) - v{{$i}}v4 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v2) - if v != nil { - bs{{$i}} = testMarshalErr(v{{$i}}v3, h, t, "enc-slice-v{{$i}}-custom") - testUnmarshalErr(v{{$i}}v4, bs{{$i}}, h, t, "dec-slice-v{{$i}}-custom") - testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-slice-v{{$i}}-custom") - } - bs{{$i}} = testMarshalErr(&v{{$i}}v3, h, t, "enc-slice-v{{$i}}-custom-p") - v{{$i}}v2 = nil - v{{$i}}v4 = {{ .MethodNamePfx "typMbs" false }}(v{{$i}}v2) - testUnmarshalErr(&v{{$i}}v4, bs{{$i}}, h, t, "dec-slice-v{{$i}}-custom-p") - testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-slice-v{{$i}}-custom-p") - } -{{end}}{{end}}{{end}} -} - -func doTestMammothMaps(t *testing.T, h Handle) { -{{range $i, $e := .Values }}{{if not .Primitive }}{{if .MapKey -}} - for _, v := range []map[{{ .MapKey }}]{{ .Elem }}{ nil, {}, { {{ nonzerocmd .MapKey }}:{{ zerocmd .Elem }} {{if ne "bool" .MapKey}}, {{ nonzerocmd .MapKey }}:{{ nonzerocmd .Elem }} {{end}} } } { - // fmt.Printf(">>>> running mammoth map v{{$i}}: %v\n", v) - var v{{$i}}v1, v{{$i}}v2 map[{{ .MapKey }}]{{ .Elem }} - var bs{{$i}} []byte - v{{$i}}v1 = v - bs{{$i}} = testMarshalErr(v{{$i}}v1, h, t, "enc-map-v{{$i}}") - if v != nil { - if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map - testUnmarshalErr(v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}") - if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map - testUnmarshalErr(rv4i(v{{$i}}v2), bs{{$i}}, h, t, "dec-map-v{{$i}}-noaddr") // decode into non-addressable map value - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-noaddr") - } - if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map - testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-len") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-p-len") - bs{{$i}} = testMarshalErr(&v{{$i}}v1, h, t, "enc-map-v{{$i}}-p") - v{{$i}}v2 = nil - testUnmarshalErr(&v{{$i}}v2, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-nil") - testDeepEqualErr(v{{$i}}v1, v{{$i}}v2, t, "equal-map-v{{$i}}-p-nil") - // ... - if v == nil { v{{$i}}v2 = nil } else { v{{$i}}v2 = make(map[{{ .MapKey }}]{{ .Elem }}, len(v)) } // reset map - var v{{$i}}v3, v{{$i}}v4 {{ .MethodNamePfx "typMap" false }} - v{{$i}}v3 = {{ .MethodNamePfx "typMap" false }}(v{{$i}}v1) - v{{$i}}v4 = {{ .MethodNamePfx "typMap" false }}(v{{$i}}v2) - if v != nil { - bs{{$i}} = testMarshalErr(v{{$i}}v3, h, t, "enc-map-v{{$i}}-custom") - testUnmarshalErr(v{{$i}}v4, bs{{$i}}, h, t, "dec-map-v{{$i}}-p-len") - testDeepEqualErr(v{{$i}}v3, v{{$i}}v4, t, "equal-map-v{{$i}}-p-len") - } - } -{{end}}{{end}}{{end}} - -} - -func doTestMammothMapsAndSlices(t *testing.T, h Handle) { - doTestMammothSlices(t, h) - doTestMammothMaps(t, h) -} diff --git a/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl b/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl deleted file mode 100644 index 71eaf618a..000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl +++ /dev/null @@ -1,94 +0,0 @@ -// +build !notfastpath - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from mammoth2-test.go.tmpl - DO NOT EDIT. - -package codec - -// Increase codecoverage by covering all the codecgen paths, in fast-path and gen-helper.go.... -// -// Add: -// - test file for creating a mammoth generated file as _mammoth_generated.go -// - generate a second mammoth files in a different file: mammoth2_generated_test.go -// - mammoth-test.go.tmpl will do this -// - run codecgen on it, into mammoth2_codecgen_generated_test.go (no build tags) -// - as part of TestMammoth, run it also -// - this will cover all the codecgen, gen-helper, etc in one full run -// - check in mammoth* files into github also -// - then -// -// Now, add some types: -// - some that implement BinaryMarshal, TextMarshal, JSONMarshal, and one that implements none of it -// - create a wrapper type that includes TestMammoth2, with it in slices, and maps, and the custom types -// - this wrapper object is what we work encode/decode (so that the codecgen methods are called) - - -// import "encoding/binary" -import "fmt" - -type TestMammoth2 struct { - -{{range .Values }}{{if .Primitive }}{{/* -*/}}{{ .MethodNamePfx "F" true }} {{ .Primitive }} -{{ .MethodNamePfx "Fptr" true }} *{{ .Primitive }} -{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if not .MapKey }}{{/* -*/}}{{ .MethodNamePfx "F" false }} []{{ .Elem }} -{{ .MethodNamePfx "Fptr" false }} *[]{{ .Elem }} -{{end}}{{end}}{{end}} - -{{range .Values }}{{if not .Primitive }}{{if .MapKey }}{{/* -*/}}{{ .MethodNamePfx "F" false }} map[{{ .MapKey }}]{{ .Elem }} -{{ .MethodNamePfx "Fptr" false }} *map[{{ .MapKey }}]{{ .Elem }} -{{end}}{{end}}{{end}} - -} - -// ----------- - -type testMammoth2Binary uint64 -func (x testMammoth2Binary) MarshalBinary() (data []byte, err error) { -data = make([]byte, 8) -bigen.PutUint64(data, uint64(x)) -return -} -func (x *testMammoth2Binary) UnmarshalBinary(data []byte) (err error) { -*x = testMammoth2Binary(bigen.Uint64(data)) -return -} - -type testMammoth2Text uint64 -func (x testMammoth2Text) MarshalText() (data []byte, err error) { -data = []byte(fmt.Sprintf("%b", uint64(x))) -return -} -func (x *testMammoth2Text) UnmarshalText(data []byte) (err error) { -_, err = fmt.Sscanf(string(data), "%b", (*uint64)(x)) -return -} - -type testMammoth2Json uint64 -func (x testMammoth2Json) MarshalJSON() (data []byte, err error) { -data = []byte(fmt.Sprintf("%v", uint64(x))) -return -} -func (x *testMammoth2Json) UnmarshalJSON(data []byte) (err error) { -_, err = fmt.Sscanf(string(data), "%v", (*uint64)(x)) -return -} - -type testMammoth2Basic [4]uint64 - -type TestMammoth2Wrapper struct { - V TestMammoth2 - T testMammoth2Text - B testMammoth2Binary - J testMammoth2Json - C testMammoth2Basic - M map[testMammoth2Basic]TestMammoth2 - L []TestMammoth2 - A [4]int64 -} diff --git a/vendor/github.com/ugorji/go/codec/mammoth2_codecgen_generated_test.go b/vendor/github.com/ugorji/go/codec/mammoth2_codecgen_generated_test.go deleted file mode 100644 index 1d47ec3ea..000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth2_codecgen_generated_test.go +++ /dev/null @@ -1,9739 +0,0 @@ -// +build go1.6 -// +build codecgen,!notfastpath generated,!notfastpath - -// Code generated by codecgen - DO NOT EDIT. - -package codec - -import ( - "errors" - "runtime" - "strconv" -) - -const ( - // ----- content types ---- - codecSelferCcUTF819781 = 1 - codecSelferCcRAW19781 = 255 - // ----- value types used ---- - codecSelferValueTypeArray19781 = 10 - codecSelferValueTypeMap19781 = 9 - codecSelferValueTypeString19781 = 6 - codecSelferValueTypeInt19781 = 2 - codecSelferValueTypeUint19781 = 3 - codecSelferValueTypeFloat19781 = 4 - codecSelferValueTypeNil19781 = 1 - codecSelferBitsize19781 = uint8(32 << (^uint(0) >> 63)) - codecSelferDecContainerLenNil19781 = -2147483648 -) - -var ( - errCodecSelferOnlyMapOrArrayEncodeToStruct19781 = errors.New(`only encoded map or array can be decoded into a struct`) -) - -type codecSelfer19781 struct{} - -func codecSelfer19781False() bool { return false } - -func init() { - if GenVersion != 16 { - _, file, _, _ := runtime.Caller(0) - ver := strconv.FormatInt(int64(GenVersion), 10) - panic("codecgen version mismatch: current: 16, need " + ver + ". Re-generate file: " + file) - } -} - -func (x *TestMammoth2) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyn4 bool = x.FptrIntf == nil - var yyn6 bool = x.FptrString == nil - var yyn8 bool = x.FptrBytes == nil - var yyn10 bool = x.FptrFloat32 == nil - var yyn12 bool = x.FptrFloat64 == nil - var yyn14 bool = x.FptrUint == nil - var yyn16 bool = x.FptrUint8 == nil - var yyn18 bool = x.FptrUint16 == nil - var yyn20 bool = x.FptrUint32 == nil - var yyn22 bool = x.FptrUint64 == nil - var yyn24 bool = x.FptrUintptr == nil - var yyn26 bool = x.FptrInt == nil - var yyn28 bool = x.FptrInt8 == nil - var yyn30 bool = x.FptrInt16 == nil - var yyn32 bool = x.FptrInt32 == nil - var yyn34 bool = x.FptrInt64 == nil - var yyn36 bool = x.FptrBool == nil - var yyn38 bool = x.FptrSliceIntf == nil - var yyn40 bool = x.FptrSliceString == nil - var yyn42 bool = x.FptrSliceBytes == nil - var yyn44 bool = x.FptrSliceFloat32 == nil - var yyn46 bool = x.FptrSliceFloat64 == nil - var yyn48 bool = x.FptrSliceUint == nil - var yyn50 bool = x.FptrSliceUint16 == nil - var yyn52 bool = x.FptrSliceUint32 == nil - var yyn54 bool = x.FptrSliceUint64 == nil - var yyn56 bool = x.FptrSliceInt == nil - var yyn58 bool = x.FptrSliceInt8 == nil - var yyn60 bool = x.FptrSliceInt16 == nil - var yyn62 bool = x.FptrSliceInt32 == nil - var yyn64 bool = x.FptrSliceInt64 == nil - var yyn66 bool = x.FptrSliceBool == nil - var yyn68 bool = x.FptrMapStringIntf == nil - var yyn70 bool = x.FptrMapStringString == nil - var yyn72 bool = x.FptrMapStringBytes == nil - var yyn74 bool = x.FptrMapStringUint == nil - var yyn76 bool = x.FptrMapStringUint8 == nil - var yyn78 bool = x.FptrMapStringUint64 == nil - var yyn80 bool = x.FptrMapStringInt == nil - var yyn82 bool = x.FptrMapStringInt64 == nil - var yyn84 bool = x.FptrMapStringFloat32 == nil - var yyn86 bool = x.FptrMapStringFloat64 == nil - var yyn88 bool = x.FptrMapStringBool == nil - var yyn90 bool = x.FptrMapUintIntf == nil - var yyn92 bool = x.FptrMapUintString == nil - var yyn94 bool = x.FptrMapUintBytes == nil - var yyn96 bool = x.FptrMapUintUint == nil - var yyn98 bool = x.FptrMapUintUint8 == nil - var yyn100 bool = x.FptrMapUintUint64 == nil - var yyn102 bool = x.FptrMapUintInt == nil - var yyn104 bool = x.FptrMapUintInt64 == nil - var yyn106 bool = x.FptrMapUintFloat32 == nil - var yyn108 bool = x.FptrMapUintFloat64 == nil - var yyn110 bool = x.FptrMapUintBool == nil - var yyn112 bool = x.FptrMapUint8Intf == nil - var yyn114 bool = x.FptrMapUint8String == nil - var yyn116 bool = x.FptrMapUint8Bytes == nil - var yyn118 bool = x.FptrMapUint8Uint == nil - var yyn120 bool = x.FptrMapUint8Uint8 == nil - var yyn122 bool = x.FptrMapUint8Uint64 == nil - var yyn124 bool = x.FptrMapUint8Int == nil - var yyn126 bool = x.FptrMapUint8Int64 == nil - var yyn128 bool = x.FptrMapUint8Float32 == nil - var yyn130 bool = x.FptrMapUint8Float64 == nil - var yyn132 bool = x.FptrMapUint8Bool == nil - var yyn134 bool = x.FptrMapUint64Intf == nil - var yyn136 bool = x.FptrMapUint64String == nil - var yyn138 bool = x.FptrMapUint64Bytes == nil - var yyn140 bool = x.FptrMapUint64Uint == nil - var yyn142 bool = x.FptrMapUint64Uint8 == nil - var yyn144 bool = x.FptrMapUint64Uint64 == nil - var yyn146 bool = x.FptrMapUint64Int == nil - var yyn148 bool = x.FptrMapUint64Int64 == nil - var yyn150 bool = x.FptrMapUint64Float32 == nil - var yyn152 bool = x.FptrMapUint64Float64 == nil - var yyn154 bool = x.FptrMapUint64Bool == nil - var yyn156 bool = x.FptrMapIntIntf == nil - var yyn158 bool = x.FptrMapIntString == nil - var yyn160 bool = x.FptrMapIntBytes == nil - var yyn162 bool = x.FptrMapIntUint == nil - var yyn164 bool = x.FptrMapIntUint8 == nil - var yyn166 bool = x.FptrMapIntUint64 == nil - var yyn168 bool = x.FptrMapIntInt == nil - var yyn170 bool = x.FptrMapIntInt64 == nil - var yyn172 bool = x.FptrMapIntFloat32 == nil - var yyn174 bool = x.FptrMapIntFloat64 == nil - var yyn176 bool = x.FptrMapIntBool == nil - var yyn178 bool = x.FptrMapInt64Intf == nil - var yyn180 bool = x.FptrMapInt64String == nil - var yyn182 bool = x.FptrMapInt64Bytes == nil - var yyn184 bool = x.FptrMapInt64Uint == nil - var yyn186 bool = x.FptrMapInt64Uint8 == nil - var yyn188 bool = x.FptrMapInt64Uint64 == nil - var yyn190 bool = x.FptrMapInt64Int == nil - var yyn192 bool = x.FptrMapInt64Int64 == nil - var yyn194 bool = x.FptrMapInt64Float32 == nil - var yyn196 bool = x.FptrMapInt64Float64 == nil - var yyn198 bool = x.FptrMapInt64Bool == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(196) - z.EncWriteArrayElem() - z.EncFallback(x.FIntf) - if yyn4 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy200 := *x.FptrIntf - z.EncFallback(yy200) - } - z.EncWriteArrayElem() - r.EncodeString(string(x.FString)) - if yyn6 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy203 := *x.FptrString - r.EncodeString(string(yy203)) - } - z.EncWriteArrayElem() - if x.FBytes == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.FBytes)) - } // end block: if x.FBytes slice == nil - if yyn8 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy206 := *x.FptrBytes - if yy206 == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(yy206)) - } // end block: if yy206 slice == nil - } - z.EncWriteArrayElem() - r.EncodeFloat32(float32(x.FFloat32)) - if yyn10 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy209 := *x.FptrFloat32 - r.EncodeFloat32(float32(yy209)) - } - z.EncWriteArrayElem() - r.EncodeFloat64(float64(x.FFloat64)) - if yyn12 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy212 := *x.FptrFloat64 - r.EncodeFloat64(float64(yy212)) - } - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.FUint)) - if yyn14 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy215 := *x.FptrUint - r.EncodeUint(uint64(yy215)) - } - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.FUint8)) - if yyn16 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy218 := *x.FptrUint8 - r.EncodeUint(uint64(yy218)) - } - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.FUint16)) - if yyn18 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy221 := *x.FptrUint16 - r.EncodeUint(uint64(yy221)) - } - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.FUint32)) - if yyn20 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy224 := *x.FptrUint32 - r.EncodeUint(uint64(yy224)) - } - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.FUint64)) - if yyn22 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy227 := *x.FptrUint64 - r.EncodeUint(uint64(yy227)) - } - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.FUintptr)) - if yyn24 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy230 := *x.FptrUintptr - r.EncodeUint(uint64(yy230)) - } - z.EncWriteArrayElem() - r.EncodeInt(int64(x.FInt)) - if yyn26 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy233 := *x.FptrInt - r.EncodeInt(int64(yy233)) - } - z.EncWriteArrayElem() - r.EncodeInt(int64(x.FInt8)) - if yyn28 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy236 := *x.FptrInt8 - r.EncodeInt(int64(yy236)) - } - z.EncWriteArrayElem() - r.EncodeInt(int64(x.FInt16)) - if yyn30 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy239 := *x.FptrInt16 - r.EncodeInt(int64(yy239)) - } - z.EncWriteArrayElem() - r.EncodeInt(int64(x.FInt32)) - if yyn32 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy242 := *x.FptrInt32 - r.EncodeInt(int64(yy242)) - } - z.EncWriteArrayElem() - r.EncodeInt(int64(x.FInt64)) - if yyn34 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy245 := *x.FptrInt64 - r.EncodeInt(int64(yy245)) - } - z.EncWriteArrayElem() - r.EncodeBool(bool(x.FBool)) - if yyn36 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy248 := *x.FptrBool - r.EncodeBool(bool(yy248)) - } - z.EncWriteArrayElem() - if x.FSliceIntf == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.FSliceIntf, e) - } // end block: if x.FSliceIntf slice == nil - if yyn38 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy251 := *x.FptrSliceIntf - if yy251 == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(yy251, e) - } // end block: if yy251 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceString == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.FSliceString, e) - } // end block: if x.FSliceString slice == nil - if yyn40 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy254 := *x.FptrSliceString - if yy254 == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(yy254, e) - } // end block: if yy254 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceBytes == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.FSliceBytes, e) - } // end block: if x.FSliceBytes slice == nil - if yyn42 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy257 := *x.FptrSliceBytes - if yy257 == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(yy257, e) - } // end block: if yy257 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.FSliceFloat32, e) - } // end block: if x.FSliceFloat32 slice == nil - if yyn44 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy260 := *x.FptrSliceFloat32 - if yy260 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(yy260, e) - } // end block: if yy260 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.FSliceFloat64, e) - } // end block: if x.FSliceFloat64 slice == nil - if yyn46 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy263 := *x.FptrSliceFloat64 - if yy263 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(yy263, e) - } // end block: if yy263 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceUint == nil { - r.EncodeNil() - } else { - z.F.EncSliceUintV(x.FSliceUint, e) - } // end block: if x.FSliceUint slice == nil - if yyn48 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy266 := *x.FptrSliceUint - if yy266 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUintV(yy266, e) - } // end block: if yy266 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceUint16 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint16V(x.FSliceUint16, e) - } // end block: if x.FSliceUint16 slice == nil - if yyn50 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy269 := *x.FptrSliceUint16 - if yy269 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint16V(yy269, e) - } // end block: if yy269 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceUint32 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint32V(x.FSliceUint32, e) - } // end block: if x.FSliceUint32 slice == nil - if yyn52 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy272 := *x.FptrSliceUint32 - if yy272 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint32V(yy272, e) - } // end block: if yy272 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceUint64 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.FSliceUint64, e) - } // end block: if x.FSliceUint64 slice == nil - if yyn54 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy275 := *x.FptrSliceUint64 - if yy275 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(yy275, e) - } // end block: if yy275 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceInt == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntV(x.FSliceInt, e) - } // end block: if x.FSliceInt slice == nil - if yyn56 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy278 := *x.FptrSliceInt - if yy278 == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntV(yy278, e) - } // end block: if yy278 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceInt8 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt8V(x.FSliceInt8, e) - } // end block: if x.FSliceInt8 slice == nil - if yyn58 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy281 := *x.FptrSliceInt8 - if yy281 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt8V(yy281, e) - } // end block: if yy281 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceInt16 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.FSliceInt16, e) - } // end block: if x.FSliceInt16 slice == nil - if yyn60 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy284 := *x.FptrSliceInt16 - if yy284 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(yy284, e) - } // end block: if yy284 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceInt32 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt32V(x.FSliceInt32, e) - } // end block: if x.FSliceInt32 slice == nil - if yyn62 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy287 := *x.FptrSliceInt32 - if yy287 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt32V(yy287, e) - } // end block: if yy287 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceInt64 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.FSliceInt64, e) - } // end block: if x.FSliceInt64 slice == nil - if yyn64 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy290 := *x.FptrSliceInt64 - if yy290 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(yy290, e) - } // end block: if yy290 slice == nil - } - z.EncWriteArrayElem() - if x.FSliceBool == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.FSliceBool, e) - } // end block: if x.FSliceBool slice == nil - if yyn66 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy293 := *x.FptrSliceBool - if yy293 == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(yy293, e) - } // end block: if yy293 slice == nil - } - z.EncWriteArrayElem() - if x.FMapStringIntf == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(x.FMapStringIntf, e) - } // end block: if x.FMapStringIntf map == nil - if yyn68 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy296 := *x.FptrMapStringIntf - if yy296 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(yy296, e) - } // end block: if yy296 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringString == nil { - r.EncodeNil() - } else { - z.F.EncMapStringStringV(x.FMapStringString, e) - } // end block: if x.FMapStringString map == nil - if yyn70 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy299 := *x.FptrMapStringString - if yy299 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringStringV(yy299, e) - } // end block: if yy299 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringBytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.FMapStringBytes, e) - } // end block: if x.FMapStringBytes map == nil - if yyn72 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy302 := *x.FptrMapStringBytes - if yy302 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(yy302, e) - } // end block: if yy302 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringUint == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUintV(x.FMapStringUint, e) - } // end block: if x.FMapStringUint map == nil - if yyn74 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy305 := *x.FptrMapStringUint - if yy305 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUintV(yy305, e) - } // end block: if yy305 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringUint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint8V(x.FMapStringUint8, e) - } // end block: if x.FMapStringUint8 map == nil - if yyn76 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy308 := *x.FptrMapStringUint8 - if yy308 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint8V(yy308, e) - } // end block: if yy308 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringUint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint64V(x.FMapStringUint64, e) - } // end block: if x.FMapStringUint64 map == nil - if yyn78 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy311 := *x.FptrMapStringUint64 - if yy311 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint64V(yy311, e) - } // end block: if yy311 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringInt == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntV(x.FMapStringInt, e) - } // end block: if x.FMapStringInt map == nil - if yyn80 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy314 := *x.FptrMapStringInt - if yy314 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntV(yy314, e) - } // end block: if yy314 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringInt64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.FMapStringInt64, e) - } // end block: if x.FMapStringInt64 map == nil - if yyn82 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy317 := *x.FptrMapStringInt64 - if yy317 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(yy317, e) - } // end block: if yy317 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat32V(x.FMapStringFloat32, e) - } // end block: if x.FMapStringFloat32 map == nil - if yyn84 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy320 := *x.FptrMapStringFloat32 - if yy320 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat32V(yy320, e) - } // end block: if yy320 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat64V(x.FMapStringFloat64, e) - } // end block: if x.FMapStringFloat64 map == nil - if yyn86 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy323 := *x.FptrMapStringFloat64 - if yy323 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat64V(yy323, e) - } // end block: if yy323 map == nil - } - z.EncWriteArrayElem() - if x.FMapStringBool == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.FMapStringBool, e) - } // end block: if x.FMapStringBool map == nil - if yyn88 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy326 := *x.FptrMapStringBool - if yy326 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(yy326, e) - } // end block: if yy326 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintIntf == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntfV(x.FMapUintIntf, e) - } // end block: if x.FMapUintIntf map == nil - if yyn90 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy329 := *x.FptrMapUintIntf - if yy329 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntfV(yy329, e) - } // end block: if yy329 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintString == nil { - r.EncodeNil() - } else { - z.F.EncMapUintStringV(x.FMapUintString, e) - } // end block: if x.FMapUintString map == nil - if yyn92 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy332 := *x.FptrMapUintString - if yy332 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintStringV(yy332, e) - } // end block: if yy332 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintBytes == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBytesV(x.FMapUintBytes, e) - } // end block: if x.FMapUintBytes map == nil - if yyn94 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy335 := *x.FptrMapUintBytes - if yy335 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBytesV(yy335, e) - } // end block: if yy335 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintUint == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUintV(x.FMapUintUint, e) - } // end block: if x.FMapUintUint map == nil - if yyn96 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy338 := *x.FptrMapUintUint - if yy338 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUintV(yy338, e) - } // end block: if yy338 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintUint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint8V(x.FMapUintUint8, e) - } // end block: if x.FMapUintUint8 map == nil - if yyn98 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy341 := *x.FptrMapUintUint8 - if yy341 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint8V(yy341, e) - } // end block: if yy341 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintUint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint64V(x.FMapUintUint64, e) - } // end block: if x.FMapUintUint64 map == nil - if yyn100 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy344 := *x.FptrMapUintUint64 - if yy344 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint64V(yy344, e) - } // end block: if yy344 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintInt == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntV(x.FMapUintInt, e) - } // end block: if x.FMapUintInt map == nil - if yyn102 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy347 := *x.FptrMapUintInt - if yy347 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntV(yy347, e) - } // end block: if yy347 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintInt64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintInt64V(x.FMapUintInt64, e) - } // end block: if x.FMapUintInt64 map == nil - if yyn104 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy350 := *x.FptrMapUintInt64 - if yy350 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintInt64V(yy350, e) - } // end block: if yy350 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat32V(x.FMapUintFloat32, e) - } // end block: if x.FMapUintFloat32 map == nil - if yyn106 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy353 := *x.FptrMapUintFloat32 - if yy353 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat32V(yy353, e) - } // end block: if yy353 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat64V(x.FMapUintFloat64, e) - } // end block: if x.FMapUintFloat64 map == nil - if yyn108 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy356 := *x.FptrMapUintFloat64 - if yy356 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat64V(yy356, e) - } // end block: if yy356 map == nil - } - z.EncWriteArrayElem() - if x.FMapUintBool == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBoolV(x.FMapUintBool, e) - } // end block: if x.FMapUintBool map == nil - if yyn110 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy359 := *x.FptrMapUintBool - if yy359 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBoolV(yy359, e) - } // end block: if yy359 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Intf == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntfV(x.FMapUint8Intf, e) - } // end block: if x.FMapUint8Intf map == nil - if yyn112 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy362 := *x.FptrMapUint8Intf - if yy362 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntfV(yy362, e) - } // end block: if yy362 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8String == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8StringV(x.FMapUint8String, e) - } // end block: if x.FMapUint8String map == nil - if yyn114 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy365 := *x.FptrMapUint8String - if yy365 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8StringV(yy365, e) - } // end block: if yy365 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Bytes == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BytesV(x.FMapUint8Bytes, e) - } // end block: if x.FMapUint8Bytes map == nil - if yyn116 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy368 := *x.FptrMapUint8Bytes - if yy368 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BytesV(yy368, e) - } // end block: if yy368 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Uint == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8UintV(x.FMapUint8Uint, e) - } // end block: if x.FMapUint8Uint map == nil - if yyn118 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy371 := *x.FptrMapUint8Uint - if yy371 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8UintV(yy371, e) - } // end block: if yy371 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Uint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint8V(x.FMapUint8Uint8, e) - } // end block: if x.FMapUint8Uint8 map == nil - if yyn120 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy374 := *x.FptrMapUint8Uint8 - if yy374 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint8V(yy374, e) - } // end block: if yy374 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Uint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint64V(x.FMapUint8Uint64, e) - } // end block: if x.FMapUint8Uint64 map == nil - if yyn122 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy377 := *x.FptrMapUint8Uint64 - if yy377 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint64V(yy377, e) - } // end block: if yy377 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Int == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntV(x.FMapUint8Int, e) - } // end block: if x.FMapUint8Int map == nil - if yyn124 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy380 := *x.FptrMapUint8Int - if yy380 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntV(yy380, e) - } // end block: if yy380 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Int64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Int64V(x.FMapUint8Int64, e) - } // end block: if x.FMapUint8Int64 map == nil - if yyn126 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy383 := *x.FptrMapUint8Int64 - if yy383 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Int64V(yy383, e) - } // end block: if yy383 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Float32 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float32V(x.FMapUint8Float32, e) - } // end block: if x.FMapUint8Float32 map == nil - if yyn128 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy386 := *x.FptrMapUint8Float32 - if yy386 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float32V(yy386, e) - } // end block: if yy386 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Float64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float64V(x.FMapUint8Float64, e) - } // end block: if x.FMapUint8Float64 map == nil - if yyn130 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy389 := *x.FptrMapUint8Float64 - if yy389 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float64V(yy389, e) - } // end block: if yy389 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint8Bool == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BoolV(x.FMapUint8Bool, e) - } // end block: if x.FMapUint8Bool map == nil - if yyn132 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy392 := *x.FptrMapUint8Bool - if yy392 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BoolV(yy392, e) - } // end block: if yy392 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Intf == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntfV(x.FMapUint64Intf, e) - } // end block: if x.FMapUint64Intf map == nil - if yyn134 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy395 := *x.FptrMapUint64Intf - if yy395 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntfV(yy395, e) - } // end block: if yy395 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64String == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64StringV(x.FMapUint64String, e) - } // end block: if x.FMapUint64String map == nil - if yyn136 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy398 := *x.FptrMapUint64String - if yy398 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64StringV(yy398, e) - } // end block: if yy398 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Bytes == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BytesV(x.FMapUint64Bytes, e) - } // end block: if x.FMapUint64Bytes map == nil - if yyn138 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy401 := *x.FptrMapUint64Bytes - if yy401 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BytesV(yy401, e) - } // end block: if yy401 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Uint == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64UintV(x.FMapUint64Uint, e) - } // end block: if x.FMapUint64Uint map == nil - if yyn140 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy404 := *x.FptrMapUint64Uint - if yy404 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64UintV(yy404, e) - } // end block: if yy404 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Uint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint8V(x.FMapUint64Uint8, e) - } // end block: if x.FMapUint64Uint8 map == nil - if yyn142 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy407 := *x.FptrMapUint64Uint8 - if yy407 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint8V(yy407, e) - } // end block: if yy407 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Uint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint64V(x.FMapUint64Uint64, e) - } // end block: if x.FMapUint64Uint64 map == nil - if yyn144 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy410 := *x.FptrMapUint64Uint64 - if yy410 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint64V(yy410, e) - } // end block: if yy410 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Int == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntV(x.FMapUint64Int, e) - } // end block: if x.FMapUint64Int map == nil - if yyn146 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy413 := *x.FptrMapUint64Int - if yy413 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntV(yy413, e) - } // end block: if yy413 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Int64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Int64V(x.FMapUint64Int64, e) - } // end block: if x.FMapUint64Int64 map == nil - if yyn148 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy416 := *x.FptrMapUint64Int64 - if yy416 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Int64V(yy416, e) - } // end block: if yy416 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Float32 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float32V(x.FMapUint64Float32, e) - } // end block: if x.FMapUint64Float32 map == nil - if yyn150 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy419 := *x.FptrMapUint64Float32 - if yy419 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float32V(yy419, e) - } // end block: if yy419 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Float64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float64V(x.FMapUint64Float64, e) - } // end block: if x.FMapUint64Float64 map == nil - if yyn152 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy422 := *x.FptrMapUint64Float64 - if yy422 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float64V(yy422, e) - } // end block: if yy422 map == nil - } - z.EncWriteArrayElem() - if x.FMapUint64Bool == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BoolV(x.FMapUint64Bool, e) - } // end block: if x.FMapUint64Bool map == nil - if yyn154 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy425 := *x.FptrMapUint64Bool - if yy425 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BoolV(yy425, e) - } // end block: if yy425 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntIntf == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntfV(x.FMapIntIntf, e) - } // end block: if x.FMapIntIntf map == nil - if yyn156 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy428 := *x.FptrMapIntIntf - if yy428 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntfV(yy428, e) - } // end block: if yy428 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntString == nil { - r.EncodeNil() - } else { - z.F.EncMapIntStringV(x.FMapIntString, e) - } // end block: if x.FMapIntString map == nil - if yyn158 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy431 := *x.FptrMapIntString - if yy431 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntStringV(yy431, e) - } // end block: if yy431 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntBytes == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBytesV(x.FMapIntBytes, e) - } // end block: if x.FMapIntBytes map == nil - if yyn160 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy434 := *x.FptrMapIntBytes - if yy434 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBytesV(yy434, e) - } // end block: if yy434 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntUint == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUintV(x.FMapIntUint, e) - } // end block: if x.FMapIntUint map == nil - if yyn162 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy437 := *x.FptrMapIntUint - if yy437 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUintV(yy437, e) - } // end block: if yy437 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntUint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint8V(x.FMapIntUint8, e) - } // end block: if x.FMapIntUint8 map == nil - if yyn164 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy440 := *x.FptrMapIntUint8 - if yy440 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint8V(yy440, e) - } // end block: if yy440 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntUint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint64V(x.FMapIntUint64, e) - } // end block: if x.FMapIntUint64 map == nil - if yyn166 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy443 := *x.FptrMapIntUint64 - if yy443 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint64V(yy443, e) - } // end block: if yy443 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntInt == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntV(x.FMapIntInt, e) - } // end block: if x.FMapIntInt map == nil - if yyn168 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy446 := *x.FptrMapIntInt - if yy446 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntV(yy446, e) - } // end block: if yy446 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntInt64 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntInt64V(x.FMapIntInt64, e) - } // end block: if x.FMapIntInt64 map == nil - if yyn170 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy449 := *x.FptrMapIntInt64 - if yy449 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntInt64V(yy449, e) - } // end block: if yy449 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat32V(x.FMapIntFloat32, e) - } // end block: if x.FMapIntFloat32 map == nil - if yyn172 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy452 := *x.FptrMapIntFloat32 - if yy452 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat32V(yy452, e) - } // end block: if yy452 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat64V(x.FMapIntFloat64, e) - } // end block: if x.FMapIntFloat64 map == nil - if yyn174 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy455 := *x.FptrMapIntFloat64 - if yy455 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat64V(yy455, e) - } // end block: if yy455 map == nil - } - z.EncWriteArrayElem() - if x.FMapIntBool == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBoolV(x.FMapIntBool, e) - } // end block: if x.FMapIntBool map == nil - if yyn176 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy458 := *x.FptrMapIntBool - if yy458 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBoolV(yy458, e) - } // end block: if yy458 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Intf == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntfV(x.FMapInt64Intf, e) - } // end block: if x.FMapInt64Intf map == nil - if yyn178 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy461 := *x.FptrMapInt64Intf - if yy461 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntfV(yy461, e) - } // end block: if yy461 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64String == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64StringV(x.FMapInt64String, e) - } // end block: if x.FMapInt64String map == nil - if yyn180 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy464 := *x.FptrMapInt64String - if yy464 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64StringV(yy464, e) - } // end block: if yy464 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Bytes == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BytesV(x.FMapInt64Bytes, e) - } // end block: if x.FMapInt64Bytes map == nil - if yyn182 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy467 := *x.FptrMapInt64Bytes - if yy467 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BytesV(yy467, e) - } // end block: if yy467 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Uint == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64UintV(x.FMapInt64Uint, e) - } // end block: if x.FMapInt64Uint map == nil - if yyn184 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy470 := *x.FptrMapInt64Uint - if yy470 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64UintV(yy470, e) - } // end block: if yy470 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Uint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint8V(x.FMapInt64Uint8, e) - } // end block: if x.FMapInt64Uint8 map == nil - if yyn186 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy473 := *x.FptrMapInt64Uint8 - if yy473 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint8V(yy473, e) - } // end block: if yy473 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Uint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint64V(x.FMapInt64Uint64, e) - } // end block: if x.FMapInt64Uint64 map == nil - if yyn188 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy476 := *x.FptrMapInt64Uint64 - if yy476 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint64V(yy476, e) - } // end block: if yy476 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Int == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntV(x.FMapInt64Int, e) - } // end block: if x.FMapInt64Int map == nil - if yyn190 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy479 := *x.FptrMapInt64Int - if yy479 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntV(yy479, e) - } // end block: if yy479 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Int64 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Int64V(x.FMapInt64Int64, e) - } // end block: if x.FMapInt64Int64 map == nil - if yyn192 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy482 := *x.FptrMapInt64Int64 - if yy482 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Int64V(yy482, e) - } // end block: if yy482 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Float32 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float32V(x.FMapInt64Float32, e) - } // end block: if x.FMapInt64Float32 map == nil - if yyn194 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy485 := *x.FptrMapInt64Float32 - if yy485 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float32V(yy485, e) - } // end block: if yy485 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Float64 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float64V(x.FMapInt64Float64, e) - } // end block: if x.FMapInt64Float64 map == nil - if yyn196 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy488 := *x.FptrMapInt64Float64 - if yy488 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float64V(yy488, e) - } // end block: if yy488 map == nil - } - z.EncWriteArrayElem() - if x.FMapInt64Bool == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BoolV(x.FMapInt64Bool, e) - } // end block: if x.FMapInt64Bool map == nil - if yyn198 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy491 := *x.FptrMapInt64Bool - if yy491 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BoolV(yy491, e) - } // end block: if yy491 map == nil - } - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(196) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FIntf\"") - } else { - r.EncodeString(`FIntf`) - } - z.EncWriteMapElemValue() - z.EncFallback(x.FIntf) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrIntf\"") - } else { - r.EncodeString(`FptrIntf`) - } - z.EncWriteMapElemValue() - if yyn4 { - r.EncodeNil() - } else { - yy494 := *x.FptrIntf - z.EncFallback(yy494) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FString\"") - } else { - r.EncodeString(`FString`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.FString)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrString\"") - } else { - r.EncodeString(`FptrString`) - } - z.EncWriteMapElemValue() - if yyn6 { - r.EncodeNil() - } else { - yy497 := *x.FptrString - r.EncodeString(string(yy497)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FBytes\"") - } else { - r.EncodeString(`FBytes`) - } - z.EncWriteMapElemValue() - if x.FBytes == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.FBytes)) - } // end block: if x.FBytes slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrBytes\"") - } else { - r.EncodeString(`FptrBytes`) - } - z.EncWriteMapElemValue() - if yyn8 { - r.EncodeNil() - } else { - yy500 := *x.FptrBytes - if yy500 == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(yy500)) - } // end block: if yy500 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FFloat32\"") - } else { - r.EncodeString(`FFloat32`) - } - z.EncWriteMapElemValue() - r.EncodeFloat32(float32(x.FFloat32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrFloat32\"") - } else { - r.EncodeString(`FptrFloat32`) - } - z.EncWriteMapElemValue() - if yyn10 { - r.EncodeNil() - } else { - yy503 := *x.FptrFloat32 - r.EncodeFloat32(float32(yy503)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FFloat64\"") - } else { - r.EncodeString(`FFloat64`) - } - z.EncWriteMapElemValue() - r.EncodeFloat64(float64(x.FFloat64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrFloat64\"") - } else { - r.EncodeString(`FptrFloat64`) - } - z.EncWriteMapElemValue() - if yyn12 { - r.EncodeNil() - } else { - yy506 := *x.FptrFloat64 - r.EncodeFloat64(float64(yy506)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FUint\"") - } else { - r.EncodeString(`FUint`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.FUint)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrUint\"") - } else { - r.EncodeString(`FptrUint`) - } - z.EncWriteMapElemValue() - if yyn14 { - r.EncodeNil() - } else { - yy509 := *x.FptrUint - r.EncodeUint(uint64(yy509)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FUint8\"") - } else { - r.EncodeString(`FUint8`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.FUint8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrUint8\"") - } else { - r.EncodeString(`FptrUint8`) - } - z.EncWriteMapElemValue() - if yyn16 { - r.EncodeNil() - } else { - yy512 := *x.FptrUint8 - r.EncodeUint(uint64(yy512)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FUint16\"") - } else { - r.EncodeString(`FUint16`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.FUint16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrUint16\"") - } else { - r.EncodeString(`FptrUint16`) - } - z.EncWriteMapElemValue() - if yyn18 { - r.EncodeNil() - } else { - yy515 := *x.FptrUint16 - r.EncodeUint(uint64(yy515)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FUint32\"") - } else { - r.EncodeString(`FUint32`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.FUint32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrUint32\"") - } else { - r.EncodeString(`FptrUint32`) - } - z.EncWriteMapElemValue() - if yyn20 { - r.EncodeNil() - } else { - yy518 := *x.FptrUint32 - r.EncodeUint(uint64(yy518)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FUint64\"") - } else { - r.EncodeString(`FUint64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.FUint64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrUint64\"") - } else { - r.EncodeString(`FptrUint64`) - } - z.EncWriteMapElemValue() - if yyn22 { - r.EncodeNil() - } else { - yy521 := *x.FptrUint64 - r.EncodeUint(uint64(yy521)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FUintptr\"") - } else { - r.EncodeString(`FUintptr`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.FUintptr)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrUintptr\"") - } else { - r.EncodeString(`FptrUintptr`) - } - z.EncWriteMapElemValue() - if yyn24 { - r.EncodeNil() - } else { - yy524 := *x.FptrUintptr - r.EncodeUint(uint64(yy524)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FInt\"") - } else { - r.EncodeString(`FInt`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.FInt)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrInt\"") - } else { - r.EncodeString(`FptrInt`) - } - z.EncWriteMapElemValue() - if yyn26 { - r.EncodeNil() - } else { - yy527 := *x.FptrInt - r.EncodeInt(int64(yy527)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FInt8\"") - } else { - r.EncodeString(`FInt8`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.FInt8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrInt8\"") - } else { - r.EncodeString(`FptrInt8`) - } - z.EncWriteMapElemValue() - if yyn28 { - r.EncodeNil() - } else { - yy530 := *x.FptrInt8 - r.EncodeInt(int64(yy530)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FInt16\"") - } else { - r.EncodeString(`FInt16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.FInt16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrInt16\"") - } else { - r.EncodeString(`FptrInt16`) - } - z.EncWriteMapElemValue() - if yyn30 { - r.EncodeNil() - } else { - yy533 := *x.FptrInt16 - r.EncodeInt(int64(yy533)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FInt32\"") - } else { - r.EncodeString(`FInt32`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.FInt32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrInt32\"") - } else { - r.EncodeString(`FptrInt32`) - } - z.EncWriteMapElemValue() - if yyn32 { - r.EncodeNil() - } else { - yy536 := *x.FptrInt32 - r.EncodeInt(int64(yy536)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FInt64\"") - } else { - r.EncodeString(`FInt64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.FInt64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrInt64\"") - } else { - r.EncodeString(`FptrInt64`) - } - z.EncWriteMapElemValue() - if yyn34 { - r.EncodeNil() - } else { - yy539 := *x.FptrInt64 - r.EncodeInt(int64(yy539)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FBool\"") - } else { - r.EncodeString(`FBool`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.FBool)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrBool\"") - } else { - r.EncodeString(`FptrBool`) - } - z.EncWriteMapElemValue() - if yyn36 { - r.EncodeNil() - } else { - yy542 := *x.FptrBool - r.EncodeBool(bool(yy542)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceIntf\"") - } else { - r.EncodeString(`FSliceIntf`) - } - z.EncWriteMapElemValue() - if x.FSliceIntf == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.FSliceIntf, e) - } // end block: if x.FSliceIntf slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceIntf\"") - } else { - r.EncodeString(`FptrSliceIntf`) - } - z.EncWriteMapElemValue() - if yyn38 { - r.EncodeNil() - } else { - yy545 := *x.FptrSliceIntf - if yy545 == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(yy545, e) - } // end block: if yy545 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceString\"") - } else { - r.EncodeString(`FSliceString`) - } - z.EncWriteMapElemValue() - if x.FSliceString == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.FSliceString, e) - } // end block: if x.FSliceString slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceString\"") - } else { - r.EncodeString(`FptrSliceString`) - } - z.EncWriteMapElemValue() - if yyn40 { - r.EncodeNil() - } else { - yy548 := *x.FptrSliceString - if yy548 == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(yy548, e) - } // end block: if yy548 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceBytes\"") - } else { - r.EncodeString(`FSliceBytes`) - } - z.EncWriteMapElemValue() - if x.FSliceBytes == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.FSliceBytes, e) - } // end block: if x.FSliceBytes slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceBytes\"") - } else { - r.EncodeString(`FptrSliceBytes`) - } - z.EncWriteMapElemValue() - if yyn42 { - r.EncodeNil() - } else { - yy551 := *x.FptrSliceBytes - if yy551 == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(yy551, e) - } // end block: if yy551 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceFloat32\"") - } else { - r.EncodeString(`FSliceFloat32`) - } - z.EncWriteMapElemValue() - if x.FSliceFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.FSliceFloat32, e) - } // end block: if x.FSliceFloat32 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceFloat32\"") - } else { - r.EncodeString(`FptrSliceFloat32`) - } - z.EncWriteMapElemValue() - if yyn44 { - r.EncodeNil() - } else { - yy554 := *x.FptrSliceFloat32 - if yy554 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(yy554, e) - } // end block: if yy554 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceFloat64\"") - } else { - r.EncodeString(`FSliceFloat64`) - } - z.EncWriteMapElemValue() - if x.FSliceFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.FSliceFloat64, e) - } // end block: if x.FSliceFloat64 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceFloat64\"") - } else { - r.EncodeString(`FptrSliceFloat64`) - } - z.EncWriteMapElemValue() - if yyn46 { - r.EncodeNil() - } else { - yy557 := *x.FptrSliceFloat64 - if yy557 == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(yy557, e) - } // end block: if yy557 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceUint\"") - } else { - r.EncodeString(`FSliceUint`) - } - z.EncWriteMapElemValue() - if x.FSliceUint == nil { - r.EncodeNil() - } else { - z.F.EncSliceUintV(x.FSliceUint, e) - } // end block: if x.FSliceUint slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceUint\"") - } else { - r.EncodeString(`FptrSliceUint`) - } - z.EncWriteMapElemValue() - if yyn48 { - r.EncodeNil() - } else { - yy560 := *x.FptrSliceUint - if yy560 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUintV(yy560, e) - } // end block: if yy560 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceUint16\"") - } else { - r.EncodeString(`FSliceUint16`) - } - z.EncWriteMapElemValue() - if x.FSliceUint16 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint16V(x.FSliceUint16, e) - } // end block: if x.FSliceUint16 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceUint16\"") - } else { - r.EncodeString(`FptrSliceUint16`) - } - z.EncWriteMapElemValue() - if yyn50 { - r.EncodeNil() - } else { - yy563 := *x.FptrSliceUint16 - if yy563 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint16V(yy563, e) - } // end block: if yy563 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceUint32\"") - } else { - r.EncodeString(`FSliceUint32`) - } - z.EncWriteMapElemValue() - if x.FSliceUint32 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint32V(x.FSliceUint32, e) - } // end block: if x.FSliceUint32 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceUint32\"") - } else { - r.EncodeString(`FptrSliceUint32`) - } - z.EncWriteMapElemValue() - if yyn52 { - r.EncodeNil() - } else { - yy566 := *x.FptrSliceUint32 - if yy566 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint32V(yy566, e) - } // end block: if yy566 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceUint64\"") - } else { - r.EncodeString(`FSliceUint64`) - } - z.EncWriteMapElemValue() - if x.FSliceUint64 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.FSliceUint64, e) - } // end block: if x.FSliceUint64 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceUint64\"") - } else { - r.EncodeString(`FptrSliceUint64`) - } - z.EncWriteMapElemValue() - if yyn54 { - r.EncodeNil() - } else { - yy569 := *x.FptrSliceUint64 - if yy569 == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(yy569, e) - } // end block: if yy569 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceInt\"") - } else { - r.EncodeString(`FSliceInt`) - } - z.EncWriteMapElemValue() - if x.FSliceInt == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntV(x.FSliceInt, e) - } // end block: if x.FSliceInt slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceInt\"") - } else { - r.EncodeString(`FptrSliceInt`) - } - z.EncWriteMapElemValue() - if yyn56 { - r.EncodeNil() - } else { - yy572 := *x.FptrSliceInt - if yy572 == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntV(yy572, e) - } // end block: if yy572 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceInt8\"") - } else { - r.EncodeString(`FSliceInt8`) - } - z.EncWriteMapElemValue() - if x.FSliceInt8 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt8V(x.FSliceInt8, e) - } // end block: if x.FSliceInt8 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceInt8\"") - } else { - r.EncodeString(`FptrSliceInt8`) - } - z.EncWriteMapElemValue() - if yyn58 { - r.EncodeNil() - } else { - yy575 := *x.FptrSliceInt8 - if yy575 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt8V(yy575, e) - } // end block: if yy575 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceInt16\"") - } else { - r.EncodeString(`FSliceInt16`) - } - z.EncWriteMapElemValue() - if x.FSliceInt16 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.FSliceInt16, e) - } // end block: if x.FSliceInt16 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceInt16\"") - } else { - r.EncodeString(`FptrSliceInt16`) - } - z.EncWriteMapElemValue() - if yyn60 { - r.EncodeNil() - } else { - yy578 := *x.FptrSliceInt16 - if yy578 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(yy578, e) - } // end block: if yy578 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceInt32\"") - } else { - r.EncodeString(`FSliceInt32`) - } - z.EncWriteMapElemValue() - if x.FSliceInt32 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt32V(x.FSliceInt32, e) - } // end block: if x.FSliceInt32 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceInt32\"") - } else { - r.EncodeString(`FptrSliceInt32`) - } - z.EncWriteMapElemValue() - if yyn62 { - r.EncodeNil() - } else { - yy581 := *x.FptrSliceInt32 - if yy581 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt32V(yy581, e) - } // end block: if yy581 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceInt64\"") - } else { - r.EncodeString(`FSliceInt64`) - } - z.EncWriteMapElemValue() - if x.FSliceInt64 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.FSliceInt64, e) - } // end block: if x.FSliceInt64 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceInt64\"") - } else { - r.EncodeString(`FptrSliceInt64`) - } - z.EncWriteMapElemValue() - if yyn64 { - r.EncodeNil() - } else { - yy584 := *x.FptrSliceInt64 - if yy584 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(yy584, e) - } // end block: if yy584 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FSliceBool\"") - } else { - r.EncodeString(`FSliceBool`) - } - z.EncWriteMapElemValue() - if x.FSliceBool == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.FSliceBool, e) - } // end block: if x.FSliceBool slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrSliceBool\"") - } else { - r.EncodeString(`FptrSliceBool`) - } - z.EncWriteMapElemValue() - if yyn66 { - r.EncodeNil() - } else { - yy587 := *x.FptrSliceBool - if yy587 == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(yy587, e) - } // end block: if yy587 slice == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringIntf\"") - } else { - r.EncodeString(`FMapStringIntf`) - } - z.EncWriteMapElemValue() - if x.FMapStringIntf == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(x.FMapStringIntf, e) - } // end block: if x.FMapStringIntf map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringIntf\"") - } else { - r.EncodeString(`FptrMapStringIntf`) - } - z.EncWriteMapElemValue() - if yyn68 { - r.EncodeNil() - } else { - yy590 := *x.FptrMapStringIntf - if yy590 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(yy590, e) - } // end block: if yy590 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringString\"") - } else { - r.EncodeString(`FMapStringString`) - } - z.EncWriteMapElemValue() - if x.FMapStringString == nil { - r.EncodeNil() - } else { - z.F.EncMapStringStringV(x.FMapStringString, e) - } // end block: if x.FMapStringString map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringString\"") - } else { - r.EncodeString(`FptrMapStringString`) - } - z.EncWriteMapElemValue() - if yyn70 { - r.EncodeNil() - } else { - yy593 := *x.FptrMapStringString - if yy593 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringStringV(yy593, e) - } // end block: if yy593 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringBytes\"") - } else { - r.EncodeString(`FMapStringBytes`) - } - z.EncWriteMapElemValue() - if x.FMapStringBytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.FMapStringBytes, e) - } // end block: if x.FMapStringBytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringBytes\"") - } else { - r.EncodeString(`FptrMapStringBytes`) - } - z.EncWriteMapElemValue() - if yyn72 { - r.EncodeNil() - } else { - yy596 := *x.FptrMapStringBytes - if yy596 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(yy596, e) - } // end block: if yy596 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringUint\"") - } else { - r.EncodeString(`FMapStringUint`) - } - z.EncWriteMapElemValue() - if x.FMapStringUint == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUintV(x.FMapStringUint, e) - } // end block: if x.FMapStringUint map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringUint\"") - } else { - r.EncodeString(`FptrMapStringUint`) - } - z.EncWriteMapElemValue() - if yyn74 { - r.EncodeNil() - } else { - yy599 := *x.FptrMapStringUint - if yy599 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUintV(yy599, e) - } // end block: if yy599 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringUint8\"") - } else { - r.EncodeString(`FMapStringUint8`) - } - z.EncWriteMapElemValue() - if x.FMapStringUint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint8V(x.FMapStringUint8, e) - } // end block: if x.FMapStringUint8 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringUint8\"") - } else { - r.EncodeString(`FptrMapStringUint8`) - } - z.EncWriteMapElemValue() - if yyn76 { - r.EncodeNil() - } else { - yy602 := *x.FptrMapStringUint8 - if yy602 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint8V(yy602, e) - } // end block: if yy602 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringUint64\"") - } else { - r.EncodeString(`FMapStringUint64`) - } - z.EncWriteMapElemValue() - if x.FMapStringUint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint64V(x.FMapStringUint64, e) - } // end block: if x.FMapStringUint64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringUint64\"") - } else { - r.EncodeString(`FptrMapStringUint64`) - } - z.EncWriteMapElemValue() - if yyn78 { - r.EncodeNil() - } else { - yy605 := *x.FptrMapStringUint64 - if yy605 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringUint64V(yy605, e) - } // end block: if yy605 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringInt\"") - } else { - r.EncodeString(`FMapStringInt`) - } - z.EncWriteMapElemValue() - if x.FMapStringInt == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntV(x.FMapStringInt, e) - } // end block: if x.FMapStringInt map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringInt\"") - } else { - r.EncodeString(`FptrMapStringInt`) - } - z.EncWriteMapElemValue() - if yyn80 { - r.EncodeNil() - } else { - yy608 := *x.FptrMapStringInt - if yy608 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntV(yy608, e) - } // end block: if yy608 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringInt64\"") - } else { - r.EncodeString(`FMapStringInt64`) - } - z.EncWriteMapElemValue() - if x.FMapStringInt64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.FMapStringInt64, e) - } // end block: if x.FMapStringInt64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringInt64\"") - } else { - r.EncodeString(`FptrMapStringInt64`) - } - z.EncWriteMapElemValue() - if yyn82 { - r.EncodeNil() - } else { - yy611 := *x.FptrMapStringInt64 - if yy611 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(yy611, e) - } // end block: if yy611 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringFloat32\"") - } else { - r.EncodeString(`FMapStringFloat32`) - } - z.EncWriteMapElemValue() - if x.FMapStringFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat32V(x.FMapStringFloat32, e) - } // end block: if x.FMapStringFloat32 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringFloat32\"") - } else { - r.EncodeString(`FptrMapStringFloat32`) - } - z.EncWriteMapElemValue() - if yyn84 { - r.EncodeNil() - } else { - yy614 := *x.FptrMapStringFloat32 - if yy614 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat32V(yy614, e) - } // end block: if yy614 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringFloat64\"") - } else { - r.EncodeString(`FMapStringFloat64`) - } - z.EncWriteMapElemValue() - if x.FMapStringFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat64V(x.FMapStringFloat64, e) - } // end block: if x.FMapStringFloat64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringFloat64\"") - } else { - r.EncodeString(`FptrMapStringFloat64`) - } - z.EncWriteMapElemValue() - if yyn86 { - r.EncodeNil() - } else { - yy617 := *x.FptrMapStringFloat64 - if yy617 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringFloat64V(yy617, e) - } // end block: if yy617 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapStringBool\"") - } else { - r.EncodeString(`FMapStringBool`) - } - z.EncWriteMapElemValue() - if x.FMapStringBool == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.FMapStringBool, e) - } // end block: if x.FMapStringBool map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapStringBool\"") - } else { - r.EncodeString(`FptrMapStringBool`) - } - z.EncWriteMapElemValue() - if yyn88 { - r.EncodeNil() - } else { - yy620 := *x.FptrMapStringBool - if yy620 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(yy620, e) - } // end block: if yy620 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintIntf\"") - } else { - r.EncodeString(`FMapUintIntf`) - } - z.EncWriteMapElemValue() - if x.FMapUintIntf == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntfV(x.FMapUintIntf, e) - } // end block: if x.FMapUintIntf map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintIntf\"") - } else { - r.EncodeString(`FptrMapUintIntf`) - } - z.EncWriteMapElemValue() - if yyn90 { - r.EncodeNil() - } else { - yy623 := *x.FptrMapUintIntf - if yy623 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntfV(yy623, e) - } // end block: if yy623 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintString\"") - } else { - r.EncodeString(`FMapUintString`) - } - z.EncWriteMapElemValue() - if x.FMapUintString == nil { - r.EncodeNil() - } else { - z.F.EncMapUintStringV(x.FMapUintString, e) - } // end block: if x.FMapUintString map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintString\"") - } else { - r.EncodeString(`FptrMapUintString`) - } - z.EncWriteMapElemValue() - if yyn92 { - r.EncodeNil() - } else { - yy626 := *x.FptrMapUintString - if yy626 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintStringV(yy626, e) - } // end block: if yy626 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintBytes\"") - } else { - r.EncodeString(`FMapUintBytes`) - } - z.EncWriteMapElemValue() - if x.FMapUintBytes == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBytesV(x.FMapUintBytes, e) - } // end block: if x.FMapUintBytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintBytes\"") - } else { - r.EncodeString(`FptrMapUintBytes`) - } - z.EncWriteMapElemValue() - if yyn94 { - r.EncodeNil() - } else { - yy629 := *x.FptrMapUintBytes - if yy629 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBytesV(yy629, e) - } // end block: if yy629 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintUint\"") - } else { - r.EncodeString(`FMapUintUint`) - } - z.EncWriteMapElemValue() - if x.FMapUintUint == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUintV(x.FMapUintUint, e) - } // end block: if x.FMapUintUint map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintUint\"") - } else { - r.EncodeString(`FptrMapUintUint`) - } - z.EncWriteMapElemValue() - if yyn96 { - r.EncodeNil() - } else { - yy632 := *x.FptrMapUintUint - if yy632 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUintV(yy632, e) - } // end block: if yy632 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintUint8\"") - } else { - r.EncodeString(`FMapUintUint8`) - } - z.EncWriteMapElemValue() - if x.FMapUintUint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint8V(x.FMapUintUint8, e) - } // end block: if x.FMapUintUint8 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintUint8\"") - } else { - r.EncodeString(`FptrMapUintUint8`) - } - z.EncWriteMapElemValue() - if yyn98 { - r.EncodeNil() - } else { - yy635 := *x.FptrMapUintUint8 - if yy635 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint8V(yy635, e) - } // end block: if yy635 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintUint64\"") - } else { - r.EncodeString(`FMapUintUint64`) - } - z.EncWriteMapElemValue() - if x.FMapUintUint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint64V(x.FMapUintUint64, e) - } // end block: if x.FMapUintUint64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintUint64\"") - } else { - r.EncodeString(`FptrMapUintUint64`) - } - z.EncWriteMapElemValue() - if yyn100 { - r.EncodeNil() - } else { - yy638 := *x.FptrMapUintUint64 - if yy638 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintUint64V(yy638, e) - } // end block: if yy638 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintInt\"") - } else { - r.EncodeString(`FMapUintInt`) - } - z.EncWriteMapElemValue() - if x.FMapUintInt == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntV(x.FMapUintInt, e) - } // end block: if x.FMapUintInt map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintInt\"") - } else { - r.EncodeString(`FptrMapUintInt`) - } - z.EncWriteMapElemValue() - if yyn102 { - r.EncodeNil() - } else { - yy641 := *x.FptrMapUintInt - if yy641 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintIntV(yy641, e) - } // end block: if yy641 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintInt64\"") - } else { - r.EncodeString(`FMapUintInt64`) - } - z.EncWriteMapElemValue() - if x.FMapUintInt64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintInt64V(x.FMapUintInt64, e) - } // end block: if x.FMapUintInt64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintInt64\"") - } else { - r.EncodeString(`FptrMapUintInt64`) - } - z.EncWriteMapElemValue() - if yyn104 { - r.EncodeNil() - } else { - yy644 := *x.FptrMapUintInt64 - if yy644 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintInt64V(yy644, e) - } // end block: if yy644 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintFloat32\"") - } else { - r.EncodeString(`FMapUintFloat32`) - } - z.EncWriteMapElemValue() - if x.FMapUintFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat32V(x.FMapUintFloat32, e) - } // end block: if x.FMapUintFloat32 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintFloat32\"") - } else { - r.EncodeString(`FptrMapUintFloat32`) - } - z.EncWriteMapElemValue() - if yyn106 { - r.EncodeNil() - } else { - yy647 := *x.FptrMapUintFloat32 - if yy647 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat32V(yy647, e) - } // end block: if yy647 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintFloat64\"") - } else { - r.EncodeString(`FMapUintFloat64`) - } - z.EncWriteMapElemValue() - if x.FMapUintFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat64V(x.FMapUintFloat64, e) - } // end block: if x.FMapUintFloat64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintFloat64\"") - } else { - r.EncodeString(`FptrMapUintFloat64`) - } - z.EncWriteMapElemValue() - if yyn108 { - r.EncodeNil() - } else { - yy650 := *x.FptrMapUintFloat64 - if yy650 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintFloat64V(yy650, e) - } // end block: if yy650 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUintBool\"") - } else { - r.EncodeString(`FMapUintBool`) - } - z.EncWriteMapElemValue() - if x.FMapUintBool == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBoolV(x.FMapUintBool, e) - } // end block: if x.FMapUintBool map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUintBool\"") - } else { - r.EncodeString(`FptrMapUintBool`) - } - z.EncWriteMapElemValue() - if yyn110 { - r.EncodeNil() - } else { - yy653 := *x.FptrMapUintBool - if yy653 == nil { - r.EncodeNil() - } else { - z.F.EncMapUintBoolV(yy653, e) - } // end block: if yy653 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Intf\"") - } else { - r.EncodeString(`FMapUint8Intf`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Intf == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntfV(x.FMapUint8Intf, e) - } // end block: if x.FMapUint8Intf map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Intf\"") - } else { - r.EncodeString(`FptrMapUint8Intf`) - } - z.EncWriteMapElemValue() - if yyn112 { - r.EncodeNil() - } else { - yy656 := *x.FptrMapUint8Intf - if yy656 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntfV(yy656, e) - } // end block: if yy656 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8String\"") - } else { - r.EncodeString(`FMapUint8String`) - } - z.EncWriteMapElemValue() - if x.FMapUint8String == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8StringV(x.FMapUint8String, e) - } // end block: if x.FMapUint8String map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8String\"") - } else { - r.EncodeString(`FptrMapUint8String`) - } - z.EncWriteMapElemValue() - if yyn114 { - r.EncodeNil() - } else { - yy659 := *x.FptrMapUint8String - if yy659 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8StringV(yy659, e) - } // end block: if yy659 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Bytes\"") - } else { - r.EncodeString(`FMapUint8Bytes`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Bytes == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BytesV(x.FMapUint8Bytes, e) - } // end block: if x.FMapUint8Bytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Bytes\"") - } else { - r.EncodeString(`FptrMapUint8Bytes`) - } - z.EncWriteMapElemValue() - if yyn116 { - r.EncodeNil() - } else { - yy662 := *x.FptrMapUint8Bytes - if yy662 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BytesV(yy662, e) - } // end block: if yy662 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Uint\"") - } else { - r.EncodeString(`FMapUint8Uint`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Uint == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8UintV(x.FMapUint8Uint, e) - } // end block: if x.FMapUint8Uint map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Uint\"") - } else { - r.EncodeString(`FptrMapUint8Uint`) - } - z.EncWriteMapElemValue() - if yyn118 { - r.EncodeNil() - } else { - yy665 := *x.FptrMapUint8Uint - if yy665 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8UintV(yy665, e) - } // end block: if yy665 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Uint8\"") - } else { - r.EncodeString(`FMapUint8Uint8`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Uint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint8V(x.FMapUint8Uint8, e) - } // end block: if x.FMapUint8Uint8 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Uint8\"") - } else { - r.EncodeString(`FptrMapUint8Uint8`) - } - z.EncWriteMapElemValue() - if yyn120 { - r.EncodeNil() - } else { - yy668 := *x.FptrMapUint8Uint8 - if yy668 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint8V(yy668, e) - } // end block: if yy668 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Uint64\"") - } else { - r.EncodeString(`FMapUint8Uint64`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Uint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint64V(x.FMapUint8Uint64, e) - } // end block: if x.FMapUint8Uint64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Uint64\"") - } else { - r.EncodeString(`FptrMapUint8Uint64`) - } - z.EncWriteMapElemValue() - if yyn122 { - r.EncodeNil() - } else { - yy671 := *x.FptrMapUint8Uint64 - if yy671 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Uint64V(yy671, e) - } // end block: if yy671 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Int\"") - } else { - r.EncodeString(`FMapUint8Int`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Int == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntV(x.FMapUint8Int, e) - } // end block: if x.FMapUint8Int map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Int\"") - } else { - r.EncodeString(`FptrMapUint8Int`) - } - z.EncWriteMapElemValue() - if yyn124 { - r.EncodeNil() - } else { - yy674 := *x.FptrMapUint8Int - if yy674 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8IntV(yy674, e) - } // end block: if yy674 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Int64\"") - } else { - r.EncodeString(`FMapUint8Int64`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Int64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Int64V(x.FMapUint8Int64, e) - } // end block: if x.FMapUint8Int64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Int64\"") - } else { - r.EncodeString(`FptrMapUint8Int64`) - } - z.EncWriteMapElemValue() - if yyn126 { - r.EncodeNil() - } else { - yy677 := *x.FptrMapUint8Int64 - if yy677 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Int64V(yy677, e) - } // end block: if yy677 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Float32\"") - } else { - r.EncodeString(`FMapUint8Float32`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Float32 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float32V(x.FMapUint8Float32, e) - } // end block: if x.FMapUint8Float32 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Float32\"") - } else { - r.EncodeString(`FptrMapUint8Float32`) - } - z.EncWriteMapElemValue() - if yyn128 { - r.EncodeNil() - } else { - yy680 := *x.FptrMapUint8Float32 - if yy680 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float32V(yy680, e) - } // end block: if yy680 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Float64\"") - } else { - r.EncodeString(`FMapUint8Float64`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Float64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float64V(x.FMapUint8Float64, e) - } // end block: if x.FMapUint8Float64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Float64\"") - } else { - r.EncodeString(`FptrMapUint8Float64`) - } - z.EncWriteMapElemValue() - if yyn130 { - r.EncodeNil() - } else { - yy683 := *x.FptrMapUint8Float64 - if yy683 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8Float64V(yy683, e) - } // end block: if yy683 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint8Bool\"") - } else { - r.EncodeString(`FMapUint8Bool`) - } - z.EncWriteMapElemValue() - if x.FMapUint8Bool == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BoolV(x.FMapUint8Bool, e) - } // end block: if x.FMapUint8Bool map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint8Bool\"") - } else { - r.EncodeString(`FptrMapUint8Bool`) - } - z.EncWriteMapElemValue() - if yyn132 { - r.EncodeNil() - } else { - yy686 := *x.FptrMapUint8Bool - if yy686 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint8BoolV(yy686, e) - } // end block: if yy686 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Intf\"") - } else { - r.EncodeString(`FMapUint64Intf`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Intf == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntfV(x.FMapUint64Intf, e) - } // end block: if x.FMapUint64Intf map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Intf\"") - } else { - r.EncodeString(`FptrMapUint64Intf`) - } - z.EncWriteMapElemValue() - if yyn134 { - r.EncodeNil() - } else { - yy689 := *x.FptrMapUint64Intf - if yy689 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntfV(yy689, e) - } // end block: if yy689 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64String\"") - } else { - r.EncodeString(`FMapUint64String`) - } - z.EncWriteMapElemValue() - if x.FMapUint64String == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64StringV(x.FMapUint64String, e) - } // end block: if x.FMapUint64String map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64String\"") - } else { - r.EncodeString(`FptrMapUint64String`) - } - z.EncWriteMapElemValue() - if yyn136 { - r.EncodeNil() - } else { - yy692 := *x.FptrMapUint64String - if yy692 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64StringV(yy692, e) - } // end block: if yy692 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Bytes\"") - } else { - r.EncodeString(`FMapUint64Bytes`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Bytes == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BytesV(x.FMapUint64Bytes, e) - } // end block: if x.FMapUint64Bytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Bytes\"") - } else { - r.EncodeString(`FptrMapUint64Bytes`) - } - z.EncWriteMapElemValue() - if yyn138 { - r.EncodeNil() - } else { - yy695 := *x.FptrMapUint64Bytes - if yy695 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BytesV(yy695, e) - } // end block: if yy695 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Uint\"") - } else { - r.EncodeString(`FMapUint64Uint`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Uint == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64UintV(x.FMapUint64Uint, e) - } // end block: if x.FMapUint64Uint map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Uint\"") - } else { - r.EncodeString(`FptrMapUint64Uint`) - } - z.EncWriteMapElemValue() - if yyn140 { - r.EncodeNil() - } else { - yy698 := *x.FptrMapUint64Uint - if yy698 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64UintV(yy698, e) - } // end block: if yy698 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Uint8\"") - } else { - r.EncodeString(`FMapUint64Uint8`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Uint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint8V(x.FMapUint64Uint8, e) - } // end block: if x.FMapUint64Uint8 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Uint8\"") - } else { - r.EncodeString(`FptrMapUint64Uint8`) - } - z.EncWriteMapElemValue() - if yyn142 { - r.EncodeNil() - } else { - yy701 := *x.FptrMapUint64Uint8 - if yy701 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint8V(yy701, e) - } // end block: if yy701 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Uint64\"") - } else { - r.EncodeString(`FMapUint64Uint64`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Uint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint64V(x.FMapUint64Uint64, e) - } // end block: if x.FMapUint64Uint64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Uint64\"") - } else { - r.EncodeString(`FptrMapUint64Uint64`) - } - z.EncWriteMapElemValue() - if yyn144 { - r.EncodeNil() - } else { - yy704 := *x.FptrMapUint64Uint64 - if yy704 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Uint64V(yy704, e) - } // end block: if yy704 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Int\"") - } else { - r.EncodeString(`FMapUint64Int`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Int == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntV(x.FMapUint64Int, e) - } // end block: if x.FMapUint64Int map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Int\"") - } else { - r.EncodeString(`FptrMapUint64Int`) - } - z.EncWriteMapElemValue() - if yyn146 { - r.EncodeNil() - } else { - yy707 := *x.FptrMapUint64Int - if yy707 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64IntV(yy707, e) - } // end block: if yy707 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Int64\"") - } else { - r.EncodeString(`FMapUint64Int64`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Int64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Int64V(x.FMapUint64Int64, e) - } // end block: if x.FMapUint64Int64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Int64\"") - } else { - r.EncodeString(`FptrMapUint64Int64`) - } - z.EncWriteMapElemValue() - if yyn148 { - r.EncodeNil() - } else { - yy710 := *x.FptrMapUint64Int64 - if yy710 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Int64V(yy710, e) - } // end block: if yy710 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Float32\"") - } else { - r.EncodeString(`FMapUint64Float32`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Float32 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float32V(x.FMapUint64Float32, e) - } // end block: if x.FMapUint64Float32 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Float32\"") - } else { - r.EncodeString(`FptrMapUint64Float32`) - } - z.EncWriteMapElemValue() - if yyn150 { - r.EncodeNil() - } else { - yy713 := *x.FptrMapUint64Float32 - if yy713 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float32V(yy713, e) - } // end block: if yy713 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Float64\"") - } else { - r.EncodeString(`FMapUint64Float64`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Float64 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float64V(x.FMapUint64Float64, e) - } // end block: if x.FMapUint64Float64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Float64\"") - } else { - r.EncodeString(`FptrMapUint64Float64`) - } - z.EncWriteMapElemValue() - if yyn152 { - r.EncodeNil() - } else { - yy716 := *x.FptrMapUint64Float64 - if yy716 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64Float64V(yy716, e) - } // end block: if yy716 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapUint64Bool\"") - } else { - r.EncodeString(`FMapUint64Bool`) - } - z.EncWriteMapElemValue() - if x.FMapUint64Bool == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BoolV(x.FMapUint64Bool, e) - } // end block: if x.FMapUint64Bool map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapUint64Bool\"") - } else { - r.EncodeString(`FptrMapUint64Bool`) - } - z.EncWriteMapElemValue() - if yyn154 { - r.EncodeNil() - } else { - yy719 := *x.FptrMapUint64Bool - if yy719 == nil { - r.EncodeNil() - } else { - z.F.EncMapUint64BoolV(yy719, e) - } // end block: if yy719 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntIntf\"") - } else { - r.EncodeString(`FMapIntIntf`) - } - z.EncWriteMapElemValue() - if x.FMapIntIntf == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntfV(x.FMapIntIntf, e) - } // end block: if x.FMapIntIntf map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntIntf\"") - } else { - r.EncodeString(`FptrMapIntIntf`) - } - z.EncWriteMapElemValue() - if yyn156 { - r.EncodeNil() - } else { - yy722 := *x.FptrMapIntIntf - if yy722 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntfV(yy722, e) - } // end block: if yy722 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntString\"") - } else { - r.EncodeString(`FMapIntString`) - } - z.EncWriteMapElemValue() - if x.FMapIntString == nil { - r.EncodeNil() - } else { - z.F.EncMapIntStringV(x.FMapIntString, e) - } // end block: if x.FMapIntString map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntString\"") - } else { - r.EncodeString(`FptrMapIntString`) - } - z.EncWriteMapElemValue() - if yyn158 { - r.EncodeNil() - } else { - yy725 := *x.FptrMapIntString - if yy725 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntStringV(yy725, e) - } // end block: if yy725 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntBytes\"") - } else { - r.EncodeString(`FMapIntBytes`) - } - z.EncWriteMapElemValue() - if x.FMapIntBytes == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBytesV(x.FMapIntBytes, e) - } // end block: if x.FMapIntBytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntBytes\"") - } else { - r.EncodeString(`FptrMapIntBytes`) - } - z.EncWriteMapElemValue() - if yyn160 { - r.EncodeNil() - } else { - yy728 := *x.FptrMapIntBytes - if yy728 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBytesV(yy728, e) - } // end block: if yy728 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntUint\"") - } else { - r.EncodeString(`FMapIntUint`) - } - z.EncWriteMapElemValue() - if x.FMapIntUint == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUintV(x.FMapIntUint, e) - } // end block: if x.FMapIntUint map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntUint\"") - } else { - r.EncodeString(`FptrMapIntUint`) - } - z.EncWriteMapElemValue() - if yyn162 { - r.EncodeNil() - } else { - yy731 := *x.FptrMapIntUint - if yy731 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUintV(yy731, e) - } // end block: if yy731 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntUint8\"") - } else { - r.EncodeString(`FMapIntUint8`) - } - z.EncWriteMapElemValue() - if x.FMapIntUint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint8V(x.FMapIntUint8, e) - } // end block: if x.FMapIntUint8 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntUint8\"") - } else { - r.EncodeString(`FptrMapIntUint8`) - } - z.EncWriteMapElemValue() - if yyn164 { - r.EncodeNil() - } else { - yy734 := *x.FptrMapIntUint8 - if yy734 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint8V(yy734, e) - } // end block: if yy734 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntUint64\"") - } else { - r.EncodeString(`FMapIntUint64`) - } - z.EncWriteMapElemValue() - if x.FMapIntUint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint64V(x.FMapIntUint64, e) - } // end block: if x.FMapIntUint64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntUint64\"") - } else { - r.EncodeString(`FptrMapIntUint64`) - } - z.EncWriteMapElemValue() - if yyn166 { - r.EncodeNil() - } else { - yy737 := *x.FptrMapIntUint64 - if yy737 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntUint64V(yy737, e) - } // end block: if yy737 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntInt\"") - } else { - r.EncodeString(`FMapIntInt`) - } - z.EncWriteMapElemValue() - if x.FMapIntInt == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntV(x.FMapIntInt, e) - } // end block: if x.FMapIntInt map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntInt\"") - } else { - r.EncodeString(`FptrMapIntInt`) - } - z.EncWriteMapElemValue() - if yyn168 { - r.EncodeNil() - } else { - yy740 := *x.FptrMapIntInt - if yy740 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntIntV(yy740, e) - } // end block: if yy740 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntInt64\"") - } else { - r.EncodeString(`FMapIntInt64`) - } - z.EncWriteMapElemValue() - if x.FMapIntInt64 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntInt64V(x.FMapIntInt64, e) - } // end block: if x.FMapIntInt64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntInt64\"") - } else { - r.EncodeString(`FptrMapIntInt64`) - } - z.EncWriteMapElemValue() - if yyn170 { - r.EncodeNil() - } else { - yy743 := *x.FptrMapIntInt64 - if yy743 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntInt64V(yy743, e) - } // end block: if yy743 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntFloat32\"") - } else { - r.EncodeString(`FMapIntFloat32`) - } - z.EncWriteMapElemValue() - if x.FMapIntFloat32 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat32V(x.FMapIntFloat32, e) - } // end block: if x.FMapIntFloat32 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntFloat32\"") - } else { - r.EncodeString(`FptrMapIntFloat32`) - } - z.EncWriteMapElemValue() - if yyn172 { - r.EncodeNil() - } else { - yy746 := *x.FptrMapIntFloat32 - if yy746 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat32V(yy746, e) - } // end block: if yy746 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntFloat64\"") - } else { - r.EncodeString(`FMapIntFloat64`) - } - z.EncWriteMapElemValue() - if x.FMapIntFloat64 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat64V(x.FMapIntFloat64, e) - } // end block: if x.FMapIntFloat64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntFloat64\"") - } else { - r.EncodeString(`FptrMapIntFloat64`) - } - z.EncWriteMapElemValue() - if yyn174 { - r.EncodeNil() - } else { - yy749 := *x.FptrMapIntFloat64 - if yy749 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntFloat64V(yy749, e) - } // end block: if yy749 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapIntBool\"") - } else { - r.EncodeString(`FMapIntBool`) - } - z.EncWriteMapElemValue() - if x.FMapIntBool == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBoolV(x.FMapIntBool, e) - } // end block: if x.FMapIntBool map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapIntBool\"") - } else { - r.EncodeString(`FptrMapIntBool`) - } - z.EncWriteMapElemValue() - if yyn176 { - r.EncodeNil() - } else { - yy752 := *x.FptrMapIntBool - if yy752 == nil { - r.EncodeNil() - } else { - z.F.EncMapIntBoolV(yy752, e) - } // end block: if yy752 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Intf\"") - } else { - r.EncodeString(`FMapInt64Intf`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Intf == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntfV(x.FMapInt64Intf, e) - } // end block: if x.FMapInt64Intf map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Intf\"") - } else { - r.EncodeString(`FptrMapInt64Intf`) - } - z.EncWriteMapElemValue() - if yyn178 { - r.EncodeNil() - } else { - yy755 := *x.FptrMapInt64Intf - if yy755 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntfV(yy755, e) - } // end block: if yy755 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64String\"") - } else { - r.EncodeString(`FMapInt64String`) - } - z.EncWriteMapElemValue() - if x.FMapInt64String == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64StringV(x.FMapInt64String, e) - } // end block: if x.FMapInt64String map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64String\"") - } else { - r.EncodeString(`FptrMapInt64String`) - } - z.EncWriteMapElemValue() - if yyn180 { - r.EncodeNil() - } else { - yy758 := *x.FptrMapInt64String - if yy758 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64StringV(yy758, e) - } // end block: if yy758 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Bytes\"") - } else { - r.EncodeString(`FMapInt64Bytes`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Bytes == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BytesV(x.FMapInt64Bytes, e) - } // end block: if x.FMapInt64Bytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Bytes\"") - } else { - r.EncodeString(`FptrMapInt64Bytes`) - } - z.EncWriteMapElemValue() - if yyn182 { - r.EncodeNil() - } else { - yy761 := *x.FptrMapInt64Bytes - if yy761 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BytesV(yy761, e) - } // end block: if yy761 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Uint\"") - } else { - r.EncodeString(`FMapInt64Uint`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Uint == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64UintV(x.FMapInt64Uint, e) - } // end block: if x.FMapInt64Uint map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Uint\"") - } else { - r.EncodeString(`FptrMapInt64Uint`) - } - z.EncWriteMapElemValue() - if yyn184 { - r.EncodeNil() - } else { - yy764 := *x.FptrMapInt64Uint - if yy764 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64UintV(yy764, e) - } // end block: if yy764 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Uint8\"") - } else { - r.EncodeString(`FMapInt64Uint8`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Uint8 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint8V(x.FMapInt64Uint8, e) - } // end block: if x.FMapInt64Uint8 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Uint8\"") - } else { - r.EncodeString(`FptrMapInt64Uint8`) - } - z.EncWriteMapElemValue() - if yyn186 { - r.EncodeNil() - } else { - yy767 := *x.FptrMapInt64Uint8 - if yy767 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint8V(yy767, e) - } // end block: if yy767 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Uint64\"") - } else { - r.EncodeString(`FMapInt64Uint64`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Uint64 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint64V(x.FMapInt64Uint64, e) - } // end block: if x.FMapInt64Uint64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Uint64\"") - } else { - r.EncodeString(`FptrMapInt64Uint64`) - } - z.EncWriteMapElemValue() - if yyn188 { - r.EncodeNil() - } else { - yy770 := *x.FptrMapInt64Uint64 - if yy770 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Uint64V(yy770, e) - } // end block: if yy770 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Int\"") - } else { - r.EncodeString(`FMapInt64Int`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Int == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntV(x.FMapInt64Int, e) - } // end block: if x.FMapInt64Int map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Int\"") - } else { - r.EncodeString(`FptrMapInt64Int`) - } - z.EncWriteMapElemValue() - if yyn190 { - r.EncodeNil() - } else { - yy773 := *x.FptrMapInt64Int - if yy773 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64IntV(yy773, e) - } // end block: if yy773 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Int64\"") - } else { - r.EncodeString(`FMapInt64Int64`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Int64 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Int64V(x.FMapInt64Int64, e) - } // end block: if x.FMapInt64Int64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Int64\"") - } else { - r.EncodeString(`FptrMapInt64Int64`) - } - z.EncWriteMapElemValue() - if yyn192 { - r.EncodeNil() - } else { - yy776 := *x.FptrMapInt64Int64 - if yy776 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Int64V(yy776, e) - } // end block: if yy776 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Float32\"") - } else { - r.EncodeString(`FMapInt64Float32`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Float32 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float32V(x.FMapInt64Float32, e) - } // end block: if x.FMapInt64Float32 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Float32\"") - } else { - r.EncodeString(`FptrMapInt64Float32`) - } - z.EncWriteMapElemValue() - if yyn194 { - r.EncodeNil() - } else { - yy779 := *x.FptrMapInt64Float32 - if yy779 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float32V(yy779, e) - } // end block: if yy779 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Float64\"") - } else { - r.EncodeString(`FMapInt64Float64`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Float64 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float64V(x.FMapInt64Float64, e) - } // end block: if x.FMapInt64Float64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Float64\"") - } else { - r.EncodeString(`FptrMapInt64Float64`) - } - z.EncWriteMapElemValue() - if yyn196 { - r.EncodeNil() - } else { - yy782 := *x.FptrMapInt64Float64 - if yy782 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64Float64V(yy782, e) - } // end block: if yy782 map == nil - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FMapInt64Bool\"") - } else { - r.EncodeString(`FMapInt64Bool`) - } - z.EncWriteMapElemValue() - if x.FMapInt64Bool == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BoolV(x.FMapInt64Bool, e) - } // end block: if x.FMapInt64Bool map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FptrMapInt64Bool\"") - } else { - r.EncodeString(`FptrMapInt64Bool`) - } - z.EncWriteMapElemValue() - if yyn198 { - r.EncodeNil() - } else { - yy785 := *x.FptrMapInt64Bool - if yy785 == nil { - r.EncodeNil() - } else { - z.F.EncMapInt64BoolV(yy785, e) - } // end block: if yy785 map == nil - } - z.EncWriteMapEnd() - } - } -} - -func (x *TestMammoth2) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19781 { - *(x) = TestMammoth2{} - } else if yyct2 == codecSelferValueTypeMap19781 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19781 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19781) - } -} - -func (x *TestMammoth2) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "FIntf": - z.DecFallback(&x.FIntf, true) - case "FptrIntf": - if r.TryNil() { - if x.FptrIntf != nil { // remove the if-true - x.FptrIntf = nil - } - } else { - if x.FptrIntf == nil { - x.FptrIntf = new(interface{}) - } - z.DecFallback(x.FptrIntf, true) - } - case "FString": - x.FString = (string)(string(r.DecodeStringAsBytes())) - case "FptrString": - if r.TryNil() { - if x.FptrString != nil { // remove the if-true - x.FptrString = nil - } - } else { - if x.FptrString == nil { - x.FptrString = new(string) - } - *x.FptrString = (string)(string(r.DecodeStringAsBytes())) - } - case "FBytes": - x.FBytes = r.DecodeBytes(([]byte)(x.FBytes), false) - case "FptrBytes": - if r.TryNil() { - if x.FptrBytes != nil { // remove the if-true - x.FptrBytes = nil - } - } else { - if x.FptrBytes == nil { - x.FptrBytes = new([]uint8) - } - *x.FptrBytes = r.DecodeBytes(*(*[]byte)(x.FptrBytes), false) - } - case "FFloat32": - x.FFloat32 = (float32)(z.DecDecodeFloat32()) - case "FptrFloat32": - if r.TryNil() { - if x.FptrFloat32 != nil { // remove the if-true - x.FptrFloat32 = nil - } - } else { - if x.FptrFloat32 == nil { - x.FptrFloat32 = new(float32) - } - *x.FptrFloat32 = (float32)(z.DecDecodeFloat32()) - } - case "FFloat64": - x.FFloat64 = (float64)(r.DecodeFloat64()) - case "FptrFloat64": - if r.TryNil() { - if x.FptrFloat64 != nil { // remove the if-true - x.FptrFloat64 = nil - } - } else { - if x.FptrFloat64 == nil { - x.FptrFloat64 = new(float64) - } - *x.FptrFloat64 = (float64)(r.DecodeFloat64()) - } - case "FUint": - x.FUint = (uint)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - case "FptrUint": - if r.TryNil() { - if x.FptrUint != nil { // remove the if-true - x.FptrUint = nil - } - } else { - if x.FptrUint == nil { - x.FptrUint = new(uint) - } - *x.FptrUint = (uint)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - } - case "FUint8": - x.FUint8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "FptrUint8": - if r.TryNil() { - if x.FptrUint8 != nil { // remove the if-true - x.FptrUint8 = nil - } - } else { - if x.FptrUint8 == nil { - x.FptrUint8 = new(uint8) - } - *x.FptrUint8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - } - case "FUint16": - x.FUint16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - case "FptrUint16": - if r.TryNil() { - if x.FptrUint16 != nil { // remove the if-true - x.FptrUint16 = nil - } - } else { - if x.FptrUint16 == nil { - x.FptrUint16 = new(uint16) - } - *x.FptrUint16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - } - case "FUint32": - x.FUint32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - case "FptrUint32": - if r.TryNil() { - if x.FptrUint32 != nil { // remove the if-true - x.FptrUint32 = nil - } - } else { - if x.FptrUint32 == nil { - x.FptrUint32 = new(uint32) - } - *x.FptrUint32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - } - case "FUint64": - x.FUint64 = (uint64)(r.DecodeUint64()) - case "FptrUint64": - if r.TryNil() { - if x.FptrUint64 != nil { // remove the if-true - x.FptrUint64 = nil - } - } else { - if x.FptrUint64 == nil { - x.FptrUint64 = new(uint64) - } - *x.FptrUint64 = (uint64)(r.DecodeUint64()) - } - case "FUintptr": - x.FUintptr = (uintptr)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - case "FptrUintptr": - if r.TryNil() { - if x.FptrUintptr != nil { // remove the if-true - x.FptrUintptr = nil - } - } else { - if x.FptrUintptr == nil { - x.FptrUintptr = new(uintptr) - } - *x.FptrUintptr = (uintptr)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - } - case "FInt": - x.FInt = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19781)) - case "FptrInt": - if r.TryNil() { - if x.FptrInt != nil { // remove the if-true - x.FptrInt = nil - } - } else { - if x.FptrInt == nil { - x.FptrInt = new(int) - } - *x.FptrInt = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19781)) - } - case "FInt8": - x.FInt8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "FptrInt8": - if r.TryNil() { - if x.FptrInt8 != nil { // remove the if-true - x.FptrInt8 = nil - } - } else { - if x.FptrInt8 == nil { - x.FptrInt8 = new(int8) - } - *x.FptrInt8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - } - case "FInt16": - x.FInt16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "FptrInt16": - if r.TryNil() { - if x.FptrInt16 != nil { // remove the if-true - x.FptrInt16 = nil - } - } else { - if x.FptrInt16 == nil { - x.FptrInt16 = new(int16) - } - *x.FptrInt16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - } - case "FInt32": - x.FInt32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "FptrInt32": - if r.TryNil() { - if x.FptrInt32 != nil { // remove the if-true - x.FptrInt32 = nil - } - } else { - if x.FptrInt32 == nil { - x.FptrInt32 = new(int32) - } - *x.FptrInt32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - } - case "FInt64": - x.FInt64 = (int64)(r.DecodeInt64()) - case "FptrInt64": - if r.TryNil() { - if x.FptrInt64 != nil { // remove the if-true - x.FptrInt64 = nil - } - } else { - if x.FptrInt64 == nil { - x.FptrInt64 = new(int64) - } - *x.FptrInt64 = (int64)(r.DecodeInt64()) - } - case "FBool": - x.FBool = (bool)(r.DecodeBool()) - case "FptrBool": - if r.TryNil() { - if x.FptrBool != nil { // remove the if-true - x.FptrBool = nil - } - } else { - if x.FptrBool == nil { - x.FptrBool = new(bool) - } - *x.FptrBool = (bool)(r.DecodeBool()) - } - case "FSliceIntf": - z.F.DecSliceIntfX(&x.FSliceIntf, d) - case "FptrSliceIntf": - if r.TryNil() { - if x.FptrSliceIntf != nil { // remove the if-true - x.FptrSliceIntf = nil - } - } else { - if x.FptrSliceIntf == nil { - x.FptrSliceIntf = new([]interface{}) - } - z.F.DecSliceIntfX(x.FptrSliceIntf, d) - } - case "FSliceString": - z.F.DecSliceStringX(&x.FSliceString, d) - case "FptrSliceString": - if r.TryNil() { - if x.FptrSliceString != nil { // remove the if-true - x.FptrSliceString = nil - } - } else { - if x.FptrSliceString == nil { - x.FptrSliceString = new([]string) - } - z.F.DecSliceStringX(x.FptrSliceString, d) - } - case "FSliceBytes": - z.F.DecSliceBytesX(&x.FSliceBytes, d) - case "FptrSliceBytes": - if r.TryNil() { - if x.FptrSliceBytes != nil { // remove the if-true - x.FptrSliceBytes = nil - } - } else { - if x.FptrSliceBytes == nil { - x.FptrSliceBytes = new([][]uint8) - } - z.F.DecSliceBytesX(x.FptrSliceBytes, d) - } - case "FSliceFloat32": - z.F.DecSliceFloat32X(&x.FSliceFloat32, d) - case "FptrSliceFloat32": - if r.TryNil() { - if x.FptrSliceFloat32 != nil { // remove the if-true - x.FptrSliceFloat32 = nil - } - } else { - if x.FptrSliceFloat32 == nil { - x.FptrSliceFloat32 = new([]float32) - } - z.F.DecSliceFloat32X(x.FptrSliceFloat32, d) - } - case "FSliceFloat64": - z.F.DecSliceFloat64X(&x.FSliceFloat64, d) - case "FptrSliceFloat64": - if r.TryNil() { - if x.FptrSliceFloat64 != nil { // remove the if-true - x.FptrSliceFloat64 = nil - } - } else { - if x.FptrSliceFloat64 == nil { - x.FptrSliceFloat64 = new([]float64) - } - z.F.DecSliceFloat64X(x.FptrSliceFloat64, d) - } - case "FSliceUint": - z.F.DecSliceUintX(&x.FSliceUint, d) - case "FptrSliceUint": - if r.TryNil() { - if x.FptrSliceUint != nil { // remove the if-true - x.FptrSliceUint = nil - } - } else { - if x.FptrSliceUint == nil { - x.FptrSliceUint = new([]uint) - } - z.F.DecSliceUintX(x.FptrSliceUint, d) - } - case "FSliceUint16": - z.F.DecSliceUint16X(&x.FSliceUint16, d) - case "FptrSliceUint16": - if r.TryNil() { - if x.FptrSliceUint16 != nil { // remove the if-true - x.FptrSliceUint16 = nil - } - } else { - if x.FptrSliceUint16 == nil { - x.FptrSliceUint16 = new([]uint16) - } - z.F.DecSliceUint16X(x.FptrSliceUint16, d) - } - case "FSliceUint32": - z.F.DecSliceUint32X(&x.FSliceUint32, d) - case "FptrSliceUint32": - if r.TryNil() { - if x.FptrSliceUint32 != nil { // remove the if-true - x.FptrSliceUint32 = nil - } - } else { - if x.FptrSliceUint32 == nil { - x.FptrSliceUint32 = new([]uint32) - } - z.F.DecSliceUint32X(x.FptrSliceUint32, d) - } - case "FSliceUint64": - z.F.DecSliceUint64X(&x.FSliceUint64, d) - case "FptrSliceUint64": - if r.TryNil() { - if x.FptrSliceUint64 != nil { // remove the if-true - x.FptrSliceUint64 = nil - } - } else { - if x.FptrSliceUint64 == nil { - x.FptrSliceUint64 = new([]uint64) - } - z.F.DecSliceUint64X(x.FptrSliceUint64, d) - } - case "FSliceInt": - z.F.DecSliceIntX(&x.FSliceInt, d) - case "FptrSliceInt": - if r.TryNil() { - if x.FptrSliceInt != nil { // remove the if-true - x.FptrSliceInt = nil - } - } else { - if x.FptrSliceInt == nil { - x.FptrSliceInt = new([]int) - } - z.F.DecSliceIntX(x.FptrSliceInt, d) - } - case "FSliceInt8": - z.F.DecSliceInt8X(&x.FSliceInt8, d) - case "FptrSliceInt8": - if r.TryNil() { - if x.FptrSliceInt8 != nil { // remove the if-true - x.FptrSliceInt8 = nil - } - } else { - if x.FptrSliceInt8 == nil { - x.FptrSliceInt8 = new([]int8) - } - z.F.DecSliceInt8X(x.FptrSliceInt8, d) - } - case "FSliceInt16": - z.F.DecSliceInt16X(&x.FSliceInt16, d) - case "FptrSliceInt16": - if r.TryNil() { - if x.FptrSliceInt16 != nil { // remove the if-true - x.FptrSliceInt16 = nil - } - } else { - if x.FptrSliceInt16 == nil { - x.FptrSliceInt16 = new([]int16) - } - z.F.DecSliceInt16X(x.FptrSliceInt16, d) - } - case "FSliceInt32": - z.F.DecSliceInt32X(&x.FSliceInt32, d) - case "FptrSliceInt32": - if r.TryNil() { - if x.FptrSliceInt32 != nil { // remove the if-true - x.FptrSliceInt32 = nil - } - } else { - if x.FptrSliceInt32 == nil { - x.FptrSliceInt32 = new([]int32) - } - z.F.DecSliceInt32X(x.FptrSliceInt32, d) - } - case "FSliceInt64": - z.F.DecSliceInt64X(&x.FSliceInt64, d) - case "FptrSliceInt64": - if r.TryNil() { - if x.FptrSliceInt64 != nil { // remove the if-true - x.FptrSliceInt64 = nil - } - } else { - if x.FptrSliceInt64 == nil { - x.FptrSliceInt64 = new([]int64) - } - z.F.DecSliceInt64X(x.FptrSliceInt64, d) - } - case "FSliceBool": - z.F.DecSliceBoolX(&x.FSliceBool, d) - case "FptrSliceBool": - if r.TryNil() { - if x.FptrSliceBool != nil { // remove the if-true - x.FptrSliceBool = nil - } - } else { - if x.FptrSliceBool == nil { - x.FptrSliceBool = new([]bool) - } - z.F.DecSliceBoolX(x.FptrSliceBool, d) - } - case "FMapStringIntf": - z.F.DecMapStringIntfX(&x.FMapStringIntf, d) - case "FptrMapStringIntf": - if r.TryNil() { - if x.FptrMapStringIntf != nil { // remove the if-true - x.FptrMapStringIntf = nil - } - } else { - if x.FptrMapStringIntf == nil { - x.FptrMapStringIntf = new(map[string]interface{}) - } - z.F.DecMapStringIntfX(x.FptrMapStringIntf, d) - } - case "FMapStringString": - z.F.DecMapStringStringX(&x.FMapStringString, d) - case "FptrMapStringString": - if r.TryNil() { - if x.FptrMapStringString != nil { // remove the if-true - x.FptrMapStringString = nil - } - } else { - if x.FptrMapStringString == nil { - x.FptrMapStringString = new(map[string]string) - } - z.F.DecMapStringStringX(x.FptrMapStringString, d) - } - case "FMapStringBytes": - z.F.DecMapStringBytesX(&x.FMapStringBytes, d) - case "FptrMapStringBytes": - if r.TryNil() { - if x.FptrMapStringBytes != nil { // remove the if-true - x.FptrMapStringBytes = nil - } - } else { - if x.FptrMapStringBytes == nil { - x.FptrMapStringBytes = new(map[string][]uint8) - } - z.F.DecMapStringBytesX(x.FptrMapStringBytes, d) - } - case "FMapStringUint": - z.F.DecMapStringUintX(&x.FMapStringUint, d) - case "FptrMapStringUint": - if r.TryNil() { - if x.FptrMapStringUint != nil { // remove the if-true - x.FptrMapStringUint = nil - } - } else { - if x.FptrMapStringUint == nil { - x.FptrMapStringUint = new(map[string]uint) - } - z.F.DecMapStringUintX(x.FptrMapStringUint, d) - } - case "FMapStringUint8": - z.F.DecMapStringUint8X(&x.FMapStringUint8, d) - case "FptrMapStringUint8": - if r.TryNil() { - if x.FptrMapStringUint8 != nil { // remove the if-true - x.FptrMapStringUint8 = nil - } - } else { - if x.FptrMapStringUint8 == nil { - x.FptrMapStringUint8 = new(map[string]uint8) - } - z.F.DecMapStringUint8X(x.FptrMapStringUint8, d) - } - case "FMapStringUint64": - z.F.DecMapStringUint64X(&x.FMapStringUint64, d) - case "FptrMapStringUint64": - if r.TryNil() { - if x.FptrMapStringUint64 != nil { // remove the if-true - x.FptrMapStringUint64 = nil - } - } else { - if x.FptrMapStringUint64 == nil { - x.FptrMapStringUint64 = new(map[string]uint64) - } - z.F.DecMapStringUint64X(x.FptrMapStringUint64, d) - } - case "FMapStringInt": - z.F.DecMapStringIntX(&x.FMapStringInt, d) - case "FptrMapStringInt": - if r.TryNil() { - if x.FptrMapStringInt != nil { // remove the if-true - x.FptrMapStringInt = nil - } - } else { - if x.FptrMapStringInt == nil { - x.FptrMapStringInt = new(map[string]int) - } - z.F.DecMapStringIntX(x.FptrMapStringInt, d) - } - case "FMapStringInt64": - z.F.DecMapStringInt64X(&x.FMapStringInt64, d) - case "FptrMapStringInt64": - if r.TryNil() { - if x.FptrMapStringInt64 != nil { // remove the if-true - x.FptrMapStringInt64 = nil - } - } else { - if x.FptrMapStringInt64 == nil { - x.FptrMapStringInt64 = new(map[string]int64) - } - z.F.DecMapStringInt64X(x.FptrMapStringInt64, d) - } - case "FMapStringFloat32": - z.F.DecMapStringFloat32X(&x.FMapStringFloat32, d) - case "FptrMapStringFloat32": - if r.TryNil() { - if x.FptrMapStringFloat32 != nil { // remove the if-true - x.FptrMapStringFloat32 = nil - } - } else { - if x.FptrMapStringFloat32 == nil { - x.FptrMapStringFloat32 = new(map[string]float32) - } - z.F.DecMapStringFloat32X(x.FptrMapStringFloat32, d) - } - case "FMapStringFloat64": - z.F.DecMapStringFloat64X(&x.FMapStringFloat64, d) - case "FptrMapStringFloat64": - if r.TryNil() { - if x.FptrMapStringFloat64 != nil { // remove the if-true - x.FptrMapStringFloat64 = nil - } - } else { - if x.FptrMapStringFloat64 == nil { - x.FptrMapStringFloat64 = new(map[string]float64) - } - z.F.DecMapStringFloat64X(x.FptrMapStringFloat64, d) - } - case "FMapStringBool": - z.F.DecMapStringBoolX(&x.FMapStringBool, d) - case "FptrMapStringBool": - if r.TryNil() { - if x.FptrMapStringBool != nil { // remove the if-true - x.FptrMapStringBool = nil - } - } else { - if x.FptrMapStringBool == nil { - x.FptrMapStringBool = new(map[string]bool) - } - z.F.DecMapStringBoolX(x.FptrMapStringBool, d) - } - case "FMapUintIntf": - z.F.DecMapUintIntfX(&x.FMapUintIntf, d) - case "FptrMapUintIntf": - if r.TryNil() { - if x.FptrMapUintIntf != nil { // remove the if-true - x.FptrMapUintIntf = nil - } - } else { - if x.FptrMapUintIntf == nil { - x.FptrMapUintIntf = new(map[uint]interface{}) - } - z.F.DecMapUintIntfX(x.FptrMapUintIntf, d) - } - case "FMapUintString": - z.F.DecMapUintStringX(&x.FMapUintString, d) - case "FptrMapUintString": - if r.TryNil() { - if x.FptrMapUintString != nil { // remove the if-true - x.FptrMapUintString = nil - } - } else { - if x.FptrMapUintString == nil { - x.FptrMapUintString = new(map[uint]string) - } - z.F.DecMapUintStringX(x.FptrMapUintString, d) - } - case "FMapUintBytes": - z.F.DecMapUintBytesX(&x.FMapUintBytes, d) - case "FptrMapUintBytes": - if r.TryNil() { - if x.FptrMapUintBytes != nil { // remove the if-true - x.FptrMapUintBytes = nil - } - } else { - if x.FptrMapUintBytes == nil { - x.FptrMapUintBytes = new(map[uint][]uint8) - } - z.F.DecMapUintBytesX(x.FptrMapUintBytes, d) - } - case "FMapUintUint": - z.F.DecMapUintUintX(&x.FMapUintUint, d) - case "FptrMapUintUint": - if r.TryNil() { - if x.FptrMapUintUint != nil { // remove the if-true - x.FptrMapUintUint = nil - } - } else { - if x.FptrMapUintUint == nil { - x.FptrMapUintUint = new(map[uint]uint) - } - z.F.DecMapUintUintX(x.FptrMapUintUint, d) - } - case "FMapUintUint8": - z.F.DecMapUintUint8X(&x.FMapUintUint8, d) - case "FptrMapUintUint8": - if r.TryNil() { - if x.FptrMapUintUint8 != nil { // remove the if-true - x.FptrMapUintUint8 = nil - } - } else { - if x.FptrMapUintUint8 == nil { - x.FptrMapUintUint8 = new(map[uint]uint8) - } - z.F.DecMapUintUint8X(x.FptrMapUintUint8, d) - } - case "FMapUintUint64": - z.F.DecMapUintUint64X(&x.FMapUintUint64, d) - case "FptrMapUintUint64": - if r.TryNil() { - if x.FptrMapUintUint64 != nil { // remove the if-true - x.FptrMapUintUint64 = nil - } - } else { - if x.FptrMapUintUint64 == nil { - x.FptrMapUintUint64 = new(map[uint]uint64) - } - z.F.DecMapUintUint64X(x.FptrMapUintUint64, d) - } - case "FMapUintInt": - z.F.DecMapUintIntX(&x.FMapUintInt, d) - case "FptrMapUintInt": - if r.TryNil() { - if x.FptrMapUintInt != nil { // remove the if-true - x.FptrMapUintInt = nil - } - } else { - if x.FptrMapUintInt == nil { - x.FptrMapUintInt = new(map[uint]int) - } - z.F.DecMapUintIntX(x.FptrMapUintInt, d) - } - case "FMapUintInt64": - z.F.DecMapUintInt64X(&x.FMapUintInt64, d) - case "FptrMapUintInt64": - if r.TryNil() { - if x.FptrMapUintInt64 != nil { // remove the if-true - x.FptrMapUintInt64 = nil - } - } else { - if x.FptrMapUintInt64 == nil { - x.FptrMapUintInt64 = new(map[uint]int64) - } - z.F.DecMapUintInt64X(x.FptrMapUintInt64, d) - } - case "FMapUintFloat32": - z.F.DecMapUintFloat32X(&x.FMapUintFloat32, d) - case "FptrMapUintFloat32": - if r.TryNil() { - if x.FptrMapUintFloat32 != nil { // remove the if-true - x.FptrMapUintFloat32 = nil - } - } else { - if x.FptrMapUintFloat32 == nil { - x.FptrMapUintFloat32 = new(map[uint]float32) - } - z.F.DecMapUintFloat32X(x.FptrMapUintFloat32, d) - } - case "FMapUintFloat64": - z.F.DecMapUintFloat64X(&x.FMapUintFloat64, d) - case "FptrMapUintFloat64": - if r.TryNil() { - if x.FptrMapUintFloat64 != nil { // remove the if-true - x.FptrMapUintFloat64 = nil - } - } else { - if x.FptrMapUintFloat64 == nil { - x.FptrMapUintFloat64 = new(map[uint]float64) - } - z.F.DecMapUintFloat64X(x.FptrMapUintFloat64, d) - } - case "FMapUintBool": - z.F.DecMapUintBoolX(&x.FMapUintBool, d) - case "FptrMapUintBool": - if r.TryNil() { - if x.FptrMapUintBool != nil { // remove the if-true - x.FptrMapUintBool = nil - } - } else { - if x.FptrMapUintBool == nil { - x.FptrMapUintBool = new(map[uint]bool) - } - z.F.DecMapUintBoolX(x.FptrMapUintBool, d) - } - case "FMapUint8Intf": - z.F.DecMapUint8IntfX(&x.FMapUint8Intf, d) - case "FptrMapUint8Intf": - if r.TryNil() { - if x.FptrMapUint8Intf != nil { // remove the if-true - x.FptrMapUint8Intf = nil - } - } else { - if x.FptrMapUint8Intf == nil { - x.FptrMapUint8Intf = new(map[uint8]interface{}) - } - z.F.DecMapUint8IntfX(x.FptrMapUint8Intf, d) - } - case "FMapUint8String": - z.F.DecMapUint8StringX(&x.FMapUint8String, d) - case "FptrMapUint8String": - if r.TryNil() { - if x.FptrMapUint8String != nil { // remove the if-true - x.FptrMapUint8String = nil - } - } else { - if x.FptrMapUint8String == nil { - x.FptrMapUint8String = new(map[uint8]string) - } - z.F.DecMapUint8StringX(x.FptrMapUint8String, d) - } - case "FMapUint8Bytes": - z.F.DecMapUint8BytesX(&x.FMapUint8Bytes, d) - case "FptrMapUint8Bytes": - if r.TryNil() { - if x.FptrMapUint8Bytes != nil { // remove the if-true - x.FptrMapUint8Bytes = nil - } - } else { - if x.FptrMapUint8Bytes == nil { - x.FptrMapUint8Bytes = new(map[uint8][]uint8) - } - z.F.DecMapUint8BytesX(x.FptrMapUint8Bytes, d) - } - case "FMapUint8Uint": - z.F.DecMapUint8UintX(&x.FMapUint8Uint, d) - case "FptrMapUint8Uint": - if r.TryNil() { - if x.FptrMapUint8Uint != nil { // remove the if-true - x.FptrMapUint8Uint = nil - } - } else { - if x.FptrMapUint8Uint == nil { - x.FptrMapUint8Uint = new(map[uint8]uint) - } - z.F.DecMapUint8UintX(x.FptrMapUint8Uint, d) - } - case "FMapUint8Uint8": - z.F.DecMapUint8Uint8X(&x.FMapUint8Uint8, d) - case "FptrMapUint8Uint8": - if r.TryNil() { - if x.FptrMapUint8Uint8 != nil { // remove the if-true - x.FptrMapUint8Uint8 = nil - } - } else { - if x.FptrMapUint8Uint8 == nil { - x.FptrMapUint8Uint8 = new(map[uint8]uint8) - } - z.F.DecMapUint8Uint8X(x.FptrMapUint8Uint8, d) - } - case "FMapUint8Uint64": - z.F.DecMapUint8Uint64X(&x.FMapUint8Uint64, d) - case "FptrMapUint8Uint64": - if r.TryNil() { - if x.FptrMapUint8Uint64 != nil { // remove the if-true - x.FptrMapUint8Uint64 = nil - } - } else { - if x.FptrMapUint8Uint64 == nil { - x.FptrMapUint8Uint64 = new(map[uint8]uint64) - } - z.F.DecMapUint8Uint64X(x.FptrMapUint8Uint64, d) - } - case "FMapUint8Int": - z.F.DecMapUint8IntX(&x.FMapUint8Int, d) - case "FptrMapUint8Int": - if r.TryNil() { - if x.FptrMapUint8Int != nil { // remove the if-true - x.FptrMapUint8Int = nil - } - } else { - if x.FptrMapUint8Int == nil { - x.FptrMapUint8Int = new(map[uint8]int) - } - z.F.DecMapUint8IntX(x.FptrMapUint8Int, d) - } - case "FMapUint8Int64": - z.F.DecMapUint8Int64X(&x.FMapUint8Int64, d) - case "FptrMapUint8Int64": - if r.TryNil() { - if x.FptrMapUint8Int64 != nil { // remove the if-true - x.FptrMapUint8Int64 = nil - } - } else { - if x.FptrMapUint8Int64 == nil { - x.FptrMapUint8Int64 = new(map[uint8]int64) - } - z.F.DecMapUint8Int64X(x.FptrMapUint8Int64, d) - } - case "FMapUint8Float32": - z.F.DecMapUint8Float32X(&x.FMapUint8Float32, d) - case "FptrMapUint8Float32": - if r.TryNil() { - if x.FptrMapUint8Float32 != nil { // remove the if-true - x.FptrMapUint8Float32 = nil - } - } else { - if x.FptrMapUint8Float32 == nil { - x.FptrMapUint8Float32 = new(map[uint8]float32) - } - z.F.DecMapUint8Float32X(x.FptrMapUint8Float32, d) - } - case "FMapUint8Float64": - z.F.DecMapUint8Float64X(&x.FMapUint8Float64, d) - case "FptrMapUint8Float64": - if r.TryNil() { - if x.FptrMapUint8Float64 != nil { // remove the if-true - x.FptrMapUint8Float64 = nil - } - } else { - if x.FptrMapUint8Float64 == nil { - x.FptrMapUint8Float64 = new(map[uint8]float64) - } - z.F.DecMapUint8Float64X(x.FptrMapUint8Float64, d) - } - case "FMapUint8Bool": - z.F.DecMapUint8BoolX(&x.FMapUint8Bool, d) - case "FptrMapUint8Bool": - if r.TryNil() { - if x.FptrMapUint8Bool != nil { // remove the if-true - x.FptrMapUint8Bool = nil - } - } else { - if x.FptrMapUint8Bool == nil { - x.FptrMapUint8Bool = new(map[uint8]bool) - } - z.F.DecMapUint8BoolX(x.FptrMapUint8Bool, d) - } - case "FMapUint64Intf": - z.F.DecMapUint64IntfX(&x.FMapUint64Intf, d) - case "FptrMapUint64Intf": - if r.TryNil() { - if x.FptrMapUint64Intf != nil { // remove the if-true - x.FptrMapUint64Intf = nil - } - } else { - if x.FptrMapUint64Intf == nil { - x.FptrMapUint64Intf = new(map[uint64]interface{}) - } - z.F.DecMapUint64IntfX(x.FptrMapUint64Intf, d) - } - case "FMapUint64String": - z.F.DecMapUint64StringX(&x.FMapUint64String, d) - case "FptrMapUint64String": - if r.TryNil() { - if x.FptrMapUint64String != nil { // remove the if-true - x.FptrMapUint64String = nil - } - } else { - if x.FptrMapUint64String == nil { - x.FptrMapUint64String = new(map[uint64]string) - } - z.F.DecMapUint64StringX(x.FptrMapUint64String, d) - } - case "FMapUint64Bytes": - z.F.DecMapUint64BytesX(&x.FMapUint64Bytes, d) - case "FptrMapUint64Bytes": - if r.TryNil() { - if x.FptrMapUint64Bytes != nil { // remove the if-true - x.FptrMapUint64Bytes = nil - } - } else { - if x.FptrMapUint64Bytes == nil { - x.FptrMapUint64Bytes = new(map[uint64][]uint8) - } - z.F.DecMapUint64BytesX(x.FptrMapUint64Bytes, d) - } - case "FMapUint64Uint": - z.F.DecMapUint64UintX(&x.FMapUint64Uint, d) - case "FptrMapUint64Uint": - if r.TryNil() { - if x.FptrMapUint64Uint != nil { // remove the if-true - x.FptrMapUint64Uint = nil - } - } else { - if x.FptrMapUint64Uint == nil { - x.FptrMapUint64Uint = new(map[uint64]uint) - } - z.F.DecMapUint64UintX(x.FptrMapUint64Uint, d) - } - case "FMapUint64Uint8": - z.F.DecMapUint64Uint8X(&x.FMapUint64Uint8, d) - case "FptrMapUint64Uint8": - if r.TryNil() { - if x.FptrMapUint64Uint8 != nil { // remove the if-true - x.FptrMapUint64Uint8 = nil - } - } else { - if x.FptrMapUint64Uint8 == nil { - x.FptrMapUint64Uint8 = new(map[uint64]uint8) - } - z.F.DecMapUint64Uint8X(x.FptrMapUint64Uint8, d) - } - case "FMapUint64Uint64": - z.F.DecMapUint64Uint64X(&x.FMapUint64Uint64, d) - case "FptrMapUint64Uint64": - if r.TryNil() { - if x.FptrMapUint64Uint64 != nil { // remove the if-true - x.FptrMapUint64Uint64 = nil - } - } else { - if x.FptrMapUint64Uint64 == nil { - x.FptrMapUint64Uint64 = new(map[uint64]uint64) - } - z.F.DecMapUint64Uint64X(x.FptrMapUint64Uint64, d) - } - case "FMapUint64Int": - z.F.DecMapUint64IntX(&x.FMapUint64Int, d) - case "FptrMapUint64Int": - if r.TryNil() { - if x.FptrMapUint64Int != nil { // remove the if-true - x.FptrMapUint64Int = nil - } - } else { - if x.FptrMapUint64Int == nil { - x.FptrMapUint64Int = new(map[uint64]int) - } - z.F.DecMapUint64IntX(x.FptrMapUint64Int, d) - } - case "FMapUint64Int64": - z.F.DecMapUint64Int64X(&x.FMapUint64Int64, d) - case "FptrMapUint64Int64": - if r.TryNil() { - if x.FptrMapUint64Int64 != nil { // remove the if-true - x.FptrMapUint64Int64 = nil - } - } else { - if x.FptrMapUint64Int64 == nil { - x.FptrMapUint64Int64 = new(map[uint64]int64) - } - z.F.DecMapUint64Int64X(x.FptrMapUint64Int64, d) - } - case "FMapUint64Float32": - z.F.DecMapUint64Float32X(&x.FMapUint64Float32, d) - case "FptrMapUint64Float32": - if r.TryNil() { - if x.FptrMapUint64Float32 != nil { // remove the if-true - x.FptrMapUint64Float32 = nil - } - } else { - if x.FptrMapUint64Float32 == nil { - x.FptrMapUint64Float32 = new(map[uint64]float32) - } - z.F.DecMapUint64Float32X(x.FptrMapUint64Float32, d) - } - case "FMapUint64Float64": - z.F.DecMapUint64Float64X(&x.FMapUint64Float64, d) - case "FptrMapUint64Float64": - if r.TryNil() { - if x.FptrMapUint64Float64 != nil { // remove the if-true - x.FptrMapUint64Float64 = nil - } - } else { - if x.FptrMapUint64Float64 == nil { - x.FptrMapUint64Float64 = new(map[uint64]float64) - } - z.F.DecMapUint64Float64X(x.FptrMapUint64Float64, d) - } - case "FMapUint64Bool": - z.F.DecMapUint64BoolX(&x.FMapUint64Bool, d) - case "FptrMapUint64Bool": - if r.TryNil() { - if x.FptrMapUint64Bool != nil { // remove the if-true - x.FptrMapUint64Bool = nil - } - } else { - if x.FptrMapUint64Bool == nil { - x.FptrMapUint64Bool = new(map[uint64]bool) - } - z.F.DecMapUint64BoolX(x.FptrMapUint64Bool, d) - } - case "FMapIntIntf": - z.F.DecMapIntIntfX(&x.FMapIntIntf, d) - case "FptrMapIntIntf": - if r.TryNil() { - if x.FptrMapIntIntf != nil { // remove the if-true - x.FptrMapIntIntf = nil - } - } else { - if x.FptrMapIntIntf == nil { - x.FptrMapIntIntf = new(map[int]interface{}) - } - z.F.DecMapIntIntfX(x.FptrMapIntIntf, d) - } - case "FMapIntString": - z.F.DecMapIntStringX(&x.FMapIntString, d) - case "FptrMapIntString": - if r.TryNil() { - if x.FptrMapIntString != nil { // remove the if-true - x.FptrMapIntString = nil - } - } else { - if x.FptrMapIntString == nil { - x.FptrMapIntString = new(map[int]string) - } - z.F.DecMapIntStringX(x.FptrMapIntString, d) - } - case "FMapIntBytes": - z.F.DecMapIntBytesX(&x.FMapIntBytes, d) - case "FptrMapIntBytes": - if r.TryNil() { - if x.FptrMapIntBytes != nil { // remove the if-true - x.FptrMapIntBytes = nil - } - } else { - if x.FptrMapIntBytes == nil { - x.FptrMapIntBytes = new(map[int][]uint8) - } - z.F.DecMapIntBytesX(x.FptrMapIntBytes, d) - } - case "FMapIntUint": - z.F.DecMapIntUintX(&x.FMapIntUint, d) - case "FptrMapIntUint": - if r.TryNil() { - if x.FptrMapIntUint != nil { // remove the if-true - x.FptrMapIntUint = nil - } - } else { - if x.FptrMapIntUint == nil { - x.FptrMapIntUint = new(map[int]uint) - } - z.F.DecMapIntUintX(x.FptrMapIntUint, d) - } - case "FMapIntUint8": - z.F.DecMapIntUint8X(&x.FMapIntUint8, d) - case "FptrMapIntUint8": - if r.TryNil() { - if x.FptrMapIntUint8 != nil { // remove the if-true - x.FptrMapIntUint8 = nil - } - } else { - if x.FptrMapIntUint8 == nil { - x.FptrMapIntUint8 = new(map[int]uint8) - } - z.F.DecMapIntUint8X(x.FptrMapIntUint8, d) - } - case "FMapIntUint64": - z.F.DecMapIntUint64X(&x.FMapIntUint64, d) - case "FptrMapIntUint64": - if r.TryNil() { - if x.FptrMapIntUint64 != nil { // remove the if-true - x.FptrMapIntUint64 = nil - } - } else { - if x.FptrMapIntUint64 == nil { - x.FptrMapIntUint64 = new(map[int]uint64) - } - z.F.DecMapIntUint64X(x.FptrMapIntUint64, d) - } - case "FMapIntInt": - z.F.DecMapIntIntX(&x.FMapIntInt, d) - case "FptrMapIntInt": - if r.TryNil() { - if x.FptrMapIntInt != nil { // remove the if-true - x.FptrMapIntInt = nil - } - } else { - if x.FptrMapIntInt == nil { - x.FptrMapIntInt = new(map[int]int) - } - z.F.DecMapIntIntX(x.FptrMapIntInt, d) - } - case "FMapIntInt64": - z.F.DecMapIntInt64X(&x.FMapIntInt64, d) - case "FptrMapIntInt64": - if r.TryNil() { - if x.FptrMapIntInt64 != nil { // remove the if-true - x.FptrMapIntInt64 = nil - } - } else { - if x.FptrMapIntInt64 == nil { - x.FptrMapIntInt64 = new(map[int]int64) - } - z.F.DecMapIntInt64X(x.FptrMapIntInt64, d) - } - case "FMapIntFloat32": - z.F.DecMapIntFloat32X(&x.FMapIntFloat32, d) - case "FptrMapIntFloat32": - if r.TryNil() { - if x.FptrMapIntFloat32 != nil { // remove the if-true - x.FptrMapIntFloat32 = nil - } - } else { - if x.FptrMapIntFloat32 == nil { - x.FptrMapIntFloat32 = new(map[int]float32) - } - z.F.DecMapIntFloat32X(x.FptrMapIntFloat32, d) - } - case "FMapIntFloat64": - z.F.DecMapIntFloat64X(&x.FMapIntFloat64, d) - case "FptrMapIntFloat64": - if r.TryNil() { - if x.FptrMapIntFloat64 != nil { // remove the if-true - x.FptrMapIntFloat64 = nil - } - } else { - if x.FptrMapIntFloat64 == nil { - x.FptrMapIntFloat64 = new(map[int]float64) - } - z.F.DecMapIntFloat64X(x.FptrMapIntFloat64, d) - } - case "FMapIntBool": - z.F.DecMapIntBoolX(&x.FMapIntBool, d) - case "FptrMapIntBool": - if r.TryNil() { - if x.FptrMapIntBool != nil { // remove the if-true - x.FptrMapIntBool = nil - } - } else { - if x.FptrMapIntBool == nil { - x.FptrMapIntBool = new(map[int]bool) - } - z.F.DecMapIntBoolX(x.FptrMapIntBool, d) - } - case "FMapInt64Intf": - z.F.DecMapInt64IntfX(&x.FMapInt64Intf, d) - case "FptrMapInt64Intf": - if r.TryNil() { - if x.FptrMapInt64Intf != nil { // remove the if-true - x.FptrMapInt64Intf = nil - } - } else { - if x.FptrMapInt64Intf == nil { - x.FptrMapInt64Intf = new(map[int64]interface{}) - } - z.F.DecMapInt64IntfX(x.FptrMapInt64Intf, d) - } - case "FMapInt64String": - z.F.DecMapInt64StringX(&x.FMapInt64String, d) - case "FptrMapInt64String": - if r.TryNil() { - if x.FptrMapInt64String != nil { // remove the if-true - x.FptrMapInt64String = nil - } - } else { - if x.FptrMapInt64String == nil { - x.FptrMapInt64String = new(map[int64]string) - } - z.F.DecMapInt64StringX(x.FptrMapInt64String, d) - } - case "FMapInt64Bytes": - z.F.DecMapInt64BytesX(&x.FMapInt64Bytes, d) - case "FptrMapInt64Bytes": - if r.TryNil() { - if x.FptrMapInt64Bytes != nil { // remove the if-true - x.FptrMapInt64Bytes = nil - } - } else { - if x.FptrMapInt64Bytes == nil { - x.FptrMapInt64Bytes = new(map[int64][]uint8) - } - z.F.DecMapInt64BytesX(x.FptrMapInt64Bytes, d) - } - case "FMapInt64Uint": - z.F.DecMapInt64UintX(&x.FMapInt64Uint, d) - case "FptrMapInt64Uint": - if r.TryNil() { - if x.FptrMapInt64Uint != nil { // remove the if-true - x.FptrMapInt64Uint = nil - } - } else { - if x.FptrMapInt64Uint == nil { - x.FptrMapInt64Uint = new(map[int64]uint) - } - z.F.DecMapInt64UintX(x.FptrMapInt64Uint, d) - } - case "FMapInt64Uint8": - z.F.DecMapInt64Uint8X(&x.FMapInt64Uint8, d) - case "FptrMapInt64Uint8": - if r.TryNil() { - if x.FptrMapInt64Uint8 != nil { // remove the if-true - x.FptrMapInt64Uint8 = nil - } - } else { - if x.FptrMapInt64Uint8 == nil { - x.FptrMapInt64Uint8 = new(map[int64]uint8) - } - z.F.DecMapInt64Uint8X(x.FptrMapInt64Uint8, d) - } - case "FMapInt64Uint64": - z.F.DecMapInt64Uint64X(&x.FMapInt64Uint64, d) - case "FptrMapInt64Uint64": - if r.TryNil() { - if x.FptrMapInt64Uint64 != nil { // remove the if-true - x.FptrMapInt64Uint64 = nil - } - } else { - if x.FptrMapInt64Uint64 == nil { - x.FptrMapInt64Uint64 = new(map[int64]uint64) - } - z.F.DecMapInt64Uint64X(x.FptrMapInt64Uint64, d) - } - case "FMapInt64Int": - z.F.DecMapInt64IntX(&x.FMapInt64Int, d) - case "FptrMapInt64Int": - if r.TryNil() { - if x.FptrMapInt64Int != nil { // remove the if-true - x.FptrMapInt64Int = nil - } - } else { - if x.FptrMapInt64Int == nil { - x.FptrMapInt64Int = new(map[int64]int) - } - z.F.DecMapInt64IntX(x.FptrMapInt64Int, d) - } - case "FMapInt64Int64": - z.F.DecMapInt64Int64X(&x.FMapInt64Int64, d) - case "FptrMapInt64Int64": - if r.TryNil() { - if x.FptrMapInt64Int64 != nil { // remove the if-true - x.FptrMapInt64Int64 = nil - } - } else { - if x.FptrMapInt64Int64 == nil { - x.FptrMapInt64Int64 = new(map[int64]int64) - } - z.F.DecMapInt64Int64X(x.FptrMapInt64Int64, d) - } - case "FMapInt64Float32": - z.F.DecMapInt64Float32X(&x.FMapInt64Float32, d) - case "FptrMapInt64Float32": - if r.TryNil() { - if x.FptrMapInt64Float32 != nil { // remove the if-true - x.FptrMapInt64Float32 = nil - } - } else { - if x.FptrMapInt64Float32 == nil { - x.FptrMapInt64Float32 = new(map[int64]float32) - } - z.F.DecMapInt64Float32X(x.FptrMapInt64Float32, d) - } - case "FMapInt64Float64": - z.F.DecMapInt64Float64X(&x.FMapInt64Float64, d) - case "FptrMapInt64Float64": - if r.TryNil() { - if x.FptrMapInt64Float64 != nil { // remove the if-true - x.FptrMapInt64Float64 = nil - } - } else { - if x.FptrMapInt64Float64 == nil { - x.FptrMapInt64Float64 = new(map[int64]float64) - } - z.F.DecMapInt64Float64X(x.FptrMapInt64Float64, d) - } - case "FMapInt64Bool": - z.F.DecMapInt64BoolX(&x.FMapInt64Bool, d) - case "FptrMapInt64Bool": - if r.TryNil() { - if x.FptrMapInt64Bool != nil { // remove the if-true - x.FptrMapInt64Bool = nil - } - } else { - if x.FptrMapInt64Bool == nil { - x.FptrMapInt64Bool = new(map[int64]bool) - } - z.F.DecMapInt64BoolX(x.FptrMapInt64Bool, d) - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestMammoth2) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj381 int - var yyb381 bool - var yyhl381 bool = l >= 0 - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.DecFallback(&x.FIntf, true) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrIntf != nil { // remove the if-true - x.FptrIntf = nil - } - } else { - if x.FptrIntf == nil { - x.FptrIntf = new(interface{}) - } - z.DecFallback(x.FptrIntf, true) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FString = (string)(string(r.DecodeStringAsBytes())) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrString != nil { // remove the if-true - x.FptrString = nil - } - } else { - if x.FptrString == nil { - x.FptrString = new(string) - } - *x.FptrString = (string)(string(r.DecodeStringAsBytes())) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FBytes = r.DecodeBytes(([]byte)(x.FBytes), false) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrBytes != nil { // remove the if-true - x.FptrBytes = nil - } - } else { - if x.FptrBytes == nil { - x.FptrBytes = new([]uint8) - } - *x.FptrBytes = r.DecodeBytes(*(*[]byte)(x.FptrBytes), false) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FFloat32 = (float32)(z.DecDecodeFloat32()) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrFloat32 != nil { // remove the if-true - x.FptrFloat32 = nil - } - } else { - if x.FptrFloat32 == nil { - x.FptrFloat32 = new(float32) - } - *x.FptrFloat32 = (float32)(z.DecDecodeFloat32()) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FFloat64 = (float64)(r.DecodeFloat64()) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrFloat64 != nil { // remove the if-true - x.FptrFloat64 = nil - } - } else { - if x.FptrFloat64 == nil { - x.FptrFloat64 = new(float64) - } - *x.FptrFloat64 = (float64)(r.DecodeFloat64()) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FUint = (uint)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrUint != nil { // remove the if-true - x.FptrUint = nil - } - } else { - if x.FptrUint == nil { - x.FptrUint = new(uint) - } - *x.FptrUint = (uint)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FUint8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrUint8 != nil { // remove the if-true - x.FptrUint8 = nil - } - } else { - if x.FptrUint8 == nil { - x.FptrUint8 = new(uint8) - } - *x.FptrUint8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FUint16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrUint16 != nil { // remove the if-true - x.FptrUint16 = nil - } - } else { - if x.FptrUint16 == nil { - x.FptrUint16 = new(uint16) - } - *x.FptrUint16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FUint32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrUint32 != nil { // remove the if-true - x.FptrUint32 = nil - } - } else { - if x.FptrUint32 == nil { - x.FptrUint32 = new(uint32) - } - *x.FptrUint32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FUint64 = (uint64)(r.DecodeUint64()) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrUint64 != nil { // remove the if-true - x.FptrUint64 = nil - } - } else { - if x.FptrUint64 == nil { - x.FptrUint64 = new(uint64) - } - *x.FptrUint64 = (uint64)(r.DecodeUint64()) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FUintptr = (uintptr)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrUintptr != nil { // remove the if-true - x.FptrUintptr = nil - } - } else { - if x.FptrUintptr == nil { - x.FptrUintptr = new(uintptr) - } - *x.FptrUintptr = (uintptr)(z.C.UintV(r.DecodeUint64(), codecSelferBitsize19781)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FInt = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19781)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrInt != nil { // remove the if-true - x.FptrInt = nil - } - } else { - if x.FptrInt == nil { - x.FptrInt = new(int) - } - *x.FptrInt = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19781)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FInt8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrInt8 != nil { // remove the if-true - x.FptrInt8 = nil - } - } else { - if x.FptrInt8 == nil { - x.FptrInt8 = new(int8) - } - *x.FptrInt8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FInt16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrInt16 != nil { // remove the if-true - x.FptrInt16 = nil - } - } else { - if x.FptrInt16 == nil { - x.FptrInt16 = new(int16) - } - *x.FptrInt16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FInt32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrInt32 != nil { // remove the if-true - x.FptrInt32 = nil - } - } else { - if x.FptrInt32 == nil { - x.FptrInt32 = new(int32) - } - *x.FptrInt32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FInt64 = (int64)(r.DecodeInt64()) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrInt64 != nil { // remove the if-true - x.FptrInt64 = nil - } - } else { - if x.FptrInt64 == nil { - x.FptrInt64 = new(int64) - } - *x.FptrInt64 = (int64)(r.DecodeInt64()) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.FBool = (bool)(r.DecodeBool()) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrBool != nil { // remove the if-true - x.FptrBool = nil - } - } else { - if x.FptrBool == nil { - x.FptrBool = new(bool) - } - *x.FptrBool = (bool)(r.DecodeBool()) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceIntfX(&x.FSliceIntf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceIntf != nil { // remove the if-true - x.FptrSliceIntf = nil - } - } else { - if x.FptrSliceIntf == nil { - x.FptrSliceIntf = new([]interface{}) - } - z.F.DecSliceIntfX(x.FptrSliceIntf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.FSliceString, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceString != nil { // remove the if-true - x.FptrSliceString = nil - } - } else { - if x.FptrSliceString == nil { - x.FptrSliceString = new([]string) - } - z.F.DecSliceStringX(x.FptrSliceString, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBytesX(&x.FSliceBytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceBytes != nil { // remove the if-true - x.FptrSliceBytes = nil - } - } else { - if x.FptrSliceBytes == nil { - x.FptrSliceBytes = new([][]uint8) - } - z.F.DecSliceBytesX(x.FptrSliceBytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat32X(&x.FSliceFloat32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceFloat32 != nil { // remove the if-true - x.FptrSliceFloat32 = nil - } - } else { - if x.FptrSliceFloat32 == nil { - x.FptrSliceFloat32 = new([]float32) - } - z.F.DecSliceFloat32X(x.FptrSliceFloat32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat64X(&x.FSliceFloat64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceFloat64 != nil { // remove the if-true - x.FptrSliceFloat64 = nil - } - } else { - if x.FptrSliceFloat64 == nil { - x.FptrSliceFloat64 = new([]float64) - } - z.F.DecSliceFloat64X(x.FptrSliceFloat64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUintX(&x.FSliceUint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceUint != nil { // remove the if-true - x.FptrSliceUint = nil - } - } else { - if x.FptrSliceUint == nil { - x.FptrSliceUint = new([]uint) - } - z.F.DecSliceUintX(x.FptrSliceUint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint16X(&x.FSliceUint16, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceUint16 != nil { // remove the if-true - x.FptrSliceUint16 = nil - } - } else { - if x.FptrSliceUint16 == nil { - x.FptrSliceUint16 = new([]uint16) - } - z.F.DecSliceUint16X(x.FptrSliceUint16, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint32X(&x.FSliceUint32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceUint32 != nil { // remove the if-true - x.FptrSliceUint32 = nil - } - } else { - if x.FptrSliceUint32 == nil { - x.FptrSliceUint32 = new([]uint32) - } - z.F.DecSliceUint32X(x.FptrSliceUint32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.FSliceUint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceUint64 != nil { // remove the if-true - x.FptrSliceUint64 = nil - } - } else { - if x.FptrSliceUint64 == nil { - x.FptrSliceUint64 = new([]uint64) - } - z.F.DecSliceUint64X(x.FptrSliceUint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceIntX(&x.FSliceInt, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceInt != nil { // remove the if-true - x.FptrSliceInt = nil - } - } else { - if x.FptrSliceInt == nil { - x.FptrSliceInt = new([]int) - } - z.F.DecSliceIntX(x.FptrSliceInt, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt8X(&x.FSliceInt8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceInt8 != nil { // remove the if-true - x.FptrSliceInt8 = nil - } - } else { - if x.FptrSliceInt8 == nil { - x.FptrSliceInt8 = new([]int8) - } - z.F.DecSliceInt8X(x.FptrSliceInt8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt16X(&x.FSliceInt16, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceInt16 != nil { // remove the if-true - x.FptrSliceInt16 = nil - } - } else { - if x.FptrSliceInt16 == nil { - x.FptrSliceInt16 = new([]int16) - } - z.F.DecSliceInt16X(x.FptrSliceInt16, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt32X(&x.FSliceInt32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceInt32 != nil { // remove the if-true - x.FptrSliceInt32 = nil - } - } else { - if x.FptrSliceInt32 == nil { - x.FptrSliceInt32 = new([]int32) - } - z.F.DecSliceInt32X(x.FptrSliceInt32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.FSliceInt64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceInt64 != nil { // remove the if-true - x.FptrSliceInt64 = nil - } - } else { - if x.FptrSliceInt64 == nil { - x.FptrSliceInt64 = new([]int64) - } - z.F.DecSliceInt64X(x.FptrSliceInt64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBoolX(&x.FSliceBool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrSliceBool != nil { // remove the if-true - x.FptrSliceBool = nil - } - } else { - if x.FptrSliceBool == nil { - x.FptrSliceBool = new([]bool) - } - z.F.DecSliceBoolX(x.FptrSliceBool, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringIntfX(&x.FMapStringIntf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringIntf != nil { // remove the if-true - x.FptrMapStringIntf = nil - } - } else { - if x.FptrMapStringIntf == nil { - x.FptrMapStringIntf = new(map[string]interface{}) - } - z.F.DecMapStringIntfX(x.FptrMapStringIntf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringStringX(&x.FMapStringString, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringString != nil { // remove the if-true - x.FptrMapStringString = nil - } - } else { - if x.FptrMapStringString == nil { - x.FptrMapStringString = new(map[string]string) - } - z.F.DecMapStringStringX(x.FptrMapStringString, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBytesX(&x.FMapStringBytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringBytes != nil { // remove the if-true - x.FptrMapStringBytes = nil - } - } else { - if x.FptrMapStringBytes == nil { - x.FptrMapStringBytes = new(map[string][]uint8) - } - z.F.DecMapStringBytesX(x.FptrMapStringBytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringUintX(&x.FMapStringUint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringUint != nil { // remove the if-true - x.FptrMapStringUint = nil - } - } else { - if x.FptrMapStringUint == nil { - x.FptrMapStringUint = new(map[string]uint) - } - z.F.DecMapStringUintX(x.FptrMapStringUint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringUint8X(&x.FMapStringUint8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringUint8 != nil { // remove the if-true - x.FptrMapStringUint8 = nil - } - } else { - if x.FptrMapStringUint8 == nil { - x.FptrMapStringUint8 = new(map[string]uint8) - } - z.F.DecMapStringUint8X(x.FptrMapStringUint8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringUint64X(&x.FMapStringUint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringUint64 != nil { // remove the if-true - x.FptrMapStringUint64 = nil - } - } else { - if x.FptrMapStringUint64 == nil { - x.FptrMapStringUint64 = new(map[string]uint64) - } - z.F.DecMapStringUint64X(x.FptrMapStringUint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringIntX(&x.FMapStringInt, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringInt != nil { // remove the if-true - x.FptrMapStringInt = nil - } - } else { - if x.FptrMapStringInt == nil { - x.FptrMapStringInt = new(map[string]int) - } - z.F.DecMapStringIntX(x.FptrMapStringInt, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringInt64X(&x.FMapStringInt64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringInt64 != nil { // remove the if-true - x.FptrMapStringInt64 = nil - } - } else { - if x.FptrMapStringInt64 == nil { - x.FptrMapStringInt64 = new(map[string]int64) - } - z.F.DecMapStringInt64X(x.FptrMapStringInt64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringFloat32X(&x.FMapStringFloat32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringFloat32 != nil { // remove the if-true - x.FptrMapStringFloat32 = nil - } - } else { - if x.FptrMapStringFloat32 == nil { - x.FptrMapStringFloat32 = new(map[string]float32) - } - z.F.DecMapStringFloat32X(x.FptrMapStringFloat32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringFloat64X(&x.FMapStringFloat64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringFloat64 != nil { // remove the if-true - x.FptrMapStringFloat64 = nil - } - } else { - if x.FptrMapStringFloat64 == nil { - x.FptrMapStringFloat64 = new(map[string]float64) - } - z.F.DecMapStringFloat64X(x.FptrMapStringFloat64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBoolX(&x.FMapStringBool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapStringBool != nil { // remove the if-true - x.FptrMapStringBool = nil - } - } else { - if x.FptrMapStringBool == nil { - x.FptrMapStringBool = new(map[string]bool) - } - z.F.DecMapStringBoolX(x.FptrMapStringBool, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintIntfX(&x.FMapUintIntf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintIntf != nil { // remove the if-true - x.FptrMapUintIntf = nil - } - } else { - if x.FptrMapUintIntf == nil { - x.FptrMapUintIntf = new(map[uint]interface{}) - } - z.F.DecMapUintIntfX(x.FptrMapUintIntf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintStringX(&x.FMapUintString, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintString != nil { // remove the if-true - x.FptrMapUintString = nil - } - } else { - if x.FptrMapUintString == nil { - x.FptrMapUintString = new(map[uint]string) - } - z.F.DecMapUintStringX(x.FptrMapUintString, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintBytesX(&x.FMapUintBytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintBytes != nil { // remove the if-true - x.FptrMapUintBytes = nil - } - } else { - if x.FptrMapUintBytes == nil { - x.FptrMapUintBytes = new(map[uint][]uint8) - } - z.F.DecMapUintBytesX(x.FptrMapUintBytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintUintX(&x.FMapUintUint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintUint != nil { // remove the if-true - x.FptrMapUintUint = nil - } - } else { - if x.FptrMapUintUint == nil { - x.FptrMapUintUint = new(map[uint]uint) - } - z.F.DecMapUintUintX(x.FptrMapUintUint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintUint8X(&x.FMapUintUint8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintUint8 != nil { // remove the if-true - x.FptrMapUintUint8 = nil - } - } else { - if x.FptrMapUintUint8 == nil { - x.FptrMapUintUint8 = new(map[uint]uint8) - } - z.F.DecMapUintUint8X(x.FptrMapUintUint8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintUint64X(&x.FMapUintUint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintUint64 != nil { // remove the if-true - x.FptrMapUintUint64 = nil - } - } else { - if x.FptrMapUintUint64 == nil { - x.FptrMapUintUint64 = new(map[uint]uint64) - } - z.F.DecMapUintUint64X(x.FptrMapUintUint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintIntX(&x.FMapUintInt, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintInt != nil { // remove the if-true - x.FptrMapUintInt = nil - } - } else { - if x.FptrMapUintInt == nil { - x.FptrMapUintInt = new(map[uint]int) - } - z.F.DecMapUintIntX(x.FptrMapUintInt, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintInt64X(&x.FMapUintInt64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintInt64 != nil { // remove the if-true - x.FptrMapUintInt64 = nil - } - } else { - if x.FptrMapUintInt64 == nil { - x.FptrMapUintInt64 = new(map[uint]int64) - } - z.F.DecMapUintInt64X(x.FptrMapUintInt64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintFloat32X(&x.FMapUintFloat32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintFloat32 != nil { // remove the if-true - x.FptrMapUintFloat32 = nil - } - } else { - if x.FptrMapUintFloat32 == nil { - x.FptrMapUintFloat32 = new(map[uint]float32) - } - z.F.DecMapUintFloat32X(x.FptrMapUintFloat32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintFloat64X(&x.FMapUintFloat64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintFloat64 != nil { // remove the if-true - x.FptrMapUintFloat64 = nil - } - } else { - if x.FptrMapUintFloat64 == nil { - x.FptrMapUintFloat64 = new(map[uint]float64) - } - z.F.DecMapUintFloat64X(x.FptrMapUintFloat64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUintBoolX(&x.FMapUintBool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUintBool != nil { // remove the if-true - x.FptrMapUintBool = nil - } - } else { - if x.FptrMapUintBool == nil { - x.FptrMapUintBool = new(map[uint]bool) - } - z.F.DecMapUintBoolX(x.FptrMapUintBool, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8IntfX(&x.FMapUint8Intf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Intf != nil { // remove the if-true - x.FptrMapUint8Intf = nil - } - } else { - if x.FptrMapUint8Intf == nil { - x.FptrMapUint8Intf = new(map[uint8]interface{}) - } - z.F.DecMapUint8IntfX(x.FptrMapUint8Intf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8StringX(&x.FMapUint8String, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8String != nil { // remove the if-true - x.FptrMapUint8String = nil - } - } else { - if x.FptrMapUint8String == nil { - x.FptrMapUint8String = new(map[uint8]string) - } - z.F.DecMapUint8StringX(x.FptrMapUint8String, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8BytesX(&x.FMapUint8Bytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Bytes != nil { // remove the if-true - x.FptrMapUint8Bytes = nil - } - } else { - if x.FptrMapUint8Bytes == nil { - x.FptrMapUint8Bytes = new(map[uint8][]uint8) - } - z.F.DecMapUint8BytesX(x.FptrMapUint8Bytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8UintX(&x.FMapUint8Uint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Uint != nil { // remove the if-true - x.FptrMapUint8Uint = nil - } - } else { - if x.FptrMapUint8Uint == nil { - x.FptrMapUint8Uint = new(map[uint8]uint) - } - z.F.DecMapUint8UintX(x.FptrMapUint8Uint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8Uint8X(&x.FMapUint8Uint8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Uint8 != nil { // remove the if-true - x.FptrMapUint8Uint8 = nil - } - } else { - if x.FptrMapUint8Uint8 == nil { - x.FptrMapUint8Uint8 = new(map[uint8]uint8) - } - z.F.DecMapUint8Uint8X(x.FptrMapUint8Uint8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8Uint64X(&x.FMapUint8Uint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Uint64 != nil { // remove the if-true - x.FptrMapUint8Uint64 = nil - } - } else { - if x.FptrMapUint8Uint64 == nil { - x.FptrMapUint8Uint64 = new(map[uint8]uint64) - } - z.F.DecMapUint8Uint64X(x.FptrMapUint8Uint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8IntX(&x.FMapUint8Int, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Int != nil { // remove the if-true - x.FptrMapUint8Int = nil - } - } else { - if x.FptrMapUint8Int == nil { - x.FptrMapUint8Int = new(map[uint8]int) - } - z.F.DecMapUint8IntX(x.FptrMapUint8Int, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8Int64X(&x.FMapUint8Int64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Int64 != nil { // remove the if-true - x.FptrMapUint8Int64 = nil - } - } else { - if x.FptrMapUint8Int64 == nil { - x.FptrMapUint8Int64 = new(map[uint8]int64) - } - z.F.DecMapUint8Int64X(x.FptrMapUint8Int64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8Float32X(&x.FMapUint8Float32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Float32 != nil { // remove the if-true - x.FptrMapUint8Float32 = nil - } - } else { - if x.FptrMapUint8Float32 == nil { - x.FptrMapUint8Float32 = new(map[uint8]float32) - } - z.F.DecMapUint8Float32X(x.FptrMapUint8Float32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8Float64X(&x.FMapUint8Float64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Float64 != nil { // remove the if-true - x.FptrMapUint8Float64 = nil - } - } else { - if x.FptrMapUint8Float64 == nil { - x.FptrMapUint8Float64 = new(map[uint8]float64) - } - z.F.DecMapUint8Float64X(x.FptrMapUint8Float64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint8BoolX(&x.FMapUint8Bool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint8Bool != nil { // remove the if-true - x.FptrMapUint8Bool = nil - } - } else { - if x.FptrMapUint8Bool == nil { - x.FptrMapUint8Bool = new(map[uint8]bool) - } - z.F.DecMapUint8BoolX(x.FptrMapUint8Bool, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64IntfX(&x.FMapUint64Intf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Intf != nil { // remove the if-true - x.FptrMapUint64Intf = nil - } - } else { - if x.FptrMapUint64Intf == nil { - x.FptrMapUint64Intf = new(map[uint64]interface{}) - } - z.F.DecMapUint64IntfX(x.FptrMapUint64Intf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64StringX(&x.FMapUint64String, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64String != nil { // remove the if-true - x.FptrMapUint64String = nil - } - } else { - if x.FptrMapUint64String == nil { - x.FptrMapUint64String = new(map[uint64]string) - } - z.F.DecMapUint64StringX(x.FptrMapUint64String, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64BytesX(&x.FMapUint64Bytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Bytes != nil { // remove the if-true - x.FptrMapUint64Bytes = nil - } - } else { - if x.FptrMapUint64Bytes == nil { - x.FptrMapUint64Bytes = new(map[uint64][]uint8) - } - z.F.DecMapUint64BytesX(x.FptrMapUint64Bytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64UintX(&x.FMapUint64Uint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Uint != nil { // remove the if-true - x.FptrMapUint64Uint = nil - } - } else { - if x.FptrMapUint64Uint == nil { - x.FptrMapUint64Uint = new(map[uint64]uint) - } - z.F.DecMapUint64UintX(x.FptrMapUint64Uint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64Uint8X(&x.FMapUint64Uint8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Uint8 != nil { // remove the if-true - x.FptrMapUint64Uint8 = nil - } - } else { - if x.FptrMapUint64Uint8 == nil { - x.FptrMapUint64Uint8 = new(map[uint64]uint8) - } - z.F.DecMapUint64Uint8X(x.FptrMapUint64Uint8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64Uint64X(&x.FMapUint64Uint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Uint64 != nil { // remove the if-true - x.FptrMapUint64Uint64 = nil - } - } else { - if x.FptrMapUint64Uint64 == nil { - x.FptrMapUint64Uint64 = new(map[uint64]uint64) - } - z.F.DecMapUint64Uint64X(x.FptrMapUint64Uint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64IntX(&x.FMapUint64Int, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Int != nil { // remove the if-true - x.FptrMapUint64Int = nil - } - } else { - if x.FptrMapUint64Int == nil { - x.FptrMapUint64Int = new(map[uint64]int) - } - z.F.DecMapUint64IntX(x.FptrMapUint64Int, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64Int64X(&x.FMapUint64Int64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Int64 != nil { // remove the if-true - x.FptrMapUint64Int64 = nil - } - } else { - if x.FptrMapUint64Int64 == nil { - x.FptrMapUint64Int64 = new(map[uint64]int64) - } - z.F.DecMapUint64Int64X(x.FptrMapUint64Int64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64Float32X(&x.FMapUint64Float32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Float32 != nil { // remove the if-true - x.FptrMapUint64Float32 = nil - } - } else { - if x.FptrMapUint64Float32 == nil { - x.FptrMapUint64Float32 = new(map[uint64]float32) - } - z.F.DecMapUint64Float32X(x.FptrMapUint64Float32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64Float64X(&x.FMapUint64Float64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Float64 != nil { // remove the if-true - x.FptrMapUint64Float64 = nil - } - } else { - if x.FptrMapUint64Float64 == nil { - x.FptrMapUint64Float64 = new(map[uint64]float64) - } - z.F.DecMapUint64Float64X(x.FptrMapUint64Float64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapUint64BoolX(&x.FMapUint64Bool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapUint64Bool != nil { // remove the if-true - x.FptrMapUint64Bool = nil - } - } else { - if x.FptrMapUint64Bool == nil { - x.FptrMapUint64Bool = new(map[uint64]bool) - } - z.F.DecMapUint64BoolX(x.FptrMapUint64Bool, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntIntfX(&x.FMapIntIntf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntIntf != nil { // remove the if-true - x.FptrMapIntIntf = nil - } - } else { - if x.FptrMapIntIntf == nil { - x.FptrMapIntIntf = new(map[int]interface{}) - } - z.F.DecMapIntIntfX(x.FptrMapIntIntf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntStringX(&x.FMapIntString, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntString != nil { // remove the if-true - x.FptrMapIntString = nil - } - } else { - if x.FptrMapIntString == nil { - x.FptrMapIntString = new(map[int]string) - } - z.F.DecMapIntStringX(x.FptrMapIntString, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntBytesX(&x.FMapIntBytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntBytes != nil { // remove the if-true - x.FptrMapIntBytes = nil - } - } else { - if x.FptrMapIntBytes == nil { - x.FptrMapIntBytes = new(map[int][]uint8) - } - z.F.DecMapIntBytesX(x.FptrMapIntBytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntUintX(&x.FMapIntUint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntUint != nil { // remove the if-true - x.FptrMapIntUint = nil - } - } else { - if x.FptrMapIntUint == nil { - x.FptrMapIntUint = new(map[int]uint) - } - z.F.DecMapIntUintX(x.FptrMapIntUint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntUint8X(&x.FMapIntUint8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntUint8 != nil { // remove the if-true - x.FptrMapIntUint8 = nil - } - } else { - if x.FptrMapIntUint8 == nil { - x.FptrMapIntUint8 = new(map[int]uint8) - } - z.F.DecMapIntUint8X(x.FptrMapIntUint8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntUint64X(&x.FMapIntUint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntUint64 != nil { // remove the if-true - x.FptrMapIntUint64 = nil - } - } else { - if x.FptrMapIntUint64 == nil { - x.FptrMapIntUint64 = new(map[int]uint64) - } - z.F.DecMapIntUint64X(x.FptrMapIntUint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntIntX(&x.FMapIntInt, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntInt != nil { // remove the if-true - x.FptrMapIntInt = nil - } - } else { - if x.FptrMapIntInt == nil { - x.FptrMapIntInt = new(map[int]int) - } - z.F.DecMapIntIntX(x.FptrMapIntInt, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntInt64X(&x.FMapIntInt64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntInt64 != nil { // remove the if-true - x.FptrMapIntInt64 = nil - } - } else { - if x.FptrMapIntInt64 == nil { - x.FptrMapIntInt64 = new(map[int]int64) - } - z.F.DecMapIntInt64X(x.FptrMapIntInt64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntFloat32X(&x.FMapIntFloat32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntFloat32 != nil { // remove the if-true - x.FptrMapIntFloat32 = nil - } - } else { - if x.FptrMapIntFloat32 == nil { - x.FptrMapIntFloat32 = new(map[int]float32) - } - z.F.DecMapIntFloat32X(x.FptrMapIntFloat32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntFloat64X(&x.FMapIntFloat64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntFloat64 != nil { // remove the if-true - x.FptrMapIntFloat64 = nil - } - } else { - if x.FptrMapIntFloat64 == nil { - x.FptrMapIntFloat64 = new(map[int]float64) - } - z.F.DecMapIntFloat64X(x.FptrMapIntFloat64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntBoolX(&x.FMapIntBool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapIntBool != nil { // remove the if-true - x.FptrMapIntBool = nil - } - } else { - if x.FptrMapIntBool == nil { - x.FptrMapIntBool = new(map[int]bool) - } - z.F.DecMapIntBoolX(x.FptrMapIntBool, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64IntfX(&x.FMapInt64Intf, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Intf != nil { // remove the if-true - x.FptrMapInt64Intf = nil - } - } else { - if x.FptrMapInt64Intf == nil { - x.FptrMapInt64Intf = new(map[int64]interface{}) - } - z.F.DecMapInt64IntfX(x.FptrMapInt64Intf, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64StringX(&x.FMapInt64String, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64String != nil { // remove the if-true - x.FptrMapInt64String = nil - } - } else { - if x.FptrMapInt64String == nil { - x.FptrMapInt64String = new(map[int64]string) - } - z.F.DecMapInt64StringX(x.FptrMapInt64String, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64BytesX(&x.FMapInt64Bytes, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Bytes != nil { // remove the if-true - x.FptrMapInt64Bytes = nil - } - } else { - if x.FptrMapInt64Bytes == nil { - x.FptrMapInt64Bytes = new(map[int64][]uint8) - } - z.F.DecMapInt64BytesX(x.FptrMapInt64Bytes, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64UintX(&x.FMapInt64Uint, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Uint != nil { // remove the if-true - x.FptrMapInt64Uint = nil - } - } else { - if x.FptrMapInt64Uint == nil { - x.FptrMapInt64Uint = new(map[int64]uint) - } - z.F.DecMapInt64UintX(x.FptrMapInt64Uint, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64Uint8X(&x.FMapInt64Uint8, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Uint8 != nil { // remove the if-true - x.FptrMapInt64Uint8 = nil - } - } else { - if x.FptrMapInt64Uint8 == nil { - x.FptrMapInt64Uint8 = new(map[int64]uint8) - } - z.F.DecMapInt64Uint8X(x.FptrMapInt64Uint8, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64Uint64X(&x.FMapInt64Uint64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Uint64 != nil { // remove the if-true - x.FptrMapInt64Uint64 = nil - } - } else { - if x.FptrMapInt64Uint64 == nil { - x.FptrMapInt64Uint64 = new(map[int64]uint64) - } - z.F.DecMapInt64Uint64X(x.FptrMapInt64Uint64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64IntX(&x.FMapInt64Int, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Int != nil { // remove the if-true - x.FptrMapInt64Int = nil - } - } else { - if x.FptrMapInt64Int == nil { - x.FptrMapInt64Int = new(map[int64]int) - } - z.F.DecMapInt64IntX(x.FptrMapInt64Int, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64Int64X(&x.FMapInt64Int64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Int64 != nil { // remove the if-true - x.FptrMapInt64Int64 = nil - } - } else { - if x.FptrMapInt64Int64 == nil { - x.FptrMapInt64Int64 = new(map[int64]int64) - } - z.F.DecMapInt64Int64X(x.FptrMapInt64Int64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64Float32X(&x.FMapInt64Float32, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Float32 != nil { // remove the if-true - x.FptrMapInt64Float32 = nil - } - } else { - if x.FptrMapInt64Float32 == nil { - x.FptrMapInt64Float32 = new(map[int64]float32) - } - z.F.DecMapInt64Float32X(x.FptrMapInt64Float32, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64Float64X(&x.FMapInt64Float64, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Float64 != nil { // remove the if-true - x.FptrMapInt64Float64 = nil - } - } else { - if x.FptrMapInt64Float64 == nil { - x.FptrMapInt64Float64 = new(map[int64]float64) - } - z.F.DecMapInt64Float64X(x.FptrMapInt64Float64, d) - } - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapInt64BoolX(&x.FMapInt64Bool, d) - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.FptrMapInt64Bool != nil { // remove the if-true - x.FptrMapInt64Bool = nil - } - } else { - if x.FptrMapInt64Bool == nil { - x.FptrMapInt64Bool = new(map[int64]bool) - } - z.F.DecMapInt64BoolX(x.FptrMapInt64Bool, d) - } - for { - yyj381++ - if yyhl381 { - yyb381 = yyj381 > l - } else { - yyb381 = z.DecCheckBreak() - } - if yyb381 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj381-1, "") - } -} - -func (x testMammoth2Binary) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if z.EncBinary() { - z.EncBinaryMarshal(x) - } else { - r.EncodeUint(uint64(x)) - } -} - -func (x *testMammoth2Binary) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - if z.DecBinary() { - z.DecBinaryUnmarshal(x) - } else { - *x = (testMammoth2Binary)(r.DecodeUint64()) - } -} - -func (x testMammoth2Text) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if !z.EncBinary() { - z.EncTextMarshal(x) - } else { - r.EncodeUint(uint64(x)) - } -} - -func (x *testMammoth2Text) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - if !z.DecBinary() { - z.DecTextUnmarshal(x) - } else { - *x = (testMammoth2Text)(r.DecodeUint64()) - } -} - -func (x testMammoth2Json) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(x) - } else { - r.EncodeUint(uint64(x)) - } -} - -func (x *testMammoth2Json) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(x) - } else { - *x = (testMammoth2Json)(r.DecodeUint64()) - } -} - -func (x *testMammoth2Basic) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.enctestMammoth2Basic((*testMammoth2Basic)(x), e) - } -} - -func (x *testMammoth2Basic) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.dectestMammoth2Basic((*testMammoth2Basic)(x), d) -} - -func (x *TestMammoth2Wrapper) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(8) - z.EncWriteArrayElem() - yy11 := &x.V - yy11.CodecEncodeSelf(e) - z.EncWriteArrayElem() - x.T.CodecEncodeSelf(e) - z.EncWriteArrayElem() - x.B.CodecEncodeSelf(e) - z.EncWriteArrayElem() - x.J.CodecEncodeSelf(e) - z.EncWriteArrayElem() - yy16 := &x.C - yy16.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.M == nil { - r.EncodeNil() - } else { - h.encMaptestMammoth2BasicTestMammoth2((map[testMammoth2Basic]TestMammoth2)(x.M), e) - } // end block: if x.M map == nil - z.EncWriteArrayElem() - if x.L == nil { - r.EncodeNil() - } else { - h.encSliceTestMammoth2(([]TestMammoth2)(x.L), e) - } // end block: if x.L slice == nil - z.EncWriteArrayElem() - yy20 := &x.A - h.encArray4int64((*[4]int64)(yy20), e) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(8) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"V\"") - } else { - r.EncodeString(`V`) - } - z.EncWriteMapElemValue() - yy22 := &x.V - yy22.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"T\"") - } else { - r.EncodeString(`T`) - } - z.EncWriteMapElemValue() - x.T.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - x.B.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"J\"") - } else { - r.EncodeString(`J`) - } - z.EncWriteMapElemValue() - x.J.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"C\"") - } else { - r.EncodeString(`C`) - } - z.EncWriteMapElemValue() - yy27 := &x.C - yy27.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"M\"") - } else { - r.EncodeString(`M`) - } - z.EncWriteMapElemValue() - if x.M == nil { - r.EncodeNil() - } else { - h.encMaptestMammoth2BasicTestMammoth2((map[testMammoth2Basic]TestMammoth2)(x.M), e) - } // end block: if x.M map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"L\"") - } else { - r.EncodeString(`L`) - } - z.EncWriteMapElemValue() - if x.L == nil { - r.EncodeNil() - } else { - h.encSliceTestMammoth2(([]TestMammoth2)(x.L), e) - } // end block: if x.L slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"A\"") - } else { - r.EncodeString(`A`) - } - z.EncWriteMapElemValue() - yy31 := &x.A - h.encArray4int64((*[4]int64)(yy31), e) - z.EncWriteMapEnd() - } - } -} - -func (x *TestMammoth2Wrapper) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19781 { - *(x) = TestMammoth2Wrapper{} - } else if yyct2 == codecSelferValueTypeMap19781 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19781 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19781) - } -} - -func (x *TestMammoth2Wrapper) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "V": - x.V.CodecDecodeSelf(d) - case "T": - x.T.CodecDecodeSelf(d) - case "B": - x.B.CodecDecodeSelf(d) - case "J": - x.J.CodecDecodeSelf(d) - case "C": - x.C.CodecDecodeSelf(d) - case "M": - h.decMaptestMammoth2BasicTestMammoth2((*map[testMammoth2Basic]TestMammoth2)(&x.M), d) - case "L": - h.decSliceTestMammoth2((*[]TestMammoth2)(&x.L), d) - case "A": - h.decArray4int64((*[4]int64)(&x.A), d) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestMammoth2Wrapper) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj15 int - var yyb15 bool - var yyhl15 bool = l >= 0 - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.V.CodecDecodeSelf(d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.T.CodecDecodeSelf(d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B.CodecDecodeSelf(d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.J.CodecDecodeSelf(d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.C.CodecDecodeSelf(d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMaptestMammoth2BasicTestMammoth2((*map[testMammoth2Basic]TestMammoth2)(&x.M), d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSliceTestMammoth2((*[]TestMammoth2)(&x.L), d) - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray4int64((*[4]int64)(&x.A), d) - for { - yyj15++ - if yyhl15 { - yyb15 = yyj15 > l - } else { - yyb15 = z.DecCheckBreak() - } - if yyb15 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj15-1, "") - } -} - -func (x codecSelfer19781) enctestMammoth2Basic(v *testMammoth2Basic, e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeUint(uint64(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19781) dectestMammoth2Basic(v *testMammoth2Basic, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := v - yyh1, yyl1 := z.DecSliceHelperStart() - if yyl1 == 0 { - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - z.DecArrayCannotExpand(len(v), yyj1+1) - yydb1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (uint64)(r.DecodeUint64()) - } - } - } - yyh1.End() -} - -func (x codecSelfer19781) encMaptestMammoth2BasicTestMammoth2(v map[testMammoth2Basic]TestMammoth2, e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - yy2 := &yyk1 - yy2.CodecEncodeSelf(e) - z.EncWriteMapElemValue() - yy4 := &yyv1 - yy4.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19781) decMaptestMammoth2BasicTestMammoth2(v *map[testMammoth2Basic]TestMammoth2, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19781 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1872) - yyv1 = make(map[testMammoth2Basic]TestMammoth2, yyrl1) - *v = yyv1 - } - var yymk1 testMammoth2Basic - var yymv1 TestMammoth2 - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1.CodecDecodeSelf(d) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = TestMammoth2{} - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = TestMammoth2{} - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19781) encSliceTestMammoth2(v []TestMammoth2, e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yy2 := &yyv1 - yy2.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19781) decSliceTestMammoth2(v *[]TestMammoth2, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []TestMammoth2{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1840) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]TestMammoth2, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1840) - } else { - yyrl1 = 8 - } - yyv1 = make([]TestMammoth2, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, TestMammoth2{}) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]TestMammoth2, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19781) encArray4int64(v *[4]int64, e *Encoder) { - var h codecSelfer19781 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeInt(int64(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19781) decArray4int64(v *[4]int64, d *Decoder) { - var h codecSelfer19781 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := v - yyh1, yyl1 := z.DecSliceHelperStart() - if yyl1 == 0 { - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - z.DecArrayCannotExpand(len(v), yyj1+1) - yydb1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (int64)(r.DecodeInt64()) - } - } - } - yyh1.End() -} diff --git a/vendor/github.com/ugorji/go/codec/mammoth2_generated_test.go b/vendor/github.com/ugorji/go/codec/mammoth2_generated_test.go deleted file mode 100644 index dd2f80fc5..000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth2_generated_test.go +++ /dev/null @@ -1,278 +0,0 @@ -// +build !notfastpath - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from mammoth2-test.go.tmpl - DO NOT EDIT. - -package codec - -// Increase codecoverage by covering all the codecgen paths, in fast-path and gen-helper.go.... -// -// Add: -// - test file for creating a mammoth generated file as _mammoth_generated.go -// - generate a second mammoth files in a different file: mammoth2_generated_test.go -// - mammoth-test.go.tmpl will do this -// - run codecgen on it, into mammoth2_codecgen_generated_test.go (no build tags) -// - as part of TestMammoth, run it also -// - this will cover all the codecgen, gen-helper, etc in one full run -// - check in mammoth* files into github also -// - then -// -// Now, add some types: -// - some that implement BinaryMarshal, TextMarshal, JSONMarshal, and one that implements none of it -// - create a wrapper type that includes TestMammoth2, with it in slices, and maps, and the custom types -// - this wrapper object is what we work encode/decode (so that the codecgen methods are called) - -// import "encoding/binary" -import "fmt" - -type TestMammoth2 struct { - FIntf interface{} - FptrIntf *interface{} - FString string - FptrString *string - FBytes []byte - FptrBytes *[]byte - FFloat32 float32 - FptrFloat32 *float32 - FFloat64 float64 - FptrFloat64 *float64 - FUint uint - FptrUint *uint - FUint8 uint8 - FptrUint8 *uint8 - FUint16 uint16 - FptrUint16 *uint16 - FUint32 uint32 - FptrUint32 *uint32 - FUint64 uint64 - FptrUint64 *uint64 - FUintptr uintptr - FptrUintptr *uintptr - FInt int - FptrInt *int - FInt8 int8 - FptrInt8 *int8 - FInt16 int16 - FptrInt16 *int16 - FInt32 int32 - FptrInt32 *int32 - FInt64 int64 - FptrInt64 *int64 - FBool bool - FptrBool *bool - - FSliceIntf []interface{} - FptrSliceIntf *[]interface{} - FSliceString []string - FptrSliceString *[]string - FSliceBytes [][]byte - FptrSliceBytes *[][]byte - FSliceFloat32 []float32 - FptrSliceFloat32 *[]float32 - FSliceFloat64 []float64 - FptrSliceFloat64 *[]float64 - FSliceUint []uint - FptrSliceUint *[]uint - FSliceUint16 []uint16 - FptrSliceUint16 *[]uint16 - FSliceUint32 []uint32 - FptrSliceUint32 *[]uint32 - FSliceUint64 []uint64 - FptrSliceUint64 *[]uint64 - FSliceInt []int - FptrSliceInt *[]int - FSliceInt8 []int8 - FptrSliceInt8 *[]int8 - FSliceInt16 []int16 - FptrSliceInt16 *[]int16 - FSliceInt32 []int32 - FptrSliceInt32 *[]int32 - FSliceInt64 []int64 - FptrSliceInt64 *[]int64 - FSliceBool []bool - FptrSliceBool *[]bool - - FMapStringIntf map[string]interface{} - FptrMapStringIntf *map[string]interface{} - FMapStringString map[string]string - FptrMapStringString *map[string]string - FMapStringBytes map[string][]byte - FptrMapStringBytes *map[string][]byte - FMapStringUint map[string]uint - FptrMapStringUint *map[string]uint - FMapStringUint8 map[string]uint8 - FptrMapStringUint8 *map[string]uint8 - FMapStringUint64 map[string]uint64 - FptrMapStringUint64 *map[string]uint64 - FMapStringInt map[string]int - FptrMapStringInt *map[string]int - FMapStringInt64 map[string]int64 - FptrMapStringInt64 *map[string]int64 - FMapStringFloat32 map[string]float32 - FptrMapStringFloat32 *map[string]float32 - FMapStringFloat64 map[string]float64 - FptrMapStringFloat64 *map[string]float64 - FMapStringBool map[string]bool - FptrMapStringBool *map[string]bool - FMapUintIntf map[uint]interface{} - FptrMapUintIntf *map[uint]interface{} - FMapUintString map[uint]string - FptrMapUintString *map[uint]string - FMapUintBytes map[uint][]byte - FptrMapUintBytes *map[uint][]byte - FMapUintUint map[uint]uint - FptrMapUintUint *map[uint]uint - FMapUintUint8 map[uint]uint8 - FptrMapUintUint8 *map[uint]uint8 - FMapUintUint64 map[uint]uint64 - FptrMapUintUint64 *map[uint]uint64 - FMapUintInt map[uint]int - FptrMapUintInt *map[uint]int - FMapUintInt64 map[uint]int64 - FptrMapUintInt64 *map[uint]int64 - FMapUintFloat32 map[uint]float32 - FptrMapUintFloat32 *map[uint]float32 - FMapUintFloat64 map[uint]float64 - FptrMapUintFloat64 *map[uint]float64 - FMapUintBool map[uint]bool - FptrMapUintBool *map[uint]bool - FMapUint8Intf map[uint8]interface{} - FptrMapUint8Intf *map[uint8]interface{} - FMapUint8String map[uint8]string - FptrMapUint8String *map[uint8]string - FMapUint8Bytes map[uint8][]byte - FptrMapUint8Bytes *map[uint8][]byte - FMapUint8Uint map[uint8]uint - FptrMapUint8Uint *map[uint8]uint - FMapUint8Uint8 map[uint8]uint8 - FptrMapUint8Uint8 *map[uint8]uint8 - FMapUint8Uint64 map[uint8]uint64 - FptrMapUint8Uint64 *map[uint8]uint64 - FMapUint8Int map[uint8]int - FptrMapUint8Int *map[uint8]int - FMapUint8Int64 map[uint8]int64 - FptrMapUint8Int64 *map[uint8]int64 - FMapUint8Float32 map[uint8]float32 - FptrMapUint8Float32 *map[uint8]float32 - FMapUint8Float64 map[uint8]float64 - FptrMapUint8Float64 *map[uint8]float64 - FMapUint8Bool map[uint8]bool - FptrMapUint8Bool *map[uint8]bool - FMapUint64Intf map[uint64]interface{} - FptrMapUint64Intf *map[uint64]interface{} - FMapUint64String map[uint64]string - FptrMapUint64String *map[uint64]string - FMapUint64Bytes map[uint64][]byte - FptrMapUint64Bytes *map[uint64][]byte - FMapUint64Uint map[uint64]uint - FptrMapUint64Uint *map[uint64]uint - FMapUint64Uint8 map[uint64]uint8 - FptrMapUint64Uint8 *map[uint64]uint8 - FMapUint64Uint64 map[uint64]uint64 - FptrMapUint64Uint64 *map[uint64]uint64 - FMapUint64Int map[uint64]int - FptrMapUint64Int *map[uint64]int - FMapUint64Int64 map[uint64]int64 - FptrMapUint64Int64 *map[uint64]int64 - FMapUint64Float32 map[uint64]float32 - FptrMapUint64Float32 *map[uint64]float32 - FMapUint64Float64 map[uint64]float64 - FptrMapUint64Float64 *map[uint64]float64 - FMapUint64Bool map[uint64]bool - FptrMapUint64Bool *map[uint64]bool - FMapIntIntf map[int]interface{} - FptrMapIntIntf *map[int]interface{} - FMapIntString map[int]string - FptrMapIntString *map[int]string - FMapIntBytes map[int][]byte - FptrMapIntBytes *map[int][]byte - FMapIntUint map[int]uint - FptrMapIntUint *map[int]uint - FMapIntUint8 map[int]uint8 - FptrMapIntUint8 *map[int]uint8 - FMapIntUint64 map[int]uint64 - FptrMapIntUint64 *map[int]uint64 - FMapIntInt map[int]int - FptrMapIntInt *map[int]int - FMapIntInt64 map[int]int64 - FptrMapIntInt64 *map[int]int64 - FMapIntFloat32 map[int]float32 - FptrMapIntFloat32 *map[int]float32 - FMapIntFloat64 map[int]float64 - FptrMapIntFloat64 *map[int]float64 - FMapIntBool map[int]bool - FptrMapIntBool *map[int]bool - FMapInt64Intf map[int64]interface{} - FptrMapInt64Intf *map[int64]interface{} - FMapInt64String map[int64]string - FptrMapInt64String *map[int64]string - FMapInt64Bytes map[int64][]byte - FptrMapInt64Bytes *map[int64][]byte - FMapInt64Uint map[int64]uint - FptrMapInt64Uint *map[int64]uint - FMapInt64Uint8 map[int64]uint8 - FptrMapInt64Uint8 *map[int64]uint8 - FMapInt64Uint64 map[int64]uint64 - FptrMapInt64Uint64 *map[int64]uint64 - FMapInt64Int map[int64]int - FptrMapInt64Int *map[int64]int - FMapInt64Int64 map[int64]int64 - FptrMapInt64Int64 *map[int64]int64 - FMapInt64Float32 map[int64]float32 - FptrMapInt64Float32 *map[int64]float32 - FMapInt64Float64 map[int64]float64 - FptrMapInt64Float64 *map[int64]float64 - FMapInt64Bool map[int64]bool - FptrMapInt64Bool *map[int64]bool -} - -// ----------- - -type testMammoth2Binary uint64 - -func (x testMammoth2Binary) MarshalBinary() (data []byte, err error) { - data = make([]byte, 8) - bigen.PutUint64(data, uint64(x)) - return -} -func (x *testMammoth2Binary) UnmarshalBinary(data []byte) (err error) { - *x = testMammoth2Binary(bigen.Uint64(data)) - return -} - -type testMammoth2Text uint64 - -func (x testMammoth2Text) MarshalText() (data []byte, err error) { - data = []byte(fmt.Sprintf("%b", uint64(x))) - return -} -func (x *testMammoth2Text) UnmarshalText(data []byte) (err error) { - _, err = fmt.Sscanf(string(data), "%b", (*uint64)(x)) - return -} - -type testMammoth2Json uint64 - -func (x testMammoth2Json) MarshalJSON() (data []byte, err error) { - data = []byte(fmt.Sprintf("%v", uint64(x))) - return -} -func (x *testMammoth2Json) UnmarshalJSON(data []byte) (err error) { - _, err = fmt.Sscanf(string(data), "%v", (*uint64)(x)) - return -} - -type testMammoth2Basic [4]uint64 - -type TestMammoth2Wrapper struct { - V TestMammoth2 - T testMammoth2Text - B testMammoth2Binary - J testMammoth2Json - C testMammoth2Basic - M map[testMammoth2Basic]TestMammoth2 - L []TestMammoth2 - A [4]int64 -} diff --git a/vendor/github.com/ugorji/go/codec/mammoth_generated_test.go b/vendor/github.com/ugorji/go/codec/mammoth_generated_test.go deleted file mode 100644 index 981b4f4aa..000000000 --- a/vendor/github.com/ugorji/go/codec/mammoth_generated_test.go +++ /dev/null @@ -1,4515 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from mammoth-test.go.tmpl - DO NOT EDIT. - -package codec - -import "testing" -import "fmt" - -// TestMammoth has all the different paths optimized in fast-path -// It has all the primitives, slices and maps. -// -// For each of those types, it has a pointer and a non-pointer field. - -func init() { _ = fmt.Printf } // so we can include fmt as needed - -type TestMammoth struct { - FIntf interface{} - FptrIntf *interface{} - FString string - FptrString *string - FBytes []byte - FptrBytes *[]byte - FFloat32 float32 - FptrFloat32 *float32 - FFloat64 float64 - FptrFloat64 *float64 - FUint uint - FptrUint *uint - FUint8 uint8 - FptrUint8 *uint8 - FUint16 uint16 - FptrUint16 *uint16 - FUint32 uint32 - FptrUint32 *uint32 - FUint64 uint64 - FptrUint64 *uint64 - FUintptr uintptr - FptrUintptr *uintptr - FInt int - FptrInt *int - FInt8 int8 - FptrInt8 *int8 - FInt16 int16 - FptrInt16 *int16 - FInt32 int32 - FptrInt32 *int32 - FInt64 int64 - FptrInt64 *int64 - FBool bool - FptrBool *bool - - FSliceIntf []interface{} - FptrSliceIntf *[]interface{} - FSliceString []string - FptrSliceString *[]string - FSliceBytes [][]byte - FptrSliceBytes *[][]byte - FSliceFloat32 []float32 - FptrSliceFloat32 *[]float32 - FSliceFloat64 []float64 - FptrSliceFloat64 *[]float64 - FSliceUint []uint - FptrSliceUint *[]uint - FSliceUint16 []uint16 - FptrSliceUint16 *[]uint16 - FSliceUint32 []uint32 - FptrSliceUint32 *[]uint32 - FSliceUint64 []uint64 - FptrSliceUint64 *[]uint64 - FSliceInt []int - FptrSliceInt *[]int - FSliceInt8 []int8 - FptrSliceInt8 *[]int8 - FSliceInt16 []int16 - FptrSliceInt16 *[]int16 - FSliceInt32 []int32 - FptrSliceInt32 *[]int32 - FSliceInt64 []int64 - FptrSliceInt64 *[]int64 - FSliceBool []bool - FptrSliceBool *[]bool - - FMapStringIntf map[string]interface{} - FptrMapStringIntf *map[string]interface{} - FMapStringString map[string]string - FptrMapStringString *map[string]string - FMapStringBytes map[string][]byte - FptrMapStringBytes *map[string][]byte - FMapStringUint map[string]uint - FptrMapStringUint *map[string]uint - FMapStringUint8 map[string]uint8 - FptrMapStringUint8 *map[string]uint8 - FMapStringUint64 map[string]uint64 - FptrMapStringUint64 *map[string]uint64 - FMapStringInt map[string]int - FptrMapStringInt *map[string]int - FMapStringInt64 map[string]int64 - FptrMapStringInt64 *map[string]int64 - FMapStringFloat32 map[string]float32 - FptrMapStringFloat32 *map[string]float32 - FMapStringFloat64 map[string]float64 - FptrMapStringFloat64 *map[string]float64 - FMapStringBool map[string]bool - FptrMapStringBool *map[string]bool - FMapUintIntf map[uint]interface{} - FptrMapUintIntf *map[uint]interface{} - FMapUintString map[uint]string - FptrMapUintString *map[uint]string - FMapUintBytes map[uint][]byte - FptrMapUintBytes *map[uint][]byte - FMapUintUint map[uint]uint - FptrMapUintUint *map[uint]uint - FMapUintUint8 map[uint]uint8 - FptrMapUintUint8 *map[uint]uint8 - FMapUintUint64 map[uint]uint64 - FptrMapUintUint64 *map[uint]uint64 - FMapUintInt map[uint]int - FptrMapUintInt *map[uint]int - FMapUintInt64 map[uint]int64 - FptrMapUintInt64 *map[uint]int64 - FMapUintFloat32 map[uint]float32 - FptrMapUintFloat32 *map[uint]float32 - FMapUintFloat64 map[uint]float64 - FptrMapUintFloat64 *map[uint]float64 - FMapUintBool map[uint]bool - FptrMapUintBool *map[uint]bool - FMapUint8Intf map[uint8]interface{} - FptrMapUint8Intf *map[uint8]interface{} - FMapUint8String map[uint8]string - FptrMapUint8String *map[uint8]string - FMapUint8Bytes map[uint8][]byte - FptrMapUint8Bytes *map[uint8][]byte - FMapUint8Uint map[uint8]uint - FptrMapUint8Uint *map[uint8]uint - FMapUint8Uint8 map[uint8]uint8 - FptrMapUint8Uint8 *map[uint8]uint8 - FMapUint8Uint64 map[uint8]uint64 - FptrMapUint8Uint64 *map[uint8]uint64 - FMapUint8Int map[uint8]int - FptrMapUint8Int *map[uint8]int - FMapUint8Int64 map[uint8]int64 - FptrMapUint8Int64 *map[uint8]int64 - FMapUint8Float32 map[uint8]float32 - FptrMapUint8Float32 *map[uint8]float32 - FMapUint8Float64 map[uint8]float64 - FptrMapUint8Float64 *map[uint8]float64 - FMapUint8Bool map[uint8]bool - FptrMapUint8Bool *map[uint8]bool - FMapUint64Intf map[uint64]interface{} - FptrMapUint64Intf *map[uint64]interface{} - FMapUint64String map[uint64]string - FptrMapUint64String *map[uint64]string - FMapUint64Bytes map[uint64][]byte - FptrMapUint64Bytes *map[uint64][]byte - FMapUint64Uint map[uint64]uint - FptrMapUint64Uint *map[uint64]uint - FMapUint64Uint8 map[uint64]uint8 - FptrMapUint64Uint8 *map[uint64]uint8 - FMapUint64Uint64 map[uint64]uint64 - FptrMapUint64Uint64 *map[uint64]uint64 - FMapUint64Int map[uint64]int - FptrMapUint64Int *map[uint64]int - FMapUint64Int64 map[uint64]int64 - FptrMapUint64Int64 *map[uint64]int64 - FMapUint64Float32 map[uint64]float32 - FptrMapUint64Float32 *map[uint64]float32 - FMapUint64Float64 map[uint64]float64 - FptrMapUint64Float64 *map[uint64]float64 - FMapUint64Bool map[uint64]bool - FptrMapUint64Bool *map[uint64]bool - FMapIntIntf map[int]interface{} - FptrMapIntIntf *map[int]interface{} - FMapIntString map[int]string - FptrMapIntString *map[int]string - FMapIntBytes map[int][]byte - FptrMapIntBytes *map[int][]byte - FMapIntUint map[int]uint - FptrMapIntUint *map[int]uint - FMapIntUint8 map[int]uint8 - FptrMapIntUint8 *map[int]uint8 - FMapIntUint64 map[int]uint64 - FptrMapIntUint64 *map[int]uint64 - FMapIntInt map[int]int - FptrMapIntInt *map[int]int - FMapIntInt64 map[int]int64 - FptrMapIntInt64 *map[int]int64 - FMapIntFloat32 map[int]float32 - FptrMapIntFloat32 *map[int]float32 - FMapIntFloat64 map[int]float64 - FptrMapIntFloat64 *map[int]float64 - FMapIntBool map[int]bool - FptrMapIntBool *map[int]bool - FMapInt64Intf map[int64]interface{} - FptrMapInt64Intf *map[int64]interface{} - FMapInt64String map[int64]string - FptrMapInt64String *map[int64]string - FMapInt64Bytes map[int64][]byte - FptrMapInt64Bytes *map[int64][]byte - FMapInt64Uint map[int64]uint - FptrMapInt64Uint *map[int64]uint - FMapInt64Uint8 map[int64]uint8 - FptrMapInt64Uint8 *map[int64]uint8 - FMapInt64Uint64 map[int64]uint64 - FptrMapInt64Uint64 *map[int64]uint64 - FMapInt64Int map[int64]int - FptrMapInt64Int *map[int64]int - FMapInt64Int64 map[int64]int64 - FptrMapInt64Int64 *map[int64]int64 - FMapInt64Float32 map[int64]float32 - FptrMapInt64Float32 *map[int64]float32 - FMapInt64Float64 map[int64]float64 - FptrMapInt64Float64 *map[int64]float64 - FMapInt64Bool map[int64]bool - FptrMapInt64Bool *map[int64]bool -} - -type typMbsSliceIntf []interface{} - -func (_ typMbsSliceIntf) MapBySlice() {} - -type typMbsSliceString []string - -func (_ typMbsSliceString) MapBySlice() {} - -type typMbsSliceBytes [][]byte - -func (_ typMbsSliceBytes) MapBySlice() {} - -type typMbsSliceFloat32 []float32 - -func (_ typMbsSliceFloat32) MapBySlice() {} - -type typMbsSliceFloat64 []float64 - -func (_ typMbsSliceFloat64) MapBySlice() {} - -type typMbsSliceUint []uint - -func (_ typMbsSliceUint) MapBySlice() {} - -type typMbsSliceUint16 []uint16 - -func (_ typMbsSliceUint16) MapBySlice() {} - -type typMbsSliceUint32 []uint32 - -func (_ typMbsSliceUint32) MapBySlice() {} - -type typMbsSliceUint64 []uint64 - -func (_ typMbsSliceUint64) MapBySlice() {} - -type typMbsSliceInt []int - -func (_ typMbsSliceInt) MapBySlice() {} - -type typMbsSliceInt8 []int8 - -func (_ typMbsSliceInt8) MapBySlice() {} - -type typMbsSliceInt16 []int16 - -func (_ typMbsSliceInt16) MapBySlice() {} - -type typMbsSliceInt32 []int32 - -func (_ typMbsSliceInt32) MapBySlice() {} - -type typMbsSliceInt64 []int64 - -func (_ typMbsSliceInt64) MapBySlice() {} - -type typMbsSliceBool []bool - -func (_ typMbsSliceBool) MapBySlice() {} - -type typMapMapStringIntf map[string]interface{} -type typMapMapStringString map[string]string -type typMapMapStringBytes map[string][]byte -type typMapMapStringUint map[string]uint -type typMapMapStringUint8 map[string]uint8 -type typMapMapStringUint64 map[string]uint64 -type typMapMapStringInt map[string]int -type typMapMapStringInt64 map[string]int64 -type typMapMapStringFloat32 map[string]float32 -type typMapMapStringFloat64 map[string]float64 -type typMapMapStringBool map[string]bool -type typMapMapUintIntf map[uint]interface{} -type typMapMapUintString map[uint]string -type typMapMapUintBytes map[uint][]byte -type typMapMapUintUint map[uint]uint -type typMapMapUintUint8 map[uint]uint8 -type typMapMapUintUint64 map[uint]uint64 -type typMapMapUintInt map[uint]int -type typMapMapUintInt64 map[uint]int64 -type typMapMapUintFloat32 map[uint]float32 -type typMapMapUintFloat64 map[uint]float64 -type typMapMapUintBool map[uint]bool -type typMapMapUint8Intf map[uint8]interface{} -type typMapMapUint8String map[uint8]string -type typMapMapUint8Bytes map[uint8][]byte -type typMapMapUint8Uint map[uint8]uint -type typMapMapUint8Uint8 map[uint8]uint8 -type typMapMapUint8Uint64 map[uint8]uint64 -type typMapMapUint8Int map[uint8]int -type typMapMapUint8Int64 map[uint8]int64 -type typMapMapUint8Float32 map[uint8]float32 -type typMapMapUint8Float64 map[uint8]float64 -type typMapMapUint8Bool map[uint8]bool -type typMapMapUint64Intf map[uint64]interface{} -type typMapMapUint64String map[uint64]string -type typMapMapUint64Bytes map[uint64][]byte -type typMapMapUint64Uint map[uint64]uint -type typMapMapUint64Uint8 map[uint64]uint8 -type typMapMapUint64Uint64 map[uint64]uint64 -type typMapMapUint64Int map[uint64]int -type typMapMapUint64Int64 map[uint64]int64 -type typMapMapUint64Float32 map[uint64]float32 -type typMapMapUint64Float64 map[uint64]float64 -type typMapMapUint64Bool map[uint64]bool -type typMapMapIntIntf map[int]interface{} -type typMapMapIntString map[int]string -type typMapMapIntBytes map[int][]byte -type typMapMapIntUint map[int]uint -type typMapMapIntUint8 map[int]uint8 -type typMapMapIntUint64 map[int]uint64 -type typMapMapIntInt map[int]int -type typMapMapIntInt64 map[int]int64 -type typMapMapIntFloat32 map[int]float32 -type typMapMapIntFloat64 map[int]float64 -type typMapMapIntBool map[int]bool -type typMapMapInt64Intf map[int64]interface{} -type typMapMapInt64String map[int64]string -type typMapMapInt64Bytes map[int64][]byte -type typMapMapInt64Uint map[int64]uint -type typMapMapInt64Uint8 map[int64]uint8 -type typMapMapInt64Uint64 map[int64]uint64 -type typMapMapInt64Int map[int64]int -type typMapMapInt64Int64 map[int64]int64 -type typMapMapInt64Float32 map[int64]float32 -type typMapMapInt64Float64 map[int64]float64 -type typMapMapInt64Bool map[int64]bool - -func doTestMammothSlices(t *testing.T, h Handle) { - var v17va [8]interface{} - for _, v := range [][]interface{}{nil, {}, {"string-is-an-interface-2", nil, nil, "string-is-an-interface-3"}} { - var v17v1, v17v2 []interface{} - var bs17 []byte - v17v1 = v - bs17 = testMarshalErr(v17v1, h, t, "enc-slice-v17") - if v != nil { - if v == nil { - v17v2 = nil - } else { - v17v2 = make([]interface{}, len(v)) - } - testUnmarshalErr(v17v2, bs17, h, t, "dec-slice-v17") - testDeepEqualErr(v17v1, v17v2, t, "equal-slice-v17") - if v == nil { - v17v2 = nil - } else { - v17v2 = make([]interface{}, len(v)) - } - testUnmarshalErr(rv4i(v17v2), bs17, h, t, "dec-slice-v17-noaddr") // non-addressable value - testDeepEqualErr(v17v1, v17v2, t, "equal-slice-v17-noaddr") - } - // ... - bs17 = testMarshalErr(&v17v1, h, t, "enc-slice-v17-p") - v17v2 = nil - testUnmarshalErr(&v17v2, bs17, h, t, "dec-slice-v17-p") - testDeepEqualErr(v17v1, v17v2, t, "equal-slice-v17-p") - v17va = [8]interface{}{} // clear the array - v17v2 = v17va[:1:1] - testUnmarshalErr(&v17v2, bs17, h, t, "dec-slice-v17-p-1") - testDeepEqualErr(v17v1, v17v2, t, "equal-slice-v17-p-1") - v17va = [8]interface{}{} // clear the array - v17v2 = v17va[:len(v17v1):len(v17v1)] - testUnmarshalErr(&v17v2, bs17, h, t, "dec-slice-v17-p-len") - testDeepEqualErr(v17v1, v17v2, t, "equal-slice-v17-p-len") - v17va = [8]interface{}{} // clear the array - v17v2 = v17va[:] - testUnmarshalErr(&v17v2, bs17, h, t, "dec-slice-v17-p-cap") - testDeepEqualErr(v17v1, v17v2, t, "equal-slice-v17-p-cap") - if len(v17v1) > 1 { - v17va = [8]interface{}{} // clear the array - testUnmarshalErr((&v17va)[:len(v17v1)], bs17, h, t, "dec-slice-v17-p-len-noaddr") - testDeepEqualErr(v17v1, v17va[:len(v17v1)], t, "equal-slice-v17-p-len-noaddr") - v17va = [8]interface{}{} // clear the array - testUnmarshalErr((&v17va)[:], bs17, h, t, "dec-slice-v17-p-cap-noaddr") - testDeepEqualErr(v17v1, v17va[:len(v17v1)], t, "equal-slice-v17-p-cap-noaddr") - } - // ... - var v17v3, v17v4 typMbsSliceIntf - v17v2 = nil - if v != nil { - v17v2 = make([]interface{}, len(v)) - } - v17v3 = typMbsSliceIntf(v17v1) - v17v4 = typMbsSliceIntf(v17v2) - if v != nil { - bs17 = testMarshalErr(v17v3, h, t, "enc-slice-v17-custom") - testUnmarshalErr(v17v4, bs17, h, t, "dec-slice-v17-custom") - testDeepEqualErr(v17v3, v17v4, t, "equal-slice-v17-custom") - } - bs17 = testMarshalErr(&v17v3, h, t, "enc-slice-v17-custom-p") - v17v2 = nil - v17v4 = typMbsSliceIntf(v17v2) - testUnmarshalErr(&v17v4, bs17, h, t, "dec-slice-v17-custom-p") - testDeepEqualErr(v17v3, v17v4, t, "equal-slice-v17-custom-p") - } - var v18va [8]string - for _, v := range [][]string{nil, {}, {"some-string-2", "", "", "some-string-3"}} { - var v18v1, v18v2 []string - var bs18 []byte - v18v1 = v - bs18 = testMarshalErr(v18v1, h, t, "enc-slice-v18") - if v != nil { - if v == nil { - v18v2 = nil - } else { - v18v2 = make([]string, len(v)) - } - testUnmarshalErr(v18v2, bs18, h, t, "dec-slice-v18") - testDeepEqualErr(v18v1, v18v2, t, "equal-slice-v18") - if v == nil { - v18v2 = nil - } else { - v18v2 = make([]string, len(v)) - } - testUnmarshalErr(rv4i(v18v2), bs18, h, t, "dec-slice-v18-noaddr") // non-addressable value - testDeepEqualErr(v18v1, v18v2, t, "equal-slice-v18-noaddr") - } - // ... - bs18 = testMarshalErr(&v18v1, h, t, "enc-slice-v18-p") - v18v2 = nil - testUnmarshalErr(&v18v2, bs18, h, t, "dec-slice-v18-p") - testDeepEqualErr(v18v1, v18v2, t, "equal-slice-v18-p") - v18va = [8]string{} // clear the array - v18v2 = v18va[:1:1] - testUnmarshalErr(&v18v2, bs18, h, t, "dec-slice-v18-p-1") - testDeepEqualErr(v18v1, v18v2, t, "equal-slice-v18-p-1") - v18va = [8]string{} // clear the array - v18v2 = v18va[:len(v18v1):len(v18v1)] - testUnmarshalErr(&v18v2, bs18, h, t, "dec-slice-v18-p-len") - testDeepEqualErr(v18v1, v18v2, t, "equal-slice-v18-p-len") - v18va = [8]string{} // clear the array - v18v2 = v18va[:] - testUnmarshalErr(&v18v2, bs18, h, t, "dec-slice-v18-p-cap") - testDeepEqualErr(v18v1, v18v2, t, "equal-slice-v18-p-cap") - if len(v18v1) > 1 { - v18va = [8]string{} // clear the array - testUnmarshalErr((&v18va)[:len(v18v1)], bs18, h, t, "dec-slice-v18-p-len-noaddr") - testDeepEqualErr(v18v1, v18va[:len(v18v1)], t, "equal-slice-v18-p-len-noaddr") - v18va = [8]string{} // clear the array - testUnmarshalErr((&v18va)[:], bs18, h, t, "dec-slice-v18-p-cap-noaddr") - testDeepEqualErr(v18v1, v18va[:len(v18v1)], t, "equal-slice-v18-p-cap-noaddr") - } - // ... - var v18v3, v18v4 typMbsSliceString - v18v2 = nil - if v != nil { - v18v2 = make([]string, len(v)) - } - v18v3 = typMbsSliceString(v18v1) - v18v4 = typMbsSliceString(v18v2) - if v != nil { - bs18 = testMarshalErr(v18v3, h, t, "enc-slice-v18-custom") - testUnmarshalErr(v18v4, bs18, h, t, "dec-slice-v18-custom") - testDeepEqualErr(v18v3, v18v4, t, "equal-slice-v18-custom") - } - bs18 = testMarshalErr(&v18v3, h, t, "enc-slice-v18-custom-p") - v18v2 = nil - v18v4 = typMbsSliceString(v18v2) - testUnmarshalErr(&v18v4, bs18, h, t, "dec-slice-v18-custom-p") - testDeepEqualErr(v18v3, v18v4, t, "equal-slice-v18-custom-p") - } - var v19va [8][]byte - for _, v := range [][][]byte{nil, {}, {[]byte("some-string-2"), nil, nil, []byte("some-string-3")}} { - var v19v1, v19v2 [][]byte - var bs19 []byte - v19v1 = v - bs19 = testMarshalErr(v19v1, h, t, "enc-slice-v19") - if v != nil { - if v == nil { - v19v2 = nil - } else { - v19v2 = make([][]byte, len(v)) - } - testUnmarshalErr(v19v2, bs19, h, t, "dec-slice-v19") - testDeepEqualErr(v19v1, v19v2, t, "equal-slice-v19") - if v == nil { - v19v2 = nil - } else { - v19v2 = make([][]byte, len(v)) - } - testUnmarshalErr(rv4i(v19v2), bs19, h, t, "dec-slice-v19-noaddr") // non-addressable value - testDeepEqualErr(v19v1, v19v2, t, "equal-slice-v19-noaddr") - } - // ... - bs19 = testMarshalErr(&v19v1, h, t, "enc-slice-v19-p") - v19v2 = nil - testUnmarshalErr(&v19v2, bs19, h, t, "dec-slice-v19-p") - testDeepEqualErr(v19v1, v19v2, t, "equal-slice-v19-p") - v19va = [8][]byte{} // clear the array - v19v2 = v19va[:1:1] - testUnmarshalErr(&v19v2, bs19, h, t, "dec-slice-v19-p-1") - testDeepEqualErr(v19v1, v19v2, t, "equal-slice-v19-p-1") - v19va = [8][]byte{} // clear the array - v19v2 = v19va[:len(v19v1):len(v19v1)] - testUnmarshalErr(&v19v2, bs19, h, t, "dec-slice-v19-p-len") - testDeepEqualErr(v19v1, v19v2, t, "equal-slice-v19-p-len") - v19va = [8][]byte{} // clear the array - v19v2 = v19va[:] - testUnmarshalErr(&v19v2, bs19, h, t, "dec-slice-v19-p-cap") - testDeepEqualErr(v19v1, v19v2, t, "equal-slice-v19-p-cap") - if len(v19v1) > 1 { - v19va = [8][]byte{} // clear the array - testUnmarshalErr((&v19va)[:len(v19v1)], bs19, h, t, "dec-slice-v19-p-len-noaddr") - testDeepEqualErr(v19v1, v19va[:len(v19v1)], t, "equal-slice-v19-p-len-noaddr") - v19va = [8][]byte{} // clear the array - testUnmarshalErr((&v19va)[:], bs19, h, t, "dec-slice-v19-p-cap-noaddr") - testDeepEqualErr(v19v1, v19va[:len(v19v1)], t, "equal-slice-v19-p-cap-noaddr") - } - // ... - var v19v3, v19v4 typMbsSliceBytes - v19v2 = nil - if v != nil { - v19v2 = make([][]byte, len(v)) - } - v19v3 = typMbsSliceBytes(v19v1) - v19v4 = typMbsSliceBytes(v19v2) - if v != nil { - bs19 = testMarshalErr(v19v3, h, t, "enc-slice-v19-custom") - testUnmarshalErr(v19v4, bs19, h, t, "dec-slice-v19-custom") - testDeepEqualErr(v19v3, v19v4, t, "equal-slice-v19-custom") - } - bs19 = testMarshalErr(&v19v3, h, t, "enc-slice-v19-custom-p") - v19v2 = nil - v19v4 = typMbsSliceBytes(v19v2) - testUnmarshalErr(&v19v4, bs19, h, t, "dec-slice-v19-custom-p") - testDeepEqualErr(v19v3, v19v4, t, "equal-slice-v19-custom-p") - } - var v20va [8]float32 - for _, v := range [][]float32{nil, {}, {22.2, 0, 0, 33.3e3}} { - var v20v1, v20v2 []float32 - var bs20 []byte - v20v1 = v - bs20 = testMarshalErr(v20v1, h, t, "enc-slice-v20") - if v != nil { - if v == nil { - v20v2 = nil - } else { - v20v2 = make([]float32, len(v)) - } - testUnmarshalErr(v20v2, bs20, h, t, "dec-slice-v20") - testDeepEqualErr(v20v1, v20v2, t, "equal-slice-v20") - if v == nil { - v20v2 = nil - } else { - v20v2 = make([]float32, len(v)) - } - testUnmarshalErr(rv4i(v20v2), bs20, h, t, "dec-slice-v20-noaddr") // non-addressable value - testDeepEqualErr(v20v1, v20v2, t, "equal-slice-v20-noaddr") - } - // ... - bs20 = testMarshalErr(&v20v1, h, t, "enc-slice-v20-p") - v20v2 = nil - testUnmarshalErr(&v20v2, bs20, h, t, "dec-slice-v20-p") - testDeepEqualErr(v20v1, v20v2, t, "equal-slice-v20-p") - v20va = [8]float32{} // clear the array - v20v2 = v20va[:1:1] - testUnmarshalErr(&v20v2, bs20, h, t, "dec-slice-v20-p-1") - testDeepEqualErr(v20v1, v20v2, t, "equal-slice-v20-p-1") - v20va = [8]float32{} // clear the array - v20v2 = v20va[:len(v20v1):len(v20v1)] - testUnmarshalErr(&v20v2, bs20, h, t, "dec-slice-v20-p-len") - testDeepEqualErr(v20v1, v20v2, t, "equal-slice-v20-p-len") - v20va = [8]float32{} // clear the array - v20v2 = v20va[:] - testUnmarshalErr(&v20v2, bs20, h, t, "dec-slice-v20-p-cap") - testDeepEqualErr(v20v1, v20v2, t, "equal-slice-v20-p-cap") - if len(v20v1) > 1 { - v20va = [8]float32{} // clear the array - testUnmarshalErr((&v20va)[:len(v20v1)], bs20, h, t, "dec-slice-v20-p-len-noaddr") - testDeepEqualErr(v20v1, v20va[:len(v20v1)], t, "equal-slice-v20-p-len-noaddr") - v20va = [8]float32{} // clear the array - testUnmarshalErr((&v20va)[:], bs20, h, t, "dec-slice-v20-p-cap-noaddr") - testDeepEqualErr(v20v1, v20va[:len(v20v1)], t, "equal-slice-v20-p-cap-noaddr") - } - // ... - var v20v3, v20v4 typMbsSliceFloat32 - v20v2 = nil - if v != nil { - v20v2 = make([]float32, len(v)) - } - v20v3 = typMbsSliceFloat32(v20v1) - v20v4 = typMbsSliceFloat32(v20v2) - if v != nil { - bs20 = testMarshalErr(v20v3, h, t, "enc-slice-v20-custom") - testUnmarshalErr(v20v4, bs20, h, t, "dec-slice-v20-custom") - testDeepEqualErr(v20v3, v20v4, t, "equal-slice-v20-custom") - } - bs20 = testMarshalErr(&v20v3, h, t, "enc-slice-v20-custom-p") - v20v2 = nil - v20v4 = typMbsSliceFloat32(v20v2) - testUnmarshalErr(&v20v4, bs20, h, t, "dec-slice-v20-custom-p") - testDeepEqualErr(v20v3, v20v4, t, "equal-slice-v20-custom-p") - } - var v21va [8]float64 - for _, v := range [][]float64{nil, {}, {11.1, 0, 0, 22.2}} { - var v21v1, v21v2 []float64 - var bs21 []byte - v21v1 = v - bs21 = testMarshalErr(v21v1, h, t, "enc-slice-v21") - if v != nil { - if v == nil { - v21v2 = nil - } else { - v21v2 = make([]float64, len(v)) - } - testUnmarshalErr(v21v2, bs21, h, t, "dec-slice-v21") - testDeepEqualErr(v21v1, v21v2, t, "equal-slice-v21") - if v == nil { - v21v2 = nil - } else { - v21v2 = make([]float64, len(v)) - } - testUnmarshalErr(rv4i(v21v2), bs21, h, t, "dec-slice-v21-noaddr") // non-addressable value - testDeepEqualErr(v21v1, v21v2, t, "equal-slice-v21-noaddr") - } - // ... - bs21 = testMarshalErr(&v21v1, h, t, "enc-slice-v21-p") - v21v2 = nil - testUnmarshalErr(&v21v2, bs21, h, t, "dec-slice-v21-p") - testDeepEqualErr(v21v1, v21v2, t, "equal-slice-v21-p") - v21va = [8]float64{} // clear the array - v21v2 = v21va[:1:1] - testUnmarshalErr(&v21v2, bs21, h, t, "dec-slice-v21-p-1") - testDeepEqualErr(v21v1, v21v2, t, "equal-slice-v21-p-1") - v21va = [8]float64{} // clear the array - v21v2 = v21va[:len(v21v1):len(v21v1)] - testUnmarshalErr(&v21v2, bs21, h, t, "dec-slice-v21-p-len") - testDeepEqualErr(v21v1, v21v2, t, "equal-slice-v21-p-len") - v21va = [8]float64{} // clear the array - v21v2 = v21va[:] - testUnmarshalErr(&v21v2, bs21, h, t, "dec-slice-v21-p-cap") - testDeepEqualErr(v21v1, v21v2, t, "equal-slice-v21-p-cap") - if len(v21v1) > 1 { - v21va = [8]float64{} // clear the array - testUnmarshalErr((&v21va)[:len(v21v1)], bs21, h, t, "dec-slice-v21-p-len-noaddr") - testDeepEqualErr(v21v1, v21va[:len(v21v1)], t, "equal-slice-v21-p-len-noaddr") - v21va = [8]float64{} // clear the array - testUnmarshalErr((&v21va)[:], bs21, h, t, "dec-slice-v21-p-cap-noaddr") - testDeepEqualErr(v21v1, v21va[:len(v21v1)], t, "equal-slice-v21-p-cap-noaddr") - } - // ... - var v21v3, v21v4 typMbsSliceFloat64 - v21v2 = nil - if v != nil { - v21v2 = make([]float64, len(v)) - } - v21v3 = typMbsSliceFloat64(v21v1) - v21v4 = typMbsSliceFloat64(v21v2) - if v != nil { - bs21 = testMarshalErr(v21v3, h, t, "enc-slice-v21-custom") - testUnmarshalErr(v21v4, bs21, h, t, "dec-slice-v21-custom") - testDeepEqualErr(v21v3, v21v4, t, "equal-slice-v21-custom") - } - bs21 = testMarshalErr(&v21v3, h, t, "enc-slice-v21-custom-p") - v21v2 = nil - v21v4 = typMbsSliceFloat64(v21v2) - testUnmarshalErr(&v21v4, bs21, h, t, "dec-slice-v21-custom-p") - testDeepEqualErr(v21v3, v21v4, t, "equal-slice-v21-custom-p") - } - var v22va [8]uint - for _, v := range [][]uint{nil, {}, {77, 0, 0, 127}} { - var v22v1, v22v2 []uint - var bs22 []byte - v22v1 = v - bs22 = testMarshalErr(v22v1, h, t, "enc-slice-v22") - if v != nil { - if v == nil { - v22v2 = nil - } else { - v22v2 = make([]uint, len(v)) - } - testUnmarshalErr(v22v2, bs22, h, t, "dec-slice-v22") - testDeepEqualErr(v22v1, v22v2, t, "equal-slice-v22") - if v == nil { - v22v2 = nil - } else { - v22v2 = make([]uint, len(v)) - } - testUnmarshalErr(rv4i(v22v2), bs22, h, t, "dec-slice-v22-noaddr") // non-addressable value - testDeepEqualErr(v22v1, v22v2, t, "equal-slice-v22-noaddr") - } - // ... - bs22 = testMarshalErr(&v22v1, h, t, "enc-slice-v22-p") - v22v2 = nil - testUnmarshalErr(&v22v2, bs22, h, t, "dec-slice-v22-p") - testDeepEqualErr(v22v1, v22v2, t, "equal-slice-v22-p") - v22va = [8]uint{} // clear the array - v22v2 = v22va[:1:1] - testUnmarshalErr(&v22v2, bs22, h, t, "dec-slice-v22-p-1") - testDeepEqualErr(v22v1, v22v2, t, "equal-slice-v22-p-1") - v22va = [8]uint{} // clear the array - v22v2 = v22va[:len(v22v1):len(v22v1)] - testUnmarshalErr(&v22v2, bs22, h, t, "dec-slice-v22-p-len") - testDeepEqualErr(v22v1, v22v2, t, "equal-slice-v22-p-len") - v22va = [8]uint{} // clear the array - v22v2 = v22va[:] - testUnmarshalErr(&v22v2, bs22, h, t, "dec-slice-v22-p-cap") - testDeepEqualErr(v22v1, v22v2, t, "equal-slice-v22-p-cap") - if len(v22v1) > 1 { - v22va = [8]uint{} // clear the array - testUnmarshalErr((&v22va)[:len(v22v1)], bs22, h, t, "dec-slice-v22-p-len-noaddr") - testDeepEqualErr(v22v1, v22va[:len(v22v1)], t, "equal-slice-v22-p-len-noaddr") - v22va = [8]uint{} // clear the array - testUnmarshalErr((&v22va)[:], bs22, h, t, "dec-slice-v22-p-cap-noaddr") - testDeepEqualErr(v22v1, v22va[:len(v22v1)], t, "equal-slice-v22-p-cap-noaddr") - } - // ... - var v22v3, v22v4 typMbsSliceUint - v22v2 = nil - if v != nil { - v22v2 = make([]uint, len(v)) - } - v22v3 = typMbsSliceUint(v22v1) - v22v4 = typMbsSliceUint(v22v2) - if v != nil { - bs22 = testMarshalErr(v22v3, h, t, "enc-slice-v22-custom") - testUnmarshalErr(v22v4, bs22, h, t, "dec-slice-v22-custom") - testDeepEqualErr(v22v3, v22v4, t, "equal-slice-v22-custom") - } - bs22 = testMarshalErr(&v22v3, h, t, "enc-slice-v22-custom-p") - v22v2 = nil - v22v4 = typMbsSliceUint(v22v2) - testUnmarshalErr(&v22v4, bs22, h, t, "dec-slice-v22-custom-p") - testDeepEqualErr(v22v3, v22v4, t, "equal-slice-v22-custom-p") - } - var v23va [8]uint16 - for _, v := range [][]uint16{nil, {}, {111, 0, 0, 77}} { - var v23v1, v23v2 []uint16 - var bs23 []byte - v23v1 = v - bs23 = testMarshalErr(v23v1, h, t, "enc-slice-v23") - if v != nil { - if v == nil { - v23v2 = nil - } else { - v23v2 = make([]uint16, len(v)) - } - testUnmarshalErr(v23v2, bs23, h, t, "dec-slice-v23") - testDeepEqualErr(v23v1, v23v2, t, "equal-slice-v23") - if v == nil { - v23v2 = nil - } else { - v23v2 = make([]uint16, len(v)) - } - testUnmarshalErr(rv4i(v23v2), bs23, h, t, "dec-slice-v23-noaddr") // non-addressable value - testDeepEqualErr(v23v1, v23v2, t, "equal-slice-v23-noaddr") - } - // ... - bs23 = testMarshalErr(&v23v1, h, t, "enc-slice-v23-p") - v23v2 = nil - testUnmarshalErr(&v23v2, bs23, h, t, "dec-slice-v23-p") - testDeepEqualErr(v23v1, v23v2, t, "equal-slice-v23-p") - v23va = [8]uint16{} // clear the array - v23v2 = v23va[:1:1] - testUnmarshalErr(&v23v2, bs23, h, t, "dec-slice-v23-p-1") - testDeepEqualErr(v23v1, v23v2, t, "equal-slice-v23-p-1") - v23va = [8]uint16{} // clear the array - v23v2 = v23va[:len(v23v1):len(v23v1)] - testUnmarshalErr(&v23v2, bs23, h, t, "dec-slice-v23-p-len") - testDeepEqualErr(v23v1, v23v2, t, "equal-slice-v23-p-len") - v23va = [8]uint16{} // clear the array - v23v2 = v23va[:] - testUnmarshalErr(&v23v2, bs23, h, t, "dec-slice-v23-p-cap") - testDeepEqualErr(v23v1, v23v2, t, "equal-slice-v23-p-cap") - if len(v23v1) > 1 { - v23va = [8]uint16{} // clear the array - testUnmarshalErr((&v23va)[:len(v23v1)], bs23, h, t, "dec-slice-v23-p-len-noaddr") - testDeepEqualErr(v23v1, v23va[:len(v23v1)], t, "equal-slice-v23-p-len-noaddr") - v23va = [8]uint16{} // clear the array - testUnmarshalErr((&v23va)[:], bs23, h, t, "dec-slice-v23-p-cap-noaddr") - testDeepEqualErr(v23v1, v23va[:len(v23v1)], t, "equal-slice-v23-p-cap-noaddr") - } - // ... - var v23v3, v23v4 typMbsSliceUint16 - v23v2 = nil - if v != nil { - v23v2 = make([]uint16, len(v)) - } - v23v3 = typMbsSliceUint16(v23v1) - v23v4 = typMbsSliceUint16(v23v2) - if v != nil { - bs23 = testMarshalErr(v23v3, h, t, "enc-slice-v23-custom") - testUnmarshalErr(v23v4, bs23, h, t, "dec-slice-v23-custom") - testDeepEqualErr(v23v3, v23v4, t, "equal-slice-v23-custom") - } - bs23 = testMarshalErr(&v23v3, h, t, "enc-slice-v23-custom-p") - v23v2 = nil - v23v4 = typMbsSliceUint16(v23v2) - testUnmarshalErr(&v23v4, bs23, h, t, "dec-slice-v23-custom-p") - testDeepEqualErr(v23v3, v23v4, t, "equal-slice-v23-custom-p") - } - var v24va [8]uint32 - for _, v := range [][]uint32{nil, {}, {127, 0, 0, 111}} { - var v24v1, v24v2 []uint32 - var bs24 []byte - v24v1 = v - bs24 = testMarshalErr(v24v1, h, t, "enc-slice-v24") - if v != nil { - if v == nil { - v24v2 = nil - } else { - v24v2 = make([]uint32, len(v)) - } - testUnmarshalErr(v24v2, bs24, h, t, "dec-slice-v24") - testDeepEqualErr(v24v1, v24v2, t, "equal-slice-v24") - if v == nil { - v24v2 = nil - } else { - v24v2 = make([]uint32, len(v)) - } - testUnmarshalErr(rv4i(v24v2), bs24, h, t, "dec-slice-v24-noaddr") // non-addressable value - testDeepEqualErr(v24v1, v24v2, t, "equal-slice-v24-noaddr") - } - // ... - bs24 = testMarshalErr(&v24v1, h, t, "enc-slice-v24-p") - v24v2 = nil - testUnmarshalErr(&v24v2, bs24, h, t, "dec-slice-v24-p") - testDeepEqualErr(v24v1, v24v2, t, "equal-slice-v24-p") - v24va = [8]uint32{} // clear the array - v24v2 = v24va[:1:1] - testUnmarshalErr(&v24v2, bs24, h, t, "dec-slice-v24-p-1") - testDeepEqualErr(v24v1, v24v2, t, "equal-slice-v24-p-1") - v24va = [8]uint32{} // clear the array - v24v2 = v24va[:len(v24v1):len(v24v1)] - testUnmarshalErr(&v24v2, bs24, h, t, "dec-slice-v24-p-len") - testDeepEqualErr(v24v1, v24v2, t, "equal-slice-v24-p-len") - v24va = [8]uint32{} // clear the array - v24v2 = v24va[:] - testUnmarshalErr(&v24v2, bs24, h, t, "dec-slice-v24-p-cap") - testDeepEqualErr(v24v1, v24v2, t, "equal-slice-v24-p-cap") - if len(v24v1) > 1 { - v24va = [8]uint32{} // clear the array - testUnmarshalErr((&v24va)[:len(v24v1)], bs24, h, t, "dec-slice-v24-p-len-noaddr") - testDeepEqualErr(v24v1, v24va[:len(v24v1)], t, "equal-slice-v24-p-len-noaddr") - v24va = [8]uint32{} // clear the array - testUnmarshalErr((&v24va)[:], bs24, h, t, "dec-slice-v24-p-cap-noaddr") - testDeepEqualErr(v24v1, v24va[:len(v24v1)], t, "equal-slice-v24-p-cap-noaddr") - } - // ... - var v24v3, v24v4 typMbsSliceUint32 - v24v2 = nil - if v != nil { - v24v2 = make([]uint32, len(v)) - } - v24v3 = typMbsSliceUint32(v24v1) - v24v4 = typMbsSliceUint32(v24v2) - if v != nil { - bs24 = testMarshalErr(v24v3, h, t, "enc-slice-v24-custom") - testUnmarshalErr(v24v4, bs24, h, t, "dec-slice-v24-custom") - testDeepEqualErr(v24v3, v24v4, t, "equal-slice-v24-custom") - } - bs24 = testMarshalErr(&v24v3, h, t, "enc-slice-v24-custom-p") - v24v2 = nil - v24v4 = typMbsSliceUint32(v24v2) - testUnmarshalErr(&v24v4, bs24, h, t, "dec-slice-v24-custom-p") - testDeepEqualErr(v24v3, v24v4, t, "equal-slice-v24-custom-p") - } - var v25va [8]uint64 - for _, v := range [][]uint64{nil, {}, {77, 0, 0, 127}} { - var v25v1, v25v2 []uint64 - var bs25 []byte - v25v1 = v - bs25 = testMarshalErr(v25v1, h, t, "enc-slice-v25") - if v != nil { - if v == nil { - v25v2 = nil - } else { - v25v2 = make([]uint64, len(v)) - } - testUnmarshalErr(v25v2, bs25, h, t, "dec-slice-v25") - testDeepEqualErr(v25v1, v25v2, t, "equal-slice-v25") - if v == nil { - v25v2 = nil - } else { - v25v2 = make([]uint64, len(v)) - } - testUnmarshalErr(rv4i(v25v2), bs25, h, t, "dec-slice-v25-noaddr") // non-addressable value - testDeepEqualErr(v25v1, v25v2, t, "equal-slice-v25-noaddr") - } - // ... - bs25 = testMarshalErr(&v25v1, h, t, "enc-slice-v25-p") - v25v2 = nil - testUnmarshalErr(&v25v2, bs25, h, t, "dec-slice-v25-p") - testDeepEqualErr(v25v1, v25v2, t, "equal-slice-v25-p") - v25va = [8]uint64{} // clear the array - v25v2 = v25va[:1:1] - testUnmarshalErr(&v25v2, bs25, h, t, "dec-slice-v25-p-1") - testDeepEqualErr(v25v1, v25v2, t, "equal-slice-v25-p-1") - v25va = [8]uint64{} // clear the array - v25v2 = v25va[:len(v25v1):len(v25v1)] - testUnmarshalErr(&v25v2, bs25, h, t, "dec-slice-v25-p-len") - testDeepEqualErr(v25v1, v25v2, t, "equal-slice-v25-p-len") - v25va = [8]uint64{} // clear the array - v25v2 = v25va[:] - testUnmarshalErr(&v25v2, bs25, h, t, "dec-slice-v25-p-cap") - testDeepEqualErr(v25v1, v25v2, t, "equal-slice-v25-p-cap") - if len(v25v1) > 1 { - v25va = [8]uint64{} // clear the array - testUnmarshalErr((&v25va)[:len(v25v1)], bs25, h, t, "dec-slice-v25-p-len-noaddr") - testDeepEqualErr(v25v1, v25va[:len(v25v1)], t, "equal-slice-v25-p-len-noaddr") - v25va = [8]uint64{} // clear the array - testUnmarshalErr((&v25va)[:], bs25, h, t, "dec-slice-v25-p-cap-noaddr") - testDeepEqualErr(v25v1, v25va[:len(v25v1)], t, "equal-slice-v25-p-cap-noaddr") - } - // ... - var v25v3, v25v4 typMbsSliceUint64 - v25v2 = nil - if v != nil { - v25v2 = make([]uint64, len(v)) - } - v25v3 = typMbsSliceUint64(v25v1) - v25v4 = typMbsSliceUint64(v25v2) - if v != nil { - bs25 = testMarshalErr(v25v3, h, t, "enc-slice-v25-custom") - testUnmarshalErr(v25v4, bs25, h, t, "dec-slice-v25-custom") - testDeepEqualErr(v25v3, v25v4, t, "equal-slice-v25-custom") - } - bs25 = testMarshalErr(&v25v3, h, t, "enc-slice-v25-custom-p") - v25v2 = nil - v25v4 = typMbsSliceUint64(v25v2) - testUnmarshalErr(&v25v4, bs25, h, t, "dec-slice-v25-custom-p") - testDeepEqualErr(v25v3, v25v4, t, "equal-slice-v25-custom-p") - } - var v26va [8]int - for _, v := range [][]int{nil, {}, {111, 0, 0, 77}} { - var v26v1, v26v2 []int - var bs26 []byte - v26v1 = v - bs26 = testMarshalErr(v26v1, h, t, "enc-slice-v26") - if v != nil { - if v == nil { - v26v2 = nil - } else { - v26v2 = make([]int, len(v)) - } - testUnmarshalErr(v26v2, bs26, h, t, "dec-slice-v26") - testDeepEqualErr(v26v1, v26v2, t, "equal-slice-v26") - if v == nil { - v26v2 = nil - } else { - v26v2 = make([]int, len(v)) - } - testUnmarshalErr(rv4i(v26v2), bs26, h, t, "dec-slice-v26-noaddr") // non-addressable value - testDeepEqualErr(v26v1, v26v2, t, "equal-slice-v26-noaddr") - } - // ... - bs26 = testMarshalErr(&v26v1, h, t, "enc-slice-v26-p") - v26v2 = nil - testUnmarshalErr(&v26v2, bs26, h, t, "dec-slice-v26-p") - testDeepEqualErr(v26v1, v26v2, t, "equal-slice-v26-p") - v26va = [8]int{} // clear the array - v26v2 = v26va[:1:1] - testUnmarshalErr(&v26v2, bs26, h, t, "dec-slice-v26-p-1") - testDeepEqualErr(v26v1, v26v2, t, "equal-slice-v26-p-1") - v26va = [8]int{} // clear the array - v26v2 = v26va[:len(v26v1):len(v26v1)] - testUnmarshalErr(&v26v2, bs26, h, t, "dec-slice-v26-p-len") - testDeepEqualErr(v26v1, v26v2, t, "equal-slice-v26-p-len") - v26va = [8]int{} // clear the array - v26v2 = v26va[:] - testUnmarshalErr(&v26v2, bs26, h, t, "dec-slice-v26-p-cap") - testDeepEqualErr(v26v1, v26v2, t, "equal-slice-v26-p-cap") - if len(v26v1) > 1 { - v26va = [8]int{} // clear the array - testUnmarshalErr((&v26va)[:len(v26v1)], bs26, h, t, "dec-slice-v26-p-len-noaddr") - testDeepEqualErr(v26v1, v26va[:len(v26v1)], t, "equal-slice-v26-p-len-noaddr") - v26va = [8]int{} // clear the array - testUnmarshalErr((&v26va)[:], bs26, h, t, "dec-slice-v26-p-cap-noaddr") - testDeepEqualErr(v26v1, v26va[:len(v26v1)], t, "equal-slice-v26-p-cap-noaddr") - } - // ... - var v26v3, v26v4 typMbsSliceInt - v26v2 = nil - if v != nil { - v26v2 = make([]int, len(v)) - } - v26v3 = typMbsSliceInt(v26v1) - v26v4 = typMbsSliceInt(v26v2) - if v != nil { - bs26 = testMarshalErr(v26v3, h, t, "enc-slice-v26-custom") - testUnmarshalErr(v26v4, bs26, h, t, "dec-slice-v26-custom") - testDeepEqualErr(v26v3, v26v4, t, "equal-slice-v26-custom") - } - bs26 = testMarshalErr(&v26v3, h, t, "enc-slice-v26-custom-p") - v26v2 = nil - v26v4 = typMbsSliceInt(v26v2) - testUnmarshalErr(&v26v4, bs26, h, t, "dec-slice-v26-custom-p") - testDeepEqualErr(v26v3, v26v4, t, "equal-slice-v26-custom-p") - } - var v27va [8]int8 - for _, v := range [][]int8{nil, {}, {127, 0, 0, 111}} { - var v27v1, v27v2 []int8 - var bs27 []byte - v27v1 = v - bs27 = testMarshalErr(v27v1, h, t, "enc-slice-v27") - if v != nil { - if v == nil { - v27v2 = nil - } else { - v27v2 = make([]int8, len(v)) - } - testUnmarshalErr(v27v2, bs27, h, t, "dec-slice-v27") - testDeepEqualErr(v27v1, v27v2, t, "equal-slice-v27") - if v == nil { - v27v2 = nil - } else { - v27v2 = make([]int8, len(v)) - } - testUnmarshalErr(rv4i(v27v2), bs27, h, t, "dec-slice-v27-noaddr") // non-addressable value - testDeepEqualErr(v27v1, v27v2, t, "equal-slice-v27-noaddr") - } - // ... - bs27 = testMarshalErr(&v27v1, h, t, "enc-slice-v27-p") - v27v2 = nil - testUnmarshalErr(&v27v2, bs27, h, t, "dec-slice-v27-p") - testDeepEqualErr(v27v1, v27v2, t, "equal-slice-v27-p") - v27va = [8]int8{} // clear the array - v27v2 = v27va[:1:1] - testUnmarshalErr(&v27v2, bs27, h, t, "dec-slice-v27-p-1") - testDeepEqualErr(v27v1, v27v2, t, "equal-slice-v27-p-1") - v27va = [8]int8{} // clear the array - v27v2 = v27va[:len(v27v1):len(v27v1)] - testUnmarshalErr(&v27v2, bs27, h, t, "dec-slice-v27-p-len") - testDeepEqualErr(v27v1, v27v2, t, "equal-slice-v27-p-len") - v27va = [8]int8{} // clear the array - v27v2 = v27va[:] - testUnmarshalErr(&v27v2, bs27, h, t, "dec-slice-v27-p-cap") - testDeepEqualErr(v27v1, v27v2, t, "equal-slice-v27-p-cap") - if len(v27v1) > 1 { - v27va = [8]int8{} // clear the array - testUnmarshalErr((&v27va)[:len(v27v1)], bs27, h, t, "dec-slice-v27-p-len-noaddr") - testDeepEqualErr(v27v1, v27va[:len(v27v1)], t, "equal-slice-v27-p-len-noaddr") - v27va = [8]int8{} // clear the array - testUnmarshalErr((&v27va)[:], bs27, h, t, "dec-slice-v27-p-cap-noaddr") - testDeepEqualErr(v27v1, v27va[:len(v27v1)], t, "equal-slice-v27-p-cap-noaddr") - } - // ... - var v27v3, v27v4 typMbsSliceInt8 - v27v2 = nil - if v != nil { - v27v2 = make([]int8, len(v)) - } - v27v3 = typMbsSliceInt8(v27v1) - v27v4 = typMbsSliceInt8(v27v2) - if v != nil { - bs27 = testMarshalErr(v27v3, h, t, "enc-slice-v27-custom") - testUnmarshalErr(v27v4, bs27, h, t, "dec-slice-v27-custom") - testDeepEqualErr(v27v3, v27v4, t, "equal-slice-v27-custom") - } - bs27 = testMarshalErr(&v27v3, h, t, "enc-slice-v27-custom-p") - v27v2 = nil - v27v4 = typMbsSliceInt8(v27v2) - testUnmarshalErr(&v27v4, bs27, h, t, "dec-slice-v27-custom-p") - testDeepEqualErr(v27v3, v27v4, t, "equal-slice-v27-custom-p") - } - var v28va [8]int16 - for _, v := range [][]int16{nil, {}, {77, 0, 0, 127}} { - var v28v1, v28v2 []int16 - var bs28 []byte - v28v1 = v - bs28 = testMarshalErr(v28v1, h, t, "enc-slice-v28") - if v != nil { - if v == nil { - v28v2 = nil - } else { - v28v2 = make([]int16, len(v)) - } - testUnmarshalErr(v28v2, bs28, h, t, "dec-slice-v28") - testDeepEqualErr(v28v1, v28v2, t, "equal-slice-v28") - if v == nil { - v28v2 = nil - } else { - v28v2 = make([]int16, len(v)) - } - testUnmarshalErr(rv4i(v28v2), bs28, h, t, "dec-slice-v28-noaddr") // non-addressable value - testDeepEqualErr(v28v1, v28v2, t, "equal-slice-v28-noaddr") - } - // ... - bs28 = testMarshalErr(&v28v1, h, t, "enc-slice-v28-p") - v28v2 = nil - testUnmarshalErr(&v28v2, bs28, h, t, "dec-slice-v28-p") - testDeepEqualErr(v28v1, v28v2, t, "equal-slice-v28-p") - v28va = [8]int16{} // clear the array - v28v2 = v28va[:1:1] - testUnmarshalErr(&v28v2, bs28, h, t, "dec-slice-v28-p-1") - testDeepEqualErr(v28v1, v28v2, t, "equal-slice-v28-p-1") - v28va = [8]int16{} // clear the array - v28v2 = v28va[:len(v28v1):len(v28v1)] - testUnmarshalErr(&v28v2, bs28, h, t, "dec-slice-v28-p-len") - testDeepEqualErr(v28v1, v28v2, t, "equal-slice-v28-p-len") - v28va = [8]int16{} // clear the array - v28v2 = v28va[:] - testUnmarshalErr(&v28v2, bs28, h, t, "dec-slice-v28-p-cap") - testDeepEqualErr(v28v1, v28v2, t, "equal-slice-v28-p-cap") - if len(v28v1) > 1 { - v28va = [8]int16{} // clear the array - testUnmarshalErr((&v28va)[:len(v28v1)], bs28, h, t, "dec-slice-v28-p-len-noaddr") - testDeepEqualErr(v28v1, v28va[:len(v28v1)], t, "equal-slice-v28-p-len-noaddr") - v28va = [8]int16{} // clear the array - testUnmarshalErr((&v28va)[:], bs28, h, t, "dec-slice-v28-p-cap-noaddr") - testDeepEqualErr(v28v1, v28va[:len(v28v1)], t, "equal-slice-v28-p-cap-noaddr") - } - // ... - var v28v3, v28v4 typMbsSliceInt16 - v28v2 = nil - if v != nil { - v28v2 = make([]int16, len(v)) - } - v28v3 = typMbsSliceInt16(v28v1) - v28v4 = typMbsSliceInt16(v28v2) - if v != nil { - bs28 = testMarshalErr(v28v3, h, t, "enc-slice-v28-custom") - testUnmarshalErr(v28v4, bs28, h, t, "dec-slice-v28-custom") - testDeepEqualErr(v28v3, v28v4, t, "equal-slice-v28-custom") - } - bs28 = testMarshalErr(&v28v3, h, t, "enc-slice-v28-custom-p") - v28v2 = nil - v28v4 = typMbsSliceInt16(v28v2) - testUnmarshalErr(&v28v4, bs28, h, t, "dec-slice-v28-custom-p") - testDeepEqualErr(v28v3, v28v4, t, "equal-slice-v28-custom-p") - } - var v29va [8]int32 - for _, v := range [][]int32{nil, {}, {111, 0, 0, 77}} { - var v29v1, v29v2 []int32 - var bs29 []byte - v29v1 = v - bs29 = testMarshalErr(v29v1, h, t, "enc-slice-v29") - if v != nil { - if v == nil { - v29v2 = nil - } else { - v29v2 = make([]int32, len(v)) - } - testUnmarshalErr(v29v2, bs29, h, t, "dec-slice-v29") - testDeepEqualErr(v29v1, v29v2, t, "equal-slice-v29") - if v == nil { - v29v2 = nil - } else { - v29v2 = make([]int32, len(v)) - } - testUnmarshalErr(rv4i(v29v2), bs29, h, t, "dec-slice-v29-noaddr") // non-addressable value - testDeepEqualErr(v29v1, v29v2, t, "equal-slice-v29-noaddr") - } - // ... - bs29 = testMarshalErr(&v29v1, h, t, "enc-slice-v29-p") - v29v2 = nil - testUnmarshalErr(&v29v2, bs29, h, t, "dec-slice-v29-p") - testDeepEqualErr(v29v1, v29v2, t, "equal-slice-v29-p") - v29va = [8]int32{} // clear the array - v29v2 = v29va[:1:1] - testUnmarshalErr(&v29v2, bs29, h, t, "dec-slice-v29-p-1") - testDeepEqualErr(v29v1, v29v2, t, "equal-slice-v29-p-1") - v29va = [8]int32{} // clear the array - v29v2 = v29va[:len(v29v1):len(v29v1)] - testUnmarshalErr(&v29v2, bs29, h, t, "dec-slice-v29-p-len") - testDeepEqualErr(v29v1, v29v2, t, "equal-slice-v29-p-len") - v29va = [8]int32{} // clear the array - v29v2 = v29va[:] - testUnmarshalErr(&v29v2, bs29, h, t, "dec-slice-v29-p-cap") - testDeepEqualErr(v29v1, v29v2, t, "equal-slice-v29-p-cap") - if len(v29v1) > 1 { - v29va = [8]int32{} // clear the array - testUnmarshalErr((&v29va)[:len(v29v1)], bs29, h, t, "dec-slice-v29-p-len-noaddr") - testDeepEqualErr(v29v1, v29va[:len(v29v1)], t, "equal-slice-v29-p-len-noaddr") - v29va = [8]int32{} // clear the array - testUnmarshalErr((&v29va)[:], bs29, h, t, "dec-slice-v29-p-cap-noaddr") - testDeepEqualErr(v29v1, v29va[:len(v29v1)], t, "equal-slice-v29-p-cap-noaddr") - } - // ... - var v29v3, v29v4 typMbsSliceInt32 - v29v2 = nil - if v != nil { - v29v2 = make([]int32, len(v)) - } - v29v3 = typMbsSliceInt32(v29v1) - v29v4 = typMbsSliceInt32(v29v2) - if v != nil { - bs29 = testMarshalErr(v29v3, h, t, "enc-slice-v29-custom") - testUnmarshalErr(v29v4, bs29, h, t, "dec-slice-v29-custom") - testDeepEqualErr(v29v3, v29v4, t, "equal-slice-v29-custom") - } - bs29 = testMarshalErr(&v29v3, h, t, "enc-slice-v29-custom-p") - v29v2 = nil - v29v4 = typMbsSliceInt32(v29v2) - testUnmarshalErr(&v29v4, bs29, h, t, "dec-slice-v29-custom-p") - testDeepEqualErr(v29v3, v29v4, t, "equal-slice-v29-custom-p") - } - var v30va [8]int64 - for _, v := range [][]int64{nil, {}, {127, 0, 0, 111}} { - var v30v1, v30v2 []int64 - var bs30 []byte - v30v1 = v - bs30 = testMarshalErr(v30v1, h, t, "enc-slice-v30") - if v != nil { - if v == nil { - v30v2 = nil - } else { - v30v2 = make([]int64, len(v)) - } - testUnmarshalErr(v30v2, bs30, h, t, "dec-slice-v30") - testDeepEqualErr(v30v1, v30v2, t, "equal-slice-v30") - if v == nil { - v30v2 = nil - } else { - v30v2 = make([]int64, len(v)) - } - testUnmarshalErr(rv4i(v30v2), bs30, h, t, "dec-slice-v30-noaddr") // non-addressable value - testDeepEqualErr(v30v1, v30v2, t, "equal-slice-v30-noaddr") - } - // ... - bs30 = testMarshalErr(&v30v1, h, t, "enc-slice-v30-p") - v30v2 = nil - testUnmarshalErr(&v30v2, bs30, h, t, "dec-slice-v30-p") - testDeepEqualErr(v30v1, v30v2, t, "equal-slice-v30-p") - v30va = [8]int64{} // clear the array - v30v2 = v30va[:1:1] - testUnmarshalErr(&v30v2, bs30, h, t, "dec-slice-v30-p-1") - testDeepEqualErr(v30v1, v30v2, t, "equal-slice-v30-p-1") - v30va = [8]int64{} // clear the array - v30v2 = v30va[:len(v30v1):len(v30v1)] - testUnmarshalErr(&v30v2, bs30, h, t, "dec-slice-v30-p-len") - testDeepEqualErr(v30v1, v30v2, t, "equal-slice-v30-p-len") - v30va = [8]int64{} // clear the array - v30v2 = v30va[:] - testUnmarshalErr(&v30v2, bs30, h, t, "dec-slice-v30-p-cap") - testDeepEqualErr(v30v1, v30v2, t, "equal-slice-v30-p-cap") - if len(v30v1) > 1 { - v30va = [8]int64{} // clear the array - testUnmarshalErr((&v30va)[:len(v30v1)], bs30, h, t, "dec-slice-v30-p-len-noaddr") - testDeepEqualErr(v30v1, v30va[:len(v30v1)], t, "equal-slice-v30-p-len-noaddr") - v30va = [8]int64{} // clear the array - testUnmarshalErr((&v30va)[:], bs30, h, t, "dec-slice-v30-p-cap-noaddr") - testDeepEqualErr(v30v1, v30va[:len(v30v1)], t, "equal-slice-v30-p-cap-noaddr") - } - // ... - var v30v3, v30v4 typMbsSliceInt64 - v30v2 = nil - if v != nil { - v30v2 = make([]int64, len(v)) - } - v30v3 = typMbsSliceInt64(v30v1) - v30v4 = typMbsSliceInt64(v30v2) - if v != nil { - bs30 = testMarshalErr(v30v3, h, t, "enc-slice-v30-custom") - testUnmarshalErr(v30v4, bs30, h, t, "dec-slice-v30-custom") - testDeepEqualErr(v30v3, v30v4, t, "equal-slice-v30-custom") - } - bs30 = testMarshalErr(&v30v3, h, t, "enc-slice-v30-custom-p") - v30v2 = nil - v30v4 = typMbsSliceInt64(v30v2) - testUnmarshalErr(&v30v4, bs30, h, t, "dec-slice-v30-custom-p") - testDeepEqualErr(v30v3, v30v4, t, "equal-slice-v30-custom-p") - } - var v31va [8]bool - for _, v := range [][]bool{nil, {}, {false, false, false, true}} { - var v31v1, v31v2 []bool - var bs31 []byte - v31v1 = v - bs31 = testMarshalErr(v31v1, h, t, "enc-slice-v31") - if v != nil { - if v == nil { - v31v2 = nil - } else { - v31v2 = make([]bool, len(v)) - } - testUnmarshalErr(v31v2, bs31, h, t, "dec-slice-v31") - testDeepEqualErr(v31v1, v31v2, t, "equal-slice-v31") - if v == nil { - v31v2 = nil - } else { - v31v2 = make([]bool, len(v)) - } - testUnmarshalErr(rv4i(v31v2), bs31, h, t, "dec-slice-v31-noaddr") // non-addressable value - testDeepEqualErr(v31v1, v31v2, t, "equal-slice-v31-noaddr") - } - // ... - bs31 = testMarshalErr(&v31v1, h, t, "enc-slice-v31-p") - v31v2 = nil - testUnmarshalErr(&v31v2, bs31, h, t, "dec-slice-v31-p") - testDeepEqualErr(v31v1, v31v2, t, "equal-slice-v31-p") - v31va = [8]bool{} // clear the array - v31v2 = v31va[:1:1] - testUnmarshalErr(&v31v2, bs31, h, t, "dec-slice-v31-p-1") - testDeepEqualErr(v31v1, v31v2, t, "equal-slice-v31-p-1") - v31va = [8]bool{} // clear the array - v31v2 = v31va[:len(v31v1):len(v31v1)] - testUnmarshalErr(&v31v2, bs31, h, t, "dec-slice-v31-p-len") - testDeepEqualErr(v31v1, v31v2, t, "equal-slice-v31-p-len") - v31va = [8]bool{} // clear the array - v31v2 = v31va[:] - testUnmarshalErr(&v31v2, bs31, h, t, "dec-slice-v31-p-cap") - testDeepEqualErr(v31v1, v31v2, t, "equal-slice-v31-p-cap") - if len(v31v1) > 1 { - v31va = [8]bool{} // clear the array - testUnmarshalErr((&v31va)[:len(v31v1)], bs31, h, t, "dec-slice-v31-p-len-noaddr") - testDeepEqualErr(v31v1, v31va[:len(v31v1)], t, "equal-slice-v31-p-len-noaddr") - v31va = [8]bool{} // clear the array - testUnmarshalErr((&v31va)[:], bs31, h, t, "dec-slice-v31-p-cap-noaddr") - testDeepEqualErr(v31v1, v31va[:len(v31v1)], t, "equal-slice-v31-p-cap-noaddr") - } - // ... - var v31v3, v31v4 typMbsSliceBool - v31v2 = nil - if v != nil { - v31v2 = make([]bool, len(v)) - } - v31v3 = typMbsSliceBool(v31v1) - v31v4 = typMbsSliceBool(v31v2) - if v != nil { - bs31 = testMarshalErr(v31v3, h, t, "enc-slice-v31-custom") - testUnmarshalErr(v31v4, bs31, h, t, "dec-slice-v31-custom") - testDeepEqualErr(v31v3, v31v4, t, "equal-slice-v31-custom") - } - bs31 = testMarshalErr(&v31v3, h, t, "enc-slice-v31-custom-p") - v31v2 = nil - v31v4 = typMbsSliceBool(v31v2) - testUnmarshalErr(&v31v4, bs31, h, t, "dec-slice-v31-custom-p") - testDeepEqualErr(v31v3, v31v4, t, "equal-slice-v31-custom-p") - } - -} - -func doTestMammothMaps(t *testing.T, h Handle) { - for _, v := range []map[string]interface{}{nil, {}, {"some-string-1": nil, "some-string-2": "string-is-an-interface-1"}} { - // fmt.Printf(">>>> running mammoth map v32: %v\n", v) - var v32v1, v32v2 map[string]interface{} - var bs32 []byte - v32v1 = v - bs32 = testMarshalErr(v32v1, h, t, "enc-map-v32") - if v != nil { - if v == nil { - v32v2 = nil - } else { - v32v2 = make(map[string]interface{}, len(v)) - } // reset map - testUnmarshalErr(v32v2, bs32, h, t, "dec-map-v32") - testDeepEqualErr(v32v1, v32v2, t, "equal-map-v32") - if v == nil { - v32v2 = nil - } else { - v32v2 = make(map[string]interface{}, len(v)) - } // reset map - testUnmarshalErr(rv4i(v32v2), bs32, h, t, "dec-map-v32-noaddr") // decode into non-addressable map value - testDeepEqualErr(v32v1, v32v2, t, "equal-map-v32-noaddr") - } - if v == nil { - v32v2 = nil - } else { - v32v2 = make(map[string]interface{}, len(v)) - } // reset map - testUnmarshalErr(&v32v2, bs32, h, t, "dec-map-v32-p-len") - testDeepEqualErr(v32v1, v32v2, t, "equal-map-v32-p-len") - bs32 = testMarshalErr(&v32v1, h, t, "enc-map-v32-p") - v32v2 = nil - testUnmarshalErr(&v32v2, bs32, h, t, "dec-map-v32-p-nil") - testDeepEqualErr(v32v1, v32v2, t, "equal-map-v32-p-nil") - // ... - if v == nil { - v32v2 = nil - } else { - v32v2 = make(map[string]interface{}, len(v)) - } // reset map - var v32v3, v32v4 typMapMapStringIntf - v32v3 = typMapMapStringIntf(v32v1) - v32v4 = typMapMapStringIntf(v32v2) - if v != nil { - bs32 = testMarshalErr(v32v3, h, t, "enc-map-v32-custom") - testUnmarshalErr(v32v4, bs32, h, t, "dec-map-v32-p-len") - testDeepEqualErr(v32v3, v32v4, t, "equal-map-v32-p-len") - } - } - for _, v := range []map[string]string{nil, {}, {"some-string-3": "", "some-string-1": "some-string-2"}} { - // fmt.Printf(">>>> running mammoth map v33: %v\n", v) - var v33v1, v33v2 map[string]string - var bs33 []byte - v33v1 = v - bs33 = testMarshalErr(v33v1, h, t, "enc-map-v33") - if v != nil { - if v == nil { - v33v2 = nil - } else { - v33v2 = make(map[string]string, len(v)) - } // reset map - testUnmarshalErr(v33v2, bs33, h, t, "dec-map-v33") - testDeepEqualErr(v33v1, v33v2, t, "equal-map-v33") - if v == nil { - v33v2 = nil - } else { - v33v2 = make(map[string]string, len(v)) - } // reset map - testUnmarshalErr(rv4i(v33v2), bs33, h, t, "dec-map-v33-noaddr") // decode into non-addressable map value - testDeepEqualErr(v33v1, v33v2, t, "equal-map-v33-noaddr") - } - if v == nil { - v33v2 = nil - } else { - v33v2 = make(map[string]string, len(v)) - } // reset map - testUnmarshalErr(&v33v2, bs33, h, t, "dec-map-v33-p-len") - testDeepEqualErr(v33v1, v33v2, t, "equal-map-v33-p-len") - bs33 = testMarshalErr(&v33v1, h, t, "enc-map-v33-p") - v33v2 = nil - testUnmarshalErr(&v33v2, bs33, h, t, "dec-map-v33-p-nil") - testDeepEqualErr(v33v1, v33v2, t, "equal-map-v33-p-nil") - // ... - if v == nil { - v33v2 = nil - } else { - v33v2 = make(map[string]string, len(v)) - } // reset map - var v33v3, v33v4 typMapMapStringString - v33v3 = typMapMapStringString(v33v1) - v33v4 = typMapMapStringString(v33v2) - if v != nil { - bs33 = testMarshalErr(v33v3, h, t, "enc-map-v33-custom") - testUnmarshalErr(v33v4, bs33, h, t, "dec-map-v33-p-len") - testDeepEqualErr(v33v3, v33v4, t, "equal-map-v33-p-len") - } - } - for _, v := range []map[string][]byte{nil, {}, {"some-string-3": nil, "some-string-1": []byte("some-string-1")}} { - // fmt.Printf(">>>> running mammoth map v34: %v\n", v) - var v34v1, v34v2 map[string][]byte - var bs34 []byte - v34v1 = v - bs34 = testMarshalErr(v34v1, h, t, "enc-map-v34") - if v != nil { - if v == nil { - v34v2 = nil - } else { - v34v2 = make(map[string][]byte, len(v)) - } // reset map - testUnmarshalErr(v34v2, bs34, h, t, "dec-map-v34") - testDeepEqualErr(v34v1, v34v2, t, "equal-map-v34") - if v == nil { - v34v2 = nil - } else { - v34v2 = make(map[string][]byte, len(v)) - } // reset map - testUnmarshalErr(rv4i(v34v2), bs34, h, t, "dec-map-v34-noaddr") // decode into non-addressable map value - testDeepEqualErr(v34v1, v34v2, t, "equal-map-v34-noaddr") - } - if v == nil { - v34v2 = nil - } else { - v34v2 = make(map[string][]byte, len(v)) - } // reset map - testUnmarshalErr(&v34v2, bs34, h, t, "dec-map-v34-p-len") - testDeepEqualErr(v34v1, v34v2, t, "equal-map-v34-p-len") - bs34 = testMarshalErr(&v34v1, h, t, "enc-map-v34-p") - v34v2 = nil - testUnmarshalErr(&v34v2, bs34, h, t, "dec-map-v34-p-nil") - testDeepEqualErr(v34v1, v34v2, t, "equal-map-v34-p-nil") - // ... - if v == nil { - v34v2 = nil - } else { - v34v2 = make(map[string][]byte, len(v)) - } // reset map - var v34v3, v34v4 typMapMapStringBytes - v34v3 = typMapMapStringBytes(v34v1) - v34v4 = typMapMapStringBytes(v34v2) - if v != nil { - bs34 = testMarshalErr(v34v3, h, t, "enc-map-v34-custom") - testUnmarshalErr(v34v4, bs34, h, t, "dec-map-v34-p-len") - testDeepEqualErr(v34v3, v34v4, t, "equal-map-v34-p-len") - } - } - for _, v := range []map[string]uint{nil, {}, {"some-string-2": 0, "some-string-3": 77}} { - // fmt.Printf(">>>> running mammoth map v35: %v\n", v) - var v35v1, v35v2 map[string]uint - var bs35 []byte - v35v1 = v - bs35 = testMarshalErr(v35v1, h, t, "enc-map-v35") - if v != nil { - if v == nil { - v35v2 = nil - } else { - v35v2 = make(map[string]uint, len(v)) - } // reset map - testUnmarshalErr(v35v2, bs35, h, t, "dec-map-v35") - testDeepEqualErr(v35v1, v35v2, t, "equal-map-v35") - if v == nil { - v35v2 = nil - } else { - v35v2 = make(map[string]uint, len(v)) - } // reset map - testUnmarshalErr(rv4i(v35v2), bs35, h, t, "dec-map-v35-noaddr") // decode into non-addressable map value - testDeepEqualErr(v35v1, v35v2, t, "equal-map-v35-noaddr") - } - if v == nil { - v35v2 = nil - } else { - v35v2 = make(map[string]uint, len(v)) - } // reset map - testUnmarshalErr(&v35v2, bs35, h, t, "dec-map-v35-p-len") - testDeepEqualErr(v35v1, v35v2, t, "equal-map-v35-p-len") - bs35 = testMarshalErr(&v35v1, h, t, "enc-map-v35-p") - v35v2 = nil - testUnmarshalErr(&v35v2, bs35, h, t, "dec-map-v35-p-nil") - testDeepEqualErr(v35v1, v35v2, t, "equal-map-v35-p-nil") - // ... - if v == nil { - v35v2 = nil - } else { - v35v2 = make(map[string]uint, len(v)) - } // reset map - var v35v3, v35v4 typMapMapStringUint - v35v3 = typMapMapStringUint(v35v1) - v35v4 = typMapMapStringUint(v35v2) - if v != nil { - bs35 = testMarshalErr(v35v3, h, t, "enc-map-v35-custom") - testUnmarshalErr(v35v4, bs35, h, t, "dec-map-v35-p-len") - testDeepEqualErr(v35v3, v35v4, t, "equal-map-v35-p-len") - } - } - for _, v := range []map[string]uint8{nil, {}, {"some-string-1": 0, "some-string-2": 127}} { - // fmt.Printf(">>>> running mammoth map v36: %v\n", v) - var v36v1, v36v2 map[string]uint8 - var bs36 []byte - v36v1 = v - bs36 = testMarshalErr(v36v1, h, t, "enc-map-v36") - if v != nil { - if v == nil { - v36v2 = nil - } else { - v36v2 = make(map[string]uint8, len(v)) - } // reset map - testUnmarshalErr(v36v2, bs36, h, t, "dec-map-v36") - testDeepEqualErr(v36v1, v36v2, t, "equal-map-v36") - if v == nil { - v36v2 = nil - } else { - v36v2 = make(map[string]uint8, len(v)) - } // reset map - testUnmarshalErr(rv4i(v36v2), bs36, h, t, "dec-map-v36-noaddr") // decode into non-addressable map value - testDeepEqualErr(v36v1, v36v2, t, "equal-map-v36-noaddr") - } - if v == nil { - v36v2 = nil - } else { - v36v2 = make(map[string]uint8, len(v)) - } // reset map - testUnmarshalErr(&v36v2, bs36, h, t, "dec-map-v36-p-len") - testDeepEqualErr(v36v1, v36v2, t, "equal-map-v36-p-len") - bs36 = testMarshalErr(&v36v1, h, t, "enc-map-v36-p") - v36v2 = nil - testUnmarshalErr(&v36v2, bs36, h, t, "dec-map-v36-p-nil") - testDeepEqualErr(v36v1, v36v2, t, "equal-map-v36-p-nil") - // ... - if v == nil { - v36v2 = nil - } else { - v36v2 = make(map[string]uint8, len(v)) - } // reset map - var v36v3, v36v4 typMapMapStringUint8 - v36v3 = typMapMapStringUint8(v36v1) - v36v4 = typMapMapStringUint8(v36v2) - if v != nil { - bs36 = testMarshalErr(v36v3, h, t, "enc-map-v36-custom") - testUnmarshalErr(v36v4, bs36, h, t, "dec-map-v36-p-len") - testDeepEqualErr(v36v3, v36v4, t, "equal-map-v36-p-len") - } - } - for _, v := range []map[string]uint64{nil, {}, {"some-string-3": 0, "some-string-1": 111}} { - // fmt.Printf(">>>> running mammoth map v37: %v\n", v) - var v37v1, v37v2 map[string]uint64 - var bs37 []byte - v37v1 = v - bs37 = testMarshalErr(v37v1, h, t, "enc-map-v37") - if v != nil { - if v == nil { - v37v2 = nil - } else { - v37v2 = make(map[string]uint64, len(v)) - } // reset map - testUnmarshalErr(v37v2, bs37, h, t, "dec-map-v37") - testDeepEqualErr(v37v1, v37v2, t, "equal-map-v37") - if v == nil { - v37v2 = nil - } else { - v37v2 = make(map[string]uint64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v37v2), bs37, h, t, "dec-map-v37-noaddr") // decode into non-addressable map value - testDeepEqualErr(v37v1, v37v2, t, "equal-map-v37-noaddr") - } - if v == nil { - v37v2 = nil - } else { - v37v2 = make(map[string]uint64, len(v)) - } // reset map - testUnmarshalErr(&v37v2, bs37, h, t, "dec-map-v37-p-len") - testDeepEqualErr(v37v1, v37v2, t, "equal-map-v37-p-len") - bs37 = testMarshalErr(&v37v1, h, t, "enc-map-v37-p") - v37v2 = nil - testUnmarshalErr(&v37v2, bs37, h, t, "dec-map-v37-p-nil") - testDeepEqualErr(v37v1, v37v2, t, "equal-map-v37-p-nil") - // ... - if v == nil { - v37v2 = nil - } else { - v37v2 = make(map[string]uint64, len(v)) - } // reset map - var v37v3, v37v4 typMapMapStringUint64 - v37v3 = typMapMapStringUint64(v37v1) - v37v4 = typMapMapStringUint64(v37v2) - if v != nil { - bs37 = testMarshalErr(v37v3, h, t, "enc-map-v37-custom") - testUnmarshalErr(v37v4, bs37, h, t, "dec-map-v37-p-len") - testDeepEqualErr(v37v3, v37v4, t, "equal-map-v37-p-len") - } - } - for _, v := range []map[string]int{nil, {}, {"some-string-2": 0, "some-string-3": 77}} { - // fmt.Printf(">>>> running mammoth map v38: %v\n", v) - var v38v1, v38v2 map[string]int - var bs38 []byte - v38v1 = v - bs38 = testMarshalErr(v38v1, h, t, "enc-map-v38") - if v != nil { - if v == nil { - v38v2 = nil - } else { - v38v2 = make(map[string]int, len(v)) - } // reset map - testUnmarshalErr(v38v2, bs38, h, t, "dec-map-v38") - testDeepEqualErr(v38v1, v38v2, t, "equal-map-v38") - if v == nil { - v38v2 = nil - } else { - v38v2 = make(map[string]int, len(v)) - } // reset map - testUnmarshalErr(rv4i(v38v2), bs38, h, t, "dec-map-v38-noaddr") // decode into non-addressable map value - testDeepEqualErr(v38v1, v38v2, t, "equal-map-v38-noaddr") - } - if v == nil { - v38v2 = nil - } else { - v38v2 = make(map[string]int, len(v)) - } // reset map - testUnmarshalErr(&v38v2, bs38, h, t, "dec-map-v38-p-len") - testDeepEqualErr(v38v1, v38v2, t, "equal-map-v38-p-len") - bs38 = testMarshalErr(&v38v1, h, t, "enc-map-v38-p") - v38v2 = nil - testUnmarshalErr(&v38v2, bs38, h, t, "dec-map-v38-p-nil") - testDeepEqualErr(v38v1, v38v2, t, "equal-map-v38-p-nil") - // ... - if v == nil { - v38v2 = nil - } else { - v38v2 = make(map[string]int, len(v)) - } // reset map - var v38v3, v38v4 typMapMapStringInt - v38v3 = typMapMapStringInt(v38v1) - v38v4 = typMapMapStringInt(v38v2) - if v != nil { - bs38 = testMarshalErr(v38v3, h, t, "enc-map-v38-custom") - testUnmarshalErr(v38v4, bs38, h, t, "dec-map-v38-p-len") - testDeepEqualErr(v38v3, v38v4, t, "equal-map-v38-p-len") - } - } - for _, v := range []map[string]int64{nil, {}, {"some-string-1": 0, "some-string-2": 127}} { - // fmt.Printf(">>>> running mammoth map v39: %v\n", v) - var v39v1, v39v2 map[string]int64 - var bs39 []byte - v39v1 = v - bs39 = testMarshalErr(v39v1, h, t, "enc-map-v39") - if v != nil { - if v == nil { - v39v2 = nil - } else { - v39v2 = make(map[string]int64, len(v)) - } // reset map - testUnmarshalErr(v39v2, bs39, h, t, "dec-map-v39") - testDeepEqualErr(v39v1, v39v2, t, "equal-map-v39") - if v == nil { - v39v2 = nil - } else { - v39v2 = make(map[string]int64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v39v2), bs39, h, t, "dec-map-v39-noaddr") // decode into non-addressable map value - testDeepEqualErr(v39v1, v39v2, t, "equal-map-v39-noaddr") - } - if v == nil { - v39v2 = nil - } else { - v39v2 = make(map[string]int64, len(v)) - } // reset map - testUnmarshalErr(&v39v2, bs39, h, t, "dec-map-v39-p-len") - testDeepEqualErr(v39v1, v39v2, t, "equal-map-v39-p-len") - bs39 = testMarshalErr(&v39v1, h, t, "enc-map-v39-p") - v39v2 = nil - testUnmarshalErr(&v39v2, bs39, h, t, "dec-map-v39-p-nil") - testDeepEqualErr(v39v1, v39v2, t, "equal-map-v39-p-nil") - // ... - if v == nil { - v39v2 = nil - } else { - v39v2 = make(map[string]int64, len(v)) - } // reset map - var v39v3, v39v4 typMapMapStringInt64 - v39v3 = typMapMapStringInt64(v39v1) - v39v4 = typMapMapStringInt64(v39v2) - if v != nil { - bs39 = testMarshalErr(v39v3, h, t, "enc-map-v39-custom") - testUnmarshalErr(v39v4, bs39, h, t, "dec-map-v39-p-len") - testDeepEqualErr(v39v3, v39v4, t, "equal-map-v39-p-len") - } - } - for _, v := range []map[string]float32{nil, {}, {"some-string-3": 0, "some-string-1": 33.3e3}} { - // fmt.Printf(">>>> running mammoth map v40: %v\n", v) - var v40v1, v40v2 map[string]float32 - var bs40 []byte - v40v1 = v - bs40 = testMarshalErr(v40v1, h, t, "enc-map-v40") - if v != nil { - if v == nil { - v40v2 = nil - } else { - v40v2 = make(map[string]float32, len(v)) - } // reset map - testUnmarshalErr(v40v2, bs40, h, t, "dec-map-v40") - testDeepEqualErr(v40v1, v40v2, t, "equal-map-v40") - if v == nil { - v40v2 = nil - } else { - v40v2 = make(map[string]float32, len(v)) - } // reset map - testUnmarshalErr(rv4i(v40v2), bs40, h, t, "dec-map-v40-noaddr") // decode into non-addressable map value - testDeepEqualErr(v40v1, v40v2, t, "equal-map-v40-noaddr") - } - if v == nil { - v40v2 = nil - } else { - v40v2 = make(map[string]float32, len(v)) - } // reset map - testUnmarshalErr(&v40v2, bs40, h, t, "dec-map-v40-p-len") - testDeepEqualErr(v40v1, v40v2, t, "equal-map-v40-p-len") - bs40 = testMarshalErr(&v40v1, h, t, "enc-map-v40-p") - v40v2 = nil - testUnmarshalErr(&v40v2, bs40, h, t, "dec-map-v40-p-nil") - testDeepEqualErr(v40v1, v40v2, t, "equal-map-v40-p-nil") - // ... - if v == nil { - v40v2 = nil - } else { - v40v2 = make(map[string]float32, len(v)) - } // reset map - var v40v3, v40v4 typMapMapStringFloat32 - v40v3 = typMapMapStringFloat32(v40v1) - v40v4 = typMapMapStringFloat32(v40v2) - if v != nil { - bs40 = testMarshalErr(v40v3, h, t, "enc-map-v40-custom") - testUnmarshalErr(v40v4, bs40, h, t, "dec-map-v40-p-len") - testDeepEqualErr(v40v3, v40v4, t, "equal-map-v40-p-len") - } - } - for _, v := range []map[string]float64{nil, {}, {"some-string-2": 0, "some-string-3": 11.1}} { - // fmt.Printf(">>>> running mammoth map v41: %v\n", v) - var v41v1, v41v2 map[string]float64 - var bs41 []byte - v41v1 = v - bs41 = testMarshalErr(v41v1, h, t, "enc-map-v41") - if v != nil { - if v == nil { - v41v2 = nil - } else { - v41v2 = make(map[string]float64, len(v)) - } // reset map - testUnmarshalErr(v41v2, bs41, h, t, "dec-map-v41") - testDeepEqualErr(v41v1, v41v2, t, "equal-map-v41") - if v == nil { - v41v2 = nil - } else { - v41v2 = make(map[string]float64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v41v2), bs41, h, t, "dec-map-v41-noaddr") // decode into non-addressable map value - testDeepEqualErr(v41v1, v41v2, t, "equal-map-v41-noaddr") - } - if v == nil { - v41v2 = nil - } else { - v41v2 = make(map[string]float64, len(v)) - } // reset map - testUnmarshalErr(&v41v2, bs41, h, t, "dec-map-v41-p-len") - testDeepEqualErr(v41v1, v41v2, t, "equal-map-v41-p-len") - bs41 = testMarshalErr(&v41v1, h, t, "enc-map-v41-p") - v41v2 = nil - testUnmarshalErr(&v41v2, bs41, h, t, "dec-map-v41-p-nil") - testDeepEqualErr(v41v1, v41v2, t, "equal-map-v41-p-nil") - // ... - if v == nil { - v41v2 = nil - } else { - v41v2 = make(map[string]float64, len(v)) - } // reset map - var v41v3, v41v4 typMapMapStringFloat64 - v41v3 = typMapMapStringFloat64(v41v1) - v41v4 = typMapMapStringFloat64(v41v2) - if v != nil { - bs41 = testMarshalErr(v41v3, h, t, "enc-map-v41-custom") - testUnmarshalErr(v41v4, bs41, h, t, "dec-map-v41-p-len") - testDeepEqualErr(v41v3, v41v4, t, "equal-map-v41-p-len") - } - } - for _, v := range []map[string]bool{nil, {}, {"some-string-1": false, "some-string-2": true}} { - // fmt.Printf(">>>> running mammoth map v42: %v\n", v) - var v42v1, v42v2 map[string]bool - var bs42 []byte - v42v1 = v - bs42 = testMarshalErr(v42v1, h, t, "enc-map-v42") - if v != nil { - if v == nil { - v42v2 = nil - } else { - v42v2 = make(map[string]bool, len(v)) - } // reset map - testUnmarshalErr(v42v2, bs42, h, t, "dec-map-v42") - testDeepEqualErr(v42v1, v42v2, t, "equal-map-v42") - if v == nil { - v42v2 = nil - } else { - v42v2 = make(map[string]bool, len(v)) - } // reset map - testUnmarshalErr(rv4i(v42v2), bs42, h, t, "dec-map-v42-noaddr") // decode into non-addressable map value - testDeepEqualErr(v42v1, v42v2, t, "equal-map-v42-noaddr") - } - if v == nil { - v42v2 = nil - } else { - v42v2 = make(map[string]bool, len(v)) - } // reset map - testUnmarshalErr(&v42v2, bs42, h, t, "dec-map-v42-p-len") - testDeepEqualErr(v42v1, v42v2, t, "equal-map-v42-p-len") - bs42 = testMarshalErr(&v42v1, h, t, "enc-map-v42-p") - v42v2 = nil - testUnmarshalErr(&v42v2, bs42, h, t, "dec-map-v42-p-nil") - testDeepEqualErr(v42v1, v42v2, t, "equal-map-v42-p-nil") - // ... - if v == nil { - v42v2 = nil - } else { - v42v2 = make(map[string]bool, len(v)) - } // reset map - var v42v3, v42v4 typMapMapStringBool - v42v3 = typMapMapStringBool(v42v1) - v42v4 = typMapMapStringBool(v42v2) - if v != nil { - bs42 = testMarshalErr(v42v3, h, t, "enc-map-v42-custom") - testUnmarshalErr(v42v4, bs42, h, t, "dec-map-v42-p-len") - testDeepEqualErr(v42v3, v42v4, t, "equal-map-v42-p-len") - } - } - for _, v := range []map[uint]interface{}{nil, {}, {111: nil, 77: "string-is-an-interface-2"}} { - // fmt.Printf(">>>> running mammoth map v43: %v\n", v) - var v43v1, v43v2 map[uint]interface{} - var bs43 []byte - v43v1 = v - bs43 = testMarshalErr(v43v1, h, t, "enc-map-v43") - if v != nil { - if v == nil { - v43v2 = nil - } else { - v43v2 = make(map[uint]interface{}, len(v)) - } // reset map - testUnmarshalErr(v43v2, bs43, h, t, "dec-map-v43") - testDeepEqualErr(v43v1, v43v2, t, "equal-map-v43") - if v == nil { - v43v2 = nil - } else { - v43v2 = make(map[uint]interface{}, len(v)) - } // reset map - testUnmarshalErr(rv4i(v43v2), bs43, h, t, "dec-map-v43-noaddr") // decode into non-addressable map value - testDeepEqualErr(v43v1, v43v2, t, "equal-map-v43-noaddr") - } - if v == nil { - v43v2 = nil - } else { - v43v2 = make(map[uint]interface{}, len(v)) - } // reset map - testUnmarshalErr(&v43v2, bs43, h, t, "dec-map-v43-p-len") - testDeepEqualErr(v43v1, v43v2, t, "equal-map-v43-p-len") - bs43 = testMarshalErr(&v43v1, h, t, "enc-map-v43-p") - v43v2 = nil - testUnmarshalErr(&v43v2, bs43, h, t, "dec-map-v43-p-nil") - testDeepEqualErr(v43v1, v43v2, t, "equal-map-v43-p-nil") - // ... - if v == nil { - v43v2 = nil - } else { - v43v2 = make(map[uint]interface{}, len(v)) - } // reset map - var v43v3, v43v4 typMapMapUintIntf - v43v3 = typMapMapUintIntf(v43v1) - v43v4 = typMapMapUintIntf(v43v2) - if v != nil { - bs43 = testMarshalErr(v43v3, h, t, "enc-map-v43-custom") - testUnmarshalErr(v43v4, bs43, h, t, "dec-map-v43-p-len") - testDeepEqualErr(v43v3, v43v4, t, "equal-map-v43-p-len") - } - } - for _, v := range []map[uint]string{nil, {}, {127: "", 111: "some-string-3"}} { - // fmt.Printf(">>>> running mammoth map v44: %v\n", v) - var v44v1, v44v2 map[uint]string - var bs44 []byte - v44v1 = v - bs44 = testMarshalErr(v44v1, h, t, "enc-map-v44") - if v != nil { - if v == nil { - v44v2 = nil - } else { - v44v2 = make(map[uint]string, len(v)) - } // reset map - testUnmarshalErr(v44v2, bs44, h, t, "dec-map-v44") - testDeepEqualErr(v44v1, v44v2, t, "equal-map-v44") - if v == nil { - v44v2 = nil - } else { - v44v2 = make(map[uint]string, len(v)) - } // reset map - testUnmarshalErr(rv4i(v44v2), bs44, h, t, "dec-map-v44-noaddr") // decode into non-addressable map value - testDeepEqualErr(v44v1, v44v2, t, "equal-map-v44-noaddr") - } - if v == nil { - v44v2 = nil - } else { - v44v2 = make(map[uint]string, len(v)) - } // reset map - testUnmarshalErr(&v44v2, bs44, h, t, "dec-map-v44-p-len") - testDeepEqualErr(v44v1, v44v2, t, "equal-map-v44-p-len") - bs44 = testMarshalErr(&v44v1, h, t, "enc-map-v44-p") - v44v2 = nil - testUnmarshalErr(&v44v2, bs44, h, t, "dec-map-v44-p-nil") - testDeepEqualErr(v44v1, v44v2, t, "equal-map-v44-p-nil") - // ... - if v == nil { - v44v2 = nil - } else { - v44v2 = make(map[uint]string, len(v)) - } // reset map - var v44v3, v44v4 typMapMapUintString - v44v3 = typMapMapUintString(v44v1) - v44v4 = typMapMapUintString(v44v2) - if v != nil { - bs44 = testMarshalErr(v44v3, h, t, "enc-map-v44-custom") - testUnmarshalErr(v44v4, bs44, h, t, "dec-map-v44-p-len") - testDeepEqualErr(v44v3, v44v4, t, "equal-map-v44-p-len") - } - } - for _, v := range []map[uint][]byte{nil, {}, {77: nil, 127: []byte("some-string-2")}} { - // fmt.Printf(">>>> running mammoth map v45: %v\n", v) - var v45v1, v45v2 map[uint][]byte - var bs45 []byte - v45v1 = v - bs45 = testMarshalErr(v45v1, h, t, "enc-map-v45") - if v != nil { - if v == nil { - v45v2 = nil - } else { - v45v2 = make(map[uint][]byte, len(v)) - } // reset map - testUnmarshalErr(v45v2, bs45, h, t, "dec-map-v45") - testDeepEqualErr(v45v1, v45v2, t, "equal-map-v45") - if v == nil { - v45v2 = nil - } else { - v45v2 = make(map[uint][]byte, len(v)) - } // reset map - testUnmarshalErr(rv4i(v45v2), bs45, h, t, "dec-map-v45-noaddr") // decode into non-addressable map value - testDeepEqualErr(v45v1, v45v2, t, "equal-map-v45-noaddr") - } - if v == nil { - v45v2 = nil - } else { - v45v2 = make(map[uint][]byte, len(v)) - } // reset map - testUnmarshalErr(&v45v2, bs45, h, t, "dec-map-v45-p-len") - testDeepEqualErr(v45v1, v45v2, t, "equal-map-v45-p-len") - bs45 = testMarshalErr(&v45v1, h, t, "enc-map-v45-p") - v45v2 = nil - testUnmarshalErr(&v45v2, bs45, h, t, "dec-map-v45-p-nil") - testDeepEqualErr(v45v1, v45v2, t, "equal-map-v45-p-nil") - // ... - if v == nil { - v45v2 = nil - } else { - v45v2 = make(map[uint][]byte, len(v)) - } // reset map - var v45v3, v45v4 typMapMapUintBytes - v45v3 = typMapMapUintBytes(v45v1) - v45v4 = typMapMapUintBytes(v45v2) - if v != nil { - bs45 = testMarshalErr(v45v3, h, t, "enc-map-v45-custom") - testUnmarshalErr(v45v4, bs45, h, t, "dec-map-v45-p-len") - testDeepEqualErr(v45v3, v45v4, t, "equal-map-v45-p-len") - } - } - for _, v := range []map[uint]uint{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v46: %v\n", v) - var v46v1, v46v2 map[uint]uint - var bs46 []byte - v46v1 = v - bs46 = testMarshalErr(v46v1, h, t, "enc-map-v46") - if v != nil { - if v == nil { - v46v2 = nil - } else { - v46v2 = make(map[uint]uint, len(v)) - } // reset map - testUnmarshalErr(v46v2, bs46, h, t, "dec-map-v46") - testDeepEqualErr(v46v1, v46v2, t, "equal-map-v46") - if v == nil { - v46v2 = nil - } else { - v46v2 = make(map[uint]uint, len(v)) - } // reset map - testUnmarshalErr(rv4i(v46v2), bs46, h, t, "dec-map-v46-noaddr") // decode into non-addressable map value - testDeepEqualErr(v46v1, v46v2, t, "equal-map-v46-noaddr") - } - if v == nil { - v46v2 = nil - } else { - v46v2 = make(map[uint]uint, len(v)) - } // reset map - testUnmarshalErr(&v46v2, bs46, h, t, "dec-map-v46-p-len") - testDeepEqualErr(v46v1, v46v2, t, "equal-map-v46-p-len") - bs46 = testMarshalErr(&v46v1, h, t, "enc-map-v46-p") - v46v2 = nil - testUnmarshalErr(&v46v2, bs46, h, t, "dec-map-v46-p-nil") - testDeepEqualErr(v46v1, v46v2, t, "equal-map-v46-p-nil") - // ... - if v == nil { - v46v2 = nil - } else { - v46v2 = make(map[uint]uint, len(v)) - } // reset map - var v46v3, v46v4 typMapMapUintUint - v46v3 = typMapMapUintUint(v46v1) - v46v4 = typMapMapUintUint(v46v2) - if v != nil { - bs46 = testMarshalErr(v46v3, h, t, "enc-map-v46-custom") - testUnmarshalErr(v46v4, bs46, h, t, "dec-map-v46-p-len") - testDeepEqualErr(v46v3, v46v4, t, "equal-map-v46-p-len") - } - } - for _, v := range []map[uint]uint8{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v47: %v\n", v) - var v47v1, v47v2 map[uint]uint8 - var bs47 []byte - v47v1 = v - bs47 = testMarshalErr(v47v1, h, t, "enc-map-v47") - if v != nil { - if v == nil { - v47v2 = nil - } else { - v47v2 = make(map[uint]uint8, len(v)) - } // reset map - testUnmarshalErr(v47v2, bs47, h, t, "dec-map-v47") - testDeepEqualErr(v47v1, v47v2, t, "equal-map-v47") - if v == nil { - v47v2 = nil - } else { - v47v2 = make(map[uint]uint8, len(v)) - } // reset map - testUnmarshalErr(rv4i(v47v2), bs47, h, t, "dec-map-v47-noaddr") // decode into non-addressable map value - testDeepEqualErr(v47v1, v47v2, t, "equal-map-v47-noaddr") - } - if v == nil { - v47v2 = nil - } else { - v47v2 = make(map[uint]uint8, len(v)) - } // reset map - testUnmarshalErr(&v47v2, bs47, h, t, "dec-map-v47-p-len") - testDeepEqualErr(v47v1, v47v2, t, "equal-map-v47-p-len") - bs47 = testMarshalErr(&v47v1, h, t, "enc-map-v47-p") - v47v2 = nil - testUnmarshalErr(&v47v2, bs47, h, t, "dec-map-v47-p-nil") - testDeepEqualErr(v47v1, v47v2, t, "equal-map-v47-p-nil") - // ... - if v == nil { - v47v2 = nil - } else { - v47v2 = make(map[uint]uint8, len(v)) - } // reset map - var v47v3, v47v4 typMapMapUintUint8 - v47v3 = typMapMapUintUint8(v47v1) - v47v4 = typMapMapUintUint8(v47v2) - if v != nil { - bs47 = testMarshalErr(v47v3, h, t, "enc-map-v47-custom") - testUnmarshalErr(v47v4, bs47, h, t, "dec-map-v47-p-len") - testDeepEqualErr(v47v3, v47v4, t, "equal-map-v47-p-len") - } - } - for _, v := range []map[uint]uint64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v48: %v\n", v) - var v48v1, v48v2 map[uint]uint64 - var bs48 []byte - v48v1 = v - bs48 = testMarshalErr(v48v1, h, t, "enc-map-v48") - if v != nil { - if v == nil { - v48v2 = nil - } else { - v48v2 = make(map[uint]uint64, len(v)) - } // reset map - testUnmarshalErr(v48v2, bs48, h, t, "dec-map-v48") - testDeepEqualErr(v48v1, v48v2, t, "equal-map-v48") - if v == nil { - v48v2 = nil - } else { - v48v2 = make(map[uint]uint64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v48v2), bs48, h, t, "dec-map-v48-noaddr") // decode into non-addressable map value - testDeepEqualErr(v48v1, v48v2, t, "equal-map-v48-noaddr") - } - if v == nil { - v48v2 = nil - } else { - v48v2 = make(map[uint]uint64, len(v)) - } // reset map - testUnmarshalErr(&v48v2, bs48, h, t, "dec-map-v48-p-len") - testDeepEqualErr(v48v1, v48v2, t, "equal-map-v48-p-len") - bs48 = testMarshalErr(&v48v1, h, t, "enc-map-v48-p") - v48v2 = nil - testUnmarshalErr(&v48v2, bs48, h, t, "dec-map-v48-p-nil") - testDeepEqualErr(v48v1, v48v2, t, "equal-map-v48-p-nil") - // ... - if v == nil { - v48v2 = nil - } else { - v48v2 = make(map[uint]uint64, len(v)) - } // reset map - var v48v3, v48v4 typMapMapUintUint64 - v48v3 = typMapMapUintUint64(v48v1) - v48v4 = typMapMapUintUint64(v48v2) - if v != nil { - bs48 = testMarshalErr(v48v3, h, t, "enc-map-v48-custom") - testUnmarshalErr(v48v4, bs48, h, t, "dec-map-v48-p-len") - testDeepEqualErr(v48v3, v48v4, t, "equal-map-v48-p-len") - } - } - for _, v := range []map[uint]int{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v49: %v\n", v) - var v49v1, v49v2 map[uint]int - var bs49 []byte - v49v1 = v - bs49 = testMarshalErr(v49v1, h, t, "enc-map-v49") - if v != nil { - if v == nil { - v49v2 = nil - } else { - v49v2 = make(map[uint]int, len(v)) - } // reset map - testUnmarshalErr(v49v2, bs49, h, t, "dec-map-v49") - testDeepEqualErr(v49v1, v49v2, t, "equal-map-v49") - if v == nil { - v49v2 = nil - } else { - v49v2 = make(map[uint]int, len(v)) - } // reset map - testUnmarshalErr(rv4i(v49v2), bs49, h, t, "dec-map-v49-noaddr") // decode into non-addressable map value - testDeepEqualErr(v49v1, v49v2, t, "equal-map-v49-noaddr") - } - if v == nil { - v49v2 = nil - } else { - v49v2 = make(map[uint]int, len(v)) - } // reset map - testUnmarshalErr(&v49v2, bs49, h, t, "dec-map-v49-p-len") - testDeepEqualErr(v49v1, v49v2, t, "equal-map-v49-p-len") - bs49 = testMarshalErr(&v49v1, h, t, "enc-map-v49-p") - v49v2 = nil - testUnmarshalErr(&v49v2, bs49, h, t, "dec-map-v49-p-nil") - testDeepEqualErr(v49v1, v49v2, t, "equal-map-v49-p-nil") - // ... - if v == nil { - v49v2 = nil - } else { - v49v2 = make(map[uint]int, len(v)) - } // reset map - var v49v3, v49v4 typMapMapUintInt - v49v3 = typMapMapUintInt(v49v1) - v49v4 = typMapMapUintInt(v49v2) - if v != nil { - bs49 = testMarshalErr(v49v3, h, t, "enc-map-v49-custom") - testUnmarshalErr(v49v4, bs49, h, t, "dec-map-v49-p-len") - testDeepEqualErr(v49v3, v49v4, t, "equal-map-v49-p-len") - } - } - for _, v := range []map[uint]int64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v50: %v\n", v) - var v50v1, v50v2 map[uint]int64 - var bs50 []byte - v50v1 = v - bs50 = testMarshalErr(v50v1, h, t, "enc-map-v50") - if v != nil { - if v == nil { - v50v2 = nil - } else { - v50v2 = make(map[uint]int64, len(v)) - } // reset map - testUnmarshalErr(v50v2, bs50, h, t, "dec-map-v50") - testDeepEqualErr(v50v1, v50v2, t, "equal-map-v50") - if v == nil { - v50v2 = nil - } else { - v50v2 = make(map[uint]int64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v50v2), bs50, h, t, "dec-map-v50-noaddr") // decode into non-addressable map value - testDeepEqualErr(v50v1, v50v2, t, "equal-map-v50-noaddr") - } - if v == nil { - v50v2 = nil - } else { - v50v2 = make(map[uint]int64, len(v)) - } // reset map - testUnmarshalErr(&v50v2, bs50, h, t, "dec-map-v50-p-len") - testDeepEqualErr(v50v1, v50v2, t, "equal-map-v50-p-len") - bs50 = testMarshalErr(&v50v1, h, t, "enc-map-v50-p") - v50v2 = nil - testUnmarshalErr(&v50v2, bs50, h, t, "dec-map-v50-p-nil") - testDeepEqualErr(v50v1, v50v2, t, "equal-map-v50-p-nil") - // ... - if v == nil { - v50v2 = nil - } else { - v50v2 = make(map[uint]int64, len(v)) - } // reset map - var v50v3, v50v4 typMapMapUintInt64 - v50v3 = typMapMapUintInt64(v50v1) - v50v4 = typMapMapUintInt64(v50v2) - if v != nil { - bs50 = testMarshalErr(v50v3, h, t, "enc-map-v50-custom") - testUnmarshalErr(v50v4, bs50, h, t, "dec-map-v50-p-len") - testDeepEqualErr(v50v3, v50v4, t, "equal-map-v50-p-len") - } - } - for _, v := range []map[uint]float32{nil, {}, {111: 0, 77: 22.2}} { - // fmt.Printf(">>>> running mammoth map v51: %v\n", v) - var v51v1, v51v2 map[uint]float32 - var bs51 []byte - v51v1 = v - bs51 = testMarshalErr(v51v1, h, t, "enc-map-v51") - if v != nil { - if v == nil { - v51v2 = nil - } else { - v51v2 = make(map[uint]float32, len(v)) - } // reset map - testUnmarshalErr(v51v2, bs51, h, t, "dec-map-v51") - testDeepEqualErr(v51v1, v51v2, t, "equal-map-v51") - if v == nil { - v51v2 = nil - } else { - v51v2 = make(map[uint]float32, len(v)) - } // reset map - testUnmarshalErr(rv4i(v51v2), bs51, h, t, "dec-map-v51-noaddr") // decode into non-addressable map value - testDeepEqualErr(v51v1, v51v2, t, "equal-map-v51-noaddr") - } - if v == nil { - v51v2 = nil - } else { - v51v2 = make(map[uint]float32, len(v)) - } // reset map - testUnmarshalErr(&v51v2, bs51, h, t, "dec-map-v51-p-len") - testDeepEqualErr(v51v1, v51v2, t, "equal-map-v51-p-len") - bs51 = testMarshalErr(&v51v1, h, t, "enc-map-v51-p") - v51v2 = nil - testUnmarshalErr(&v51v2, bs51, h, t, "dec-map-v51-p-nil") - testDeepEqualErr(v51v1, v51v2, t, "equal-map-v51-p-nil") - // ... - if v == nil { - v51v2 = nil - } else { - v51v2 = make(map[uint]float32, len(v)) - } // reset map - var v51v3, v51v4 typMapMapUintFloat32 - v51v3 = typMapMapUintFloat32(v51v1) - v51v4 = typMapMapUintFloat32(v51v2) - if v != nil { - bs51 = testMarshalErr(v51v3, h, t, "enc-map-v51-custom") - testUnmarshalErr(v51v4, bs51, h, t, "dec-map-v51-p-len") - testDeepEqualErr(v51v3, v51v4, t, "equal-map-v51-p-len") - } - } - for _, v := range []map[uint]float64{nil, {}, {127: 0, 111: 33.3e3}} { - // fmt.Printf(">>>> running mammoth map v52: %v\n", v) - var v52v1, v52v2 map[uint]float64 - var bs52 []byte - v52v1 = v - bs52 = testMarshalErr(v52v1, h, t, "enc-map-v52") - if v != nil { - if v == nil { - v52v2 = nil - } else { - v52v2 = make(map[uint]float64, len(v)) - } // reset map - testUnmarshalErr(v52v2, bs52, h, t, "dec-map-v52") - testDeepEqualErr(v52v1, v52v2, t, "equal-map-v52") - if v == nil { - v52v2 = nil - } else { - v52v2 = make(map[uint]float64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v52v2), bs52, h, t, "dec-map-v52-noaddr") // decode into non-addressable map value - testDeepEqualErr(v52v1, v52v2, t, "equal-map-v52-noaddr") - } - if v == nil { - v52v2 = nil - } else { - v52v2 = make(map[uint]float64, len(v)) - } // reset map - testUnmarshalErr(&v52v2, bs52, h, t, "dec-map-v52-p-len") - testDeepEqualErr(v52v1, v52v2, t, "equal-map-v52-p-len") - bs52 = testMarshalErr(&v52v1, h, t, "enc-map-v52-p") - v52v2 = nil - testUnmarshalErr(&v52v2, bs52, h, t, "dec-map-v52-p-nil") - testDeepEqualErr(v52v1, v52v2, t, "equal-map-v52-p-nil") - // ... - if v == nil { - v52v2 = nil - } else { - v52v2 = make(map[uint]float64, len(v)) - } // reset map - var v52v3, v52v4 typMapMapUintFloat64 - v52v3 = typMapMapUintFloat64(v52v1) - v52v4 = typMapMapUintFloat64(v52v2) - if v != nil { - bs52 = testMarshalErr(v52v3, h, t, "enc-map-v52-custom") - testUnmarshalErr(v52v4, bs52, h, t, "dec-map-v52-p-len") - testDeepEqualErr(v52v3, v52v4, t, "equal-map-v52-p-len") - } - } - for _, v := range []map[uint]bool{nil, {}, {77: false, 127: false}} { - // fmt.Printf(">>>> running mammoth map v53: %v\n", v) - var v53v1, v53v2 map[uint]bool - var bs53 []byte - v53v1 = v - bs53 = testMarshalErr(v53v1, h, t, "enc-map-v53") - if v != nil { - if v == nil { - v53v2 = nil - } else { - v53v2 = make(map[uint]bool, len(v)) - } // reset map - testUnmarshalErr(v53v2, bs53, h, t, "dec-map-v53") - testDeepEqualErr(v53v1, v53v2, t, "equal-map-v53") - if v == nil { - v53v2 = nil - } else { - v53v2 = make(map[uint]bool, len(v)) - } // reset map - testUnmarshalErr(rv4i(v53v2), bs53, h, t, "dec-map-v53-noaddr") // decode into non-addressable map value - testDeepEqualErr(v53v1, v53v2, t, "equal-map-v53-noaddr") - } - if v == nil { - v53v2 = nil - } else { - v53v2 = make(map[uint]bool, len(v)) - } // reset map - testUnmarshalErr(&v53v2, bs53, h, t, "dec-map-v53-p-len") - testDeepEqualErr(v53v1, v53v2, t, "equal-map-v53-p-len") - bs53 = testMarshalErr(&v53v1, h, t, "enc-map-v53-p") - v53v2 = nil - testUnmarshalErr(&v53v2, bs53, h, t, "dec-map-v53-p-nil") - testDeepEqualErr(v53v1, v53v2, t, "equal-map-v53-p-nil") - // ... - if v == nil { - v53v2 = nil - } else { - v53v2 = make(map[uint]bool, len(v)) - } // reset map - var v53v3, v53v4 typMapMapUintBool - v53v3 = typMapMapUintBool(v53v1) - v53v4 = typMapMapUintBool(v53v2) - if v != nil { - bs53 = testMarshalErr(v53v3, h, t, "enc-map-v53-custom") - testUnmarshalErr(v53v4, bs53, h, t, "dec-map-v53-p-len") - testDeepEqualErr(v53v3, v53v4, t, "equal-map-v53-p-len") - } - } - for _, v := range []map[uint8]interface{}{nil, {}, {111: nil, 77: "string-is-an-interface-3"}} { - // fmt.Printf(">>>> running mammoth map v54: %v\n", v) - var v54v1, v54v2 map[uint8]interface{} - var bs54 []byte - v54v1 = v - bs54 = testMarshalErr(v54v1, h, t, "enc-map-v54") - if v != nil { - if v == nil { - v54v2 = nil - } else { - v54v2 = make(map[uint8]interface{}, len(v)) - } // reset map - testUnmarshalErr(v54v2, bs54, h, t, "dec-map-v54") - testDeepEqualErr(v54v1, v54v2, t, "equal-map-v54") - if v == nil { - v54v2 = nil - } else { - v54v2 = make(map[uint8]interface{}, len(v)) - } // reset map - testUnmarshalErr(rv4i(v54v2), bs54, h, t, "dec-map-v54-noaddr") // decode into non-addressable map value - testDeepEqualErr(v54v1, v54v2, t, "equal-map-v54-noaddr") - } - if v == nil { - v54v2 = nil - } else { - v54v2 = make(map[uint8]interface{}, len(v)) - } // reset map - testUnmarshalErr(&v54v2, bs54, h, t, "dec-map-v54-p-len") - testDeepEqualErr(v54v1, v54v2, t, "equal-map-v54-p-len") - bs54 = testMarshalErr(&v54v1, h, t, "enc-map-v54-p") - v54v2 = nil - testUnmarshalErr(&v54v2, bs54, h, t, "dec-map-v54-p-nil") - testDeepEqualErr(v54v1, v54v2, t, "equal-map-v54-p-nil") - // ... - if v == nil { - v54v2 = nil - } else { - v54v2 = make(map[uint8]interface{}, len(v)) - } // reset map - var v54v3, v54v4 typMapMapUint8Intf - v54v3 = typMapMapUint8Intf(v54v1) - v54v4 = typMapMapUint8Intf(v54v2) - if v != nil { - bs54 = testMarshalErr(v54v3, h, t, "enc-map-v54-custom") - testUnmarshalErr(v54v4, bs54, h, t, "dec-map-v54-p-len") - testDeepEqualErr(v54v3, v54v4, t, "equal-map-v54-p-len") - } - } - for _, v := range []map[uint8]string{nil, {}, {127: "", 111: "some-string-1"}} { - // fmt.Printf(">>>> running mammoth map v55: %v\n", v) - var v55v1, v55v2 map[uint8]string - var bs55 []byte - v55v1 = v - bs55 = testMarshalErr(v55v1, h, t, "enc-map-v55") - if v != nil { - if v == nil { - v55v2 = nil - } else { - v55v2 = make(map[uint8]string, len(v)) - } // reset map - testUnmarshalErr(v55v2, bs55, h, t, "dec-map-v55") - testDeepEqualErr(v55v1, v55v2, t, "equal-map-v55") - if v == nil { - v55v2 = nil - } else { - v55v2 = make(map[uint8]string, len(v)) - } // reset map - testUnmarshalErr(rv4i(v55v2), bs55, h, t, "dec-map-v55-noaddr") // decode into non-addressable map value - testDeepEqualErr(v55v1, v55v2, t, "equal-map-v55-noaddr") - } - if v == nil { - v55v2 = nil - } else { - v55v2 = make(map[uint8]string, len(v)) - } // reset map - testUnmarshalErr(&v55v2, bs55, h, t, "dec-map-v55-p-len") - testDeepEqualErr(v55v1, v55v2, t, "equal-map-v55-p-len") - bs55 = testMarshalErr(&v55v1, h, t, "enc-map-v55-p") - v55v2 = nil - testUnmarshalErr(&v55v2, bs55, h, t, "dec-map-v55-p-nil") - testDeepEqualErr(v55v1, v55v2, t, "equal-map-v55-p-nil") - // ... - if v == nil { - v55v2 = nil - } else { - v55v2 = make(map[uint8]string, len(v)) - } // reset map - var v55v3, v55v4 typMapMapUint8String - v55v3 = typMapMapUint8String(v55v1) - v55v4 = typMapMapUint8String(v55v2) - if v != nil { - bs55 = testMarshalErr(v55v3, h, t, "enc-map-v55-custom") - testUnmarshalErr(v55v4, bs55, h, t, "dec-map-v55-p-len") - testDeepEqualErr(v55v3, v55v4, t, "equal-map-v55-p-len") - } - } - for _, v := range []map[uint8][]byte{nil, {}, {77: nil, 127: []byte("some-string-3")}} { - // fmt.Printf(">>>> running mammoth map v56: %v\n", v) - var v56v1, v56v2 map[uint8][]byte - var bs56 []byte - v56v1 = v - bs56 = testMarshalErr(v56v1, h, t, "enc-map-v56") - if v != nil { - if v == nil { - v56v2 = nil - } else { - v56v2 = make(map[uint8][]byte, len(v)) - } // reset map - testUnmarshalErr(v56v2, bs56, h, t, "dec-map-v56") - testDeepEqualErr(v56v1, v56v2, t, "equal-map-v56") - if v == nil { - v56v2 = nil - } else { - v56v2 = make(map[uint8][]byte, len(v)) - } // reset map - testUnmarshalErr(rv4i(v56v2), bs56, h, t, "dec-map-v56-noaddr") // decode into non-addressable map value - testDeepEqualErr(v56v1, v56v2, t, "equal-map-v56-noaddr") - } - if v == nil { - v56v2 = nil - } else { - v56v2 = make(map[uint8][]byte, len(v)) - } // reset map - testUnmarshalErr(&v56v2, bs56, h, t, "dec-map-v56-p-len") - testDeepEqualErr(v56v1, v56v2, t, "equal-map-v56-p-len") - bs56 = testMarshalErr(&v56v1, h, t, "enc-map-v56-p") - v56v2 = nil - testUnmarshalErr(&v56v2, bs56, h, t, "dec-map-v56-p-nil") - testDeepEqualErr(v56v1, v56v2, t, "equal-map-v56-p-nil") - // ... - if v == nil { - v56v2 = nil - } else { - v56v2 = make(map[uint8][]byte, len(v)) - } // reset map - var v56v3, v56v4 typMapMapUint8Bytes - v56v3 = typMapMapUint8Bytes(v56v1) - v56v4 = typMapMapUint8Bytes(v56v2) - if v != nil { - bs56 = testMarshalErr(v56v3, h, t, "enc-map-v56-custom") - testUnmarshalErr(v56v4, bs56, h, t, "dec-map-v56-p-len") - testDeepEqualErr(v56v3, v56v4, t, "equal-map-v56-p-len") - } - } - for _, v := range []map[uint8]uint{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v57: %v\n", v) - var v57v1, v57v2 map[uint8]uint - var bs57 []byte - v57v1 = v - bs57 = testMarshalErr(v57v1, h, t, "enc-map-v57") - if v != nil { - if v == nil { - v57v2 = nil - } else { - v57v2 = make(map[uint8]uint, len(v)) - } // reset map - testUnmarshalErr(v57v2, bs57, h, t, "dec-map-v57") - testDeepEqualErr(v57v1, v57v2, t, "equal-map-v57") - if v == nil { - v57v2 = nil - } else { - v57v2 = make(map[uint8]uint, len(v)) - } // reset map - testUnmarshalErr(rv4i(v57v2), bs57, h, t, "dec-map-v57-noaddr") // decode into non-addressable map value - testDeepEqualErr(v57v1, v57v2, t, "equal-map-v57-noaddr") - } - if v == nil { - v57v2 = nil - } else { - v57v2 = make(map[uint8]uint, len(v)) - } // reset map - testUnmarshalErr(&v57v2, bs57, h, t, "dec-map-v57-p-len") - testDeepEqualErr(v57v1, v57v2, t, "equal-map-v57-p-len") - bs57 = testMarshalErr(&v57v1, h, t, "enc-map-v57-p") - v57v2 = nil - testUnmarshalErr(&v57v2, bs57, h, t, "dec-map-v57-p-nil") - testDeepEqualErr(v57v1, v57v2, t, "equal-map-v57-p-nil") - // ... - if v == nil { - v57v2 = nil - } else { - v57v2 = make(map[uint8]uint, len(v)) - } // reset map - var v57v3, v57v4 typMapMapUint8Uint - v57v3 = typMapMapUint8Uint(v57v1) - v57v4 = typMapMapUint8Uint(v57v2) - if v != nil { - bs57 = testMarshalErr(v57v3, h, t, "enc-map-v57-custom") - testUnmarshalErr(v57v4, bs57, h, t, "dec-map-v57-p-len") - testDeepEqualErr(v57v3, v57v4, t, "equal-map-v57-p-len") - } - } - for _, v := range []map[uint8]uint8{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v58: %v\n", v) - var v58v1, v58v2 map[uint8]uint8 - var bs58 []byte - v58v1 = v - bs58 = testMarshalErr(v58v1, h, t, "enc-map-v58") - if v != nil { - if v == nil { - v58v2 = nil - } else { - v58v2 = make(map[uint8]uint8, len(v)) - } // reset map - testUnmarshalErr(v58v2, bs58, h, t, "dec-map-v58") - testDeepEqualErr(v58v1, v58v2, t, "equal-map-v58") - if v == nil { - v58v2 = nil - } else { - v58v2 = make(map[uint8]uint8, len(v)) - } // reset map - testUnmarshalErr(rv4i(v58v2), bs58, h, t, "dec-map-v58-noaddr") // decode into non-addressable map value - testDeepEqualErr(v58v1, v58v2, t, "equal-map-v58-noaddr") - } - if v == nil { - v58v2 = nil - } else { - v58v2 = make(map[uint8]uint8, len(v)) - } // reset map - testUnmarshalErr(&v58v2, bs58, h, t, "dec-map-v58-p-len") - testDeepEqualErr(v58v1, v58v2, t, "equal-map-v58-p-len") - bs58 = testMarshalErr(&v58v1, h, t, "enc-map-v58-p") - v58v2 = nil - testUnmarshalErr(&v58v2, bs58, h, t, "dec-map-v58-p-nil") - testDeepEqualErr(v58v1, v58v2, t, "equal-map-v58-p-nil") - // ... - if v == nil { - v58v2 = nil - } else { - v58v2 = make(map[uint8]uint8, len(v)) - } // reset map - var v58v3, v58v4 typMapMapUint8Uint8 - v58v3 = typMapMapUint8Uint8(v58v1) - v58v4 = typMapMapUint8Uint8(v58v2) - if v != nil { - bs58 = testMarshalErr(v58v3, h, t, "enc-map-v58-custom") - testUnmarshalErr(v58v4, bs58, h, t, "dec-map-v58-p-len") - testDeepEqualErr(v58v3, v58v4, t, "equal-map-v58-p-len") - } - } - for _, v := range []map[uint8]uint64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v59: %v\n", v) - var v59v1, v59v2 map[uint8]uint64 - var bs59 []byte - v59v1 = v - bs59 = testMarshalErr(v59v1, h, t, "enc-map-v59") - if v != nil { - if v == nil { - v59v2 = nil - } else { - v59v2 = make(map[uint8]uint64, len(v)) - } // reset map - testUnmarshalErr(v59v2, bs59, h, t, "dec-map-v59") - testDeepEqualErr(v59v1, v59v2, t, "equal-map-v59") - if v == nil { - v59v2 = nil - } else { - v59v2 = make(map[uint8]uint64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v59v2), bs59, h, t, "dec-map-v59-noaddr") // decode into non-addressable map value - testDeepEqualErr(v59v1, v59v2, t, "equal-map-v59-noaddr") - } - if v == nil { - v59v2 = nil - } else { - v59v2 = make(map[uint8]uint64, len(v)) - } // reset map - testUnmarshalErr(&v59v2, bs59, h, t, "dec-map-v59-p-len") - testDeepEqualErr(v59v1, v59v2, t, "equal-map-v59-p-len") - bs59 = testMarshalErr(&v59v1, h, t, "enc-map-v59-p") - v59v2 = nil - testUnmarshalErr(&v59v2, bs59, h, t, "dec-map-v59-p-nil") - testDeepEqualErr(v59v1, v59v2, t, "equal-map-v59-p-nil") - // ... - if v == nil { - v59v2 = nil - } else { - v59v2 = make(map[uint8]uint64, len(v)) - } // reset map - var v59v3, v59v4 typMapMapUint8Uint64 - v59v3 = typMapMapUint8Uint64(v59v1) - v59v4 = typMapMapUint8Uint64(v59v2) - if v != nil { - bs59 = testMarshalErr(v59v3, h, t, "enc-map-v59-custom") - testUnmarshalErr(v59v4, bs59, h, t, "dec-map-v59-p-len") - testDeepEqualErr(v59v3, v59v4, t, "equal-map-v59-p-len") - } - } - for _, v := range []map[uint8]int{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v60: %v\n", v) - var v60v1, v60v2 map[uint8]int - var bs60 []byte - v60v1 = v - bs60 = testMarshalErr(v60v1, h, t, "enc-map-v60") - if v != nil { - if v == nil { - v60v2 = nil - } else { - v60v2 = make(map[uint8]int, len(v)) - } // reset map - testUnmarshalErr(v60v2, bs60, h, t, "dec-map-v60") - testDeepEqualErr(v60v1, v60v2, t, "equal-map-v60") - if v == nil { - v60v2 = nil - } else { - v60v2 = make(map[uint8]int, len(v)) - } // reset map - testUnmarshalErr(rv4i(v60v2), bs60, h, t, "dec-map-v60-noaddr") // decode into non-addressable map value - testDeepEqualErr(v60v1, v60v2, t, "equal-map-v60-noaddr") - } - if v == nil { - v60v2 = nil - } else { - v60v2 = make(map[uint8]int, len(v)) - } // reset map - testUnmarshalErr(&v60v2, bs60, h, t, "dec-map-v60-p-len") - testDeepEqualErr(v60v1, v60v2, t, "equal-map-v60-p-len") - bs60 = testMarshalErr(&v60v1, h, t, "enc-map-v60-p") - v60v2 = nil - testUnmarshalErr(&v60v2, bs60, h, t, "dec-map-v60-p-nil") - testDeepEqualErr(v60v1, v60v2, t, "equal-map-v60-p-nil") - // ... - if v == nil { - v60v2 = nil - } else { - v60v2 = make(map[uint8]int, len(v)) - } // reset map - var v60v3, v60v4 typMapMapUint8Int - v60v3 = typMapMapUint8Int(v60v1) - v60v4 = typMapMapUint8Int(v60v2) - if v != nil { - bs60 = testMarshalErr(v60v3, h, t, "enc-map-v60-custom") - testUnmarshalErr(v60v4, bs60, h, t, "dec-map-v60-p-len") - testDeepEqualErr(v60v3, v60v4, t, "equal-map-v60-p-len") - } - } - for _, v := range []map[uint8]int64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v61: %v\n", v) - var v61v1, v61v2 map[uint8]int64 - var bs61 []byte - v61v1 = v - bs61 = testMarshalErr(v61v1, h, t, "enc-map-v61") - if v != nil { - if v == nil { - v61v2 = nil - } else { - v61v2 = make(map[uint8]int64, len(v)) - } // reset map - testUnmarshalErr(v61v2, bs61, h, t, "dec-map-v61") - testDeepEqualErr(v61v1, v61v2, t, "equal-map-v61") - if v == nil { - v61v2 = nil - } else { - v61v2 = make(map[uint8]int64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v61v2), bs61, h, t, "dec-map-v61-noaddr") // decode into non-addressable map value - testDeepEqualErr(v61v1, v61v2, t, "equal-map-v61-noaddr") - } - if v == nil { - v61v2 = nil - } else { - v61v2 = make(map[uint8]int64, len(v)) - } // reset map - testUnmarshalErr(&v61v2, bs61, h, t, "dec-map-v61-p-len") - testDeepEqualErr(v61v1, v61v2, t, "equal-map-v61-p-len") - bs61 = testMarshalErr(&v61v1, h, t, "enc-map-v61-p") - v61v2 = nil - testUnmarshalErr(&v61v2, bs61, h, t, "dec-map-v61-p-nil") - testDeepEqualErr(v61v1, v61v2, t, "equal-map-v61-p-nil") - // ... - if v == nil { - v61v2 = nil - } else { - v61v2 = make(map[uint8]int64, len(v)) - } // reset map - var v61v3, v61v4 typMapMapUint8Int64 - v61v3 = typMapMapUint8Int64(v61v1) - v61v4 = typMapMapUint8Int64(v61v2) - if v != nil { - bs61 = testMarshalErr(v61v3, h, t, "enc-map-v61-custom") - testUnmarshalErr(v61v4, bs61, h, t, "dec-map-v61-p-len") - testDeepEqualErr(v61v3, v61v4, t, "equal-map-v61-p-len") - } - } - for _, v := range []map[uint8]float32{nil, {}, {111: 0, 77: 11.1}} { - // fmt.Printf(">>>> running mammoth map v62: %v\n", v) - var v62v1, v62v2 map[uint8]float32 - var bs62 []byte - v62v1 = v - bs62 = testMarshalErr(v62v1, h, t, "enc-map-v62") - if v != nil { - if v == nil { - v62v2 = nil - } else { - v62v2 = make(map[uint8]float32, len(v)) - } // reset map - testUnmarshalErr(v62v2, bs62, h, t, "dec-map-v62") - testDeepEqualErr(v62v1, v62v2, t, "equal-map-v62") - if v == nil { - v62v2 = nil - } else { - v62v2 = make(map[uint8]float32, len(v)) - } // reset map - testUnmarshalErr(rv4i(v62v2), bs62, h, t, "dec-map-v62-noaddr") // decode into non-addressable map value - testDeepEqualErr(v62v1, v62v2, t, "equal-map-v62-noaddr") - } - if v == nil { - v62v2 = nil - } else { - v62v2 = make(map[uint8]float32, len(v)) - } // reset map - testUnmarshalErr(&v62v2, bs62, h, t, "dec-map-v62-p-len") - testDeepEqualErr(v62v1, v62v2, t, "equal-map-v62-p-len") - bs62 = testMarshalErr(&v62v1, h, t, "enc-map-v62-p") - v62v2 = nil - testUnmarshalErr(&v62v2, bs62, h, t, "dec-map-v62-p-nil") - testDeepEqualErr(v62v1, v62v2, t, "equal-map-v62-p-nil") - // ... - if v == nil { - v62v2 = nil - } else { - v62v2 = make(map[uint8]float32, len(v)) - } // reset map - var v62v3, v62v4 typMapMapUint8Float32 - v62v3 = typMapMapUint8Float32(v62v1) - v62v4 = typMapMapUint8Float32(v62v2) - if v != nil { - bs62 = testMarshalErr(v62v3, h, t, "enc-map-v62-custom") - testUnmarshalErr(v62v4, bs62, h, t, "dec-map-v62-p-len") - testDeepEqualErr(v62v3, v62v4, t, "equal-map-v62-p-len") - } - } - for _, v := range []map[uint8]float64{nil, {}, {127: 0, 111: 22.2}} { - // fmt.Printf(">>>> running mammoth map v63: %v\n", v) - var v63v1, v63v2 map[uint8]float64 - var bs63 []byte - v63v1 = v - bs63 = testMarshalErr(v63v1, h, t, "enc-map-v63") - if v != nil { - if v == nil { - v63v2 = nil - } else { - v63v2 = make(map[uint8]float64, len(v)) - } // reset map - testUnmarshalErr(v63v2, bs63, h, t, "dec-map-v63") - testDeepEqualErr(v63v1, v63v2, t, "equal-map-v63") - if v == nil { - v63v2 = nil - } else { - v63v2 = make(map[uint8]float64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v63v2), bs63, h, t, "dec-map-v63-noaddr") // decode into non-addressable map value - testDeepEqualErr(v63v1, v63v2, t, "equal-map-v63-noaddr") - } - if v == nil { - v63v2 = nil - } else { - v63v2 = make(map[uint8]float64, len(v)) - } // reset map - testUnmarshalErr(&v63v2, bs63, h, t, "dec-map-v63-p-len") - testDeepEqualErr(v63v1, v63v2, t, "equal-map-v63-p-len") - bs63 = testMarshalErr(&v63v1, h, t, "enc-map-v63-p") - v63v2 = nil - testUnmarshalErr(&v63v2, bs63, h, t, "dec-map-v63-p-nil") - testDeepEqualErr(v63v1, v63v2, t, "equal-map-v63-p-nil") - // ... - if v == nil { - v63v2 = nil - } else { - v63v2 = make(map[uint8]float64, len(v)) - } // reset map - var v63v3, v63v4 typMapMapUint8Float64 - v63v3 = typMapMapUint8Float64(v63v1) - v63v4 = typMapMapUint8Float64(v63v2) - if v != nil { - bs63 = testMarshalErr(v63v3, h, t, "enc-map-v63-custom") - testUnmarshalErr(v63v4, bs63, h, t, "dec-map-v63-p-len") - testDeepEqualErr(v63v3, v63v4, t, "equal-map-v63-p-len") - } - } - for _, v := range []map[uint8]bool{nil, {}, {77: false, 127: true}} { - // fmt.Printf(">>>> running mammoth map v64: %v\n", v) - var v64v1, v64v2 map[uint8]bool - var bs64 []byte - v64v1 = v - bs64 = testMarshalErr(v64v1, h, t, "enc-map-v64") - if v != nil { - if v == nil { - v64v2 = nil - } else { - v64v2 = make(map[uint8]bool, len(v)) - } // reset map - testUnmarshalErr(v64v2, bs64, h, t, "dec-map-v64") - testDeepEqualErr(v64v1, v64v2, t, "equal-map-v64") - if v == nil { - v64v2 = nil - } else { - v64v2 = make(map[uint8]bool, len(v)) - } // reset map - testUnmarshalErr(rv4i(v64v2), bs64, h, t, "dec-map-v64-noaddr") // decode into non-addressable map value - testDeepEqualErr(v64v1, v64v2, t, "equal-map-v64-noaddr") - } - if v == nil { - v64v2 = nil - } else { - v64v2 = make(map[uint8]bool, len(v)) - } // reset map - testUnmarshalErr(&v64v2, bs64, h, t, "dec-map-v64-p-len") - testDeepEqualErr(v64v1, v64v2, t, "equal-map-v64-p-len") - bs64 = testMarshalErr(&v64v1, h, t, "enc-map-v64-p") - v64v2 = nil - testUnmarshalErr(&v64v2, bs64, h, t, "dec-map-v64-p-nil") - testDeepEqualErr(v64v1, v64v2, t, "equal-map-v64-p-nil") - // ... - if v == nil { - v64v2 = nil - } else { - v64v2 = make(map[uint8]bool, len(v)) - } // reset map - var v64v3, v64v4 typMapMapUint8Bool - v64v3 = typMapMapUint8Bool(v64v1) - v64v4 = typMapMapUint8Bool(v64v2) - if v != nil { - bs64 = testMarshalErr(v64v3, h, t, "enc-map-v64-custom") - testUnmarshalErr(v64v4, bs64, h, t, "dec-map-v64-p-len") - testDeepEqualErr(v64v3, v64v4, t, "equal-map-v64-p-len") - } - } - for _, v := range []map[uint64]interface{}{nil, {}, {111: nil, 77: "string-is-an-interface-1"}} { - // fmt.Printf(">>>> running mammoth map v65: %v\n", v) - var v65v1, v65v2 map[uint64]interface{} - var bs65 []byte - v65v1 = v - bs65 = testMarshalErr(v65v1, h, t, "enc-map-v65") - if v != nil { - if v == nil { - v65v2 = nil - } else { - v65v2 = make(map[uint64]interface{}, len(v)) - } // reset map - testUnmarshalErr(v65v2, bs65, h, t, "dec-map-v65") - testDeepEqualErr(v65v1, v65v2, t, "equal-map-v65") - if v == nil { - v65v2 = nil - } else { - v65v2 = make(map[uint64]interface{}, len(v)) - } // reset map - testUnmarshalErr(rv4i(v65v2), bs65, h, t, "dec-map-v65-noaddr") // decode into non-addressable map value - testDeepEqualErr(v65v1, v65v2, t, "equal-map-v65-noaddr") - } - if v == nil { - v65v2 = nil - } else { - v65v2 = make(map[uint64]interface{}, len(v)) - } // reset map - testUnmarshalErr(&v65v2, bs65, h, t, "dec-map-v65-p-len") - testDeepEqualErr(v65v1, v65v2, t, "equal-map-v65-p-len") - bs65 = testMarshalErr(&v65v1, h, t, "enc-map-v65-p") - v65v2 = nil - testUnmarshalErr(&v65v2, bs65, h, t, "dec-map-v65-p-nil") - testDeepEqualErr(v65v1, v65v2, t, "equal-map-v65-p-nil") - // ... - if v == nil { - v65v2 = nil - } else { - v65v2 = make(map[uint64]interface{}, len(v)) - } // reset map - var v65v3, v65v4 typMapMapUint64Intf - v65v3 = typMapMapUint64Intf(v65v1) - v65v4 = typMapMapUint64Intf(v65v2) - if v != nil { - bs65 = testMarshalErr(v65v3, h, t, "enc-map-v65-custom") - testUnmarshalErr(v65v4, bs65, h, t, "dec-map-v65-p-len") - testDeepEqualErr(v65v3, v65v4, t, "equal-map-v65-p-len") - } - } - for _, v := range []map[uint64]string{nil, {}, {127: "", 111: "some-string-2"}} { - // fmt.Printf(">>>> running mammoth map v66: %v\n", v) - var v66v1, v66v2 map[uint64]string - var bs66 []byte - v66v1 = v - bs66 = testMarshalErr(v66v1, h, t, "enc-map-v66") - if v != nil { - if v == nil { - v66v2 = nil - } else { - v66v2 = make(map[uint64]string, len(v)) - } // reset map - testUnmarshalErr(v66v2, bs66, h, t, "dec-map-v66") - testDeepEqualErr(v66v1, v66v2, t, "equal-map-v66") - if v == nil { - v66v2 = nil - } else { - v66v2 = make(map[uint64]string, len(v)) - } // reset map - testUnmarshalErr(rv4i(v66v2), bs66, h, t, "dec-map-v66-noaddr") // decode into non-addressable map value - testDeepEqualErr(v66v1, v66v2, t, "equal-map-v66-noaddr") - } - if v == nil { - v66v2 = nil - } else { - v66v2 = make(map[uint64]string, len(v)) - } // reset map - testUnmarshalErr(&v66v2, bs66, h, t, "dec-map-v66-p-len") - testDeepEqualErr(v66v1, v66v2, t, "equal-map-v66-p-len") - bs66 = testMarshalErr(&v66v1, h, t, "enc-map-v66-p") - v66v2 = nil - testUnmarshalErr(&v66v2, bs66, h, t, "dec-map-v66-p-nil") - testDeepEqualErr(v66v1, v66v2, t, "equal-map-v66-p-nil") - // ... - if v == nil { - v66v2 = nil - } else { - v66v2 = make(map[uint64]string, len(v)) - } // reset map - var v66v3, v66v4 typMapMapUint64String - v66v3 = typMapMapUint64String(v66v1) - v66v4 = typMapMapUint64String(v66v2) - if v != nil { - bs66 = testMarshalErr(v66v3, h, t, "enc-map-v66-custom") - testUnmarshalErr(v66v4, bs66, h, t, "dec-map-v66-p-len") - testDeepEqualErr(v66v3, v66v4, t, "equal-map-v66-p-len") - } - } - for _, v := range []map[uint64][]byte{nil, {}, {77: nil, 127: []byte("some-string-1")}} { - // fmt.Printf(">>>> running mammoth map v67: %v\n", v) - var v67v1, v67v2 map[uint64][]byte - var bs67 []byte - v67v1 = v - bs67 = testMarshalErr(v67v1, h, t, "enc-map-v67") - if v != nil { - if v == nil { - v67v2 = nil - } else { - v67v2 = make(map[uint64][]byte, len(v)) - } // reset map - testUnmarshalErr(v67v2, bs67, h, t, "dec-map-v67") - testDeepEqualErr(v67v1, v67v2, t, "equal-map-v67") - if v == nil { - v67v2 = nil - } else { - v67v2 = make(map[uint64][]byte, len(v)) - } // reset map - testUnmarshalErr(rv4i(v67v2), bs67, h, t, "dec-map-v67-noaddr") // decode into non-addressable map value - testDeepEqualErr(v67v1, v67v2, t, "equal-map-v67-noaddr") - } - if v == nil { - v67v2 = nil - } else { - v67v2 = make(map[uint64][]byte, len(v)) - } // reset map - testUnmarshalErr(&v67v2, bs67, h, t, "dec-map-v67-p-len") - testDeepEqualErr(v67v1, v67v2, t, "equal-map-v67-p-len") - bs67 = testMarshalErr(&v67v1, h, t, "enc-map-v67-p") - v67v2 = nil - testUnmarshalErr(&v67v2, bs67, h, t, "dec-map-v67-p-nil") - testDeepEqualErr(v67v1, v67v2, t, "equal-map-v67-p-nil") - // ... - if v == nil { - v67v2 = nil - } else { - v67v2 = make(map[uint64][]byte, len(v)) - } // reset map - var v67v3, v67v4 typMapMapUint64Bytes - v67v3 = typMapMapUint64Bytes(v67v1) - v67v4 = typMapMapUint64Bytes(v67v2) - if v != nil { - bs67 = testMarshalErr(v67v3, h, t, "enc-map-v67-custom") - testUnmarshalErr(v67v4, bs67, h, t, "dec-map-v67-p-len") - testDeepEqualErr(v67v3, v67v4, t, "equal-map-v67-p-len") - } - } - for _, v := range []map[uint64]uint{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v68: %v\n", v) - var v68v1, v68v2 map[uint64]uint - var bs68 []byte - v68v1 = v - bs68 = testMarshalErr(v68v1, h, t, "enc-map-v68") - if v != nil { - if v == nil { - v68v2 = nil - } else { - v68v2 = make(map[uint64]uint, len(v)) - } // reset map - testUnmarshalErr(v68v2, bs68, h, t, "dec-map-v68") - testDeepEqualErr(v68v1, v68v2, t, "equal-map-v68") - if v == nil { - v68v2 = nil - } else { - v68v2 = make(map[uint64]uint, len(v)) - } // reset map - testUnmarshalErr(rv4i(v68v2), bs68, h, t, "dec-map-v68-noaddr") // decode into non-addressable map value - testDeepEqualErr(v68v1, v68v2, t, "equal-map-v68-noaddr") - } - if v == nil { - v68v2 = nil - } else { - v68v2 = make(map[uint64]uint, len(v)) - } // reset map - testUnmarshalErr(&v68v2, bs68, h, t, "dec-map-v68-p-len") - testDeepEqualErr(v68v1, v68v2, t, "equal-map-v68-p-len") - bs68 = testMarshalErr(&v68v1, h, t, "enc-map-v68-p") - v68v2 = nil - testUnmarshalErr(&v68v2, bs68, h, t, "dec-map-v68-p-nil") - testDeepEqualErr(v68v1, v68v2, t, "equal-map-v68-p-nil") - // ... - if v == nil { - v68v2 = nil - } else { - v68v2 = make(map[uint64]uint, len(v)) - } // reset map - var v68v3, v68v4 typMapMapUint64Uint - v68v3 = typMapMapUint64Uint(v68v1) - v68v4 = typMapMapUint64Uint(v68v2) - if v != nil { - bs68 = testMarshalErr(v68v3, h, t, "enc-map-v68-custom") - testUnmarshalErr(v68v4, bs68, h, t, "dec-map-v68-p-len") - testDeepEqualErr(v68v3, v68v4, t, "equal-map-v68-p-len") - } - } - for _, v := range []map[uint64]uint8{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v69: %v\n", v) - var v69v1, v69v2 map[uint64]uint8 - var bs69 []byte - v69v1 = v - bs69 = testMarshalErr(v69v1, h, t, "enc-map-v69") - if v != nil { - if v == nil { - v69v2 = nil - } else { - v69v2 = make(map[uint64]uint8, len(v)) - } // reset map - testUnmarshalErr(v69v2, bs69, h, t, "dec-map-v69") - testDeepEqualErr(v69v1, v69v2, t, "equal-map-v69") - if v == nil { - v69v2 = nil - } else { - v69v2 = make(map[uint64]uint8, len(v)) - } // reset map - testUnmarshalErr(rv4i(v69v2), bs69, h, t, "dec-map-v69-noaddr") // decode into non-addressable map value - testDeepEqualErr(v69v1, v69v2, t, "equal-map-v69-noaddr") - } - if v == nil { - v69v2 = nil - } else { - v69v2 = make(map[uint64]uint8, len(v)) - } // reset map - testUnmarshalErr(&v69v2, bs69, h, t, "dec-map-v69-p-len") - testDeepEqualErr(v69v1, v69v2, t, "equal-map-v69-p-len") - bs69 = testMarshalErr(&v69v1, h, t, "enc-map-v69-p") - v69v2 = nil - testUnmarshalErr(&v69v2, bs69, h, t, "dec-map-v69-p-nil") - testDeepEqualErr(v69v1, v69v2, t, "equal-map-v69-p-nil") - // ... - if v == nil { - v69v2 = nil - } else { - v69v2 = make(map[uint64]uint8, len(v)) - } // reset map - var v69v3, v69v4 typMapMapUint64Uint8 - v69v3 = typMapMapUint64Uint8(v69v1) - v69v4 = typMapMapUint64Uint8(v69v2) - if v != nil { - bs69 = testMarshalErr(v69v3, h, t, "enc-map-v69-custom") - testUnmarshalErr(v69v4, bs69, h, t, "dec-map-v69-p-len") - testDeepEqualErr(v69v3, v69v4, t, "equal-map-v69-p-len") - } - } - for _, v := range []map[uint64]uint64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v70: %v\n", v) - var v70v1, v70v2 map[uint64]uint64 - var bs70 []byte - v70v1 = v - bs70 = testMarshalErr(v70v1, h, t, "enc-map-v70") - if v != nil { - if v == nil { - v70v2 = nil - } else { - v70v2 = make(map[uint64]uint64, len(v)) - } // reset map - testUnmarshalErr(v70v2, bs70, h, t, "dec-map-v70") - testDeepEqualErr(v70v1, v70v2, t, "equal-map-v70") - if v == nil { - v70v2 = nil - } else { - v70v2 = make(map[uint64]uint64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v70v2), bs70, h, t, "dec-map-v70-noaddr") // decode into non-addressable map value - testDeepEqualErr(v70v1, v70v2, t, "equal-map-v70-noaddr") - } - if v == nil { - v70v2 = nil - } else { - v70v2 = make(map[uint64]uint64, len(v)) - } // reset map - testUnmarshalErr(&v70v2, bs70, h, t, "dec-map-v70-p-len") - testDeepEqualErr(v70v1, v70v2, t, "equal-map-v70-p-len") - bs70 = testMarshalErr(&v70v1, h, t, "enc-map-v70-p") - v70v2 = nil - testUnmarshalErr(&v70v2, bs70, h, t, "dec-map-v70-p-nil") - testDeepEqualErr(v70v1, v70v2, t, "equal-map-v70-p-nil") - // ... - if v == nil { - v70v2 = nil - } else { - v70v2 = make(map[uint64]uint64, len(v)) - } // reset map - var v70v3, v70v4 typMapMapUint64Uint64 - v70v3 = typMapMapUint64Uint64(v70v1) - v70v4 = typMapMapUint64Uint64(v70v2) - if v != nil { - bs70 = testMarshalErr(v70v3, h, t, "enc-map-v70-custom") - testUnmarshalErr(v70v4, bs70, h, t, "dec-map-v70-p-len") - testDeepEqualErr(v70v3, v70v4, t, "equal-map-v70-p-len") - } - } - for _, v := range []map[uint64]int{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v71: %v\n", v) - var v71v1, v71v2 map[uint64]int - var bs71 []byte - v71v1 = v - bs71 = testMarshalErr(v71v1, h, t, "enc-map-v71") - if v != nil { - if v == nil { - v71v2 = nil - } else { - v71v2 = make(map[uint64]int, len(v)) - } // reset map - testUnmarshalErr(v71v2, bs71, h, t, "dec-map-v71") - testDeepEqualErr(v71v1, v71v2, t, "equal-map-v71") - if v == nil { - v71v2 = nil - } else { - v71v2 = make(map[uint64]int, len(v)) - } // reset map - testUnmarshalErr(rv4i(v71v2), bs71, h, t, "dec-map-v71-noaddr") // decode into non-addressable map value - testDeepEqualErr(v71v1, v71v2, t, "equal-map-v71-noaddr") - } - if v == nil { - v71v2 = nil - } else { - v71v2 = make(map[uint64]int, len(v)) - } // reset map - testUnmarshalErr(&v71v2, bs71, h, t, "dec-map-v71-p-len") - testDeepEqualErr(v71v1, v71v2, t, "equal-map-v71-p-len") - bs71 = testMarshalErr(&v71v1, h, t, "enc-map-v71-p") - v71v2 = nil - testUnmarshalErr(&v71v2, bs71, h, t, "dec-map-v71-p-nil") - testDeepEqualErr(v71v1, v71v2, t, "equal-map-v71-p-nil") - // ... - if v == nil { - v71v2 = nil - } else { - v71v2 = make(map[uint64]int, len(v)) - } // reset map - var v71v3, v71v4 typMapMapUint64Int - v71v3 = typMapMapUint64Int(v71v1) - v71v4 = typMapMapUint64Int(v71v2) - if v != nil { - bs71 = testMarshalErr(v71v3, h, t, "enc-map-v71-custom") - testUnmarshalErr(v71v4, bs71, h, t, "dec-map-v71-p-len") - testDeepEqualErr(v71v3, v71v4, t, "equal-map-v71-p-len") - } - } - for _, v := range []map[uint64]int64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v72: %v\n", v) - var v72v1, v72v2 map[uint64]int64 - var bs72 []byte - v72v1 = v - bs72 = testMarshalErr(v72v1, h, t, "enc-map-v72") - if v != nil { - if v == nil { - v72v2 = nil - } else { - v72v2 = make(map[uint64]int64, len(v)) - } // reset map - testUnmarshalErr(v72v2, bs72, h, t, "dec-map-v72") - testDeepEqualErr(v72v1, v72v2, t, "equal-map-v72") - if v == nil { - v72v2 = nil - } else { - v72v2 = make(map[uint64]int64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v72v2), bs72, h, t, "dec-map-v72-noaddr") // decode into non-addressable map value - testDeepEqualErr(v72v1, v72v2, t, "equal-map-v72-noaddr") - } - if v == nil { - v72v2 = nil - } else { - v72v2 = make(map[uint64]int64, len(v)) - } // reset map - testUnmarshalErr(&v72v2, bs72, h, t, "dec-map-v72-p-len") - testDeepEqualErr(v72v1, v72v2, t, "equal-map-v72-p-len") - bs72 = testMarshalErr(&v72v1, h, t, "enc-map-v72-p") - v72v2 = nil - testUnmarshalErr(&v72v2, bs72, h, t, "dec-map-v72-p-nil") - testDeepEqualErr(v72v1, v72v2, t, "equal-map-v72-p-nil") - // ... - if v == nil { - v72v2 = nil - } else { - v72v2 = make(map[uint64]int64, len(v)) - } // reset map - var v72v3, v72v4 typMapMapUint64Int64 - v72v3 = typMapMapUint64Int64(v72v1) - v72v4 = typMapMapUint64Int64(v72v2) - if v != nil { - bs72 = testMarshalErr(v72v3, h, t, "enc-map-v72-custom") - testUnmarshalErr(v72v4, bs72, h, t, "dec-map-v72-p-len") - testDeepEqualErr(v72v3, v72v4, t, "equal-map-v72-p-len") - } - } - for _, v := range []map[uint64]float32{nil, {}, {111: 0, 77: 33.3e3}} { - // fmt.Printf(">>>> running mammoth map v73: %v\n", v) - var v73v1, v73v2 map[uint64]float32 - var bs73 []byte - v73v1 = v - bs73 = testMarshalErr(v73v1, h, t, "enc-map-v73") - if v != nil { - if v == nil { - v73v2 = nil - } else { - v73v2 = make(map[uint64]float32, len(v)) - } // reset map - testUnmarshalErr(v73v2, bs73, h, t, "dec-map-v73") - testDeepEqualErr(v73v1, v73v2, t, "equal-map-v73") - if v == nil { - v73v2 = nil - } else { - v73v2 = make(map[uint64]float32, len(v)) - } // reset map - testUnmarshalErr(rv4i(v73v2), bs73, h, t, "dec-map-v73-noaddr") // decode into non-addressable map value - testDeepEqualErr(v73v1, v73v2, t, "equal-map-v73-noaddr") - } - if v == nil { - v73v2 = nil - } else { - v73v2 = make(map[uint64]float32, len(v)) - } // reset map - testUnmarshalErr(&v73v2, bs73, h, t, "dec-map-v73-p-len") - testDeepEqualErr(v73v1, v73v2, t, "equal-map-v73-p-len") - bs73 = testMarshalErr(&v73v1, h, t, "enc-map-v73-p") - v73v2 = nil - testUnmarshalErr(&v73v2, bs73, h, t, "dec-map-v73-p-nil") - testDeepEqualErr(v73v1, v73v2, t, "equal-map-v73-p-nil") - // ... - if v == nil { - v73v2 = nil - } else { - v73v2 = make(map[uint64]float32, len(v)) - } // reset map - var v73v3, v73v4 typMapMapUint64Float32 - v73v3 = typMapMapUint64Float32(v73v1) - v73v4 = typMapMapUint64Float32(v73v2) - if v != nil { - bs73 = testMarshalErr(v73v3, h, t, "enc-map-v73-custom") - testUnmarshalErr(v73v4, bs73, h, t, "dec-map-v73-p-len") - testDeepEqualErr(v73v3, v73v4, t, "equal-map-v73-p-len") - } - } - for _, v := range []map[uint64]float64{nil, {}, {127: 0, 111: 11.1}} { - // fmt.Printf(">>>> running mammoth map v74: %v\n", v) - var v74v1, v74v2 map[uint64]float64 - var bs74 []byte - v74v1 = v - bs74 = testMarshalErr(v74v1, h, t, "enc-map-v74") - if v != nil { - if v == nil { - v74v2 = nil - } else { - v74v2 = make(map[uint64]float64, len(v)) - } // reset map - testUnmarshalErr(v74v2, bs74, h, t, "dec-map-v74") - testDeepEqualErr(v74v1, v74v2, t, "equal-map-v74") - if v == nil { - v74v2 = nil - } else { - v74v2 = make(map[uint64]float64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v74v2), bs74, h, t, "dec-map-v74-noaddr") // decode into non-addressable map value - testDeepEqualErr(v74v1, v74v2, t, "equal-map-v74-noaddr") - } - if v == nil { - v74v2 = nil - } else { - v74v2 = make(map[uint64]float64, len(v)) - } // reset map - testUnmarshalErr(&v74v2, bs74, h, t, "dec-map-v74-p-len") - testDeepEqualErr(v74v1, v74v2, t, "equal-map-v74-p-len") - bs74 = testMarshalErr(&v74v1, h, t, "enc-map-v74-p") - v74v2 = nil - testUnmarshalErr(&v74v2, bs74, h, t, "dec-map-v74-p-nil") - testDeepEqualErr(v74v1, v74v2, t, "equal-map-v74-p-nil") - // ... - if v == nil { - v74v2 = nil - } else { - v74v2 = make(map[uint64]float64, len(v)) - } // reset map - var v74v3, v74v4 typMapMapUint64Float64 - v74v3 = typMapMapUint64Float64(v74v1) - v74v4 = typMapMapUint64Float64(v74v2) - if v != nil { - bs74 = testMarshalErr(v74v3, h, t, "enc-map-v74-custom") - testUnmarshalErr(v74v4, bs74, h, t, "dec-map-v74-p-len") - testDeepEqualErr(v74v3, v74v4, t, "equal-map-v74-p-len") - } - } - for _, v := range []map[uint64]bool{nil, {}, {77: false, 127: true}} { - // fmt.Printf(">>>> running mammoth map v75: %v\n", v) - var v75v1, v75v2 map[uint64]bool - var bs75 []byte - v75v1 = v - bs75 = testMarshalErr(v75v1, h, t, "enc-map-v75") - if v != nil { - if v == nil { - v75v2 = nil - } else { - v75v2 = make(map[uint64]bool, len(v)) - } // reset map - testUnmarshalErr(v75v2, bs75, h, t, "dec-map-v75") - testDeepEqualErr(v75v1, v75v2, t, "equal-map-v75") - if v == nil { - v75v2 = nil - } else { - v75v2 = make(map[uint64]bool, len(v)) - } // reset map - testUnmarshalErr(rv4i(v75v2), bs75, h, t, "dec-map-v75-noaddr") // decode into non-addressable map value - testDeepEqualErr(v75v1, v75v2, t, "equal-map-v75-noaddr") - } - if v == nil { - v75v2 = nil - } else { - v75v2 = make(map[uint64]bool, len(v)) - } // reset map - testUnmarshalErr(&v75v2, bs75, h, t, "dec-map-v75-p-len") - testDeepEqualErr(v75v1, v75v2, t, "equal-map-v75-p-len") - bs75 = testMarshalErr(&v75v1, h, t, "enc-map-v75-p") - v75v2 = nil - testUnmarshalErr(&v75v2, bs75, h, t, "dec-map-v75-p-nil") - testDeepEqualErr(v75v1, v75v2, t, "equal-map-v75-p-nil") - // ... - if v == nil { - v75v2 = nil - } else { - v75v2 = make(map[uint64]bool, len(v)) - } // reset map - var v75v3, v75v4 typMapMapUint64Bool - v75v3 = typMapMapUint64Bool(v75v1) - v75v4 = typMapMapUint64Bool(v75v2) - if v != nil { - bs75 = testMarshalErr(v75v3, h, t, "enc-map-v75-custom") - testUnmarshalErr(v75v4, bs75, h, t, "dec-map-v75-p-len") - testDeepEqualErr(v75v3, v75v4, t, "equal-map-v75-p-len") - } - } - for _, v := range []map[int]interface{}{nil, {}, {111: nil, 77: "string-is-an-interface-2"}} { - // fmt.Printf(">>>> running mammoth map v76: %v\n", v) - var v76v1, v76v2 map[int]interface{} - var bs76 []byte - v76v1 = v - bs76 = testMarshalErr(v76v1, h, t, "enc-map-v76") - if v != nil { - if v == nil { - v76v2 = nil - } else { - v76v2 = make(map[int]interface{}, len(v)) - } // reset map - testUnmarshalErr(v76v2, bs76, h, t, "dec-map-v76") - testDeepEqualErr(v76v1, v76v2, t, "equal-map-v76") - if v == nil { - v76v2 = nil - } else { - v76v2 = make(map[int]interface{}, len(v)) - } // reset map - testUnmarshalErr(rv4i(v76v2), bs76, h, t, "dec-map-v76-noaddr") // decode into non-addressable map value - testDeepEqualErr(v76v1, v76v2, t, "equal-map-v76-noaddr") - } - if v == nil { - v76v2 = nil - } else { - v76v2 = make(map[int]interface{}, len(v)) - } // reset map - testUnmarshalErr(&v76v2, bs76, h, t, "dec-map-v76-p-len") - testDeepEqualErr(v76v1, v76v2, t, "equal-map-v76-p-len") - bs76 = testMarshalErr(&v76v1, h, t, "enc-map-v76-p") - v76v2 = nil - testUnmarshalErr(&v76v2, bs76, h, t, "dec-map-v76-p-nil") - testDeepEqualErr(v76v1, v76v2, t, "equal-map-v76-p-nil") - // ... - if v == nil { - v76v2 = nil - } else { - v76v2 = make(map[int]interface{}, len(v)) - } // reset map - var v76v3, v76v4 typMapMapIntIntf - v76v3 = typMapMapIntIntf(v76v1) - v76v4 = typMapMapIntIntf(v76v2) - if v != nil { - bs76 = testMarshalErr(v76v3, h, t, "enc-map-v76-custom") - testUnmarshalErr(v76v4, bs76, h, t, "dec-map-v76-p-len") - testDeepEqualErr(v76v3, v76v4, t, "equal-map-v76-p-len") - } - } - for _, v := range []map[int]string{nil, {}, {127: "", 111: "some-string-3"}} { - // fmt.Printf(">>>> running mammoth map v77: %v\n", v) - var v77v1, v77v2 map[int]string - var bs77 []byte - v77v1 = v - bs77 = testMarshalErr(v77v1, h, t, "enc-map-v77") - if v != nil { - if v == nil { - v77v2 = nil - } else { - v77v2 = make(map[int]string, len(v)) - } // reset map - testUnmarshalErr(v77v2, bs77, h, t, "dec-map-v77") - testDeepEqualErr(v77v1, v77v2, t, "equal-map-v77") - if v == nil { - v77v2 = nil - } else { - v77v2 = make(map[int]string, len(v)) - } // reset map - testUnmarshalErr(rv4i(v77v2), bs77, h, t, "dec-map-v77-noaddr") // decode into non-addressable map value - testDeepEqualErr(v77v1, v77v2, t, "equal-map-v77-noaddr") - } - if v == nil { - v77v2 = nil - } else { - v77v2 = make(map[int]string, len(v)) - } // reset map - testUnmarshalErr(&v77v2, bs77, h, t, "dec-map-v77-p-len") - testDeepEqualErr(v77v1, v77v2, t, "equal-map-v77-p-len") - bs77 = testMarshalErr(&v77v1, h, t, "enc-map-v77-p") - v77v2 = nil - testUnmarshalErr(&v77v2, bs77, h, t, "dec-map-v77-p-nil") - testDeepEqualErr(v77v1, v77v2, t, "equal-map-v77-p-nil") - // ... - if v == nil { - v77v2 = nil - } else { - v77v2 = make(map[int]string, len(v)) - } // reset map - var v77v3, v77v4 typMapMapIntString - v77v3 = typMapMapIntString(v77v1) - v77v4 = typMapMapIntString(v77v2) - if v != nil { - bs77 = testMarshalErr(v77v3, h, t, "enc-map-v77-custom") - testUnmarshalErr(v77v4, bs77, h, t, "dec-map-v77-p-len") - testDeepEqualErr(v77v3, v77v4, t, "equal-map-v77-p-len") - } - } - for _, v := range []map[int][]byte{nil, {}, {77: nil, 127: []byte("some-string-2")}} { - // fmt.Printf(">>>> running mammoth map v78: %v\n", v) - var v78v1, v78v2 map[int][]byte - var bs78 []byte - v78v1 = v - bs78 = testMarshalErr(v78v1, h, t, "enc-map-v78") - if v != nil { - if v == nil { - v78v2 = nil - } else { - v78v2 = make(map[int][]byte, len(v)) - } // reset map - testUnmarshalErr(v78v2, bs78, h, t, "dec-map-v78") - testDeepEqualErr(v78v1, v78v2, t, "equal-map-v78") - if v == nil { - v78v2 = nil - } else { - v78v2 = make(map[int][]byte, len(v)) - } // reset map - testUnmarshalErr(rv4i(v78v2), bs78, h, t, "dec-map-v78-noaddr") // decode into non-addressable map value - testDeepEqualErr(v78v1, v78v2, t, "equal-map-v78-noaddr") - } - if v == nil { - v78v2 = nil - } else { - v78v2 = make(map[int][]byte, len(v)) - } // reset map - testUnmarshalErr(&v78v2, bs78, h, t, "dec-map-v78-p-len") - testDeepEqualErr(v78v1, v78v2, t, "equal-map-v78-p-len") - bs78 = testMarshalErr(&v78v1, h, t, "enc-map-v78-p") - v78v2 = nil - testUnmarshalErr(&v78v2, bs78, h, t, "dec-map-v78-p-nil") - testDeepEqualErr(v78v1, v78v2, t, "equal-map-v78-p-nil") - // ... - if v == nil { - v78v2 = nil - } else { - v78v2 = make(map[int][]byte, len(v)) - } // reset map - var v78v3, v78v4 typMapMapIntBytes - v78v3 = typMapMapIntBytes(v78v1) - v78v4 = typMapMapIntBytes(v78v2) - if v != nil { - bs78 = testMarshalErr(v78v3, h, t, "enc-map-v78-custom") - testUnmarshalErr(v78v4, bs78, h, t, "dec-map-v78-p-len") - testDeepEqualErr(v78v3, v78v4, t, "equal-map-v78-p-len") - } - } - for _, v := range []map[int]uint{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v79: %v\n", v) - var v79v1, v79v2 map[int]uint - var bs79 []byte - v79v1 = v - bs79 = testMarshalErr(v79v1, h, t, "enc-map-v79") - if v != nil { - if v == nil { - v79v2 = nil - } else { - v79v2 = make(map[int]uint, len(v)) - } // reset map - testUnmarshalErr(v79v2, bs79, h, t, "dec-map-v79") - testDeepEqualErr(v79v1, v79v2, t, "equal-map-v79") - if v == nil { - v79v2 = nil - } else { - v79v2 = make(map[int]uint, len(v)) - } // reset map - testUnmarshalErr(rv4i(v79v2), bs79, h, t, "dec-map-v79-noaddr") // decode into non-addressable map value - testDeepEqualErr(v79v1, v79v2, t, "equal-map-v79-noaddr") - } - if v == nil { - v79v2 = nil - } else { - v79v2 = make(map[int]uint, len(v)) - } // reset map - testUnmarshalErr(&v79v2, bs79, h, t, "dec-map-v79-p-len") - testDeepEqualErr(v79v1, v79v2, t, "equal-map-v79-p-len") - bs79 = testMarshalErr(&v79v1, h, t, "enc-map-v79-p") - v79v2 = nil - testUnmarshalErr(&v79v2, bs79, h, t, "dec-map-v79-p-nil") - testDeepEqualErr(v79v1, v79v2, t, "equal-map-v79-p-nil") - // ... - if v == nil { - v79v2 = nil - } else { - v79v2 = make(map[int]uint, len(v)) - } // reset map - var v79v3, v79v4 typMapMapIntUint - v79v3 = typMapMapIntUint(v79v1) - v79v4 = typMapMapIntUint(v79v2) - if v != nil { - bs79 = testMarshalErr(v79v3, h, t, "enc-map-v79-custom") - testUnmarshalErr(v79v4, bs79, h, t, "dec-map-v79-p-len") - testDeepEqualErr(v79v3, v79v4, t, "equal-map-v79-p-len") - } - } - for _, v := range []map[int]uint8{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v80: %v\n", v) - var v80v1, v80v2 map[int]uint8 - var bs80 []byte - v80v1 = v - bs80 = testMarshalErr(v80v1, h, t, "enc-map-v80") - if v != nil { - if v == nil { - v80v2 = nil - } else { - v80v2 = make(map[int]uint8, len(v)) - } // reset map - testUnmarshalErr(v80v2, bs80, h, t, "dec-map-v80") - testDeepEqualErr(v80v1, v80v2, t, "equal-map-v80") - if v == nil { - v80v2 = nil - } else { - v80v2 = make(map[int]uint8, len(v)) - } // reset map - testUnmarshalErr(rv4i(v80v2), bs80, h, t, "dec-map-v80-noaddr") // decode into non-addressable map value - testDeepEqualErr(v80v1, v80v2, t, "equal-map-v80-noaddr") - } - if v == nil { - v80v2 = nil - } else { - v80v2 = make(map[int]uint8, len(v)) - } // reset map - testUnmarshalErr(&v80v2, bs80, h, t, "dec-map-v80-p-len") - testDeepEqualErr(v80v1, v80v2, t, "equal-map-v80-p-len") - bs80 = testMarshalErr(&v80v1, h, t, "enc-map-v80-p") - v80v2 = nil - testUnmarshalErr(&v80v2, bs80, h, t, "dec-map-v80-p-nil") - testDeepEqualErr(v80v1, v80v2, t, "equal-map-v80-p-nil") - // ... - if v == nil { - v80v2 = nil - } else { - v80v2 = make(map[int]uint8, len(v)) - } // reset map - var v80v3, v80v4 typMapMapIntUint8 - v80v3 = typMapMapIntUint8(v80v1) - v80v4 = typMapMapIntUint8(v80v2) - if v != nil { - bs80 = testMarshalErr(v80v3, h, t, "enc-map-v80-custom") - testUnmarshalErr(v80v4, bs80, h, t, "dec-map-v80-p-len") - testDeepEqualErr(v80v3, v80v4, t, "equal-map-v80-p-len") - } - } - for _, v := range []map[int]uint64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v81: %v\n", v) - var v81v1, v81v2 map[int]uint64 - var bs81 []byte - v81v1 = v - bs81 = testMarshalErr(v81v1, h, t, "enc-map-v81") - if v != nil { - if v == nil { - v81v2 = nil - } else { - v81v2 = make(map[int]uint64, len(v)) - } // reset map - testUnmarshalErr(v81v2, bs81, h, t, "dec-map-v81") - testDeepEqualErr(v81v1, v81v2, t, "equal-map-v81") - if v == nil { - v81v2 = nil - } else { - v81v2 = make(map[int]uint64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v81v2), bs81, h, t, "dec-map-v81-noaddr") // decode into non-addressable map value - testDeepEqualErr(v81v1, v81v2, t, "equal-map-v81-noaddr") - } - if v == nil { - v81v2 = nil - } else { - v81v2 = make(map[int]uint64, len(v)) - } // reset map - testUnmarshalErr(&v81v2, bs81, h, t, "dec-map-v81-p-len") - testDeepEqualErr(v81v1, v81v2, t, "equal-map-v81-p-len") - bs81 = testMarshalErr(&v81v1, h, t, "enc-map-v81-p") - v81v2 = nil - testUnmarshalErr(&v81v2, bs81, h, t, "dec-map-v81-p-nil") - testDeepEqualErr(v81v1, v81v2, t, "equal-map-v81-p-nil") - // ... - if v == nil { - v81v2 = nil - } else { - v81v2 = make(map[int]uint64, len(v)) - } // reset map - var v81v3, v81v4 typMapMapIntUint64 - v81v3 = typMapMapIntUint64(v81v1) - v81v4 = typMapMapIntUint64(v81v2) - if v != nil { - bs81 = testMarshalErr(v81v3, h, t, "enc-map-v81-custom") - testUnmarshalErr(v81v4, bs81, h, t, "dec-map-v81-p-len") - testDeepEqualErr(v81v3, v81v4, t, "equal-map-v81-p-len") - } - } - for _, v := range []map[int]int{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v82: %v\n", v) - var v82v1, v82v2 map[int]int - var bs82 []byte - v82v1 = v - bs82 = testMarshalErr(v82v1, h, t, "enc-map-v82") - if v != nil { - if v == nil { - v82v2 = nil - } else { - v82v2 = make(map[int]int, len(v)) - } // reset map - testUnmarshalErr(v82v2, bs82, h, t, "dec-map-v82") - testDeepEqualErr(v82v1, v82v2, t, "equal-map-v82") - if v == nil { - v82v2 = nil - } else { - v82v2 = make(map[int]int, len(v)) - } // reset map - testUnmarshalErr(rv4i(v82v2), bs82, h, t, "dec-map-v82-noaddr") // decode into non-addressable map value - testDeepEqualErr(v82v1, v82v2, t, "equal-map-v82-noaddr") - } - if v == nil { - v82v2 = nil - } else { - v82v2 = make(map[int]int, len(v)) - } // reset map - testUnmarshalErr(&v82v2, bs82, h, t, "dec-map-v82-p-len") - testDeepEqualErr(v82v1, v82v2, t, "equal-map-v82-p-len") - bs82 = testMarshalErr(&v82v1, h, t, "enc-map-v82-p") - v82v2 = nil - testUnmarshalErr(&v82v2, bs82, h, t, "dec-map-v82-p-nil") - testDeepEqualErr(v82v1, v82v2, t, "equal-map-v82-p-nil") - // ... - if v == nil { - v82v2 = nil - } else { - v82v2 = make(map[int]int, len(v)) - } // reset map - var v82v3, v82v4 typMapMapIntInt - v82v3 = typMapMapIntInt(v82v1) - v82v4 = typMapMapIntInt(v82v2) - if v != nil { - bs82 = testMarshalErr(v82v3, h, t, "enc-map-v82-custom") - testUnmarshalErr(v82v4, bs82, h, t, "dec-map-v82-p-len") - testDeepEqualErr(v82v3, v82v4, t, "equal-map-v82-p-len") - } - } - for _, v := range []map[int]int64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v83: %v\n", v) - var v83v1, v83v2 map[int]int64 - var bs83 []byte - v83v1 = v - bs83 = testMarshalErr(v83v1, h, t, "enc-map-v83") - if v != nil { - if v == nil { - v83v2 = nil - } else { - v83v2 = make(map[int]int64, len(v)) - } // reset map - testUnmarshalErr(v83v2, bs83, h, t, "dec-map-v83") - testDeepEqualErr(v83v1, v83v2, t, "equal-map-v83") - if v == nil { - v83v2 = nil - } else { - v83v2 = make(map[int]int64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v83v2), bs83, h, t, "dec-map-v83-noaddr") // decode into non-addressable map value - testDeepEqualErr(v83v1, v83v2, t, "equal-map-v83-noaddr") - } - if v == nil { - v83v2 = nil - } else { - v83v2 = make(map[int]int64, len(v)) - } // reset map - testUnmarshalErr(&v83v2, bs83, h, t, "dec-map-v83-p-len") - testDeepEqualErr(v83v1, v83v2, t, "equal-map-v83-p-len") - bs83 = testMarshalErr(&v83v1, h, t, "enc-map-v83-p") - v83v2 = nil - testUnmarshalErr(&v83v2, bs83, h, t, "dec-map-v83-p-nil") - testDeepEqualErr(v83v1, v83v2, t, "equal-map-v83-p-nil") - // ... - if v == nil { - v83v2 = nil - } else { - v83v2 = make(map[int]int64, len(v)) - } // reset map - var v83v3, v83v4 typMapMapIntInt64 - v83v3 = typMapMapIntInt64(v83v1) - v83v4 = typMapMapIntInt64(v83v2) - if v != nil { - bs83 = testMarshalErr(v83v3, h, t, "enc-map-v83-custom") - testUnmarshalErr(v83v4, bs83, h, t, "dec-map-v83-p-len") - testDeepEqualErr(v83v3, v83v4, t, "equal-map-v83-p-len") - } - } - for _, v := range []map[int]float32{nil, {}, {111: 0, 77: 22.2}} { - // fmt.Printf(">>>> running mammoth map v84: %v\n", v) - var v84v1, v84v2 map[int]float32 - var bs84 []byte - v84v1 = v - bs84 = testMarshalErr(v84v1, h, t, "enc-map-v84") - if v != nil { - if v == nil { - v84v2 = nil - } else { - v84v2 = make(map[int]float32, len(v)) - } // reset map - testUnmarshalErr(v84v2, bs84, h, t, "dec-map-v84") - testDeepEqualErr(v84v1, v84v2, t, "equal-map-v84") - if v == nil { - v84v2 = nil - } else { - v84v2 = make(map[int]float32, len(v)) - } // reset map - testUnmarshalErr(rv4i(v84v2), bs84, h, t, "dec-map-v84-noaddr") // decode into non-addressable map value - testDeepEqualErr(v84v1, v84v2, t, "equal-map-v84-noaddr") - } - if v == nil { - v84v2 = nil - } else { - v84v2 = make(map[int]float32, len(v)) - } // reset map - testUnmarshalErr(&v84v2, bs84, h, t, "dec-map-v84-p-len") - testDeepEqualErr(v84v1, v84v2, t, "equal-map-v84-p-len") - bs84 = testMarshalErr(&v84v1, h, t, "enc-map-v84-p") - v84v2 = nil - testUnmarshalErr(&v84v2, bs84, h, t, "dec-map-v84-p-nil") - testDeepEqualErr(v84v1, v84v2, t, "equal-map-v84-p-nil") - // ... - if v == nil { - v84v2 = nil - } else { - v84v2 = make(map[int]float32, len(v)) - } // reset map - var v84v3, v84v4 typMapMapIntFloat32 - v84v3 = typMapMapIntFloat32(v84v1) - v84v4 = typMapMapIntFloat32(v84v2) - if v != nil { - bs84 = testMarshalErr(v84v3, h, t, "enc-map-v84-custom") - testUnmarshalErr(v84v4, bs84, h, t, "dec-map-v84-p-len") - testDeepEqualErr(v84v3, v84v4, t, "equal-map-v84-p-len") - } - } - for _, v := range []map[int]float64{nil, {}, {127: 0, 111: 33.3e3}} { - // fmt.Printf(">>>> running mammoth map v85: %v\n", v) - var v85v1, v85v2 map[int]float64 - var bs85 []byte - v85v1 = v - bs85 = testMarshalErr(v85v1, h, t, "enc-map-v85") - if v != nil { - if v == nil { - v85v2 = nil - } else { - v85v2 = make(map[int]float64, len(v)) - } // reset map - testUnmarshalErr(v85v2, bs85, h, t, "dec-map-v85") - testDeepEqualErr(v85v1, v85v2, t, "equal-map-v85") - if v == nil { - v85v2 = nil - } else { - v85v2 = make(map[int]float64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v85v2), bs85, h, t, "dec-map-v85-noaddr") // decode into non-addressable map value - testDeepEqualErr(v85v1, v85v2, t, "equal-map-v85-noaddr") - } - if v == nil { - v85v2 = nil - } else { - v85v2 = make(map[int]float64, len(v)) - } // reset map - testUnmarshalErr(&v85v2, bs85, h, t, "dec-map-v85-p-len") - testDeepEqualErr(v85v1, v85v2, t, "equal-map-v85-p-len") - bs85 = testMarshalErr(&v85v1, h, t, "enc-map-v85-p") - v85v2 = nil - testUnmarshalErr(&v85v2, bs85, h, t, "dec-map-v85-p-nil") - testDeepEqualErr(v85v1, v85v2, t, "equal-map-v85-p-nil") - // ... - if v == nil { - v85v2 = nil - } else { - v85v2 = make(map[int]float64, len(v)) - } // reset map - var v85v3, v85v4 typMapMapIntFloat64 - v85v3 = typMapMapIntFloat64(v85v1) - v85v4 = typMapMapIntFloat64(v85v2) - if v != nil { - bs85 = testMarshalErr(v85v3, h, t, "enc-map-v85-custom") - testUnmarshalErr(v85v4, bs85, h, t, "dec-map-v85-p-len") - testDeepEqualErr(v85v3, v85v4, t, "equal-map-v85-p-len") - } - } - for _, v := range []map[int]bool{nil, {}, {77: false, 127: false}} { - // fmt.Printf(">>>> running mammoth map v86: %v\n", v) - var v86v1, v86v2 map[int]bool - var bs86 []byte - v86v1 = v - bs86 = testMarshalErr(v86v1, h, t, "enc-map-v86") - if v != nil { - if v == nil { - v86v2 = nil - } else { - v86v2 = make(map[int]bool, len(v)) - } // reset map - testUnmarshalErr(v86v2, bs86, h, t, "dec-map-v86") - testDeepEqualErr(v86v1, v86v2, t, "equal-map-v86") - if v == nil { - v86v2 = nil - } else { - v86v2 = make(map[int]bool, len(v)) - } // reset map - testUnmarshalErr(rv4i(v86v2), bs86, h, t, "dec-map-v86-noaddr") // decode into non-addressable map value - testDeepEqualErr(v86v1, v86v2, t, "equal-map-v86-noaddr") - } - if v == nil { - v86v2 = nil - } else { - v86v2 = make(map[int]bool, len(v)) - } // reset map - testUnmarshalErr(&v86v2, bs86, h, t, "dec-map-v86-p-len") - testDeepEqualErr(v86v1, v86v2, t, "equal-map-v86-p-len") - bs86 = testMarshalErr(&v86v1, h, t, "enc-map-v86-p") - v86v2 = nil - testUnmarshalErr(&v86v2, bs86, h, t, "dec-map-v86-p-nil") - testDeepEqualErr(v86v1, v86v2, t, "equal-map-v86-p-nil") - // ... - if v == nil { - v86v2 = nil - } else { - v86v2 = make(map[int]bool, len(v)) - } // reset map - var v86v3, v86v4 typMapMapIntBool - v86v3 = typMapMapIntBool(v86v1) - v86v4 = typMapMapIntBool(v86v2) - if v != nil { - bs86 = testMarshalErr(v86v3, h, t, "enc-map-v86-custom") - testUnmarshalErr(v86v4, bs86, h, t, "dec-map-v86-p-len") - testDeepEqualErr(v86v3, v86v4, t, "equal-map-v86-p-len") - } - } - for _, v := range []map[int64]interface{}{nil, {}, {111: nil, 77: "string-is-an-interface-3"}} { - // fmt.Printf(">>>> running mammoth map v87: %v\n", v) - var v87v1, v87v2 map[int64]interface{} - var bs87 []byte - v87v1 = v - bs87 = testMarshalErr(v87v1, h, t, "enc-map-v87") - if v != nil { - if v == nil { - v87v2 = nil - } else { - v87v2 = make(map[int64]interface{}, len(v)) - } // reset map - testUnmarshalErr(v87v2, bs87, h, t, "dec-map-v87") - testDeepEqualErr(v87v1, v87v2, t, "equal-map-v87") - if v == nil { - v87v2 = nil - } else { - v87v2 = make(map[int64]interface{}, len(v)) - } // reset map - testUnmarshalErr(rv4i(v87v2), bs87, h, t, "dec-map-v87-noaddr") // decode into non-addressable map value - testDeepEqualErr(v87v1, v87v2, t, "equal-map-v87-noaddr") - } - if v == nil { - v87v2 = nil - } else { - v87v2 = make(map[int64]interface{}, len(v)) - } // reset map - testUnmarshalErr(&v87v2, bs87, h, t, "dec-map-v87-p-len") - testDeepEqualErr(v87v1, v87v2, t, "equal-map-v87-p-len") - bs87 = testMarshalErr(&v87v1, h, t, "enc-map-v87-p") - v87v2 = nil - testUnmarshalErr(&v87v2, bs87, h, t, "dec-map-v87-p-nil") - testDeepEqualErr(v87v1, v87v2, t, "equal-map-v87-p-nil") - // ... - if v == nil { - v87v2 = nil - } else { - v87v2 = make(map[int64]interface{}, len(v)) - } // reset map - var v87v3, v87v4 typMapMapInt64Intf - v87v3 = typMapMapInt64Intf(v87v1) - v87v4 = typMapMapInt64Intf(v87v2) - if v != nil { - bs87 = testMarshalErr(v87v3, h, t, "enc-map-v87-custom") - testUnmarshalErr(v87v4, bs87, h, t, "dec-map-v87-p-len") - testDeepEqualErr(v87v3, v87v4, t, "equal-map-v87-p-len") - } - } - for _, v := range []map[int64]string{nil, {}, {127: "", 111: "some-string-1"}} { - // fmt.Printf(">>>> running mammoth map v88: %v\n", v) - var v88v1, v88v2 map[int64]string - var bs88 []byte - v88v1 = v - bs88 = testMarshalErr(v88v1, h, t, "enc-map-v88") - if v != nil { - if v == nil { - v88v2 = nil - } else { - v88v2 = make(map[int64]string, len(v)) - } // reset map - testUnmarshalErr(v88v2, bs88, h, t, "dec-map-v88") - testDeepEqualErr(v88v1, v88v2, t, "equal-map-v88") - if v == nil { - v88v2 = nil - } else { - v88v2 = make(map[int64]string, len(v)) - } // reset map - testUnmarshalErr(rv4i(v88v2), bs88, h, t, "dec-map-v88-noaddr") // decode into non-addressable map value - testDeepEqualErr(v88v1, v88v2, t, "equal-map-v88-noaddr") - } - if v == nil { - v88v2 = nil - } else { - v88v2 = make(map[int64]string, len(v)) - } // reset map - testUnmarshalErr(&v88v2, bs88, h, t, "dec-map-v88-p-len") - testDeepEqualErr(v88v1, v88v2, t, "equal-map-v88-p-len") - bs88 = testMarshalErr(&v88v1, h, t, "enc-map-v88-p") - v88v2 = nil - testUnmarshalErr(&v88v2, bs88, h, t, "dec-map-v88-p-nil") - testDeepEqualErr(v88v1, v88v2, t, "equal-map-v88-p-nil") - // ... - if v == nil { - v88v2 = nil - } else { - v88v2 = make(map[int64]string, len(v)) - } // reset map - var v88v3, v88v4 typMapMapInt64String - v88v3 = typMapMapInt64String(v88v1) - v88v4 = typMapMapInt64String(v88v2) - if v != nil { - bs88 = testMarshalErr(v88v3, h, t, "enc-map-v88-custom") - testUnmarshalErr(v88v4, bs88, h, t, "dec-map-v88-p-len") - testDeepEqualErr(v88v3, v88v4, t, "equal-map-v88-p-len") - } - } - for _, v := range []map[int64][]byte{nil, {}, {77: nil, 127: []byte("some-string-3")}} { - // fmt.Printf(">>>> running mammoth map v89: %v\n", v) - var v89v1, v89v2 map[int64][]byte - var bs89 []byte - v89v1 = v - bs89 = testMarshalErr(v89v1, h, t, "enc-map-v89") - if v != nil { - if v == nil { - v89v2 = nil - } else { - v89v2 = make(map[int64][]byte, len(v)) - } // reset map - testUnmarshalErr(v89v2, bs89, h, t, "dec-map-v89") - testDeepEqualErr(v89v1, v89v2, t, "equal-map-v89") - if v == nil { - v89v2 = nil - } else { - v89v2 = make(map[int64][]byte, len(v)) - } // reset map - testUnmarshalErr(rv4i(v89v2), bs89, h, t, "dec-map-v89-noaddr") // decode into non-addressable map value - testDeepEqualErr(v89v1, v89v2, t, "equal-map-v89-noaddr") - } - if v == nil { - v89v2 = nil - } else { - v89v2 = make(map[int64][]byte, len(v)) - } // reset map - testUnmarshalErr(&v89v2, bs89, h, t, "dec-map-v89-p-len") - testDeepEqualErr(v89v1, v89v2, t, "equal-map-v89-p-len") - bs89 = testMarshalErr(&v89v1, h, t, "enc-map-v89-p") - v89v2 = nil - testUnmarshalErr(&v89v2, bs89, h, t, "dec-map-v89-p-nil") - testDeepEqualErr(v89v1, v89v2, t, "equal-map-v89-p-nil") - // ... - if v == nil { - v89v2 = nil - } else { - v89v2 = make(map[int64][]byte, len(v)) - } // reset map - var v89v3, v89v4 typMapMapInt64Bytes - v89v3 = typMapMapInt64Bytes(v89v1) - v89v4 = typMapMapInt64Bytes(v89v2) - if v != nil { - bs89 = testMarshalErr(v89v3, h, t, "enc-map-v89-custom") - testUnmarshalErr(v89v4, bs89, h, t, "dec-map-v89-p-len") - testDeepEqualErr(v89v3, v89v4, t, "equal-map-v89-p-len") - } - } - for _, v := range []map[int64]uint{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v90: %v\n", v) - var v90v1, v90v2 map[int64]uint - var bs90 []byte - v90v1 = v - bs90 = testMarshalErr(v90v1, h, t, "enc-map-v90") - if v != nil { - if v == nil { - v90v2 = nil - } else { - v90v2 = make(map[int64]uint, len(v)) - } // reset map - testUnmarshalErr(v90v2, bs90, h, t, "dec-map-v90") - testDeepEqualErr(v90v1, v90v2, t, "equal-map-v90") - if v == nil { - v90v2 = nil - } else { - v90v2 = make(map[int64]uint, len(v)) - } // reset map - testUnmarshalErr(rv4i(v90v2), bs90, h, t, "dec-map-v90-noaddr") // decode into non-addressable map value - testDeepEqualErr(v90v1, v90v2, t, "equal-map-v90-noaddr") - } - if v == nil { - v90v2 = nil - } else { - v90v2 = make(map[int64]uint, len(v)) - } // reset map - testUnmarshalErr(&v90v2, bs90, h, t, "dec-map-v90-p-len") - testDeepEqualErr(v90v1, v90v2, t, "equal-map-v90-p-len") - bs90 = testMarshalErr(&v90v1, h, t, "enc-map-v90-p") - v90v2 = nil - testUnmarshalErr(&v90v2, bs90, h, t, "dec-map-v90-p-nil") - testDeepEqualErr(v90v1, v90v2, t, "equal-map-v90-p-nil") - // ... - if v == nil { - v90v2 = nil - } else { - v90v2 = make(map[int64]uint, len(v)) - } // reset map - var v90v3, v90v4 typMapMapInt64Uint - v90v3 = typMapMapInt64Uint(v90v1) - v90v4 = typMapMapInt64Uint(v90v2) - if v != nil { - bs90 = testMarshalErr(v90v3, h, t, "enc-map-v90-custom") - testUnmarshalErr(v90v4, bs90, h, t, "dec-map-v90-p-len") - testDeepEqualErr(v90v3, v90v4, t, "equal-map-v90-p-len") - } - } - for _, v := range []map[int64]uint8{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v91: %v\n", v) - var v91v1, v91v2 map[int64]uint8 - var bs91 []byte - v91v1 = v - bs91 = testMarshalErr(v91v1, h, t, "enc-map-v91") - if v != nil { - if v == nil { - v91v2 = nil - } else { - v91v2 = make(map[int64]uint8, len(v)) - } // reset map - testUnmarshalErr(v91v2, bs91, h, t, "dec-map-v91") - testDeepEqualErr(v91v1, v91v2, t, "equal-map-v91") - if v == nil { - v91v2 = nil - } else { - v91v2 = make(map[int64]uint8, len(v)) - } // reset map - testUnmarshalErr(rv4i(v91v2), bs91, h, t, "dec-map-v91-noaddr") // decode into non-addressable map value - testDeepEqualErr(v91v1, v91v2, t, "equal-map-v91-noaddr") - } - if v == nil { - v91v2 = nil - } else { - v91v2 = make(map[int64]uint8, len(v)) - } // reset map - testUnmarshalErr(&v91v2, bs91, h, t, "dec-map-v91-p-len") - testDeepEqualErr(v91v1, v91v2, t, "equal-map-v91-p-len") - bs91 = testMarshalErr(&v91v1, h, t, "enc-map-v91-p") - v91v2 = nil - testUnmarshalErr(&v91v2, bs91, h, t, "dec-map-v91-p-nil") - testDeepEqualErr(v91v1, v91v2, t, "equal-map-v91-p-nil") - // ... - if v == nil { - v91v2 = nil - } else { - v91v2 = make(map[int64]uint8, len(v)) - } // reset map - var v91v3, v91v4 typMapMapInt64Uint8 - v91v3 = typMapMapInt64Uint8(v91v1) - v91v4 = typMapMapInt64Uint8(v91v2) - if v != nil { - bs91 = testMarshalErr(v91v3, h, t, "enc-map-v91-custom") - testUnmarshalErr(v91v4, bs91, h, t, "dec-map-v91-p-len") - testDeepEqualErr(v91v3, v91v4, t, "equal-map-v91-p-len") - } - } - for _, v := range []map[int64]uint64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v92: %v\n", v) - var v92v1, v92v2 map[int64]uint64 - var bs92 []byte - v92v1 = v - bs92 = testMarshalErr(v92v1, h, t, "enc-map-v92") - if v != nil { - if v == nil { - v92v2 = nil - } else { - v92v2 = make(map[int64]uint64, len(v)) - } // reset map - testUnmarshalErr(v92v2, bs92, h, t, "dec-map-v92") - testDeepEqualErr(v92v1, v92v2, t, "equal-map-v92") - if v == nil { - v92v2 = nil - } else { - v92v2 = make(map[int64]uint64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v92v2), bs92, h, t, "dec-map-v92-noaddr") // decode into non-addressable map value - testDeepEqualErr(v92v1, v92v2, t, "equal-map-v92-noaddr") - } - if v == nil { - v92v2 = nil - } else { - v92v2 = make(map[int64]uint64, len(v)) - } // reset map - testUnmarshalErr(&v92v2, bs92, h, t, "dec-map-v92-p-len") - testDeepEqualErr(v92v1, v92v2, t, "equal-map-v92-p-len") - bs92 = testMarshalErr(&v92v1, h, t, "enc-map-v92-p") - v92v2 = nil - testUnmarshalErr(&v92v2, bs92, h, t, "dec-map-v92-p-nil") - testDeepEqualErr(v92v1, v92v2, t, "equal-map-v92-p-nil") - // ... - if v == nil { - v92v2 = nil - } else { - v92v2 = make(map[int64]uint64, len(v)) - } // reset map - var v92v3, v92v4 typMapMapInt64Uint64 - v92v3 = typMapMapInt64Uint64(v92v1) - v92v4 = typMapMapInt64Uint64(v92v2) - if v != nil { - bs92 = testMarshalErr(v92v3, h, t, "enc-map-v92-custom") - testUnmarshalErr(v92v4, bs92, h, t, "dec-map-v92-p-len") - testDeepEqualErr(v92v3, v92v4, t, "equal-map-v92-p-len") - } - } - for _, v := range []map[int64]int{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v93: %v\n", v) - var v93v1, v93v2 map[int64]int - var bs93 []byte - v93v1 = v - bs93 = testMarshalErr(v93v1, h, t, "enc-map-v93") - if v != nil { - if v == nil { - v93v2 = nil - } else { - v93v2 = make(map[int64]int, len(v)) - } // reset map - testUnmarshalErr(v93v2, bs93, h, t, "dec-map-v93") - testDeepEqualErr(v93v1, v93v2, t, "equal-map-v93") - if v == nil { - v93v2 = nil - } else { - v93v2 = make(map[int64]int, len(v)) - } // reset map - testUnmarshalErr(rv4i(v93v2), bs93, h, t, "dec-map-v93-noaddr") // decode into non-addressable map value - testDeepEqualErr(v93v1, v93v2, t, "equal-map-v93-noaddr") - } - if v == nil { - v93v2 = nil - } else { - v93v2 = make(map[int64]int, len(v)) - } // reset map - testUnmarshalErr(&v93v2, bs93, h, t, "dec-map-v93-p-len") - testDeepEqualErr(v93v1, v93v2, t, "equal-map-v93-p-len") - bs93 = testMarshalErr(&v93v1, h, t, "enc-map-v93-p") - v93v2 = nil - testUnmarshalErr(&v93v2, bs93, h, t, "dec-map-v93-p-nil") - testDeepEqualErr(v93v1, v93v2, t, "equal-map-v93-p-nil") - // ... - if v == nil { - v93v2 = nil - } else { - v93v2 = make(map[int64]int, len(v)) - } // reset map - var v93v3, v93v4 typMapMapInt64Int - v93v3 = typMapMapInt64Int(v93v1) - v93v4 = typMapMapInt64Int(v93v2) - if v != nil { - bs93 = testMarshalErr(v93v3, h, t, "enc-map-v93-custom") - testUnmarshalErr(v93v4, bs93, h, t, "dec-map-v93-p-len") - testDeepEqualErr(v93v3, v93v4, t, "equal-map-v93-p-len") - } - } - for _, v := range []map[int64]int64{nil, {}, {111: 0, 77: 127}} { - // fmt.Printf(">>>> running mammoth map v94: %v\n", v) - var v94v1, v94v2 map[int64]int64 - var bs94 []byte - v94v1 = v - bs94 = testMarshalErr(v94v1, h, t, "enc-map-v94") - if v != nil { - if v == nil { - v94v2 = nil - } else { - v94v2 = make(map[int64]int64, len(v)) - } // reset map - testUnmarshalErr(v94v2, bs94, h, t, "dec-map-v94") - testDeepEqualErr(v94v1, v94v2, t, "equal-map-v94") - if v == nil { - v94v2 = nil - } else { - v94v2 = make(map[int64]int64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v94v2), bs94, h, t, "dec-map-v94-noaddr") // decode into non-addressable map value - testDeepEqualErr(v94v1, v94v2, t, "equal-map-v94-noaddr") - } - if v == nil { - v94v2 = nil - } else { - v94v2 = make(map[int64]int64, len(v)) - } // reset map - testUnmarshalErr(&v94v2, bs94, h, t, "dec-map-v94-p-len") - testDeepEqualErr(v94v1, v94v2, t, "equal-map-v94-p-len") - bs94 = testMarshalErr(&v94v1, h, t, "enc-map-v94-p") - v94v2 = nil - testUnmarshalErr(&v94v2, bs94, h, t, "dec-map-v94-p-nil") - testDeepEqualErr(v94v1, v94v2, t, "equal-map-v94-p-nil") - // ... - if v == nil { - v94v2 = nil - } else { - v94v2 = make(map[int64]int64, len(v)) - } // reset map - var v94v3, v94v4 typMapMapInt64Int64 - v94v3 = typMapMapInt64Int64(v94v1) - v94v4 = typMapMapInt64Int64(v94v2) - if v != nil { - bs94 = testMarshalErr(v94v3, h, t, "enc-map-v94-custom") - testUnmarshalErr(v94v4, bs94, h, t, "dec-map-v94-p-len") - testDeepEqualErr(v94v3, v94v4, t, "equal-map-v94-p-len") - } - } - for _, v := range []map[int64]float32{nil, {}, {111: 0, 77: 11.1}} { - // fmt.Printf(">>>> running mammoth map v95: %v\n", v) - var v95v1, v95v2 map[int64]float32 - var bs95 []byte - v95v1 = v - bs95 = testMarshalErr(v95v1, h, t, "enc-map-v95") - if v != nil { - if v == nil { - v95v2 = nil - } else { - v95v2 = make(map[int64]float32, len(v)) - } // reset map - testUnmarshalErr(v95v2, bs95, h, t, "dec-map-v95") - testDeepEqualErr(v95v1, v95v2, t, "equal-map-v95") - if v == nil { - v95v2 = nil - } else { - v95v2 = make(map[int64]float32, len(v)) - } // reset map - testUnmarshalErr(rv4i(v95v2), bs95, h, t, "dec-map-v95-noaddr") // decode into non-addressable map value - testDeepEqualErr(v95v1, v95v2, t, "equal-map-v95-noaddr") - } - if v == nil { - v95v2 = nil - } else { - v95v2 = make(map[int64]float32, len(v)) - } // reset map - testUnmarshalErr(&v95v2, bs95, h, t, "dec-map-v95-p-len") - testDeepEqualErr(v95v1, v95v2, t, "equal-map-v95-p-len") - bs95 = testMarshalErr(&v95v1, h, t, "enc-map-v95-p") - v95v2 = nil - testUnmarshalErr(&v95v2, bs95, h, t, "dec-map-v95-p-nil") - testDeepEqualErr(v95v1, v95v2, t, "equal-map-v95-p-nil") - // ... - if v == nil { - v95v2 = nil - } else { - v95v2 = make(map[int64]float32, len(v)) - } // reset map - var v95v3, v95v4 typMapMapInt64Float32 - v95v3 = typMapMapInt64Float32(v95v1) - v95v4 = typMapMapInt64Float32(v95v2) - if v != nil { - bs95 = testMarshalErr(v95v3, h, t, "enc-map-v95-custom") - testUnmarshalErr(v95v4, bs95, h, t, "dec-map-v95-p-len") - testDeepEqualErr(v95v3, v95v4, t, "equal-map-v95-p-len") - } - } - for _, v := range []map[int64]float64{nil, {}, {127: 0, 111: 22.2}} { - // fmt.Printf(">>>> running mammoth map v96: %v\n", v) - var v96v1, v96v2 map[int64]float64 - var bs96 []byte - v96v1 = v - bs96 = testMarshalErr(v96v1, h, t, "enc-map-v96") - if v != nil { - if v == nil { - v96v2 = nil - } else { - v96v2 = make(map[int64]float64, len(v)) - } // reset map - testUnmarshalErr(v96v2, bs96, h, t, "dec-map-v96") - testDeepEqualErr(v96v1, v96v2, t, "equal-map-v96") - if v == nil { - v96v2 = nil - } else { - v96v2 = make(map[int64]float64, len(v)) - } // reset map - testUnmarshalErr(rv4i(v96v2), bs96, h, t, "dec-map-v96-noaddr") // decode into non-addressable map value - testDeepEqualErr(v96v1, v96v2, t, "equal-map-v96-noaddr") - } - if v == nil { - v96v2 = nil - } else { - v96v2 = make(map[int64]float64, len(v)) - } // reset map - testUnmarshalErr(&v96v2, bs96, h, t, "dec-map-v96-p-len") - testDeepEqualErr(v96v1, v96v2, t, "equal-map-v96-p-len") - bs96 = testMarshalErr(&v96v1, h, t, "enc-map-v96-p") - v96v2 = nil - testUnmarshalErr(&v96v2, bs96, h, t, "dec-map-v96-p-nil") - testDeepEqualErr(v96v1, v96v2, t, "equal-map-v96-p-nil") - // ... - if v == nil { - v96v2 = nil - } else { - v96v2 = make(map[int64]float64, len(v)) - } // reset map - var v96v3, v96v4 typMapMapInt64Float64 - v96v3 = typMapMapInt64Float64(v96v1) - v96v4 = typMapMapInt64Float64(v96v2) - if v != nil { - bs96 = testMarshalErr(v96v3, h, t, "enc-map-v96-custom") - testUnmarshalErr(v96v4, bs96, h, t, "dec-map-v96-p-len") - testDeepEqualErr(v96v3, v96v4, t, "equal-map-v96-p-len") - } - } - for _, v := range []map[int64]bool{nil, {}, {77: false, 127: true}} { - // fmt.Printf(">>>> running mammoth map v97: %v\n", v) - var v97v1, v97v2 map[int64]bool - var bs97 []byte - v97v1 = v - bs97 = testMarshalErr(v97v1, h, t, "enc-map-v97") - if v != nil { - if v == nil { - v97v2 = nil - } else { - v97v2 = make(map[int64]bool, len(v)) - } // reset map - testUnmarshalErr(v97v2, bs97, h, t, "dec-map-v97") - testDeepEqualErr(v97v1, v97v2, t, "equal-map-v97") - if v == nil { - v97v2 = nil - } else { - v97v2 = make(map[int64]bool, len(v)) - } // reset map - testUnmarshalErr(rv4i(v97v2), bs97, h, t, "dec-map-v97-noaddr") // decode into non-addressable map value - testDeepEqualErr(v97v1, v97v2, t, "equal-map-v97-noaddr") - } - if v == nil { - v97v2 = nil - } else { - v97v2 = make(map[int64]bool, len(v)) - } // reset map - testUnmarshalErr(&v97v2, bs97, h, t, "dec-map-v97-p-len") - testDeepEqualErr(v97v1, v97v2, t, "equal-map-v97-p-len") - bs97 = testMarshalErr(&v97v1, h, t, "enc-map-v97-p") - v97v2 = nil - testUnmarshalErr(&v97v2, bs97, h, t, "dec-map-v97-p-nil") - testDeepEqualErr(v97v1, v97v2, t, "equal-map-v97-p-nil") - // ... - if v == nil { - v97v2 = nil - } else { - v97v2 = make(map[int64]bool, len(v)) - } // reset map - var v97v3, v97v4 typMapMapInt64Bool - v97v3 = typMapMapInt64Bool(v97v1) - v97v4 = typMapMapInt64Bool(v97v2) - if v != nil { - bs97 = testMarshalErr(v97v3, h, t, "enc-map-v97-custom") - testUnmarshalErr(v97v4, bs97, h, t, "dec-map-v97-p-len") - testDeepEqualErr(v97v3, v97v4, t, "equal-map-v97-p-len") - } - } - -} - -func doTestMammothMapsAndSlices(t *testing.T, h Handle) { - doTestMammothSlices(t, h) - doTestMammothMaps(t, h) -} diff --git a/vendor/github.com/ugorji/go/codec/msgpack.go b/vendor/github.com/ugorji/go/codec/msgpack.go deleted file mode 100644 index 68408fb0b..000000000 --- a/vendor/github.com/ugorji/go/codec/msgpack.go +++ /dev/null @@ -1,1158 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -/* -Msgpack-c implementation powers the c, c++, python, ruby, etc libraries. -We need to maintain compatibility with it and how it encodes integer values -without caring about the type. - -For compatibility with behaviour of msgpack-c reference implementation: - - Go intX (>0) and uintX - IS ENCODED AS - msgpack +ve fixnum, unsigned - - Go intX (<0) - IS ENCODED AS - msgpack -ve fixnum, signed -*/ - -package codec - -import ( - "fmt" - "io" - "math" - "net/rpc" - "time" -) - -const ( - mpPosFixNumMin byte = 0x00 - mpPosFixNumMax byte = 0x7f - mpFixMapMin byte = 0x80 - mpFixMapMax byte = 0x8f - mpFixArrayMin byte = 0x90 - mpFixArrayMax byte = 0x9f - mpFixStrMin byte = 0xa0 - mpFixStrMax byte = 0xbf - mpNil byte = 0xc0 - _ byte = 0xc1 - mpFalse byte = 0xc2 - mpTrue byte = 0xc3 - mpFloat byte = 0xca - mpDouble byte = 0xcb - mpUint8 byte = 0xcc - mpUint16 byte = 0xcd - mpUint32 byte = 0xce - mpUint64 byte = 0xcf - mpInt8 byte = 0xd0 - mpInt16 byte = 0xd1 - mpInt32 byte = 0xd2 - mpInt64 byte = 0xd3 - - // extensions below - mpBin8 byte = 0xc4 - mpBin16 byte = 0xc5 - mpBin32 byte = 0xc6 - mpExt8 byte = 0xc7 - mpExt16 byte = 0xc8 - mpExt32 byte = 0xc9 - mpFixExt1 byte = 0xd4 - mpFixExt2 byte = 0xd5 - mpFixExt4 byte = 0xd6 - mpFixExt8 byte = 0xd7 - mpFixExt16 byte = 0xd8 - - mpStr8 byte = 0xd9 // new - mpStr16 byte = 0xda - mpStr32 byte = 0xdb - - mpArray16 byte = 0xdc - mpArray32 byte = 0xdd - - mpMap16 byte = 0xde - mpMap32 byte = 0xdf - - mpNegFixNumMin byte = 0xe0 - mpNegFixNumMax byte = 0xff -) - -var mpTimeExtTag int8 = -1 -var mpTimeExtTagU = uint8(mpTimeExtTag) - -// var mpdesc = map[byte]string{ -// mpPosFixNumMin: "PosFixNumMin", -// mpPosFixNumMax: "PosFixNumMax", -// mpFixMapMin: "FixMapMin", -// mpFixMapMax: "FixMapMax", -// mpFixArrayMin: "FixArrayMin", -// mpFixArrayMax: "FixArrayMax", -// mpFixStrMin: "FixStrMin", -// mpFixStrMax: "FixStrMax", -// mpNil: "Nil", -// mpFalse: "False", -// mpTrue: "True", -// mpFloat: "Float", -// mpDouble: "Double", -// mpUint8: "Uint8", -// mpUint16: "Uint16", -// mpUint32: "Uint32", -// mpUint64: "Uint64", -// mpInt8: "Int8", -// mpInt16: "Int16", -// mpInt32: "Int32", -// mpInt64: "Int64", -// mpBin8: "Bin8", -// mpBin16: "Bin16", -// mpBin32: "Bin32", -// mpExt8: "Ext8", -// mpExt16: "Ext16", -// mpExt32: "Ext32", -// mpFixExt1: "FixExt1", -// mpFixExt2: "FixExt2", -// mpFixExt4: "FixExt4", -// mpFixExt8: "FixExt8", -// mpFixExt16: "FixExt16", -// mpStr8: "Str8", -// mpStr16: "Str16", -// mpStr32: "Str32", -// mpArray16: "Array16", -// mpArray32: "Array32", -// mpMap16: "Map16", -// mpMap32: "Map32", -// mpNegFixNumMin: "NegFixNumMin", -// mpNegFixNumMax: "NegFixNumMax", -// } - -var mpdescNames = map[byte]string{ - mpNil: "nil", - mpFalse: "false", - mpTrue: "true", - mpFloat: "float", - mpDouble: "float", - mpUint8: "uuint", - mpUint16: "uint", - mpUint32: "uint", - mpUint64: "uint", - mpInt8: "int", - mpInt16: "int", - mpInt32: "int", - mpInt64: "int", - - mpStr8: "string|bytes", - mpStr16: "string|bytes", - mpStr32: "string|bytes", - - mpBin8: "bytes", - mpBin16: "bytes", - mpBin32: "bytes", - - mpArray16: "array", - mpArray32: "array", - - mpMap16: "map", - mpMap32: "map", -} - -func mpdesc(bd byte) (s string) { - s = mpdescNames[bd] - if s == "" { - switch { - case bd >= mpPosFixNumMin && bd <= mpPosFixNumMax, - bd >= mpNegFixNumMin && bd <= mpNegFixNumMax: - s = "int" - case bd >= mpFixStrMin && bd <= mpFixStrMax: - s = "string|bytes" - case bd >= mpFixArrayMin && bd <= mpFixArrayMax: - s = "array" - case bd >= mpFixMapMin && bd <= mpFixMapMax: - s = "map" - case bd >= mpFixExt1 && bd <= mpFixExt16, - bd >= mpExt8 && bd <= mpExt32: - s = "ext" - default: - s = "unknown" - } - } - return - - // switch bd { - // case mpNil: - // return "nil" - // case mpFalse: - // return "false" - // case mpTrue: - // return "true" - // case mpFloat, mpDouble: - // return "float" - // case mpUint8, mpUint16, mpUint32, mpUint64: - // return "uint" - // case mpInt8, mpInt16, mpInt32, mpInt64: - // return "int" - // default: - // switch { - // case bd >= mpPosFixNumMin && bd <= mpPosFixNumMax: - // return "int" - // case bd >= mpNegFixNumMin && bd <= mpNegFixNumMax: - // return "int" - // case bd == mpStr8, bd == mpStr16, bd == mpStr32, bd >= mpFixStrMin && bd <= mpFixStrMax: - // return "string|bytes" - // case bd == mpBin8, bd == mpBin16, bd == mpBin32: - // return "bytes" - // case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax: - // return "array" - // case bd == mpMap16, bd == mpMap32, bd >= mpFixMapMin && bd <= mpFixMapMax: - // return "map" - // case bd >= mpFixExt1 && bd <= mpFixExt16, bd >= mpExt8 && bd <= mpExt32: - // return "ext" - // default: - // return "unknown" - // } - // } -} - -// MsgpackSpecRpcMultiArgs is a special type which signifies to the MsgpackSpecRpcCodec -// that the backend RPC service takes multiple arguments, which have been arranged -// in sequence in the slice. -// -// The Codec then passes it AS-IS to the rpc service (without wrapping it in an -// array of 1 element). -type MsgpackSpecRpcMultiArgs []interface{} - -// A MsgpackContainer type specifies the different types of msgpackContainers. -type msgpackContainerType struct { - fixCutoff uint8 - bFixMin, b8, b16, b32 byte - // hasFixMin, has8, has8Always bool -} - -var ( - msgpackContainerRawLegacy = msgpackContainerType{ - 32, mpFixStrMin, 0, mpStr16, mpStr32, - } - msgpackContainerStr = msgpackContainerType{ - 32, mpFixStrMin, mpStr8, mpStr16, mpStr32, // true, true, false, - } - msgpackContainerBin = msgpackContainerType{ - 0, 0, mpBin8, mpBin16, mpBin32, // false, true, true, - } - msgpackContainerList = msgpackContainerType{ - 16, mpFixArrayMin, 0, mpArray16, mpArray32, // true, false, false, - } - msgpackContainerMap = msgpackContainerType{ - 16, mpFixMapMin, 0, mpMap16, mpMap32, // true, false, false, - } -) - -//--------------------------------------------- - -type msgpackEncDriver struct { - noBuiltInTypes - encDriverNoopContainerWriter - h *MsgpackHandle - x [8]byte - _ [6]uint64 // padding - e Encoder -} - -func (e *msgpackEncDriver) encoder() *Encoder { - return &e.e -} - -func (e *msgpackEncDriver) EncodeNil() { - e.e.encWr.writen1(mpNil) -} - -func (e *msgpackEncDriver) EncodeInt(i int64) { - if e.h.PositiveIntUnsigned && i >= 0 { - e.EncodeUint(uint64(i)) - } else if i > math.MaxInt8 { - if i <= math.MaxInt16 { - e.e.encWr.writen1(mpInt16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i)) - } else if i <= math.MaxInt32 { - e.e.encWr.writen1(mpInt32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i)) - } else { - e.e.encWr.writen1(mpInt64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i)) - } - } else if i >= -32 { - if e.h.NoFixedNum { - e.e.encWr.writen2(mpInt8, byte(i)) - } else { - e.e.encWr.writen1(byte(i)) - } - } else if i >= math.MinInt8 { - e.e.encWr.writen2(mpInt8, byte(i)) - } else if i >= math.MinInt16 { - e.e.encWr.writen1(mpInt16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i)) - } else if i >= math.MinInt32 { - e.e.encWr.writen1(mpInt32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i)) - } else { - e.e.encWr.writen1(mpInt64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i)) - } -} - -func (e *msgpackEncDriver) EncodeUint(i uint64) { - if i <= math.MaxInt8 { - if e.h.NoFixedNum { - e.e.encWr.writen2(mpUint8, byte(i)) - } else { - e.e.encWr.writen1(byte(i)) - } - } else if i <= math.MaxUint8 { - e.e.encWr.writen2(mpUint8, byte(i)) - } else if i <= math.MaxUint16 { - e.e.encWr.writen1(mpUint16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(i)) - } else if i <= math.MaxUint32 { - e.e.encWr.writen1(mpUint32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(i)) - } else { - e.e.encWr.writen1(mpUint64) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(i)) - } -} - -func (e *msgpackEncDriver) EncodeBool(b bool) { - if b { - e.e.encWr.writen1(mpTrue) - } else { - e.e.encWr.writen1(mpFalse) - } -} - -func (e *msgpackEncDriver) EncodeFloat32(f float32) { - e.e.encWr.writen1(mpFloat) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(math.Float32bits(f)) -} - -func (e *msgpackEncDriver) EncodeFloat64(f float64) { - e.e.encWr.writen1(mpDouble) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(math.Float64bits(f)) -} - -func (e *msgpackEncDriver) EncodeTime(t time.Time) { - if t.IsZero() { - e.EncodeNil() - return - } - t = t.UTC() - sec, nsec := t.Unix(), uint64(t.Nanosecond()) - var data64 uint64 - var l = 4 - if sec >= 0 && sec>>34 == 0 { - data64 = (nsec << 34) | uint64(sec) - if data64&0xffffffff00000000 != 0 { - l = 8 - } - } else { - l = 12 - } - if e.h.WriteExt { - e.encodeExtPreamble(mpTimeExtTagU, l) - } else { - e.writeContainerLen(msgpackContainerRawLegacy, l) - } - switch l { - case 4: - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(data64)) - case 8: - bigenHelper{e.x[:8], e.e.w()}.writeUint64(data64) - case 12: - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(nsec)) - bigenHelper{e.x[:8], e.e.w()}.writeUint64(uint64(sec)) - } -} - -func (e *msgpackEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) { - var bs []byte - if ext == SelfExt { - bs = e.e.blist.get(1024)[:0] - e.e.sideEncode(v, &bs) - } else { - bs = ext.WriteExt(v) - } - if bs == nil { - e.EncodeNil() - return - } - if e.h.WriteExt { - e.encodeExtPreamble(uint8(xtag), len(bs)) - e.e.encWr.writeb(bs) - } else { - e.EncodeStringBytesRaw(bs) - } - if ext == SelfExt { - e.e.blist.put(bs) - } -} - -func (e *msgpackEncDriver) EncodeRawExt(re *RawExt) { - e.encodeExtPreamble(uint8(re.Tag), len(re.Data)) - e.e.encWr.writeb(re.Data) -} - -func (e *msgpackEncDriver) encodeExtPreamble(xtag byte, l int) { - if l == 1 { - e.e.encWr.writen2(mpFixExt1, xtag) - } else if l == 2 { - e.e.encWr.writen2(mpFixExt2, xtag) - } else if l == 4 { - e.e.encWr.writen2(mpFixExt4, xtag) - } else if l == 8 { - e.e.encWr.writen2(mpFixExt8, xtag) - } else if l == 16 { - e.e.encWr.writen2(mpFixExt16, xtag) - } else if l < 256 { - e.e.encWr.writen2(mpExt8, byte(l)) - e.e.encWr.writen1(xtag) - } else if l < 65536 { - e.e.encWr.writen1(mpExt16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(l)) - e.e.encWr.writen1(xtag) - } else { - e.e.encWr.writen1(mpExt32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(l)) - e.e.encWr.writen1(xtag) - } -} - -func (e *msgpackEncDriver) WriteArrayStart(length int) { - e.writeContainerLen(msgpackContainerList, length) -} - -func (e *msgpackEncDriver) WriteMapStart(length int) { - e.writeContainerLen(msgpackContainerMap, length) -} - -func (e *msgpackEncDriver) EncodeString(s string) { - var ct msgpackContainerType - if e.h.WriteExt { - if e.h.StringToRaw { - ct = msgpackContainerBin - } else { - ct = msgpackContainerStr - } - } else { - ct = msgpackContainerRawLegacy - } - e.writeContainerLen(ct, len(s)) - if len(s) > 0 { - e.e.encWr.writestr(s) - } -} - -func (e *msgpackEncDriver) EncodeStringBytesRaw(bs []byte) { - if bs == nil { - e.EncodeNil() - return - } - if e.h.WriteExt { - e.writeContainerLen(msgpackContainerBin, len(bs)) - } else { - e.writeContainerLen(msgpackContainerRawLegacy, len(bs)) - } - if len(bs) > 0 { - e.e.encWr.writeb(bs) - } -} - -func (e *msgpackEncDriver) writeContainerLen(ct msgpackContainerType, l int) { - if ct.fixCutoff > 0 && l < int(ct.fixCutoff) { - e.e.encWr.writen1(ct.bFixMin | byte(l)) - } else if ct.b8 > 0 && l < 256 { - e.e.encWr.writen2(ct.b8, uint8(l)) - } else if l < 65536 { - e.e.encWr.writen1(ct.b16) - bigenHelper{e.x[:2], e.e.w()}.writeUint16(uint16(l)) - } else { - e.e.encWr.writen1(ct.b32) - bigenHelper{e.x[:4], e.e.w()}.writeUint32(uint32(l)) - } -} - -//--------------------------------------------- - -type msgpackDecDriver struct { - decDriverNoopContainerReader - h *MsgpackHandle - // b [scratchByteArrayLen]byte - bd byte - bdRead bool - fnil bool - noBuiltInTypes - _ [6]uint64 // padding - d Decoder -} - -func (d *msgpackDecDriver) decoder() *Decoder { - return &d.d -} - -// Note: This returns either a primitive (int, bool, etc) for non-containers, -// or a containerType, or a specific type denoting nil or extension. -// It is called when a nil interface{} is passed, leaving it up to the DecDriver -// to introspect the stream and decide how best to decode. -// It deciphers the value by looking at the stream first. -func (d *msgpackDecDriver) DecodeNaked() { - if !d.bdRead { - d.readNextBd() - } - d.fnil = false - bd := d.bd - n := d.d.naked() - var decodeFurther bool - - switch bd { - case mpNil: - n.v = valueTypeNil - d.bdRead = false - d.fnil = true - case mpFalse: - n.v = valueTypeBool - n.b = false - case mpTrue: - n.v = valueTypeBool - n.b = true - - case mpFloat: - n.v = valueTypeFloat - n.f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) - case mpDouble: - n.v = valueTypeFloat - n.f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) - - case mpUint8: - n.v = valueTypeUint - n.u = uint64(d.d.decRd.readn1()) - case mpUint16: - n.v = valueTypeUint - n.u = uint64(bigen.Uint16(d.d.decRd.readx(2))) - case mpUint32: - n.v = valueTypeUint - n.u = uint64(bigen.Uint32(d.d.decRd.readx(4))) - case mpUint64: - n.v = valueTypeUint - n.u = uint64(bigen.Uint64(d.d.decRd.readx(8))) - - case mpInt8: - n.v = valueTypeInt - n.i = int64(int8(d.d.decRd.readn1())) - case mpInt16: - n.v = valueTypeInt - n.i = int64(int16(bigen.Uint16(d.d.decRd.readx(2)))) - case mpInt32: - n.v = valueTypeInt - n.i = int64(int32(bigen.Uint32(d.d.decRd.readx(4)))) - case mpInt64: - n.v = valueTypeInt - n.i = int64(int64(bigen.Uint64(d.d.decRd.readx(8)))) - - default: - switch { - case bd >= mpPosFixNumMin && bd <= mpPosFixNumMax: - // positive fixnum (always signed) - n.v = valueTypeInt - n.i = int64(int8(bd)) - case bd >= mpNegFixNumMin && bd <= mpNegFixNumMax: - // negative fixnum - n.v = valueTypeInt - n.i = int64(int8(bd)) - case bd == mpStr8, bd == mpStr16, bd == mpStr32, bd >= mpFixStrMin && bd <= mpFixStrMax: - if d.h.WriteExt || d.h.RawToString { - n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - } else { - n.v = valueTypeBytes - n.l = d.DecodeBytes(nil, false) - } - case bd == mpBin8, bd == mpBin16, bd == mpBin32: - fauxUnionReadRawBytes(d, &d.d, n, d.h.RawToString) - case bd == mpArray16, bd == mpArray32, bd >= mpFixArrayMin && bd <= mpFixArrayMax: - n.v = valueTypeArray - decodeFurther = true - case bd == mpMap16, bd == mpMap32, bd >= mpFixMapMin && bd <= mpFixMapMax: - n.v = valueTypeMap - decodeFurther = true - case bd >= mpFixExt1 && bd <= mpFixExt16, bd >= mpExt8 && bd <= mpExt32: - n.v = valueTypeExt - clen := d.readExtLen() - n.u = uint64(d.d.decRd.readn1()) - if n.u == uint64(mpTimeExtTagU) { - n.v = valueTypeTime - n.t = d.decodeTime(clen) - } else if d.d.bytes { - n.l = d.d.decRd.rb.readx(uint(clen)) - } else { - n.l = decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, d.d.b[:]) - } - default: - d.d.errorf("cannot infer value: %s: Ox%x/%d/%s", msgBadDesc, bd, bd, mpdesc(bd)) - } - } - if !decodeFurther { - d.bdRead = false - } - if n.v == valueTypeUint && d.h.SignedInteger { - n.v = valueTypeInt - n.i = int64(n.u) - } -} - -// int can be decoded from msgpack type: intXXX or uintXXX -func (d *msgpackDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } - switch d.bd { - case mpUint8: - i = int64(uint64(d.d.decRd.readn1())) - case mpUint16: - i = int64(uint64(bigen.Uint16(d.d.decRd.readx(2)))) - case mpUint32: - i = int64(uint64(bigen.Uint32(d.d.decRd.readx(4)))) - case mpUint64: - i = int64(bigen.Uint64(d.d.decRd.readx(8))) - case mpInt8: - i = int64(int8(d.d.decRd.readn1())) - case mpInt16: - i = int64(int16(bigen.Uint16(d.d.decRd.readx(2)))) - case mpInt32: - i = int64(int32(bigen.Uint32(d.d.decRd.readx(4)))) - case mpInt64: - i = int64(bigen.Uint64(d.d.decRd.readx(8))) - default: - switch { - case d.bd >= mpPosFixNumMin && d.bd <= mpPosFixNumMax: - i = int64(int8(d.bd)) - case d.bd >= mpNegFixNumMin && d.bd <= mpNegFixNumMax: - i = int64(int8(d.bd)) - default: - d.d.errorf("cannot decode signed integer: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd)) - return - } - } - d.bdRead = false - return -} - -// uint can be decoded from msgpack type: intXXX or uintXXX -func (d *msgpackDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } - switch d.bd { - case mpUint8: - ui = uint64(d.d.decRd.readn1()) - case mpUint16: - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) - case mpUint32: - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) - case mpUint64: - ui = bigen.Uint64(d.d.decRd.readx(8)) - case mpInt8: - if i := int64(int8(d.d.decRd.readn1())); i >= 0 { - ui = uint64(i) - } else { - d.d.errorf("assigning negative signed value: %v, to unsigned type", i) - return - } - case mpInt16: - if i := int64(int16(bigen.Uint16(d.d.decRd.readx(2)))); i >= 0 { - ui = uint64(i) - } else { - d.d.errorf("assigning negative signed value: %v, to unsigned type", i) - return - } - case mpInt32: - if i := int64(int32(bigen.Uint32(d.d.decRd.readx(4)))); i >= 0 { - ui = uint64(i) - } else { - d.d.errorf("assigning negative signed value: %v, to unsigned type", i) - return - } - case mpInt64: - if i := int64(bigen.Uint64(d.d.decRd.readx(8))); i >= 0 { - ui = uint64(i) - } else { - d.d.errorf("assigning negative signed value: %v, to unsigned type", i) - return - } - default: - switch { - case d.bd >= mpPosFixNumMin && d.bd <= mpPosFixNumMax: - ui = uint64(d.bd) - case d.bd >= mpNegFixNumMin && d.bd <= mpNegFixNumMax: - d.d.errorf("assigning negative signed value: %v, to unsigned type", int(d.bd)) - return - default: - d.d.errorf("cannot decode unsigned integer: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd)) - return - } - } - d.bdRead = false - return -} - -// float can either be decoded from msgpack type: float, double or intX -func (d *msgpackDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return - } - if d.bd == mpFloat { - f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) - } else if d.bd == mpDouble { - f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) - } else { - f = float64(d.DecodeInt64()) - } - d.bdRead = false - return -} - -// bool can be decoded from bool, fixnum 0 or 1. -func (d *msgpackDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return - } - if d.bd == mpFalse || d.bd == 0 { - // b = false - } else if d.bd == mpTrue || d.bd == 1 { - b = true - } else { - d.d.errorf("cannot decode bool: %s: %x/%s", msgBadDesc, d.bd, mpdesc(d.bd)) - return - } - d.bdRead = false - return -} - -func (d *msgpackDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return - } - - bd := d.bd - var clen int - if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { - clen = d.readContainerLen(msgpackContainerBin) // binary - } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || - (bd >= mpFixStrMin && bd <= mpFixStrMax) { - clen = d.readContainerLen(msgpackContainerStr) // string/raw - } else if bd == mpArray16 || bd == mpArray32 || - (bd >= mpFixArrayMin && bd <= mpFixArrayMax) { - // check if an "array" of uint8's - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - slen := d.ReadArrayStart() - bs = usableByteSlice(bs, slen) - for i := 0; i < len(bs); i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs - } else { - d.d.errorf("invalid byte descriptor for decoding bytes, got: 0x%x", d.bd) - return - } - - d.bdRead = false - if d.d.bytes && (zerocopy || d.h.ZeroCopy) { - return d.d.decRd.rb.readx(uint(clen)) - } - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - return decByteSlice(d.d.r(), clen, d.h.MaxInitLen, bs) -} - -func (d *msgpackDecDriver) DecodeStringAsBytes() (s []byte) { - return d.DecodeBytes(d.d.b[:], true) -} - -func (d *msgpackDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() - d.bdRead = true -} - -// func (d *msgpackDecDriver) uncacheRead() { -// if d.bdRead { -// d.d.decRd.unreadn1() -// d.bdRead = false -// } -// } - -func (d *msgpackDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == mpNil { - d.bdRead = false - d.fnil = true - null = true - } - return -} - -// func (d *msgpackDecDriver) Nil() bool { -// return d.fnil -// } - -func (d *msgpackDecDriver) ContainerType() (vt valueType) { - if !d.bdRead { - d.readNextBd() - } - bd := d.bd - d.fnil = false - if bd == mpNil { - d.bdRead = false - d.fnil = true - return valueTypeNil - } else if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { - return valueTypeBytes - } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || - (bd >= mpFixStrMin && bd <= mpFixStrMax) { - if d.h.WriteExt || d.h.RawToString { // UTF-8 string (new spec) - return valueTypeString - } - return valueTypeBytes // raw (old spec) - } else if bd == mpArray16 || bd == mpArray32 || (bd >= mpFixArrayMin && bd <= mpFixArrayMax) { - return valueTypeArray - } else if bd == mpMap16 || bd == mpMap32 || (bd >= mpFixMapMin && bd <= mpFixMapMax) { - return valueTypeMap - } - return valueTypeUnset -} - -func (d *msgpackDecDriver) TryNil() (v bool) { - return d.advanceNil() -} - -func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int) { - bd := d.bd - if bd == ct.b8 { - clen = int(d.d.decRd.readn1()) - } else if bd == ct.b16 { - clen = int(bigen.Uint16(d.d.decRd.readx(2))) - } else if bd == ct.b32 { - clen = int(bigen.Uint32(d.d.decRd.readx(4))) - } else if (ct.bFixMin & bd) == ct.bFixMin { - clen = int(ct.bFixMin ^ bd) - } else { - d.d.errorf("cannot read container length: %s: hex: %x, decimal: %d", msgBadDesc, bd, bd) - return - } - d.bdRead = false - return -} - -func (d *msgpackDecDriver) ReadMapStart() int { - if d.advanceNil() { - return decContainerLenNil - } - return d.readContainerLen(msgpackContainerMap) -} - -func (d *msgpackDecDriver) ReadArrayStart() int { - if d.advanceNil() { - return decContainerLenNil - } - return d.readContainerLen(msgpackContainerList) -} - -func (d *msgpackDecDriver) readExtLen() (clen int) { - switch d.bd { - case mpFixExt1: - clen = 1 - case mpFixExt2: - clen = 2 - case mpFixExt4: - clen = 4 - case mpFixExt8: - clen = 8 - case mpFixExt16: - clen = 16 - case mpExt8: - clen = int(d.d.decRd.readn1()) - case mpExt16: - clen = int(bigen.Uint16(d.d.decRd.readx(2))) - case mpExt32: - clen = int(bigen.Uint32(d.d.decRd.readx(4))) - default: - d.d.errorf("decoding ext bytes: found unexpected byte: %x", d.bd) - return - } - return -} - -func (d *msgpackDecDriver) DecodeTime() (t time.Time) { - // decode time from string bytes or ext - if d.advanceNil() { - return - } - bd := d.bd - var clen int - if bd == mpBin8 || bd == mpBin16 || bd == mpBin32 { - clen = d.readContainerLen(msgpackContainerBin) // binary - } else if bd == mpStr8 || bd == mpStr16 || bd == mpStr32 || - (bd >= mpFixStrMin && bd <= mpFixStrMax) { - clen = d.readContainerLen(msgpackContainerStr) // string/raw - } else { - // expect to see mpFixExt4,-1 OR mpFixExt8,-1 OR mpExt8,12,-1 - d.bdRead = false - b2 := d.d.decRd.readn1() - if d.bd == mpFixExt4 && b2 == mpTimeExtTagU { - clen = 4 - } else if d.bd == mpFixExt8 && b2 == mpTimeExtTagU { - clen = 8 - } else if d.bd == mpExt8 && b2 == 12 && d.d.decRd.readn1() == mpTimeExtTagU { - clen = 12 - } else { - d.d.errorf("invalid stream for decoding time as extension: got 0x%x, 0x%x", d.bd, b2) - return - } - } - return d.decodeTime(clen) -} - -func (d *msgpackDecDriver) decodeTime(clen int) (t time.Time) { - // bs = d.d.decRd.readx(clen) - d.bdRead = false - switch clen { - case 4: - t = time.Unix(int64(bigen.Uint32(d.d.decRd.readx(4))), 0).UTC() - case 8: - tv := bigen.Uint64(d.d.decRd.readx(8)) - t = time.Unix(int64(tv&0x00000003ffffffff), int64(tv>>34)).UTC() - case 12: - nsec := bigen.Uint32(d.d.decRd.readx(4)) - sec := bigen.Uint64(d.d.decRd.readx(8)) - t = time.Unix(int64(sec), int64(nsec)).UTC() - default: - d.d.errorf("invalid length of bytes for decoding time - expecting 4 or 8 or 12, got %d", clen) - return - } - return -} - -func (d *msgpackDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - if xtag > 0xff { - d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag) - return - } - if d.advanceNil() { - return - } - realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag)) - realxtag := uint64(realxtag1) - if ext == nil { - re := rv.(*RawExt) - re.Tag = realxtag - re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs) - } else if ext == SelfExt { - d.d.sideDecode(rv, xbs) - } else { - ext.ReadExt(rv, xbs) - } -} - -func (d *msgpackDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) { - xbd := d.bd - if xbd == mpBin8 || xbd == mpBin16 || xbd == mpBin32 { - xbs = d.DecodeBytes(nil, true) - } else if xbd == mpStr8 || xbd == mpStr16 || xbd == mpStr32 || - (xbd >= mpFixStrMin && xbd <= mpFixStrMax) { - xbs = d.DecodeStringAsBytes() - } else { - clen := d.readExtLen() - xtag = d.d.decRd.readn1() - if verifyTag && xtag != tag { - d.d.errorf("wrong extension tag - got %b, expecting %v", xtag, tag) - return - } - if d.d.bytes { - xbs = d.d.decRd.rb.readx(uint(clen)) - } else { - xbs = decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, d.d.b[:]) - } - } - d.bdRead = false - return -} - -//-------------------------------------------------- - -//MsgpackHandle is a Handle for the Msgpack Schema-Free Encoding Format. -type MsgpackHandle struct { - binaryEncodingType - BasicHandle - - // NoFixedNum says to output all signed integers as 2-bytes, never as 1-byte fixednum. - NoFixedNum bool - - // WriteExt controls whether the new spec is honored. - // - // With WriteExt=true, we can encode configured extensions with extension tags - // and encode string/[]byte/extensions in a way compatible with the new spec - // but incompatible with the old spec. - // - // For compatibility with the old spec, set WriteExt=false. - // - // With WriteExt=false: - // configured extensions are serialized as raw bytes (not msgpack extensions). - // reserved byte descriptors like Str8 and those enabling the new msgpack Binary type - // are not encoded. - WriteExt bool - - // PositiveIntUnsigned says to encode positive integers as unsigned. - PositiveIntUnsigned bool - - _ [7]uint64 // padding (cache-aligned) -} - -// Name returns the name of the handle: msgpack -func (h *MsgpackHandle) Name() string { return "msgpack" } - -func (h *MsgpackHandle) newEncDriver() encDriver { - var e = &msgpackEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e -} - -func (h *MsgpackHandle) newDecDriver() decDriver { - d := &msgpackDecDriver{h: h} - d.d.d = d - d.d.init(h) - d.reset() - return d -} - -func (e *msgpackEncDriver) reset() { -} - -func (d *msgpackDecDriver) reset() { - d.bd, d.bdRead = 0, false - d.fnil = false -} - -//-------------------------------------------------- - -type msgpackSpecRpcCodec struct { - rpcCodec -} - -// /////////////// Spec RPC Codec /////////////////// -func (c *msgpackSpecRpcCodec) WriteRequest(r *rpc.Request, body interface{}) error { - // WriteRequest can write to both a Go service, and other services that do - // not abide by the 1 argument rule of a Go service. - // We discriminate based on if the body is a MsgpackSpecRpcMultiArgs - var bodyArr []interface{} - if m, ok := body.(MsgpackSpecRpcMultiArgs); ok { - bodyArr = ([]interface{})(m) - } else { - bodyArr = []interface{}{body} - } - r2 := []interface{}{0, uint32(r.Seq), r.ServiceMethod, bodyArr} - return c.write(r2, nil, false) -} - -func (c *msgpackSpecRpcCodec) WriteResponse(r *rpc.Response, body interface{}) error { - var moe interface{} - if r.Error != "" { - moe = r.Error - } - if moe != nil && body != nil { - body = nil - } - r2 := []interface{}{1, uint32(r.Seq), moe, body} - return c.write(r2, nil, false) -} - -func (c *msgpackSpecRpcCodec) ReadResponseHeader(r *rpc.Response) error { - return c.parseCustomHeader(1, &r.Seq, &r.Error) -} - -func (c *msgpackSpecRpcCodec) ReadRequestHeader(r *rpc.Request) error { - return c.parseCustomHeader(0, &r.Seq, &r.ServiceMethod) -} - -func (c *msgpackSpecRpcCodec) ReadRequestBody(body interface{}) error { - if body == nil { // read and discard - return c.read(nil) - } - bodyArr := []interface{}{body} - return c.read(&bodyArr) -} - -func (c *msgpackSpecRpcCodec) parseCustomHeader(expectTypeByte byte, msgid *uint64, methodOrError *string) (err error) { - if cls := c.cls.load(); cls.closed { - return io.EOF - } - - // We read the response header by hand - // so that the body can be decoded on its own from the stream at a later time. - - const fia byte = 0x94 //four item array descriptor value - - var ba [1]byte - var n int - for { - n, err = c.r.Read(ba[:]) - if err != nil { - return - } - if n == 1 { - break - } - } - - var b = ba[0] - if b != fia { - err = fmt.Errorf("not array - %s %x/%s", msgBadDesc, b, mpdesc(b)) - } else { - err = c.read(&b) - if err == nil { - if b != expectTypeByte { - err = fmt.Errorf("%s - expecting %v but got %x/%s", - msgBadDesc, expectTypeByte, b, mpdesc(b)) - } else { - err = c.read(msgid) - if err == nil { - err = c.read(methodOrError) - } - } - } - } - return -} - -//-------------------------------------------------- - -// msgpackSpecRpc is the implementation of Rpc that uses custom communication protocol -// as defined in the msgpack spec at https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md -type msgpackSpecRpc struct{} - -// MsgpackSpecRpc implements Rpc using the communication protocol defined in -// the msgpack spec at https://github.com/msgpack-rpc/msgpack-rpc/blob/master/spec.md . -// -// See GoRpc documentation, for information on buffering for better performance. -var MsgpackSpecRpc msgpackSpecRpc - -func (x msgpackSpecRpc) ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec { - return &msgpackSpecRpcCodec{newRPCCodec(conn, h)} -} - -func (x msgpackSpecRpc) ClientCodec(conn io.ReadWriteCloser, h Handle) rpc.ClientCodec { - return &msgpackSpecRpcCodec{newRPCCodec(conn, h)} -} - -var _ decDriver = (*msgpackDecDriver)(nil) -var _ encDriver = (*msgpackEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/prebuild.go b/vendor/github.com/ugorji/go/codec/prebuild.go deleted file mode 100644 index 7771057ef..000000000 --- a/vendor/github.com/ugorji/go/codec/prebuild.go +++ /dev/null @@ -1,136 +0,0 @@ -// +build prebuild - -package main - -// prebuild.go generates sort implementations for -// various slice types and combination slice+reflect.Value types. -// -// The combination slice+reflect.Value types are used -// during canonical encode, and the others are used during fast-path -// encoding of map keys. - -import ( - "bytes" - "go/format" - "io/ioutil" - "os" - "strings" - "text/template" -) - -// genInternalSortableTypes returns the types -// that are used for fast-path canonical's encoding of maps. -// -// For now, we only support the highest sizes for -// int64, uint64, float64, bool, string, bytes. -func genInternalSortableTypes() []string { - return []string{ - "string", - // "float32", - "float64", - // "uint", - // "uint8", - // "uint16", - // "uint32", - "uint64", - "uintptr", - // "int", - // "int8", - // "int16", - // "int32", - "int64", - "bool", - "time", - "bytes", - } -} - -// genInternalSortablePlusTypes returns the types -// that are used for reflection-based canonical's encoding of maps. -// -// For now, we only support the highest sizes for -// int64, uint64, float64, bool, string, bytes. -func genInternalSortablePlusTypes() []string { - return []string{ - "string", - "float64", - "uint64", - "uintptr", - "int64", - "bool", - "time", - "bytes", - } -} - -func genTypeForShortName(s string) string { - switch s { - case "time": - return "time.Time" - case "bytes": - return "[]byte" - } - return s -} - -func genArgs(args ...interface{}) map[string]interface{} { - m := make(map[string]interface{}, len(args)/2) - for i := 0; i < len(args); { - m[args[i].(string)] = args[i+1] - i += 2 - } - return m -} - -func genEndsWith(s0 string, sn ...string) bool { - for _, s := range sn { - if strings.HasSuffix(s0, s) { - return true - } - } - return false -} - -func chkerr(err error) { - if err != nil { - panic(err) - } -} - -func run(fnameIn, fnameOut string) { - var err error - - funcs := make(template.FuncMap) - funcs["sortables"] = genInternalSortableTypes - funcs["sortablesplus"] = genInternalSortablePlusTypes - funcs["tshort"] = genTypeForShortName - funcs["endswith"] = genEndsWith - funcs["args"] = genArgs - - t := template.New("").Funcs(funcs) - fin, err := os.Open(fnameIn) - chkerr(err) - defer fin.Close() - fout, err := os.Create(fnameOut) - chkerr(err) - defer fout.Close() - tmplstr, err := ioutil.ReadAll(fin) - chkerr(err) - t, err = t.Parse(string(tmplstr)) - chkerr(err) - var out bytes.Buffer - err = t.Execute(&out, 0) - chkerr(err) - bout, err := format.Source(out.Bytes()) - if err != nil { - fout.Write(out.Bytes()) // write out if error, so we can still see. - } - chkerr(err) - // write out if error, as much as possible, so we can still see. - _, err = fout.Write(bout) - chkerr(err) -} - -func main() { - run("sort-slice.go.tmpl", "sort-slice.generated.go") -} diff --git a/vendor/github.com/ugorji/go/codec/py_test.go b/vendor/github.com/ugorji/go/codec/py_test.go deleted file mode 100644 index 54abc0d12..000000000 --- a/vendor/github.com/ugorji/go/codec/py_test.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build x - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// These tests are used to verify msgpack and cbor implementations against their python libraries. -// If you have the library installed, you can enable the tests back by running: go test -tags=x . -// Look at test.py for how to setup your environment. - -import ( - "testing" -) - -func TestMsgpackPythonGenStreams(t *testing.T) { - doTestPythonGenStreams(t, testMsgpackH) -} - -func TestCborPythonGenStreams(t *testing.T) { - doTestPythonGenStreams(t, testCborH) -} - -func TestMsgpackRpcSpecGoClientToPythonSvc(t *testing.T) { - doTestMsgpackRpcSpecGoClientToPythonSvc(t) -} - -func TestMsgpackRpcSpecPythonClientToGoSvc(t *testing.T) { - doTestMsgpackRpcSpecPythonClientToGoSvc(t) -} diff --git a/vendor/github.com/ugorji/go/codec/reader.go b/vendor/github.com/ugorji/go/codec/reader.go deleted file mode 100644 index e2079bf0b..000000000 --- a/vendor/github.com/ugorji/go/codec/reader.go +++ /dev/null @@ -1,1244 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import "io" - -// decReader abstracts the reading source, allowing implementations that can -// read from an io.Reader or directly off a byte slice with zero-copying. -type decReader interface { - unreadn1() - - // readx will use the implementation scratch buffer if possible i.e. n < len(scratchbuf), OR - // just return a view of the []byte being decoded from. - // Ensure you call detachZeroCopyBytes later if this needs to be sent outside codec control. - readx(n uint) []byte - readb([]byte) - readn1() uint8 - readn1eof() (v uint8, eof bool) - - // read up to 7 bytes at a time - readn(num uint8) (v [rwNLen]byte) - numread() uint // number of bytes read - track() - stopTrack() []byte - - // readNumber(includeLastByteRead bool) []byte - - // skip any whitespace characters, and return the first non-matching byte - skipWhitespace() (token byte) - - // skip will skip any byte that matches, and return the first non-matching byte - // skip(accept *bitset256) (token byte) - - // readTo will read any byte that matches, stopping once no-longer matching. - readTo(accept *bitset256) (out []byte) - - // readUntil will read, only stopping once it matches the 'stop' byte. - readUntil(stop byte, includeLast bool) (out []byte) -} - -// ------------------------------------------------ - -type unreadByteStatus uint8 - -// unreadByteStatus goes from -// undefined (when initialized) -- (read) --> canUnread -- (unread) --> canRead ... -const ( - unreadByteUndefined unreadByteStatus = iota - unreadByteCanRead - unreadByteCanUnread -) - -// -------------------- - -type ioDecReaderCommon struct { - r io.Reader // the reader passed in - - n uint // num read - - l byte // last byte - ls unreadByteStatus // last byte status - trb bool // tracking bytes turned on - _ bool - b [4]byte // tiny buffer for reading single bytes - - blist *bytesFreelist - - tr []byte // buffer for tracking bytes - bufr []byte // buffer for readTo/readUntil -} - -func (z *ioDecReaderCommon) last() byte { - return z.l -} - -func (z *ioDecReaderCommon) reset(r io.Reader, blist *bytesFreelist) { - z.blist = blist - z.r = r - z.ls = unreadByteUndefined - z.l, z.n = 0, 0 - z.trb = false -} - -func (z *ioDecReaderCommon) numread() uint { - return z.n -} - -func (z *ioDecReaderCommon) track() { - z.tr = z.blist.check(z.tr, 256)[:0] - z.trb = true -} - -func (z *ioDecReaderCommon) stopTrack() (bs []byte) { - z.trb = false - return z.tr -} - -// ------------------------------------------ - -// ioDecReader is a decReader that reads off an io.Reader. -// -// It also has a fallback implementation of ByteScanner if needed. -type ioDecReader struct { - ioDecReaderCommon - - // rr io.Reader - br io.ByteScanner - - x [64 + 16]byte // for: get struct field name, swallow valueTypeBytes, etc - // _ [1]uint64 // padding -} - -func (z *ioDecReader) reset(r io.Reader, blist *bytesFreelist) { - z.ioDecReaderCommon.reset(r, blist) - - z.br, _ = r.(io.ByteScanner) -} - -func (z *ioDecReader) Read(p []byte) (n int, err error) { - if len(p) == 0 { - return - } - var firstByte bool - if z.ls == unreadByteCanRead { - z.ls = unreadByteCanUnread - p[0] = z.l - if len(p) == 1 { - n = 1 - return - } - firstByte = true - p = p[1:] - } - n, err = z.r.Read(p) - if n > 0 { - if err == io.EOF && n == len(p) { - err = nil // read was successful, so postpone EOF (till next time) - } - z.l = p[n-1] - z.ls = unreadByteCanUnread - } - if firstByte { - n++ - } - return -} - -func (z *ioDecReader) ReadByte() (c byte, err error) { - if z.br != nil { - c, err = z.br.ReadByte() - if err == nil { - z.l = c - z.ls = unreadByteCanUnread - } - return - } - - n, err := z.Read(z.b[:1]) - if n == 1 { - c = z.b[0] - if err == io.EOF { - err = nil // read was successful, so postpone EOF (till next time) - } - } - return -} - -func (z *ioDecReader) UnreadByte() (err error) { - if z.br != nil { - err = z.br.UnreadByte() - if err == nil { - z.ls = unreadByteCanRead - } - return - } - - switch z.ls { - case unreadByteCanUnread: - z.ls = unreadByteCanRead - case unreadByteCanRead: - err = errDecUnreadByteLastByteNotRead - case unreadByteUndefined: - err = errDecUnreadByteNothingToRead - default: - err = errDecUnreadByteUnknown - } - return -} - -func (z *ioDecReader) readn(num uint8) (bs [rwNLen]byte) { - z.readb(bs[:num]) - // copy(bs[:], z.readx(uint(num))) - return -} - -func (z *ioDecReader) readx(n uint) (bs []byte) { - if n == 0 { - return - } - if n < uint(len(z.x)) { - bs = z.x[:n] - } else { - bs = make([]byte, n) - } - if _, err := decReadFull(z.r, bs); err != nil { - panic(err) - } - z.n += uint(len(bs)) - if z.trb { - z.tr = append(z.tr, bs...) - } - return -} - -func (z *ioDecReader) readb(bs []byte) { - if len(bs) == 0 { - return - } - if _, err := decReadFull(z.r, bs); err != nil { - panic(err) - } - z.n += uint(len(bs)) - if z.trb { - z.tr = append(z.tr, bs...) - } -} - -func (z *ioDecReader) readn1eof() (b uint8, eof bool) { - b, err := z.ReadByte() - if err == nil { - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - } else if err == io.EOF { - eof = true - } else { - panic(err) - } - return -} - -func (z *ioDecReader) readn1() (b uint8) { - b, err := z.ReadByte() - if err == nil { - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - return - } - panic(err) -} - -// func (z *ioDecReader) skip(accept *bitset256) (token byte) { -// var eof bool -// LOOP: -// token, eof = z.readn1eof() -// if eof { -// return -// } -// if accept.isset(token) { -// goto LOOP -// } -// return -// } - -func (z *ioDecReader) skipWhitespace() (token byte) { - var eof bool -LOOP: - token, eof = z.readn1eof() - if eof { - return - } - if isWhitespaceChar(token) { - goto LOOP - } - return -} - -func (z *ioDecReader) readTo(accept *bitset256) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] -LOOP: - token, eof := z.readn1eof() - if eof { - return z.bufr - } - if accept.isset(token) { - z.bufr = append(z.bufr, token) - goto LOOP - } - z.unreadn1() - return z.bufr -} - -func (z *ioDecReader) readUntil(stop byte, includeLast bool) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] -LOOP: - token, eof := z.readn1eof() - if eof { - panic(io.EOF) - } - z.bufr = append(z.bufr, token) - if token == stop { - if includeLast { - return z.bufr - } - return z.bufr[:len(z.bufr)-1] - } - goto LOOP -} - -//go:noinline -func (z *ioDecReader) unreadn1() { - err := z.UnreadByte() - if err != nil { - panic(err) - } - z.n-- - if z.trb { - if l := len(z.tr) - 1; l >= 0 { - z.tr = z.tr[:l] - } - } -} - -// ------------------------------------ - -type bufioDecReader struct { - ioDecReaderCommon - - c uint // cursor - buf []byte -} - -func (z *bufioDecReader) reset(r io.Reader, bufsize int, blist *bytesFreelist) { - z.ioDecReaderCommon.reset(r, blist) - z.c = 0 - if cap(z.buf) < bufsize { - z.buf = blist.get(bufsize) - } - z.buf = z.buf[:0] -} - -func (z *bufioDecReader) readb(p []byte) { - var n = uint(copy(p, z.buf[z.c:])) - z.n += n - z.c += n - if len(p) == int(n) { - if z.trb { - z.tr = append(z.tr, p...) - } - } else { - z.readbFill(p, n, true, false) - } -} - -func (z *bufioDecReader) readbFill(p0 []byte, n uint, must bool, eof bool) (isEOF bool, err error) { - // at this point, there's nothing in z.buf to read (z.buf is fully consumed) - var p []byte - if p0 != nil { - p = p0[n:] - } - var n2 uint - if len(p) > cap(z.buf) { - n2, err = decReadFull(z.r, p) - if err != nil { - if err == io.EOF { - isEOF = true - } - if must && !(eof && isEOF) { - panic(err) - } - return - } - n += n2 - z.n += n2 - // always keep last byte in z.buf - z.buf = z.buf[:1] - z.buf[0] = p[len(p)-1] - z.c = 1 - if z.trb { - z.tr = append(z.tr, p0[:n]...) - } - return - } - // z.c is now 0, and len(p) <= cap(z.buf) - var n1 int -LOOP: - // for len(p) > 0 && z.err == nil { - z.buf = z.buf[0:cap(z.buf)] - n1, err = z.r.Read(z.buf) - n2 = uint(n1) - if n2 == 0 && err != nil { - if err == io.EOF { - isEOF = true - } - if must && !(eof && isEOF) { - panic(err) - } - return - } - err = nil - z.buf = z.buf[:n2] - z.c = 0 - if len(p) > 0 { - n2 = uint(copy(p, z.buf)) - z.c = n2 - n += n2 - z.n += n2 - p = p[n2:] - if len(p) > 0 { - goto LOOP - } - if z.c == 0 { - z.buf = z.buf[:1] - z.buf[0] = p[len(p)-1] - z.c = 1 - } - } - if z.trb && p0 != nil { - z.tr = append(z.tr, p0[:n]...) - } - return -} - -func (z *bufioDecReader) last() byte { - return z.buf[z.c-1] -} - -func (z *bufioDecReader) readn1eof() (b byte, eof bool) { - if z.c >= uint(len(z.buf)) { - eof, _ = z.readbFill(nil, 0, true, true) - if eof { - return - } - } - b = z.buf[z.c] - z.c++ - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - return -} - -func (z *bufioDecReader) readn1() (b byte) { - if z.c >= uint(len(z.buf)) { - z.readbFill(nil, 0, true, false) - } - b = z.buf[z.c] - z.c++ - z.n++ - if z.trb { - z.tr = append(z.tr, b) - } - return -} - -func (z *bufioDecReader) unreadn1() { - if z.c == 0 { - panic(errDecUnreadByteNothingToRead) - } - z.c-- - z.n-- - if z.trb { - z.tr = z.tr[:len(z.tr)-1] - } -} - -func (z *bufioDecReader) readn(num uint8) (bs [rwNLen]byte) { - z.readb(bs[:num]) - // copy(bs[:], z.readx(uint(num))) - return -} - -func (z *bufioDecReader) readx(n uint) (bs []byte) { - if n == 0 { - // return - } else if z.c+n <= uint(len(z.buf)) { - bs = z.buf[z.c : z.c+n] - z.n += n - z.c += n - if z.trb { - z.tr = append(z.tr, bs...) - } - } else { - bs = make([]byte, n) - // n no longer used - can reuse - n = uint(copy(bs, z.buf[z.c:])) - z.n += n - z.c += n - z.readbFill(bs, n, true, false) - } - return -} - -// func (z *bufioDecReader) skip(accept *bitset256) (token byte) { -// i := z.c -// LOOP: -// if i < uint(len(z.buf)) { -// // inline z.skipLoopFn(i) and refactor, so cost is within inline budget -// token = z.buf[i] -// i++ -// if accept.isset(token) { -// goto LOOP -// } -// z.n += i - 2 - z.c -// if z.trb { -// z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) -// } -// z.c = i -// return -// } -// return z.skipFill(accept) -// } - -// func (z *bufioDecReader) skipFill(accept *bitset256) (token byte) { -// z.n += uint(len(z.buf)) - z.c -// if z.trb { -// z.tr = append(z.tr, z.buf[z.c:]...) -// } -// var i, n2 int -// var err error -// for { -// z.c = 0 -// z.buf = z.buf[0:cap(z.buf)] -// n2, err = z.r.Read(z.buf) -// if n2 == 0 && err != nil { -// panic(err) -// } -// z.buf = z.buf[:n2] -// for i, token = range z.buf { -// // if !accept.isset(token) { -// if accept.isnotset(token) { -// z.n += (uint(i) - z.c) - 1 -// z.loopFn(uint(i + 1)) -// return -// } -// } -// z.n += uint(n2) -// if z.trb { -// z.tr = append(z.tr, z.buf...) -// } -// } -// } - -func (z *bufioDecReader) skipWhitespace() (token byte) { - i := z.c -LOOP: - if i < uint(len(z.buf)) { - // inline z.skipLoopFn(i) and refactor, so cost is within inline budget - token = z.buf[i] - i++ - if isWhitespaceChar(token) { - goto LOOP - } - z.n += i - 2 - z.c - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i - return - } - return z.skipFillWhitespace() -} - -func (z *bufioDecReader) skipFillWhitespace() (token byte) { - z.n += uint(len(z.buf)) - z.c - if z.trb { - z.tr = append(z.tr, z.buf[z.c:]...) - } - var i, n2 int - var err error - for { - z.c = 0 - z.buf = z.buf[0:cap(z.buf)] - n2, err = z.r.Read(z.buf) - if n2 == 0 && err != nil { - panic(err) - } - z.buf = z.buf[:n2] - for i, token = range z.buf { - if !isWhitespaceChar(token) { - z.n += (uint(i) - z.c) - 1 - z.loopFn(uint(i + 1)) - return - } - } - z.n += uint(n2) - if z.trb { - z.tr = append(z.tr, z.buf...) - } - } -} - -func (z *bufioDecReader) loopFn(i uint) { - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i -} - -func (z *bufioDecReader) readTo(accept *bitset256) (out []byte) { - i := z.c -LOOP: - if i < uint(len(z.buf)) { - // if !accept.isset(z.buf[i]) { - if accept.isnotset(z.buf[i]) { - // inline readToLoopFn here (for performance) - z.n += (i - z.c) - 1 - out = z.buf[z.c:i] - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i - return - } - i++ - goto LOOP - } - return z.readToFill(accept) -} - -func (z *bufioDecReader) readToFill(accept *bitset256) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] - z.n += uint(len(z.buf)) - z.c - z.bufr = append(z.bufr, z.buf[z.c:]...) - if z.trb { - z.tr = append(z.tr, z.buf[z.c:]...) - } - var n2 int - var err error - for { - z.c = 0 - z.buf = z.buf[:cap(z.buf)] - n2, err = z.r.Read(z.buf) - if n2 == 0 && err != nil { - if err == io.EOF { - return z.bufr // readTo should read until it matches or end is reached - } - panic(err) - } - z.buf = z.buf[:n2] - for i, token := range z.buf { - // if !accept.isset(token) { - if accept.isnotset(token) { - z.n += (uint(i) - z.c) - 1 - z.bufr = append(z.bufr, z.buf[z.c:i]...) - z.loopFn(uint(i)) - return z.bufr - } - } - z.bufr = append(z.bufr, z.buf...) - z.n += uint(n2) - if z.trb { - z.tr = append(z.tr, z.buf...) - } - } -} - -func (z *bufioDecReader) readUntil(stop byte, includeLast bool) (out []byte) { - i := z.c -LOOP: - if i < uint(len(z.buf)) { - if z.buf[i] == stop { - z.n += (i - z.c) - 1 - i++ - out = z.buf[z.c:i] - if z.trb { - z.tr = append(z.tr, z.buf[z.c:i]...) // z.doTrack(i) - } - z.c = i - goto FINISH - } - i++ - goto LOOP - } - out = z.readUntilFill(stop) -FINISH: - if includeLast { - return - } - return out[:len(out)-1] -} - -func (z *bufioDecReader) readUntilFill(stop byte) []byte { - z.bufr = z.blist.check(z.bufr, 256)[:0] - z.n += uint(len(z.buf)) - z.c - z.bufr = append(z.bufr, z.buf[z.c:]...) - if z.trb { - z.tr = append(z.tr, z.buf[z.c:]...) - } - for { - z.c = 0 - z.buf = z.buf[0:cap(z.buf)] - n1, err := z.r.Read(z.buf) - if n1 == 0 && err != nil { - panic(err) - } - n2 := uint(n1) - z.buf = z.buf[:n2] - for i, token := range z.buf { - if token == stop { - z.n += (uint(i) - z.c) - 1 - z.bufr = append(z.bufr, z.buf[z.c:i+1]...) - z.loopFn(uint(i + 1)) - return z.bufr - } - } - z.bufr = append(z.bufr, z.buf...) - z.n += n2 - if z.trb { - z.tr = append(z.tr, z.buf...) - } - } -} - -// ------------------------------------ - -// bytesDecReader is a decReader that reads off a byte slice with zero copying -type bytesDecReader struct { - b []byte // data - c uint // cursor - t uint // track start - // a int // available -} - -func (z *bytesDecReader) reset(in []byte) { - z.b = in - z.c = 0 - z.t = 0 -} - -func (z *bytesDecReader) numread() uint { - return z.c -} - -func (z *bytesDecReader) last() byte { - return z.b[z.c-1] -} - -func (z *bytesDecReader) unreadn1() { - // if z.c == 0 || len(z.b) == 0 { - // panic(errBytesDecReaderCannotUnread) - // } - z.c-- -} - -func (z *bytesDecReader) readx(n uint) (bs []byte) { - // slicing from a non-constant start position is more expensive, - // as more computation is required to decipher the pointer start position. - // However, we do it only once, and it's better than reslicing both z.b and return value. - - z.c += n - return z.b[z.c-n : z.c] -} - -func (z *bytesDecReader) readb(bs []byte) { - copy(bs, z.readx(uint(len(bs)))) -} - -func (z *bytesDecReader) readn1() (v uint8) { - v = z.b[z.c] // cost 7 - z.c++ // cost 4 - return -} - -// func (z *bytesDecReader) readn1() uint8 { -// z.c++ -// return z.b[z.c-1] -// } - -// func (z *bytesDecReader) readn1() uint8 { -// v = z.b[z.c] // cost 7 -// c := z.c // cost 6 -// z.c++ // cost 4 -// z.c = z.c + 1 // cost 7 -// return z.b[z.c-1] -// } - -func (z *bytesDecReader) readn1eof() (v uint8, eof bool) { - if z.c >= uint(len(z.b)) { - eof = true - } else { - v = z.b[z.c] - z.c++ - } - return -} - -func (z *bytesDecReader) readn(num uint8) (bs [rwNLen]byte) { - // if z.c >= uint(len(z.b)) || z.c+uint(num) >= uint(len(z.b)) { - // panic(io.EOF) - // } - - // for bounds-check elimination, reslice z.b and ensure bs is within len - // bb := z.b[z.c:][:num] - bb := z.b[z.c : z.c+uint(num)] - _ = bs[len(bb)-1] - var i int -LOOP: - if i < len(bb) { - bs[i] = bb[i] - i++ - goto LOOP - } - - z.c += uint(num) - return -} - -// func (z *bytesDecReader) skip(accept *bitset256) (token byte) { -// i := z.c -// LOOP: -// // if i < uint(len(z.b)) { -// token = z.b[i] -// i++ -// if accept.isset(token) { -// goto LOOP -// } -// z.c = i -// return -// } - -func (z *bytesDecReader) skipWhitespace() (token byte) { - i := z.c -LOOP: - // if i < uint(len(z.b)) { - token = z.b[i] - i++ - if isWhitespaceChar(token) { - goto LOOP - } - z.c = i - return -} - -func (z *bytesDecReader) readNumberWithLastByte() (out []byte) { - z.c-- - i := z.c -LOOP: - if i < uint(len(z.b)) && isNumberChar(z.b[i]) { - i++ - goto LOOP - } - - out = z.b[z.c:i] - z.c = i - return // z.b[c:i] -} - -func (z *bytesDecReader) readTo(accept *bitset256) (out []byte) { - i := z.c -LOOP: - if i < uint(len(z.b)) && accept.isset(z.b[i]) { - i++ - goto LOOP - } - - out = z.b[z.c:i] - z.c = i - return // z.b[c:i] -} - -func (z *bytesDecReader) readUntil(stop byte, includeLast bool) (out []byte) { - i := z.c -LOOP: - // if i < uint(len(z.b)) { - if z.b[i] == stop { - i++ - if includeLast { - out = z.b[z.c:i] - } else { - out = z.b[z.c : i-1] - } - // z.a -= (i - z.c) - z.c = i - return - } - i++ - goto LOOP - // } - // panic(io.EOF) -} - -func (z *bytesDecReader) track() { - z.t = z.c -} - -func (z *bytesDecReader) stopTrack() (bs []byte) { - return z.b[z.t:z.c] -} - -// -------------- - -type decRd struct { - mtr bool // is maptype a known type? - str bool // is slicetype a known type? - - be bool // is binary encoding - js bool // is json handle - jsms bool // is json handle, and MapKeyAsString - cbor bool // is cbor handle - - bytes bool // is bytes reader - bufio bool // is this a bufioDecReader? - - rb bytesDecReader - ri *ioDecReader - bi *bufioDecReader -} - -// numread, track and stopTrack are always inlined, as they just check int fields, etc. - -// the if/else-if/else block is expensive to inline. -// Each node of this construct costs a lot and dominates the budget. -// Best to only do an if fast-path else block (so fast-path is inlined). -// This is irrespective of inlineExtraCallCost set in $GOROOT/src/cmd/compile/internal/gc/inl.go -// -// In decRd methods below, we delegate all IO functions into their own methods. -// This allows for the inlining of the common path when z.bytes=true. -// Go 1.12+ supports inlining methods with up to 1 inlined function (or 2 if no other constructs). -// -// However, up through Go 1.13, decRd's readXXX, skip and unreadXXX methods are not inlined. -// Consequently, there is no benefit to do the xxxIO methods for decRd at this time. -// Instead, we have a if/else-if/else block so that IO calls do not have to jump through -// a second unnecessary function call. -// -// If golang inlining gets better and bytesDecReader methods can be inlined, -// then we can revert to using these 2 functions so the bytesDecReader -// methods are inlined and the IO paths call out to a function. - -func (z *decRd) numread() uint { - if z.bytes { - return z.rb.numread() - } else if z.bufio { - return z.bi.numread() - } else { - return z.ri.numread() - } -} -func (z *decRd) stopTrack() []byte { - if z.bytes { - return z.rb.stopTrack() - } else if z.bufio { - return z.bi.stopTrack() - } else { - return z.ri.stopTrack() - } -} - -func (z *decRd) track() { - if z.bytes { - z.rb.track() - } else if z.bufio { - z.bi.track() - } else { - z.ri.track() - } -} - -// func (z *decRd) unreadn1() { -// if z.bytes { -// z.rb.unreadn1() -// } else if z.bufio { -// z.bi.unreadn1() -// } else { -// z.ri.unreadn1() -// } -// } - -func (z *decRd) unreadn1() { - if z.bytes { - z.rb.unreadn1() - } else { - z.unreadn1IO() - } -} -func (z *decRd) unreadn1IO() { - if z.bufio { - z.bi.unreadn1() - } else { - z.ri.unreadn1() - } -} - -func (z *decRd) readn(num uint8) [rwNLen]byte { - if z.bytes { - return z.rb.readn(num) - } else if z.bufio { - return z.bi.readn(num) - } else { - return z.ri.readn(num) - } -} - -func (z *decRd) readx(n uint) []byte { - if z.bytes { - return z.rb.readx(n) - } else if z.bufio { - return z.bi.readx(n) - } else { - return z.ri.readx(n) - } -} - -func (z *decRd) readb(s []byte) { - if z.bytes { - z.rb.readb(s) - } else if z.bufio { - z.bi.readb(s) - } else { - z.ri.readb(s) - } -} - -// func (z *decRd) readn1() uint8 { -// if z.bytes { -// return z.rb.readn1() -// } else if z.bufio { -// return z.bi.readn1() -// } else { -// return z.ri.readn1() -// } -// } - -func (z *decRd) readn1() uint8 { - if z.bytes { - // unfortunately, calling the function prevents inlining it here. - // explicitly writing it here will allow it inline. - // NOTE: Keep in sync with function implementation. - // - // return z.rb.readn1() - z.rb.c++ - return z.rb.b[z.rb.c-1] - } - return z.readn1IO() -} -func (z *decRd) readn1IO() uint8 { - if z.bufio { - return z.bi.readn1() - } - return z.ri.readn1() -} - -func (z *decRd) readn1eof() (uint8, bool) { - if z.bytes { - return z.rb.readn1eof() - } else if z.bufio { - return z.bi.readn1eof() - } else { - return z.ri.readn1eof() - } -} - -func (z *decRd) skipWhitespace() (token byte) { - if z.bytes { - return z.rb.skipWhitespace() - } else if z.bufio { - return z.bi.skipWhitespace() - } else { - return z.ri.skipWhitespace() - } -} - -// func (z *decRd) skip(accept *bitset256) (token byte) { -// if z.bytes { -// return z.rb.skip(accept) -// } else if z.bufio { -// return z.bi.skip(accept) -// } else { -// return z.ri.skip(accept) -// } -// } - -func (z *decRd) readTo(accept *bitset256) (out []byte) { - if z.bytes { - return z.rb.readTo(accept) - } else if z.bufio { - return z.bi.readTo(accept) - } else { - return z.ri.readTo(accept) - } -} - -func (z *decRd) readUntil(stop byte, includeLast bool) (out []byte) { - if z.bytes { - return z.rb.readUntil(stop, includeLast) - } else if z.bufio { - return z.bi.readUntil(stop, includeLast) - } else { - return z.ri.readUntil(stop, includeLast) - } -} - -func (z *decRd) readNumberWithLastByte() []byte { - if z.bytes { - return z.rb.readNumberWithLastByte() - } - z.unreadn1() - return z.readTo(&numCharBitset) -} - -/* -func (z *decRd) track() { - if z.bytes { - z.rb.track() - } else { - z.trackIO() - } -} -func (z *decRd) trackIO() { - if z.bufio { - z.bi.track() - } else { - z.ri.track() - } -} - -func (z *decRd) unreadn1() { - if z.bytes { - z.rb.unreadn1() - } else { - z.unreadn1IO() - } -} -func (z *decRd) unreadn1IO() { - if z.bufio { - z.bi.unreadn1() - } else { - z.ri.unreadn1() - } -} - -func (z *decRd) readn(num uint8) [rwNLen]byte { - if z.bytes { - return z.rb.readn(num) - } - return z.readnIO(num) -} -func (z *decRd) readnIO(num uint8) [rwNLen]byte { - if z.bufio { - return z.bi.readn(num) - } - return z.ri.readn(num) -} - -func (z *decRd) readx(n uint) []byte { - if z.bytes { - return z.rb.readx(n) - } - return z.readxIO(n) -} -func (z *decRd) readxIO(n uint) []byte { - if z.bufio { - return z.bi.readx(n) - } - return z.ri.readx(n) -} - -func (z *decRd) readb(s []byte) { - if z.bytes { - z.rb.readb(s) - } else { - z.readbIO(s) - } -} -func (z *decRd) readbIO(s []byte) { - if z.bufio { - z.bi.readb(s) - } else { - z.ri.readb(s) - } -} - -func (z *decRd) readn1() uint8 { - if z.bytes { - return z.rb.readn1() - } - return z.readn1IO() -} -func (z *decRd) readn1IO() uint8 { - if z.bufio { - return z.bi.readn1() - } - return z.ri.readn1() -} - -func (z *decRd) readn1eof() (uint8, bool) { - if z.bytes { - return z.rb.readn1eof() - } - return z.readn1eofIO() -} -func (z *decRd) readn1eofIO() (uint8, bool) { - if z.bufio { - return z.bi.readn1eof() - } - return z.ri.readn1eof() -} - -func (z *decRd) skip(accept *bitset256) (token byte) { - if z.bytes { - return z.rb.skip(accept) - } - return z.skipIO(accept) -} -func (z *decRd) skipIO(accept *bitset256) (token byte) { - if z.bufio { - return z.bi.skip(accept) - } - return z.ri.skip(accept) -} - -func (z *decRd) readTo(accept *bitset256) (out []byte) { - if z.bytes { - return z.rb.readTo(accept) - } - return z.readToIO(accept) -} -func (z *decRd) readToIO(accept *bitset256) (out []byte) { - if z.bufio { - return z.bi.readTo(accept) - } - return z.ri.readTo(accept) -} - -func (z *decRd) readUntil(stop byte, includeLast bool) (out []byte) { - if z.bytes { - return z.rb.readUntil(stop, includeLast) - } - return z.readUntilIO(stop, includeLast) -} -func (z *decRd) readUntilIO(stop byte, includeLast bool) (out []byte) { - if z.bufio { - return z.bi.readUntil(stop, includeLast) - } - return z.ri.readUntil(stop, includeLast) -} -*/ - -var _ decReader = (*decRd)(nil) diff --git a/vendor/github.com/ugorji/go/codec/register_ext.go b/vendor/github.com/ugorji/go/codec/register_ext.go deleted file mode 100644 index 68b002cc8..000000000 --- a/vendor/github.com/ugorji/go/codec/register_ext.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import "reflect" - -// This file exists, so that the files for specific formats do not all import reflect. -// This just helps us ensure that reflect package is isolated to a few files. - -// SetInterfaceExt sets an extension -func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetInterfaceExt sets an extension -func (h *CborHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetBytesExt sets an extension -func (h *MsgpackHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetBytesExt sets an extension -func (h *SimpleHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// SetBytesExt sets an extension -func (h *BincHandle) SetBytesExt(rt reflect.Type, tag uint64, ext BytesExt) (err error) { - return h.SetExt(rt, tag, makeExt(ext)) -} - -// func (h *XMLHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) { -// return h.SetExt(rt, tag, &interfaceExtWrapper{InterfaceExt: ext}) -// } diff --git a/vendor/github.com/ugorji/go/codec/rpc.go b/vendor/github.com/ugorji/go/codec/rpc.go deleted file mode 100644 index eae6d5546..000000000 --- a/vendor/github.com/ugorji/go/codec/rpc.go +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "bufio" - "errors" - "io" - "net/rpc" -) - -var errRpcJsonNeedsTermWhitespace = errors.New("rpc requires JsonHandle with TermWhitespace=true") - -// Rpc provides a rpc Server or Client Codec for rpc communication. -type Rpc interface { - ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec - ClientCodec(conn io.ReadWriteCloser, h Handle) rpc.ClientCodec -} - -// RPCOptions holds options specific to rpc functionality -type RPCOptions struct { - // RPCNoBuffer configures whether we attempt to buffer reads and writes during RPC calls. - // - // Set RPCNoBuffer=true to turn buffering off. - // Buffering can still be done if buffered connections are passed in, or - // buffering is configured on the handle. - RPCNoBuffer bool -} - -// rpcCodec defines the struct members and common methods. -type rpcCodec struct { - c io.Closer - r io.Reader - w io.Writer - f ioFlusher - - dec *Decoder - enc *Encoder - // bw *bufio.Writer - // br *bufio.Reader - h Handle - - cls atomicClsErr -} - -func newRPCCodec(conn io.ReadWriteCloser, h Handle) rpcCodec { - // return newRPCCodec2(bufio.NewReader(conn), bufio.NewWriter(conn), conn, h) - return newRPCCodec2(conn, conn, conn, h) -} - -func newRPCCodec2(r io.Reader, w io.Writer, c io.Closer, h Handle) rpcCodec { - // defensive: ensure that jsonH has TermWhitespace turned on. - if jsonH, ok := h.(*JsonHandle); ok && !jsonH.TermWhitespace { - panic(errRpcJsonNeedsTermWhitespace) - } - // always ensure that we use a flusher, and always flush what was written to the connection. - // we lose nothing by using a buffered writer internally. - f, ok := w.(ioFlusher) - bh := basicHandle(h) - if !bh.RPCNoBuffer { - if bh.WriterBufferSize <= 0 { - if !ok { - bw := bufio.NewWriter(w) - f, w = bw, bw - } - } - if bh.ReaderBufferSize <= 0 { - if _, ok = w.(ioPeeker); !ok { - if _, ok = w.(ioBuffered); !ok { - r = bufio.NewReader(r) - } - } - } - } - return rpcCodec{ - c: c, - w: w, - r: r, - f: f, - h: h, - enc: NewEncoder(w, h), - dec: NewDecoder(r, h), - } -} - -func (c *rpcCodec) write(obj1, obj2 interface{}, writeObj2 bool) (err error) { - if c.c != nil { - cls := c.cls.load() - if cls.closed { - return cls.errClosed - } - } - err = c.enc.Encode(obj1) - if err == nil { - if writeObj2 { - err = c.enc.Encode(obj2) - } - } - if c.f != nil { - if err == nil { - err = c.f.Flush() - } else { - _ = c.f.Flush() // swallow flush error, so we maintain prior error on write - } - } - return -} - -func (c *rpcCodec) read(obj interface{}) (err error) { - if c.c != nil { - cls := c.cls.load() - if cls.closed { - return cls.errClosed - } - } - //If nil is passed in, we should read and discard - if obj == nil { - // var obj2 interface{} - // return c.dec.Decode(&obj2) - defer panicToErr(c.dec, &err) - c.dec.swallow() - return - } - return c.dec.Decode(obj) -} - -func (c *rpcCodec) Close() error { - if c.c == nil { - return nil - } - cls := c.cls.load() - if cls.closed { - return cls.errClosed - } - cls.errClosed = c.c.Close() - cls.closed = true - c.cls.store(cls) - return cls.errClosed -} - -func (c *rpcCodec) ReadResponseBody(body interface{}) error { - return c.read(body) -} - -// ------------------------------------- - -type goRpcCodec struct { - rpcCodec -} - -func (c *goRpcCodec) WriteRequest(r *rpc.Request, body interface{}) error { - return c.write(r, body, true) -} - -func (c *goRpcCodec) WriteResponse(r *rpc.Response, body interface{}) error { - return c.write(r, body, true) -} - -func (c *goRpcCodec) ReadResponseHeader(r *rpc.Response) error { - return c.read(r) -} - -func (c *goRpcCodec) ReadRequestHeader(r *rpc.Request) error { - return c.read(r) -} - -func (c *goRpcCodec) ReadRequestBody(body interface{}) error { - return c.read(body) -} - -// ------------------------------------- - -// goRpc is the implementation of Rpc that uses the communication protocol -// as defined in net/rpc package. -type goRpc struct{} - -// GoRpc implements Rpc using the communication protocol defined in net/rpc package. -// -// Note: network connection (from net.Dial, of type io.ReadWriteCloser) is not buffered. -// -// For performance, you should configure WriterBufferSize and ReaderBufferSize on the handle. -// This ensures we use an adequate buffer during reading and writing. -// If not configured, we will internally initialize and use a buffer during reads and writes. -// This can be turned off via the RPCNoBuffer option on the Handle. -// var handle codec.JsonHandle -// handle.RPCNoBuffer = true // turns off attempt by rpc module to initialize a buffer -// -// Example 1: one way of configuring buffering explicitly: -// var handle codec.JsonHandle // codec handle -// handle.ReaderBufferSize = 1024 -// handle.WriterBufferSize = 1024 -// var conn io.ReadWriteCloser // connection got from a socket -// var serverCodec = GoRpc.ServerCodec(conn, handle) -// var clientCodec = GoRpc.ClientCodec(conn, handle) -// -// Example 2: you can also explicitly create a buffered connection yourself, -// and not worry about configuring the buffer sizes in the Handle. -// var handle codec.Handle // codec handle -// var conn io.ReadWriteCloser // connection got from a socket -// var bufconn = struct { // bufconn here is a buffered io.ReadWriteCloser -// io.Closer -// *bufio.Reader -// *bufio.Writer -// }{conn, bufio.NewReader(conn), bufio.NewWriter(conn)} -// var serverCodec = GoRpc.ServerCodec(bufconn, handle) -// var clientCodec = GoRpc.ClientCodec(bufconn, handle) -// -var GoRpc goRpc - -func (x goRpc) ServerCodec(conn io.ReadWriteCloser, h Handle) rpc.ServerCodec { - return &goRpcCodec{newRPCCodec(conn, h)} -} - -func (x goRpc) ClientCodec(conn io.ReadWriteCloser, h Handle) rpc.ClientCodec { - return &goRpcCodec{newRPCCodec(conn, h)} -} diff --git a/vendor/github.com/ugorji/go/codec/shared_test.go b/vendor/github.com/ugorji/go/codec/shared_test.go deleted file mode 100644 index ac8c82d69..000000000 --- a/vendor/github.com/ugorji/go/codec/shared_test.go +++ /dev/null @@ -1,349 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// This file sets up the variables used, including testInitFns. -// Each file should add initialization that should be performed -// after flags are parsed. -// -// init is a multi-step process: -// - setup vars (handled by init functions in each file) -// - parse flags -// - setup derived vars (handled by pre-init registered functions - registered in init function) -// - post init (handled by post-init registered functions - registered in init function) -// This way, no one has to manage carefully control the initialization -// using file names, etc. -// -// Tests which require external dependencies need the -tag=x parameter. -// They should be run as: -// go test -tags=x -run=. -// Benchmarks should also take this parameter, to include the sereal, xdr, etc. -// To run against codecgen, etc, make sure you pass extra parameters. -// Example usage: -// go test "-tags=x codecgen" -bench=. -// -// To fully test everything: -// go test -tags=x -benchtime=100ms -tv -bg -bi -brw -bu -v -run=. -bench=. - -// Handling flags -// codec_test.go will define a set of global flags for testing, including: -// - Use Reset -// - Use IO reader/writer (vs direct bytes) -// - Set Canonical -// - Set InternStrings -// - Use Symbols -// -// This way, we can test them all by running same set of tests with a different -// set of flags. -// -// Following this, all the benchmarks will utilize flags set by codec_test.go -// and will not redefine these "global" flags. - -import ( - "bytes" - "flag" - "io" - "io/ioutil" - "log" - "sync" -) - -// __DO_NOT_REMOVE__NEEDED_FOR_REPLACING__IMPORT_PATH__FOR_CODEC_BENCH__ - -type testHED struct { - H Handle - E *Encoder - D *Decoder -} - -type ioReaderWrapper struct { - r io.Reader -} - -func (x ioReaderWrapper) Read(p []byte) (n int, err error) { - return x.r.Read(p) -} - -type ioWriterWrapper struct { - w io.Writer -} - -func (x ioWriterWrapper) Write(p []byte) (n int, err error) { - return x.w.Write(p) -} - -var ( - // testNoopH = NoopHandle(8) - testMsgpackH = &MsgpackHandle{} - testBincH = &BincHandle{} - testSimpleH = &SimpleHandle{} - testCborH = &CborHandle{} - testJsonH = &JsonHandle{} - - testHandles []Handle - testPreInitFns []func() - testPostInitFns []func() - - testOnce sync.Once - - testHEDs []testHED -) - -// flag variables used by tests (and bench) -var ( - testVerbose bool - - //depth of 0 maps to ~400bytes json-encoded string, 1 maps to ~1400 bytes, etc - //For depth>1, we likely trigger stack growth for encoders, making benchmarking unreliable. - testDepth int - - testMaxInitLen int - - testInitDebug bool - testUseReset bool - testSkipIntf bool - testUseMust bool - - testUseIoEncDec int - testUseIoWrapper bool - - testNumRepeatString int - - testRpcBufsize int - testMapStringKeyOnly bool -) - -// variables that are not flags, but which can configure the handles -var ( - testEncodeOptions EncodeOptions - testDecodeOptions DecodeOptions -) - -func init() { - log.SetOutput(ioutil.Discard) // don't allow things log to standard out/err - testHEDs = make([]testHED, 0, 32) - testHandles = append(testHandles, - // testNoopH, - testMsgpackH, testBincH, testSimpleH, testCborH, testJsonH) - // JSON should do HTMLCharsAsIs by default - testJsonH.HTMLCharsAsIs = true - // set ExplicitRelease on each handle - testMsgpackH.ExplicitRelease = true - testBincH.ExplicitRelease = true - testSimpleH.ExplicitRelease = true - testCborH.ExplicitRelease = true - testJsonH.ExplicitRelease = true - - testInitFlags() - benchInitFlags() -} - -func testInitFlags() { - // delete(testDecOpts.ExtFuncs, timeTyp) - flag.BoolVar(&testVerbose, "tv", false, "Text Extra Verbose Logging if -v if set") - flag.BoolVar(&testInitDebug, "tg", false, "Test Init Debug") - flag.IntVar(&testUseIoEncDec, "ti", -1, "Use IO Reader/Writer for Marshal/Unmarshal ie >= 0") - flag.BoolVar(&testUseIoWrapper, "tiw", false, "Wrap the IO Reader/Writer with a base pass-through reader/writer") - - flag.BoolVar(&testSkipIntf, "tf", false, "Skip Interfaces") - flag.BoolVar(&testUseReset, "tr", false, "Use Reset") - flag.IntVar(&testNumRepeatString, "trs", 8, "Create string variables by repeating a string N times") - flag.BoolVar(&testUseMust, "tm", true, "Use Must(En|De)code") - - flag.IntVar(&testMaxInitLen, "tx", 0, "Max Init Len") - - flag.IntVar(&testDepth, "tsd", 0, "Test Struc Depth") - flag.BoolVar(&testMapStringKeyOnly, "tsk", false, "use maps with string keys only") -} - -func benchInitFlags() { - // flags reproduced here for compatibility (duplicate some in testInitFlags) - flag.BoolVar(&testMapStringKeyOnly, "bs", false, "use maps with string keys only") - flag.IntVar(&testDepth, "bd", 1, "Bench Depth") -} - -func testHEDGet(h Handle) *testHED { - for i := range testHEDs { - v := &testHEDs[i] - if v.H == h { - return v - } - } - testHEDs = append(testHEDs, testHED{h, NewEncoder(nil, h), NewDecoder(nil, h)}) - return &testHEDs[len(testHEDs)-1] -} - -func testReinit() { - testOnce = sync.Once{} - testHEDs = nil -} - -func testInitAll() { - // only parse it once. - if !flag.Parsed() { - flag.Parse() - } - for _, f := range testPreInitFns { - f() - } - for _, f := range testPostInitFns { - f() - } -} - -func sTestCodecEncode(ts interface{}, bsIn []byte, fn func([]byte) *bytes.Buffer, - h Handle, bh *BasicHandle) (bs []byte, err error) { - // bs = make([]byte, 0, approxSize) - var e *Encoder - var buf *bytes.Buffer - if testUseReset { - e = testHEDGet(h).E - } else { - e = NewEncoder(nil, h) - } - var oldWriteBufferSize int - if testUseIoEncDec >= 0 { - buf = fn(bsIn) - // set the encode options for using a buffer - oldWriteBufferSize = bh.WriterBufferSize - bh.WriterBufferSize = testUseIoEncDec - if testUseIoWrapper { - e.Reset(ioWriterWrapper{buf}) - } else { - e.Reset(buf) - } - } else { - bs = bsIn - e.ResetBytes(&bs) - } - if testUseMust { - e.MustEncode(ts) - } else { - err = e.Encode(ts) - } - if testUseIoEncDec >= 0 { - bs = buf.Bytes() - bh.WriterBufferSize = oldWriteBufferSize - } - if !testUseReset { - e.Release() - } - return -} - -func sTestCodecDecode(bs []byte, ts interface{}, h Handle, bh *BasicHandle) (err error) { - var d *Decoder - // var buf *bytes.Reader - if testUseReset { - d = testHEDGet(h).D - } else { - d = NewDecoder(nil, h) - } - var oldReadBufferSize int - if testUseIoEncDec >= 0 { - buf := bytes.NewReader(bs) - oldReadBufferSize = bh.ReaderBufferSize - bh.ReaderBufferSize = testUseIoEncDec - if testUseIoWrapper { - d.Reset(ioReaderWrapper{buf}) - } else { - d.Reset(buf) - } - } else { - d.ResetBytes(bs) - } - if testUseMust { - d.MustDecode(ts) - } else { - err = d.Decode(ts) - } - if testUseIoEncDec >= 0 { - bh.ReaderBufferSize = oldReadBufferSize - } - if !testUseReset { - d.Release() - } - return -} - -// // --- functions below are used by both benchmarks and tests - -// // log message only when testVerbose = true (ie go test ... -- -tv). -// // -// // These are for intormational messages that do not necessarily -// // help with diagnosing a failure, or which are too large. -// func logTv(x interface{}, format string, args ...interface{}) { -// if !testVerbose { -// return -// } -// if t, ok := x.(testing.TB); ok { // only available from go 1.9 -// t.Helper() -// } -// logT(x, format, args...) -// } - -// // logT logs messages when running as go test -v -// // -// // Use it for diagnostics messages that help diagnost failure, -// // and when the output is not too long ie shorter than like 100 characters. -// // -// // In general, any logT followed by failT should call this. -// func logT(x interface{}, format string, args ...interface{}) { -// if x == nil { -// if len(format) == 0 || format[len(format)-1] != '\n' { -// format = format + "\n" -// } -// fmt.Printf(format, args...) -// return -// } -// if t, ok := x.(testing.TB); ok { // only available from go 1.9 -// t.Helper() -// t.Logf(format, args...) -// } -// } - -// func failTv(x testing.TB, args ...interface{}) { -// x.Helper() -// if testVerbose { -// failTMsg(x, args...) -// } -// x.FailNow() -// } - -// func failT(x testing.TB, args ...interface{}) { -// x.Helper() -// failTMsg(x, args...) -// x.FailNow() -// } - -// func failTMsg(x testing.TB, args ...interface{}) { -// x.Helper() -// if len(args) > 0 { -// if format, ok := args[0].(string); ok { -// logT(x, format, args[1:]...) -// } else if len(args) == 1 { -// logT(x, "%v", args[0]) -// } else { -// logT(x, "%v", args) -// } -// } -// } - -// --- functions below are used only by benchmarks alone - -func fnBenchmarkByteBuf(bsIn []byte) (buf *bytes.Buffer) { - // var buf bytes.Buffer - // buf.Grow(approxSize) - buf = bytes.NewBuffer(bsIn) - buf.Truncate(0) - return -} - -// func benchFnCodecEncode(ts interface{}, bsIn []byte, h Handle) (bs []byte, err error) { -// return testCodecEncode(ts, bsIn, fnBenchmarkByteBuf, h) -// } - -// func benchFnCodecDecode(bs []byte, ts interface{}, h Handle) (err error) { -// return testCodecDecode(bs, ts, h) -// } diff --git a/vendor/github.com/ugorji/go/codec/simple.go b/vendor/github.com/ugorji/go/codec/simple.go deleted file mode 100644 index 4d1b7990c..000000000 --- a/vendor/github.com/ugorji/go/codec/simple.go +++ /dev/null @@ -1,646 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "math" - "time" -) - -const ( - _ uint8 = iota - simpleVdNil = 1 - simpleVdFalse = 2 - simpleVdTrue = 3 - simpleVdFloat32 = 4 - simpleVdFloat64 = 5 - - // each lasts for 4 (ie n, n+1, n+2, n+3) - simpleVdPosInt = 8 - simpleVdNegInt = 12 - - simpleVdTime = 24 - - // containers: each lasts for 4 (ie n, n+1, n+2, ... n+7) - simpleVdString = 216 - simpleVdByteArray = 224 - simpleVdArray = 232 - simpleVdMap = 240 - simpleVdExt = 248 -) - -type simpleEncDriver struct { - noBuiltInTypes - encDriverNoopContainerWriter - h *SimpleHandle - b [8]byte - _ [6]uint64 // padding (cache-aligned) - e Encoder -} - -func (e *simpleEncDriver) encoder() *Encoder { - return &e.e -} - -func (e *simpleEncDriver) EncodeNil() { - e.e.encWr.writen1(simpleVdNil) -} - -func (e *simpleEncDriver) EncodeBool(b bool) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && !b { - e.EncodeNil() - return - } - if b { - e.e.encWr.writen1(simpleVdTrue) - } else { - e.e.encWr.writen1(simpleVdFalse) - } -} - -func (e *simpleEncDriver) EncodeFloat32(f float32) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && f == 0.0 { - e.EncodeNil() - return - } - e.e.encWr.writen1(simpleVdFloat32) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(math.Float32bits(f)) -} - -func (e *simpleEncDriver) EncodeFloat64(f float64) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && f == 0.0 { - e.EncodeNil() - return - } - e.e.encWr.writen1(simpleVdFloat64) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(math.Float64bits(f)) -} - -func (e *simpleEncDriver) EncodeInt(v int64) { - if v < 0 { - e.encUint(uint64(-v), simpleVdNegInt) - } else { - e.encUint(uint64(v), simpleVdPosInt) - } -} - -func (e *simpleEncDriver) EncodeUint(v uint64) { - e.encUint(v, simpleVdPosInt) -} - -func (e *simpleEncDriver) encUint(v uint64, bd uint8) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && v == 0 { - e.EncodeNil() - return - } - if v <= math.MaxUint8 { - e.e.encWr.writen2(bd, uint8(v)) - } else if v <= math.MaxUint16 { - e.e.encWr.writen1(bd + 1) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(v)) - } else if v <= math.MaxUint32 { - e.e.encWr.writen1(bd + 2) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(v)) - } else { // if v <= math.MaxUint64 { - e.e.encWr.writen1(bd + 3) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(v) - } -} - -func (e *simpleEncDriver) encLen(bd byte, length int) { - if length == 0 { - e.e.encWr.writen1(bd) - } else if length <= math.MaxUint8 { - e.e.encWr.writen1(bd + 1) - e.e.encWr.writen1(uint8(length)) - } else if length <= math.MaxUint16 { - e.e.encWr.writen1(bd + 2) - bigenHelper{e.b[:2], e.e.w()}.writeUint16(uint16(length)) - } else if int64(length) <= math.MaxUint32 { - e.e.encWr.writen1(bd + 3) - bigenHelper{e.b[:4], e.e.w()}.writeUint32(uint32(length)) - } else { - e.e.encWr.writen1(bd + 4) - bigenHelper{e.b[:8], e.e.w()}.writeUint64(uint64(length)) - } -} - -func (e *simpleEncDriver) EncodeExt(v interface{}, xtag uint64, ext Ext) { - var bs []byte - if ext == SelfExt { - bs = e.e.blist.get(1024)[:0] - e.e.sideEncode(v, &bs) - } else { - bs = ext.WriteExt(v) - } - if bs == nil { - e.EncodeNil() - return - } - e.encodeExtPreamble(uint8(xtag), len(bs)) - e.e.encWr.writeb(bs) - if ext == SelfExt { - e.e.blist.put(bs) - } -} - -func (e *simpleEncDriver) EncodeRawExt(re *RawExt) { - e.encodeExtPreamble(uint8(re.Tag), len(re.Data)) - e.e.encWr.writeb(re.Data) -} - -func (e *simpleEncDriver) encodeExtPreamble(xtag byte, length int) { - e.encLen(simpleVdExt, length) - e.e.encWr.writen1(xtag) -} - -func (e *simpleEncDriver) WriteArrayStart(length int) { - e.encLen(simpleVdArray, length) -} - -func (e *simpleEncDriver) WriteMapStart(length int) { - e.encLen(simpleVdMap, length) -} - -func (e *simpleEncDriver) EncodeString(v string) { - if e.h.EncZeroValuesAsNil && e.e.c != containerMapKey && v == "" { - e.EncodeNil() - return - } - if e.h.StringToRaw { - e.encLen(simpleVdByteArray, len(v)) - } else { - e.encLen(simpleVdString, len(v)) - } - e.e.encWr.writestr(v) -} - -func (e *simpleEncDriver) EncodeStringBytesRaw(v []byte) { - // if e.h.EncZeroValuesAsNil && e.c != containerMapKey && v == nil { - if v == nil { - e.EncodeNil() - return - } - e.encLen(simpleVdByteArray, len(v)) - e.e.encWr.writeb(v) -} - -func (e *simpleEncDriver) EncodeTime(t time.Time) { - // if e.h.EncZeroValuesAsNil && e.c != containerMapKey && t.IsZero() { - if t.IsZero() { - e.EncodeNil() - return - } - v, err := t.MarshalBinary() - if err != nil { - e.e.errorv(err) - return - } - // time.Time marshalbinary takes about 14 bytes. - e.e.encWr.writen2(simpleVdTime, uint8(len(v))) - e.e.encWr.writeb(v) -} - -//------------------------------------ - -type simpleDecDriver struct { - h *SimpleHandle - bdRead bool - bd byte - fnil bool - noBuiltInTypes - decDriverNoopContainerReader - _ [6]uint64 // padding - d Decoder -} - -func (d *simpleDecDriver) decoder() *Decoder { - return &d.d -} - -func (d *simpleDecDriver) readNextBd() { - d.bd = d.d.decRd.readn1() - d.bdRead = true -} - -// func (d *simpleDecDriver) uncacheRead() { -// if d.bdRead { -// d.d.decRd.unreadn1() -// d.bdRead = false -// } -// } - -func (d *simpleDecDriver) advanceNil() (null bool) { - d.fnil = false - if !d.bdRead { - d.readNextBd() - } - if d.bd == simpleVdNil { - d.bdRead = false - d.fnil = true - null = true - } - return -} - -// func (d *simpleDecDriver) Nil() bool { -// return d.fnil -// } - -func (d *simpleDecDriver) ContainerType() (vt valueType) { - if !d.bdRead { - d.readNextBd() - } - d.fnil = false - switch d.bd { - case simpleVdNil: - d.bdRead = false - d.fnil = true - return valueTypeNil - case simpleVdByteArray, simpleVdByteArray + 1, - simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: - return valueTypeBytes - case simpleVdString, simpleVdString + 1, - simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: - return valueTypeString - case simpleVdArray, simpleVdArray + 1, - simpleVdArray + 2, simpleVdArray + 3, simpleVdArray + 4: - return valueTypeArray - case simpleVdMap, simpleVdMap + 1, - simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4: - return valueTypeMap - } - return valueTypeUnset -} - -func (d *simpleDecDriver) TryNil() bool { - return d.advanceNil() -} - -func (d *simpleDecDriver) decCheckInteger() (ui uint64, neg bool) { - switch d.bd { - case simpleVdPosInt: - ui = uint64(d.d.decRd.readn1()) - case simpleVdPosInt + 1: - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) - case simpleVdPosInt + 2: - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) - case simpleVdPosInt + 3: - ui = uint64(bigen.Uint64(d.d.decRd.readx(8))) - case simpleVdNegInt: - ui = uint64(d.d.decRd.readn1()) - neg = true - case simpleVdNegInt + 1: - ui = uint64(bigen.Uint16(d.d.decRd.readx(2))) - neg = true - case simpleVdNegInt + 2: - ui = uint64(bigen.Uint32(d.d.decRd.readx(4))) - neg = true - case simpleVdNegInt + 3: - ui = uint64(bigen.Uint64(d.d.decRd.readx(8))) - neg = true - default: - d.d.errorf("integer only valid from pos/neg integer1..8. Invalid descriptor: %v", d.bd) - return - } - // DO NOT do this check below, because callers may only want the unsigned value: - // - // if ui > math.MaxInt64 { - // d.d.errorf("decIntAny: Integer out of range for signed int64: %v", ui) - // return - // } - return -} - -func (d *simpleDecDriver) DecodeInt64() (i int64) { - if d.advanceNil() { - return - } - ui, neg := d.decCheckInteger() - i = chkOvf.SignedIntV(ui) - if neg { - i = -i - } - d.bdRead = false - return -} - -func (d *simpleDecDriver) DecodeUint64() (ui uint64) { - if d.advanceNil() { - return - } - ui, neg := d.decCheckInteger() - if neg { - d.d.errorf("assigning negative signed value to unsigned type") - return - } - d.bdRead = false - return -} - -func (d *simpleDecDriver) DecodeFloat64() (f float64) { - if d.advanceNil() { - return - } - if d.bd == simpleVdFloat32 { - f = float64(math.Float32frombits(bigen.Uint32(d.d.decRd.readx(4)))) - } else if d.bd == simpleVdFloat64 { - f = math.Float64frombits(bigen.Uint64(d.d.decRd.readx(8))) - } else { - if d.bd >= simpleVdPosInt && d.bd <= simpleVdNegInt+3 { - f = float64(d.DecodeInt64()) - } else { - d.d.errorf("float only valid from float32/64: Invalid descriptor: %v", d.bd) - return - } - } - d.bdRead = false - return -} - -// bool can be decoded from bool only (single byte). -func (d *simpleDecDriver) DecodeBool() (b bool) { - if d.advanceNil() { - return - } - if d.bd == simpleVdFalse { - } else if d.bd == simpleVdTrue { - b = true - } else { - d.d.errorf("cannot decode bool - %s: %x", msgBadDesc, d.bd) - return - } - d.bdRead = false - return -} - -func (d *simpleDecDriver) ReadMapStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - d.bdRead = false - return d.decLen() -} - -func (d *simpleDecDriver) ReadArrayStart() (length int) { - if d.advanceNil() { - return decContainerLenNil - } - d.bdRead = false - return d.decLen() -} - -func (d *simpleDecDriver) decLen() int { - switch d.bd % 8 { - case 0: - return 0 - case 1: - return int(d.d.decRd.readn1()) - case 2: - return int(bigen.Uint16(d.d.decRd.readx(2))) - case 3: - ui := uint64(bigen.Uint32(d.d.decRd.readx(4))) - if chkOvf.Uint(ui, intBitsize) { - d.d.errorf("overflow integer: %v", ui) - return 0 - } - return int(ui) - case 4: - ui := bigen.Uint64(d.d.decRd.readx(8)) - if chkOvf.Uint(ui, intBitsize) { - d.d.errorf("overflow integer: %v", ui) - return 0 - } - return int(ui) - } - d.d.errorf("cannot read length: bd%%8 must be in range 0..4. Got: %d", d.bd%8) - return -1 -} - -func (d *simpleDecDriver) DecodeStringAsBytes() (s []byte) { - return d.DecodeBytes(d.d.b[:], true) -} - -func (d *simpleDecDriver) DecodeBytes(bs []byte, zerocopy bool) (bsOut []byte) { - if d.advanceNil() { - return - } - // check if an "array" of uint8's (see ContainerType for how to infer if an array) - if d.bd >= simpleVdArray && d.bd <= simpleVdMap+4 { - if len(bs) == 0 && zerocopy { - bs = d.d.b[:] - } - // bsOut, _ = fastpathTV.DecSliceUint8V(bs, true, d.d) - slen := d.ReadArrayStart() - bs = usableByteSlice(bs, slen) - for i := 0; i < len(bs); i++ { - bs[i] = uint8(chkOvf.UintV(d.DecodeUint64(), 8)) - } - return bs - } - - clen := d.decLen() - d.bdRead = false - if d.d.bytes && (zerocopy || d.h.ZeroCopy) { - return d.d.decRd.rb.readx(uint(clen)) - } - if zerocopy && len(bs) == 0 { - bs = d.d.b[:] - } - return decByteSlice(d.d.r(), clen, d.d.h.MaxInitLen, bs) -} - -func (d *simpleDecDriver) DecodeTime() (t time.Time) { - if d.advanceNil() { - return - } - if d.bd != simpleVdTime { - d.d.errorf("invalid descriptor for time.Time - expect 0x%x, received 0x%x", simpleVdTime, d.bd) - return - } - d.bdRead = false - clen := int(d.d.decRd.readn1()) - b := d.d.decRd.readx(uint(clen)) - if err := (&t).UnmarshalBinary(b); err != nil { - d.d.errorv(err) - } - return -} - -func (d *simpleDecDriver) DecodeExt(rv interface{}, xtag uint64, ext Ext) { - if xtag > 0xff { - d.d.errorf("ext: tag must be <= 0xff; got: %v", xtag) - return - } - if d.advanceNil() { - return - } - realxtag1, xbs := d.decodeExtV(ext != nil, uint8(xtag)) - realxtag := uint64(realxtag1) - if ext == nil { - re := rv.(*RawExt) - re.Tag = realxtag - re.Data = detachZeroCopyBytes(d.d.bytes, re.Data, xbs) - } else if ext == SelfExt { - d.d.sideDecode(rv, xbs) - } else { - ext.ReadExt(rv, xbs) - } -} - -func (d *simpleDecDriver) decodeExtV(verifyTag bool, tag byte) (xtag byte, xbs []byte) { - switch d.bd { - case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4: - l := d.decLen() - xtag = d.d.decRd.readn1() - if verifyTag && xtag != tag { - d.d.errorf("wrong extension tag. Got %b. Expecting: %v", xtag, tag) - return - } - if d.d.bytes { - xbs = d.d.decRd.rb.readx(uint(l)) - } else { - xbs = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) - } - case simpleVdByteArray, simpleVdByteArray + 1, - simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: - xbs = d.DecodeBytes(nil, true) - default: - d.d.errorf("ext - %s - expecting extensions/bytearray, got: 0x%x", msgBadDesc, d.bd) - return - } - d.bdRead = false - return -} - -func (d *simpleDecDriver) DecodeNaked() { - if !d.bdRead { - d.readNextBd() - } - - d.fnil = false - n := d.d.naked() - var decodeFurther bool - - switch d.bd { - case simpleVdNil: - n.v = valueTypeNil - d.fnil = true - case simpleVdFalse: - n.v = valueTypeBool - n.b = false - case simpleVdTrue: - n.v = valueTypeBool - n.b = true - case simpleVdPosInt, simpleVdPosInt + 1, simpleVdPosInt + 2, simpleVdPosInt + 3: - if d.h.SignedInteger { - n.v = valueTypeInt - n.i = d.DecodeInt64() - } else { - n.v = valueTypeUint - n.u = d.DecodeUint64() - } - case simpleVdNegInt, simpleVdNegInt + 1, simpleVdNegInt + 2, simpleVdNegInt + 3: - n.v = valueTypeInt - n.i = d.DecodeInt64() - case simpleVdFloat32: - n.v = valueTypeFloat - n.f = d.DecodeFloat64() - case simpleVdFloat64: - n.v = valueTypeFloat - n.f = d.DecodeFloat64() - case simpleVdTime: - n.v = valueTypeTime - n.t = d.DecodeTime() - case simpleVdString, simpleVdString + 1, - simpleVdString + 2, simpleVdString + 3, simpleVdString + 4: - n.v = valueTypeString - n.s = string(d.DecodeStringAsBytes()) - case simpleVdByteArray, simpleVdByteArray + 1, - simpleVdByteArray + 2, simpleVdByteArray + 3, simpleVdByteArray + 4: - fauxUnionReadRawBytes(d, &d.d, n, d.h.RawToString) - case simpleVdExt, simpleVdExt + 1, simpleVdExt + 2, simpleVdExt + 3, simpleVdExt + 4: - n.v = valueTypeExt - l := d.decLen() - n.u = uint64(d.d.decRd.readn1()) - if d.d.bytes { - n.l = d.d.decRd.rb.readx(uint(l)) - } else { - n.l = decByteSlice(d.d.r(), l, d.d.h.MaxInitLen, d.d.b[:]) - } - case simpleVdArray, simpleVdArray + 1, simpleVdArray + 2, - simpleVdArray + 3, simpleVdArray + 4: - n.v = valueTypeArray - decodeFurther = true - case simpleVdMap, simpleVdMap + 1, simpleVdMap + 2, simpleVdMap + 3, simpleVdMap + 4: - n.v = valueTypeMap - decodeFurther = true - default: - d.d.errorf("cannot infer value - %s 0x%x", msgBadDesc, d.bd) - } - - if !decodeFurther { - d.bdRead = false - } -} - -//------------------------------------ - -// SimpleHandle is a Handle for a very simple encoding format. -// -// simple is a simplistic codec similar to binc, but not as compact. -// - Encoding of a value is always preceded by the descriptor byte (bd) -// - True, false, nil are encoded fully in 1 byte (the descriptor) -// - Integers (intXXX, uintXXX) are encoded in 1, 2, 4 or 8 bytes (plus a descriptor byte). -// There are positive (uintXXX and intXXX >= 0) and negative (intXXX < 0) integers. -// - Floats are encoded in 4 or 8 bytes (plus a descriptor byte) -// - Length of containers (strings, bytes, array, map, extensions) -// are encoded in 0, 1, 2, 4 or 8 bytes. -// Zero-length containers have no length encoded. -// For others, the number of bytes is given by pow(2, bd%3) -// - maps are encoded as [bd] [length] [[key][value]]... -// - arrays are encoded as [bd] [length] [value]... -// - extensions are encoded as [bd] [length] [tag] [byte]... -// - strings/bytearrays are encoded as [bd] [length] [byte]... -// - time.Time are encoded as [bd] [length] [byte]... -// -// The full spec will be published soon. -type SimpleHandle struct { - binaryEncodingType - BasicHandle - // EncZeroValuesAsNil says to encode zero values for numbers, bool, string, etc as nil - EncZeroValuesAsNil bool - - _ [7]uint64 // padding (cache-aligned) -} - -// Name returns the name of the handle: simple -func (h *SimpleHandle) Name() string { return "simple" } - -func (h *SimpleHandle) newEncDriver() encDriver { - var e = &simpleEncDriver{h: h} - e.e.e = e - e.e.init(h) - e.reset() - return e -} - -func (h *SimpleHandle) newDecDriver() decDriver { - d := &simpleDecDriver{h: h} - d.d.d = d - d.d.init(h) - d.reset() - return d -} - -func (e *simpleEncDriver) reset() { -} - -func (d *simpleDecDriver) reset() { - d.bd, d.bdRead = 0, false - d.fnil = false -} - -var _ decDriver = (*simpleDecDriver)(nil) -var _ encDriver = (*simpleEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/sort-slice.generated.go b/vendor/github.com/ugorji/go/codec/sort-slice.generated.go deleted file mode 100644 index 52f9fc21a..000000000 --- a/vendor/github.com/ugorji/go/codec/sort-slice.generated.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from sort-slice.go.tmpl - DO NOT EDIT. - -package codec - -import "time" -import "reflect" -import "bytes" - -type stringSlice []string - -func (p stringSlice) Len() int { return len(p) } -func (p stringSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p stringSlice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type float64Slice []float64 - -func (p float64Slice) Len() int { return len(p) } -func (p float64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p float64Slice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] || isNaN64(p[uint(i)]) && !isNaN64(p[uint(j)]) -} - -type uint64Slice []uint64 - -func (p uint64Slice) Len() int { return len(p) } -func (p uint64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uint64Slice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type uintptrSlice []uintptr - -func (p uintptrSlice) Len() int { return len(p) } -func (p uintptrSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uintptrSlice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type int64Slice []int64 - -func (p int64Slice) Len() int { return len(p) } -func (p int64Slice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p int64Slice) Less(i, j int) bool { - return p[uint(i)] < p[uint(j)] -} - -type boolSlice []bool - -func (p boolSlice) Len() int { return len(p) } -func (p boolSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p boolSlice) Less(i, j int) bool { - return !p[uint(i)] && p[uint(j)] -} - -type timeSlice []time.Time - -func (p timeSlice) Len() int { return len(p) } -func (p timeSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p timeSlice) Less(i, j int) bool { - return p[uint(i)].Before(p[uint(j)]) -} - -type bytesSlice [][]byte - -func (p bytesSlice) Len() int { return len(p) } -func (p bytesSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p bytesSlice) Less(i, j int) bool { - return bytes.Compare(p[uint(i)], p[uint(j)]) == -1 -} - -type stringRv struct { - v string - r reflect.Value -} -type stringRvSlice []stringRv - -func (p stringRvSlice) Len() int { return len(p) } -func (p stringRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p stringRvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type float64Rv struct { - v float64 - r reflect.Value -} -type float64RvSlice []float64Rv - -func (p float64RvSlice) Len() int { return len(p) } -func (p float64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p float64RvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v || isNaN64(p[uint(i)].v) && !isNaN64(p[uint(j)].v) -} - -type uint64Rv struct { - v uint64 - r reflect.Value -} -type uint64RvSlice []uint64Rv - -func (p uint64RvSlice) Len() int { return len(p) } -func (p uint64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uint64RvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type uintptrRv struct { - v uintptr - r reflect.Value -} -type uintptrRvSlice []uintptrRv - -func (p uintptrRvSlice) Len() int { return len(p) } -func (p uintptrRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p uintptrRvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type int64Rv struct { - v int64 - r reflect.Value -} -type int64RvSlice []int64Rv - -func (p int64RvSlice) Len() int { return len(p) } -func (p int64RvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p int64RvSlice) Less(i, j int) bool { - return p[uint(i)].v < p[uint(j)].v -} - -type boolRv struct { - v bool - r reflect.Value -} -type boolRvSlice []boolRv - -func (p boolRvSlice) Len() int { return len(p) } -func (p boolRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p boolRvSlice) Less(i, j int) bool { - return !p[uint(i)].v && p[uint(j)].v -} - -type timeRv struct { - v time.Time - r reflect.Value -} -type timeRvSlice []timeRv - -func (p timeRvSlice) Len() int { return len(p) } -func (p timeRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p timeRvSlice) Less(i, j int) bool { - return p[uint(i)].v.Before(p[uint(j)].v) -} - -type bytesRv struct { - v []byte - r reflect.Value -} -type bytesRvSlice []bytesRv - -func (p bytesRvSlice) Len() int { return len(p) } -func (p bytesRvSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p bytesRvSlice) Less(i, j int) bool { - return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 -} - -type bytesIntf struct { - v []byte - i interface{} -} -type bytesIntfSlice []bytesIntf - -func (p bytesIntfSlice) Len() int { return len(p) } -func (p bytesIntfSlice) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p bytesIntfSlice) Less(i, j int) bool { - return bytes.Compare(p[uint(i)].v, p[uint(j)].v) == -1 -} diff --git a/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl b/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl deleted file mode 100644 index 80b8ff8aa..000000000 --- a/vendor/github.com/ugorji/go/codec/sort-slice.go.tmpl +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// Code generated from sort-slice.go.tmpl - DO NOT EDIT. - -{{/* -xxxSlice -xxxIntf -xxxIntfSlice -xxxRv -xxxRvSlice - -I'm now going to create them for -- sortables -- sortablesplus - -With the parameters passed in sortables or sortablesplus, -'time, 'bytes' are special, and correspond to time.Time and []byte respectively. -*/}} - -package codec - -import "time" -import "reflect" -import "bytes" - -{{/* func init() { _ = time.Unix } */}} - -{{define "T"}} -func (p {{ .Type }}) Len() int { return len(p) } -func (p {{ .Type }}) Swap(i, j int) { p[uint(i)], p[uint(j)] = p[uint(j)], p[uint(i)] } -func (p {{ .Type }}) Less(i, j int) bool { - {{ if eq .Kind "bool" }} return !p[uint(i)]{{.V}} && p[uint(j)]{{.V}} - {{ else if eq .Kind "float32" }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} || isNaN32(p[uint(i)]{{.V}}) && !isNaN32(p[uint(j)]{{.V}}) - {{ else if eq .Kind "float64" }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} || isNaN64(p[uint(i)]{{.V}}) && !isNaN64(p[uint(j)]{{.V}}) - {{ else if eq .Kind "time" }} return p[uint(i)]{{.V}}.Before(p[uint(j)]{{.V}}) - {{ else if eq .Kind "bytes" }} return bytes.Compare(p[uint(i)]{{.V}}, p[uint(j)]{{.V}}) == -1 - {{ else }} return p[uint(i)]{{.V}} < p[uint(j)]{{.V}} - {{ end -}} -} -{{end}} - -{{range $i, $v := sortables }}{{ $t := tshort $v }} -type {{ $v }}Slice []{{ $t }} -{{template "T" args "Kind" $v "Type" (print $v "Slice") "V" ""}} -{{end}} - -{{range $i, $v := sortablesplus }}{{ $t := tshort $v }} - -type {{ $v }}Rv struct { - v {{ $t }} - r reflect.Value -} -type {{ $v }}RvSlice []{{ $v }}Rv -{{template "T" args "Kind" $v "Type" (print $v "RvSlice") "V" ".v"}} - -{{if eq $v "bytes" -}} -type {{ $v }}Intf struct { - v {{ $t }} - i interface{} -} -type {{ $v }}IntfSlice []{{ $v }}Intf -{{template "T" args "Kind" $v "Type" (print $v "IntfSlice") "V" ".v"}} -{{end}} - -{{end}} diff --git a/vendor/github.com/ugorji/go/codec/test-cbor-goldens.json b/vendor/github.com/ugorji/go/codec/test-cbor-goldens.json deleted file mode 100644 index 902858671..000000000 --- a/vendor/github.com/ugorji/go/codec/test-cbor-goldens.json +++ /dev/null @@ -1,639 +0,0 @@ -[ - { - "cbor": "AA==", - "hex": "00", - "roundtrip": true, - "decoded": 0 - }, - { - "cbor": "AQ==", - "hex": "01", - "roundtrip": true, - "decoded": 1 - }, - { - "cbor": "Cg==", - "hex": "0a", - "roundtrip": true, - "decoded": 10 - }, - { - "cbor": "Fw==", - "hex": "17", - "roundtrip": true, - "decoded": 23 - }, - { - "cbor": "GBg=", - "hex": "1818", - "roundtrip": true, - "decoded": 24 - }, - { - "cbor": "GBk=", - "hex": "1819", - "roundtrip": true, - "decoded": 25 - }, - { - "cbor": "GGQ=", - "hex": "1864", - "roundtrip": true, - "decoded": 100 - }, - { - "cbor": "GQPo", - "hex": "1903e8", - "roundtrip": true, - "decoded": 1000 - }, - { - "cbor": "GgAPQkA=", - "hex": "1a000f4240", - "roundtrip": true, - "decoded": 1000000 - }, - { - "cbor": "GwAAAOjUpRAA", - "hex": "1b000000e8d4a51000", - "roundtrip": true, - "decoded": 1000000000000 - }, - { - "cbor": "G///////////", - "hex": "1bffffffffffffffff", - "roundtrip": true, - "decoded": 18446744073709551615 - }, - { - "cbor": "wkkBAAAAAAAAAAA=", - "hex": "c249010000000000000000", - "roundtrip": true, - "decoded": 18446744073709551616 - }, - { - "cbor": "O///////////", - "hex": "3bffffffffffffffff", - "roundtrip": true, - "decoded": -18446744073709551616, - "skip": true - }, - { - "cbor": "w0kBAAAAAAAAAAA=", - "hex": "c349010000000000000000", - "roundtrip": true, - "decoded": -18446744073709551617 - }, - { - "cbor": "IA==", - "hex": "20", - "roundtrip": true, - "decoded": -1 - }, - { - "cbor": "KQ==", - "hex": "29", - "roundtrip": true, - "decoded": -10 - }, - { - "cbor": "OGM=", - "hex": "3863", - "roundtrip": true, - "decoded": -100 - }, - { - "cbor": "OQPn", - "hex": "3903e7", - "roundtrip": true, - "decoded": -1000 - }, - { - "cbor": "+QAA", - "hex": "f90000", - "roundtrip": true, - "decoded": 0.0 - }, - { - "cbor": "+YAA", - "hex": "f98000", - "roundtrip": true, - "decoded": -0.0 - }, - { - "cbor": "+TwA", - "hex": "f93c00", - "roundtrip": true, - "decoded": 1.0 - }, - { - "cbor": "+z/xmZmZmZma", - "hex": "fb3ff199999999999a", - "roundtrip": true, - "decoded": 1.1 - }, - { - "cbor": "+T4A", - "hex": "f93e00", - "roundtrip": true, - "decoded": 1.5 - }, - { - "cbor": "+Xv/", - "hex": "f97bff", - "roundtrip": true, - "decoded": 65504.0 - }, - { - "cbor": "+kfDUAA=", - "hex": "fa47c35000", - "roundtrip": true, - "decoded": 100000.0 - }, - { - "cbor": "+n9///8=", - "hex": "fa7f7fffff", - "roundtrip": true, - "decoded": 3.4028234663852886e+38 - }, - { - "cbor": "+3435DyIAHWc", - "hex": "fb7e37e43c8800759c", - "roundtrip": true, - "decoded": 1.0e+300 - }, - { - "cbor": "+QAB", - "hex": "f90001", - "roundtrip": true, - "decoded": 5.960464477539063e-08 - }, - { - "cbor": "+QQA", - "hex": "f90400", - "roundtrip": true, - "decoded": 6.103515625e-05 - }, - { - "cbor": "+cQA", - "hex": "f9c400", - "roundtrip": true, - "decoded": -4.0 - }, - { - "cbor": "+8AQZmZmZmZm", - "hex": "fbc010666666666666", - "roundtrip": true, - "decoded": -4.1 - }, - { - "cbor": "+XwA", - "hex": "f97c00", - "roundtrip": true, - "diagnostic": "Infinity" - }, - { - "cbor": "+X4A", - "hex": "f97e00", - "roundtrip": true, - "diagnostic": "NaN" - }, - { - "cbor": "+fwA", - "hex": "f9fc00", - "roundtrip": true, - "diagnostic": "-Infinity" - }, - { - "cbor": "+n+AAAA=", - "hex": "fa7f800000", - "roundtrip": false, - "diagnostic": "Infinity" - }, - { - "cbor": "+n/AAAA=", - "hex": "fa7fc00000", - "roundtrip": false, - "diagnostic": "NaN" - }, - { - "cbor": "+v+AAAA=", - "hex": "faff800000", - "roundtrip": false, - "diagnostic": "-Infinity" - }, - { - "cbor": "+3/wAAAAAAAA", - "hex": "fb7ff0000000000000", - "roundtrip": false, - "diagnostic": "Infinity" - }, - { - "cbor": "+3/4AAAAAAAA", - "hex": "fb7ff8000000000000", - "roundtrip": false, - "diagnostic": "NaN" - }, - { - "cbor": "+//wAAAAAAAA", - "hex": "fbfff0000000000000", - "roundtrip": false, - "diagnostic": "-Infinity" - }, - { - "cbor": "9A==", - "hex": "f4", - "roundtrip": true, - "decoded": false - }, - { - "cbor": "9Q==", - "hex": "f5", - "roundtrip": true, - "decoded": true - }, - { - "cbor": "9g==", - "hex": "f6", - "roundtrip": true, - "decoded": null - }, - { - "cbor": "9w==", - "hex": "f7", - "roundtrip": true, - "diagnostic": "undefined" - }, - { - "cbor": "8A==", - "hex": "f0", - "roundtrip": true, - "diagnostic": "simple(16)" - }, - { - "cbor": "+Bg=", - "hex": "f818", - "roundtrip": true, - "diagnostic": "simple(24)" - }, - { - "cbor": "+P8=", - "hex": "f8ff", - "roundtrip": true, - "diagnostic": "simple(255)" - }, - { - "cbor": "wHQyMDEzLTAzLTIxVDIwOjA0OjAwWg==", - "hex": "c074323031332d30332d32315432303a30343a30305a", - "roundtrip": true, - "diagnostic": "0(\"2013-03-21T20:04:00Z\")" - }, - { - "cbor": "wRpRS2ew", - "hex": "c11a514b67b0", - "roundtrip": true, - "diagnostic": "1(1363896240)" - }, - { - "cbor": "wftB1FLZ7CAAAA==", - "hex": "c1fb41d452d9ec200000", - "roundtrip": true, - "diagnostic": "1(1363896240.5)" - }, - { - "cbor": "10QBAgME", - "hex": "d74401020304", - "roundtrip": true, - "diagnostic": "23(h'01020304')" - }, - { - "cbor": "2BhFZElFVEY=", - "hex": "d818456449455446", - "roundtrip": true, - "diagnostic": "24(h'6449455446')" - }, - { - "cbor": "2CB2aHR0cDovL3d3dy5leGFtcGxlLmNvbQ==", - "hex": "d82076687474703a2f2f7777772e6578616d706c652e636f6d", - "roundtrip": true, - "diagnostic": "32(\"http://www.example.com\")" - }, - { - "cbor": "QA==", - "hex": "40", - "roundtrip": true, - "diagnostic": "h''" - }, - { - "cbor": "RAECAwQ=", - "hex": "4401020304", - "roundtrip": true, - "diagnostic": "h'01020304'" - }, - { - "cbor": "YA==", - "hex": "60", - "roundtrip": true, - "decoded": "" - }, - { - "cbor": "YWE=", - "hex": "6161", - "roundtrip": true, - "decoded": "a" - }, - { - "cbor": "ZElFVEY=", - "hex": "6449455446", - "roundtrip": true, - "decoded": "IETF" - }, - { - "cbor": "YiJc", - "hex": "62225c", - "roundtrip": true, - "decoded": "\"\\" - }, - { - "cbor": "YsO8", - "hex": "62c3bc", - "roundtrip": true, - "decoded": "ü" - }, - { - "cbor": "Y+awtA==", - "hex": "63e6b0b4", - "roundtrip": true, - "decoded": "水" - }, - { - "cbor": "ZPCQhZE=", - "hex": "64f0908591", - "roundtrip": true, - "decoded": "𐅑" - }, - { - "cbor": "gA==", - "hex": "80", - "roundtrip": true, - "decoded": [ - - ] - }, - { - "cbor": "gwECAw==", - "hex": "83010203", - "roundtrip": true, - "decoded": [ - 1, - 2, - 3 - ] - }, - { - "cbor": "gwGCAgOCBAU=", - "hex": "8301820203820405", - "roundtrip": true, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "mBkBAgMEBQYHCAkKCwwNDg8QERITFBUWFxgYGBk=", - "hex": "98190102030405060708090a0b0c0d0e0f101112131415161718181819", - "roundtrip": true, - "decoded": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ] - }, - { - "cbor": "oA==", - "hex": "a0", - "roundtrip": true, - "decoded": { - } - }, - { - "cbor": "ogECAwQ=", - "hex": "a201020304", - "roundtrip": true, - "skip": true, - "diagnostic": "{1: 2, 3: 4}" - }, - { - "cbor": "omFhAWFiggID", - "hex": "a26161016162820203", - "roundtrip": true, - "decoded": { - "a": 1, - "b": [ - 2, - 3 - ] - } - }, - { - "cbor": "gmFhoWFiYWM=", - "hex": "826161a161626163", - "roundtrip": true, - "decoded": [ - "a", - { - "b": "c" - } - ] - }, - { - "cbor": "pWFhYUFhYmFCYWNhQ2FkYURhZWFF", - "hex": "a56161614161626142616361436164614461656145", - "roundtrip": true, - "decoded": { - "a": "A", - "b": "B", - "c": "C", - "d": "D", - "e": "E" - } - }, - { - "cbor": "X0IBAkMDBAX/", - "hex": "5f42010243030405ff", - "roundtrip": false, - "skip": true, - "diagnostic": "(_ h'0102', h'030405')" - }, - { - "cbor": "f2VzdHJlYWRtaW5n/w==", - "hex": "7f657374726561646d696e67ff", - "roundtrip": false, - "decoded": "streaming" - }, - { - "cbor": "n/8=", - "hex": "9fff", - "roundtrip": false, - "decoded": [ - - ] - }, - { - "cbor": "nwGCAgOfBAX//w==", - "hex": "9f018202039f0405ffff", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "nwGCAgOCBAX/", - "hex": "9f01820203820405ff", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "gwGCAgOfBAX/", - "hex": "83018202039f0405ff", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "gwGfAgP/ggQF", - "hex": "83019f0203ff820405", - "roundtrip": false, - "decoded": [ - 1, - [ - 2, - 3 - ], - [ - 4, - 5 - ] - ] - }, - { - "cbor": "nwECAwQFBgcICQoLDA0ODxAREhMUFRYXGBgYGf8=", - "hex": "9f0102030405060708090a0b0c0d0e0f101112131415161718181819ff", - "roundtrip": false, - "decoded": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ] - }, - { - "cbor": "v2FhAWFinwID//8=", - "hex": "bf61610161629f0203ffff", - "roundtrip": false, - "decoded": { - "a": 1, - "b": [ - 2, - 3 - ] - } - }, - { - "cbor": "gmFhv2FiYWP/", - "hex": "826161bf61626163ff", - "roundtrip": false, - "decoded": [ - "a", - { - "b": "c" - } - ] - }, - { - "cbor": "v2NGdW71Y0FtdCH/", - "hex": "bf6346756ef563416d7421ff", - "roundtrip": false, - "decoded": { - "Fun": true, - "Amt": -2 - } - } -] diff --git a/vendor/github.com/ugorji/go/codec/test.py b/vendor/github.com/ugorji/go/codec/test.py deleted file mode 100755 index 2222c0585..000000000 --- a/vendor/github.com/ugorji/go/codec/test.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python - -# This will create golden files in a directory passed to it. -# A Test calls this internally to create the golden files -# So it can process them (so we don't have to checkin the files). - -# Ensure msgpack-python and cbor are installed first, using: -# sudo apt-get install python-dev -# sudo apt-get install python-pip -# pip install --user msgpack-python msgpack-rpc-python cbor - -# Ensure all "string" keys are utf strings (else encoded as bytes) - -from __future__ import print_function -import cbor, msgpack, msgpackrpc, sys, os, threading - -def get_test_data_list(): - # get list with all primitive types, and a combo type - l0 = [ - -8, - -1616, - -32323232, - -6464646464646464, - 192, - 1616, - 32323232, - 6464646464646464, - 192, - -3232.0, - -6464646464.0, - 3232.0, - 6464.0, - 6464646464.0, - False, - True, - u"null", - None, - u"some&day>some 0 - if stopTimeSec > 0: - def myStopRpcServer(): - server.stop() - t = threading.Timer(stopTimeSec, myStopRpcServer) - t.start() - server.start() - -def doRpcClientToPythonSvc(port): - address = msgpackrpc.Address('127.0.0.1', port) - client = msgpackrpc.Client(address, unpack_encoding='utf-8') - print(client.call("Echo123", "A1", "B2", "C3")) - print(client.call("EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})) - -def doRpcClientToGoSvc(port): - # print(">>>> port: ", port, " <<<<<") - address = msgpackrpc.Address('127.0.0.1', port) - client = msgpackrpc.Client(address, unpack_encoding='utf-8') - print(client.call("TestRpcInt.Echo123", ["A1", "B2", "C3"])) - print(client.call("TestRpcInt.EchoStruct", {"A" :"Aa", "B":"Bb", "C":"Cc"})) - -def doMain(args): - if len(args) == 2 and args[0] == "testdata": - build_test_data(args[1]) - elif len(args) == 3 and args[0] == "rpc-server": - doRpcServer(int(args[1]), int(args[2])) - elif len(args) == 2 and args[0] == "rpc-client-python-service": - doRpcClientToPythonSvc(int(args[1])) - elif len(args) == 2 and args[0] == "rpc-client-go-service": - doRpcClientToGoSvc(int(args[1])) - else: - print("Usage: test.py " + - "[testdata|rpc-server|rpc-client-python-service|rpc-client-go-service] ...") - -if __name__ == "__main__": - doMain(sys.argv[1:]) diff --git a/vendor/github.com/ugorji/go/codec/values_codecgen_generated_test.go b/vendor/github.com/ugorji/go/codec/values_codecgen_generated_test.go deleted file mode 100644 index 36acf0991..000000000 --- a/vendor/github.com/ugorji/go/codec/values_codecgen_generated_test.go +++ /dev/null @@ -1,14057 +0,0 @@ -// +build go1.6 -// +build codecgen generated - -// Code generated by codecgen - DO NOT EDIT. - -package codec - -import ( - "errors" - "runtime" - "strconv" - "time" -) - -const ( - // ----- content types ---- - codecSelferCcUTF819780 = 1 - codecSelferCcRAW19780 = 255 - // ----- value types used ---- - codecSelferValueTypeArray19780 = 10 - codecSelferValueTypeMap19780 = 9 - codecSelferValueTypeString19780 = 6 - codecSelferValueTypeInt19780 = 2 - codecSelferValueTypeUint19780 = 3 - codecSelferValueTypeFloat19780 = 4 - codecSelferValueTypeNil19780 = 1 - codecSelferBitsize19780 = uint8(32 << (^uint(0) >> 63)) - codecSelferDecContainerLenNil19780 = -2147483648 -) - -var ( - errCodecSelferOnlyMapOrArrayEncodeToStruct19780 = errors.New(`only encoded map or array can be decoded into a struct`) -) - -type codecSelfer19780 struct{} - -func codecSelfer19780False() bool { return false } - -func init() { - if GenVersion != 16 { - _, file, _, _ := runtime.Caller(0) - ver := strconv.FormatInt(int64(GenVersion), 10) - panic("codecgen version mismatch: current: 16, need " + ver + ". Re-generate file: " + file) - } - if false { // reference the types, but skip this branch at build/run time - var _ time.Time - } -} - -func (x wrapSliceUint64) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.encwrapSliceUint64((wrapSliceUint64)(x), e) - } // end block: if x slice == nil -} - -func (x *wrapSliceUint64) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.decwrapSliceUint64((*wrapSliceUint64)(x), d) -} - -func (x wrapSliceString) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.encwrapSliceString((wrapSliceString)(x), e) - } // end block: if x slice == nil -} - -func (x *wrapSliceString) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.decwrapSliceString((*wrapSliceString)(x), d) -} - -func (x wrapUint64) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - r.EncodeUint(uint64(x)) -} - -func (x *wrapUint64) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *x = (wrapUint64)(r.DecodeUint64()) -} - -func (x wrapString) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - r.EncodeString(string(x)) -} - -func (x *wrapString) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *x = (wrapString)(string(r.DecodeStringAsBytes())) -} - -func (x wrapUint64Slice) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.encwrapUint64Slice((wrapUint64Slice)(x), e) - } // end block: if x slice == nil -} - -func (x *wrapUint64Slice) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.decwrapUint64Slice((*wrapUint64Slice)(x), d) -} - -func (x wrapStringSlice) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.encwrapStringSlice((wrapStringSlice)(x), e) - } // end block: if x slice == nil -} - -func (x *wrapStringSlice) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.decwrapStringSlice((*wrapStringSlice)(x), d) -} - -func (x *stringUint64T) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.U)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"U\"") - } else { - r.EncodeString(`U`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.U)) - z.EncWriteMapEnd() - } - } -} - -func (x *stringUint64T) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = stringUint64T{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *stringUint64T) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - case "U": - x.U = (uint64)(r.DecodeUint64()) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *stringUint64T) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.U = (uint64)(r.DecodeUint64()) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *AnonInTestStruc) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(15) - z.EncWriteArrayElem() - r.EncodeString(string(x.AS)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.AI64)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.AI16)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.AUi64)) - z.EncWriteArrayElem() - if x.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.ASslice, e) - } // end block: if x.ASslice slice == nil - z.EncWriteArrayElem() - if x.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AI64slice, e) - } // end block: if x.AI64slice slice == nil - z.EncWriteArrayElem() - if x.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AUi64slice, e) - } // end block: if x.AUi64slice slice == nil - z.EncWriteArrayElem() - if x.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.AF64slice, e) - } // end block: if x.AF64slice slice == nil - z.EncWriteArrayElem() - if x.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.AF32slice, e) - } // end block: if x.AF32slice slice == nil - z.EncWriteArrayElem() - if x.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AMSU16), e) - } // end block: if x.AMSU16 map == nil - z.EncWriteArrayElem() - yy28 := &x.AI64arr0 - h.encArray0int64((*[0]int64)(yy28), e) - z.EncWriteArrayElem() - if x.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AI64slice0, e) - } // end block: if x.AI64slice0 slice == nil - z.EncWriteArrayElem() - if x.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AUi64sliceN, e) - } // end block: if x.AUi64sliceN slice == nil - z.EncWriteArrayElem() - if x.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AMSU16N), e) - } // end block: if x.AMSU16N map == nil - z.EncWriteArrayElem() - if x.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AMSU16E), e) - } // end block: if x.AMSU16E map == nil - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(15) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AS\"") - } else { - r.EncodeString(`AS`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.AS)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64\"") - } else { - r.EncodeString(`AI64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.AI64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI16\"") - } else { - r.EncodeString(`AI16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.AI16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64\"") - } else { - r.EncodeString(`AUi64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.AUi64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"ASslice\"") - } else { - r.EncodeString(`ASslice`) - } - z.EncWriteMapElemValue() - if x.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.ASslice, e) - } // end block: if x.ASslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice\"") - } else { - r.EncodeString(`AI64slice`) - } - z.EncWriteMapElemValue() - if x.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AI64slice, e) - } // end block: if x.AI64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64slice\"") - } else { - r.EncodeString(`AUi64slice`) - } - z.EncWriteMapElemValue() - if x.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AUi64slice, e) - } // end block: if x.AUi64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF64slice\"") - } else { - r.EncodeString(`AF64slice`) - } - z.EncWriteMapElemValue() - if x.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.AF64slice, e) - } // end block: if x.AF64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF32slice\"") - } else { - r.EncodeString(`AF32slice`) - } - z.EncWriteMapElemValue() - if x.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.AF32slice, e) - } // end block: if x.AF32slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16\"") - } else { - r.EncodeString(`AMSU16`) - } - z.EncWriteMapElemValue() - if x.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AMSU16), e) - } // end block: if x.AMSU16 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64arr0\"") - } else { - r.EncodeString(`AI64arr0`) - } - z.EncWriteMapElemValue() - yy44 := &x.AI64arr0 - h.encArray0int64((*[0]int64)(yy44), e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice0\"") - } else { - r.EncodeString(`AI64slice0`) - } - z.EncWriteMapElemValue() - if x.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AI64slice0, e) - } // end block: if x.AI64slice0 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64sliceN\"") - } else { - r.EncodeString(`AUi64sliceN`) - } - z.EncWriteMapElemValue() - if x.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AUi64sliceN, e) - } // end block: if x.AUi64sliceN slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16N\"") - } else { - r.EncodeString(`AMSU16N`) - } - z.EncWriteMapElemValue() - if x.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AMSU16N), e) - } // end block: if x.AMSU16N map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16E\"") - } else { - r.EncodeString(`AMSU16E`) - } - z.EncWriteMapElemValue() - if x.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AMSU16E), e) - } // end block: if x.AMSU16E map == nil - z.EncWriteMapEnd() - } - } -} - -func (x *AnonInTestStruc) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = AnonInTestStruc{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *AnonInTestStruc) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "AS": - x.AS = (string)(string(r.DecodeStringAsBytes())) - case "AI64": - x.AI64 = (int64)(r.DecodeInt64()) - case "AI16": - x.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "AUi64": - x.AUi64 = (uint64)(r.DecodeUint64()) - case "ASslice": - z.F.DecSliceStringX(&x.ASslice, d) - case "AI64slice": - z.F.DecSliceInt64X(&x.AI64slice, d) - case "AUi64slice": - z.F.DecSliceUint64X(&x.AUi64slice, d) - case "AF64slice": - z.F.DecSliceFloat64X(&x.AF64slice, d) - case "AF32slice": - z.F.DecSliceFloat32X(&x.AF32slice, d) - case "AMSU16": - h.decMapstringuint16((*map[string]uint16)(&x.AMSU16), d) - case "AI64arr0": - h.decArray0int64((*[0]int64)(&x.AI64arr0), d) - case "AI64slice0": - z.F.DecSliceInt64X(&x.AI64slice0, d) - case "AUi64sliceN": - z.F.DecSliceUint64X(&x.AUi64sliceN, d) - case "AMSU16N": - h.decMapstringuint16((*map[string]uint16)(&x.AMSU16N), d) - case "AMSU16E": - h.decMapstringuint16((*map[string]uint16)(&x.AMSU16E), d) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *AnonInTestStruc) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj30 int - var yyb30 bool - var yyhl30 bool = l >= 0 - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AS = (string)(string(r.DecodeStringAsBytes())) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AI64 = (int64)(r.DecodeInt64()) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AUi64 = (uint64)(r.DecodeUint64()) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.ASslice, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.AI64slice, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.AUi64slice, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat64X(&x.AF64slice, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat32X(&x.AF32slice, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.AMSU16), d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray0int64((*[0]int64)(&x.AI64arr0), d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.AI64slice0, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.AUi64sliceN, d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.AMSU16N), d) - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.AMSU16E), d) - for { - yyj30++ - if yyhl30 { - yyb30 = yyj30 > l - } else { - yyb30 = z.DecCheckBreak() - } - if yyb30 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj30-1, "") - } -} - -func (x *testSimpleFields) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(17) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I64)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I8)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Ui64)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Ui8)) - z.EncWriteArrayElem() - r.EncodeFloat64(float64(x.F64)) - z.EncWriteArrayElem() - r.EncodeFloat32(float32(x.F32)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - z.EncWriteArrayElem() - if x.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.Sslice, e) - } // end block: if x.Sslice slice == nil - z.EncWriteArrayElem() - if x.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.I16slice, e) - } // end block: if x.I16slice slice == nil - z.EncWriteArrayElem() - if x.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.Ui64slice, e) - } // end block: if x.Ui64slice slice == nil - z.EncWriteArrayElem() - if x.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Ui8slice)) - } // end block: if x.Ui8slice slice == nil - z.EncWriteArrayElem() - if x.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.Bslice, e) - } // end block: if x.Bslice slice == nil - z.EncWriteArrayElem() - if x.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.Iptrslice), e) - } // end block: if x.Iptrslice slice == nil - z.EncWriteArrayElem() - x.WrapSliceInt64.CodecEncodeSelf(e) - z.EncWriteArrayElem() - x.WrapSliceString.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.Msi64, e) - } // end block: if x.Msi64 map == nil - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(17) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64\"") - } else { - r.EncodeString(`I64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8\"") - } else { - r.EncodeString(`I8`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64\"") - } else { - r.EncodeString(`Ui64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Ui64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8\"") - } else { - r.EncodeString(`Ui8`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Ui8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F64\"") - } else { - r.EncodeString(`F64`) - } - z.EncWriteMapElemValue() - r.EncodeFloat64(float64(x.F64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F32\"") - } else { - r.EncodeString(`F32`) - } - z.EncWriteMapElemValue() - r.EncodeFloat32(float32(x.F32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Sslice\"") - } else { - r.EncodeString(`Sslice`) - } - z.EncWriteMapElemValue() - if x.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.Sslice, e) - } // end block: if x.Sslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16slice\"") - } else { - r.EncodeString(`I16slice`) - } - z.EncWriteMapElemValue() - if x.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.I16slice, e) - } // end block: if x.I16slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64slice\"") - } else { - r.EncodeString(`Ui64slice`) - } - z.EncWriteMapElemValue() - if x.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.Ui64slice, e) - } // end block: if x.Ui64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8slice\"") - } else { - r.EncodeString(`Ui8slice`) - } - z.EncWriteMapElemValue() - if x.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Ui8slice)) - } // end block: if x.Ui8slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Bslice\"") - } else { - r.EncodeString(`Bslice`) - } - z.EncWriteMapElemValue() - if x.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.Bslice, e) - } // end block: if x.Bslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Iptrslice\"") - } else { - r.EncodeString(`Iptrslice`) - } - z.EncWriteMapElemValue() - if x.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.Iptrslice), e) - } // end block: if x.Iptrslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceInt64\"") - } else { - r.EncodeString(`WrapSliceInt64`) - } - z.EncWriteMapElemValue() - x.WrapSliceInt64.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceString\"") - } else { - r.EncodeString(`WrapSliceString`) - } - z.EncWriteMapElemValue() - x.WrapSliceString.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msi64\"") - } else { - r.EncodeString(`Msi64`) - } - z.EncWriteMapElemValue() - if x.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.Msi64, e) - } // end block: if x.Msi64 map == nil - z.EncWriteMapEnd() - } - } -} - -func (x *testSimpleFields) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testSimpleFields{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testSimpleFields) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - case "I64": - x.I64 = (int64)(r.DecodeInt64()) - case "I8": - x.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "Ui64": - x.Ui64 = (uint64)(r.DecodeUint64()) - case "Ui8": - x.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "F64": - x.F64 = (float64)(r.DecodeFloat64()) - case "F32": - x.F32 = (float32)(z.DecDecodeFloat32()) - case "B": - x.B = (bool)(r.DecodeBool()) - case "Sslice": - z.F.DecSliceStringX(&x.Sslice, d) - case "I16slice": - z.F.DecSliceInt16X(&x.I16slice, d) - case "Ui64slice": - z.F.DecSliceUint64X(&x.Ui64slice, d) - case "Ui8slice": - x.Ui8slice = r.DecodeBytes(([]byte)(x.Ui8slice), false) - case "Bslice": - z.F.DecSliceBoolX(&x.Bslice, d) - case "Iptrslice": - h.decSlicePtrtoint64((*[]*int64)(&x.Iptrslice), d) - case "WrapSliceInt64": - x.WrapSliceInt64.CodecDecodeSelf(d) - case "WrapSliceString": - x.WrapSliceString.CodecDecodeSelf(d) - case "Msi64": - z.F.DecMapStringInt64X(&x.Msi64, d) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testSimpleFields) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj28 int - var yyb28 bool - var yyhl28 bool = l >= 0 - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I64 = (int64)(r.DecodeInt64()) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui64 = (uint64)(r.DecodeUint64()) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F64 = (float64)(r.DecodeFloat64()) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F32 = (float32)(z.DecDecodeFloat32()) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.Sslice, d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt16X(&x.I16slice, d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.Ui64slice, d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui8slice = r.DecodeBytes(([]byte)(x.Ui8slice), false) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBoolX(&x.Bslice, d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoint64((*[]*int64)(&x.Iptrslice), d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.WrapSliceInt64.CodecDecodeSelf(d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.WrapSliceString.CodecDecodeSelf(d) - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringInt64X(&x.Msi64, d) - for { - yyj28++ - if yyhl28 { - yyb28 = yyj28 > l - } else { - yyb28 = z.DecCheckBreak() - } - if yyb28 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj28-1, "") - } -} - -func (x *TestStrucCommon) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyn54 bool = x.Nint64 == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(52) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I64)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I32)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I16)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I8)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I64n)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I32n)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I16n)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I8n)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Ui64)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Ui32)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Ui16)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Ui8)) - z.EncWriteArrayElem() - r.EncodeFloat64(float64(x.F64)) - z.EncWriteArrayElem() - r.EncodeFloat32(float32(x.F32)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.By)) - z.EncWriteArrayElem() - if x.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.Sslice, e) - } // end block: if x.Sslice slice == nil - z.EncWriteArrayElem() - if x.I64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.I64slice, e) - } // end block: if x.I64slice slice == nil - z.EncWriteArrayElem() - if x.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.I16slice, e) - } // end block: if x.I16slice slice == nil - z.EncWriteArrayElem() - if x.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.Ui64slice, e) - } // end block: if x.Ui64slice slice == nil - z.EncWriteArrayElem() - if x.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Ui8slice)) - } // end block: if x.Ui8slice slice == nil - z.EncWriteArrayElem() - if x.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.Bslice, e) - } // end block: if x.Bslice slice == nil - z.EncWriteArrayElem() - if x.Byslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Byslice)) - } // end block: if x.Byslice slice == nil - z.EncWriteArrayElem() - if x.BytesSlice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.BytesSlice, e) - } // end block: if x.BytesSlice slice == nil - z.EncWriteArrayElem() - if x.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.Iptrslice), e) - } // end block: if x.Iptrslice slice == nil - z.EncWriteArrayElem() - x.WrapSliceInt64.CodecEncodeSelf(e) - z.EncWriteArrayElem() - x.WrapSliceString.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.Msi64, e) - } // end block: if x.Msi64 map == nil - z.EncWriteArrayElem() - if x.Msbytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.Msbytes, e) - } // end block: if x.Msbytes map == nil - z.EncWriteArrayElem() - yy85 := &x.Simplef - yy85.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.SstrUi64T == nil { - r.EncodeNil() - } else { - h.encSlicestringUint64T(([]stringUint64T)(x.SstrUi64T), e) - } // end block: if x.SstrUi64T slice == nil - z.EncWriteArrayElem() - if x.MstrUi64T == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtostringUint64T((map[string]*stringUint64T)(x.MstrUi64T), e) - } // end block: if x.MstrUi64T map == nil - z.EncWriteArrayElem() - r.EncodeString(string(x.AnonInTestStruc.AS)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.AnonInTestStruc.AI64)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.AnonInTestStruc.AI16)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.AnonInTestStruc.AUi64)) - z.EncWriteArrayElem() - if x.AnonInTestStruc.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.AnonInTestStruc.ASslice, e) - } // end block: if x.AnonInTestStruc.ASslice slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AnonInTestStruc.AI64slice, e) - } // end block: if x.AnonInTestStruc.AI64slice slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AnonInTestStruc.AUi64slice, e) - } // end block: if x.AnonInTestStruc.AUi64slice slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.AnonInTestStruc.AF64slice, e) - } // end block: if x.AnonInTestStruc.AF64slice slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.AnonInTestStruc.AF32slice, e) - } // end block: if x.AnonInTestStruc.AF32slice slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AnonInTestStruc.AMSU16), e) - } // end block: if x.AnonInTestStruc.AMSU16 map == nil - z.EncWriteArrayElem() - yy99 := &x.AnonInTestStruc.AI64arr0 - h.encArray0int64((*[0]int64)(yy99), e) - z.EncWriteArrayElem() - if x.AnonInTestStruc.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AnonInTestStruc.AI64slice0, e) - } // end block: if x.AnonInTestStruc.AI64slice0 slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AnonInTestStruc.AUi64sliceN, e) - } // end block: if x.AnonInTestStruc.AUi64sliceN slice == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AnonInTestStruc.AMSU16N), e) - } // end block: if x.AnonInTestStruc.AMSU16N map == nil - z.EncWriteArrayElem() - if x.AnonInTestStruc.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AnonInTestStruc.AMSU16E), e) - } // end block: if x.AnonInTestStruc.AMSU16E map == nil - z.EncWriteArrayElem() - yy105 := &x.NotAnon - yy105.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.Nmap == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.Nmap, e) - } // end block: if x.Nmap map == nil - z.EncWriteArrayElem() - if x.Nslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Nslice)) - } // end block: if x.Nslice slice == nil - if yyn54 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy109 := *x.Nint64 - r.EncodeInt(int64(yy109)) - } - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(52) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64\"") - } else { - r.EncodeString(`I64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I32\"") - } else { - r.EncodeString(`I32`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16\"") - } else { - r.EncodeString(`I16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8\"") - } else { - r.EncodeString(`I8`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64n\"") - } else { - r.EncodeString(`I64n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I64n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I32n\"") - } else { - r.EncodeString(`I32n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I32n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16n\"") - } else { - r.EncodeString(`I16n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I16n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8n\"") - } else { - r.EncodeString(`I8n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I8n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64\"") - } else { - r.EncodeString(`Ui64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Ui64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui32\"") - } else { - r.EncodeString(`Ui32`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Ui32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui16\"") - } else { - r.EncodeString(`Ui16`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Ui16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8\"") - } else { - r.EncodeString(`Ui8`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Ui8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F64\"") - } else { - r.EncodeString(`F64`) - } - z.EncWriteMapElemValue() - r.EncodeFloat64(float64(x.F64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F32\"") - } else { - r.EncodeString(`F32`) - } - z.EncWriteMapElemValue() - r.EncodeFloat32(float32(x.F32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"By\"") - } else { - r.EncodeString(`By`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.By)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Sslice\"") - } else { - r.EncodeString(`Sslice`) - } - z.EncWriteMapElemValue() - if x.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.Sslice, e) - } // end block: if x.Sslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64slice\"") - } else { - r.EncodeString(`I64slice`) - } - z.EncWriteMapElemValue() - if x.I64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.I64slice, e) - } // end block: if x.I64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16slice\"") - } else { - r.EncodeString(`I16slice`) - } - z.EncWriteMapElemValue() - if x.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.I16slice, e) - } // end block: if x.I16slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64slice\"") - } else { - r.EncodeString(`Ui64slice`) - } - z.EncWriteMapElemValue() - if x.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.Ui64slice, e) - } // end block: if x.Ui64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8slice\"") - } else { - r.EncodeString(`Ui8slice`) - } - z.EncWriteMapElemValue() - if x.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Ui8slice)) - } // end block: if x.Ui8slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Bslice\"") - } else { - r.EncodeString(`Bslice`) - } - z.EncWriteMapElemValue() - if x.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.Bslice, e) - } // end block: if x.Bslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Byslice\"") - } else { - r.EncodeString(`Byslice`) - } - z.EncWriteMapElemValue() - if x.Byslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Byslice)) - } // end block: if x.Byslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"BytesSlice\"") - } else { - r.EncodeString(`BytesSlice`) - } - z.EncWriteMapElemValue() - if x.BytesSlice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.BytesSlice, e) - } // end block: if x.BytesSlice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Iptrslice\"") - } else { - r.EncodeString(`Iptrslice`) - } - z.EncWriteMapElemValue() - if x.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.Iptrslice), e) - } // end block: if x.Iptrslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceInt64\"") - } else { - r.EncodeString(`WrapSliceInt64`) - } - z.EncWriteMapElemValue() - x.WrapSliceInt64.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceString\"") - } else { - r.EncodeString(`WrapSliceString`) - } - z.EncWriteMapElemValue() - x.WrapSliceString.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msi64\"") - } else { - r.EncodeString(`Msi64`) - } - z.EncWriteMapElemValue() - if x.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.Msi64, e) - } // end block: if x.Msi64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msbytes\"") - } else { - r.EncodeString(`Msbytes`) - } - z.EncWriteMapElemValue() - if x.Msbytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.Msbytes, e) - } // end block: if x.Msbytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Simplef\"") - } else { - r.EncodeString(`Simplef`) - } - z.EncWriteMapElemValue() - yy141 := &x.Simplef - yy141.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"SstrUi64T\"") - } else { - r.EncodeString(`SstrUi64T`) - } - z.EncWriteMapElemValue() - if x.SstrUi64T == nil { - r.EncodeNil() - } else { - h.encSlicestringUint64T(([]stringUint64T)(x.SstrUi64T), e) - } // end block: if x.SstrUi64T slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"MstrUi64T\"") - } else { - r.EncodeString(`MstrUi64T`) - } - z.EncWriteMapElemValue() - if x.MstrUi64T == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtostringUint64T((map[string]*stringUint64T)(x.MstrUi64T), e) - } // end block: if x.MstrUi64T map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AS\"") - } else { - r.EncodeString(`AS`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.AnonInTestStruc.AS)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64\"") - } else { - r.EncodeString(`AI64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.AnonInTestStruc.AI64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI16\"") - } else { - r.EncodeString(`AI16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.AnonInTestStruc.AI16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64\"") - } else { - r.EncodeString(`AUi64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.AnonInTestStruc.AUi64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"ASslice\"") - } else { - r.EncodeString(`ASslice`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.AnonInTestStruc.ASslice, e) - } // end block: if x.AnonInTestStruc.ASslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice\"") - } else { - r.EncodeString(`AI64slice`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AnonInTestStruc.AI64slice, e) - } // end block: if x.AnonInTestStruc.AI64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64slice\"") - } else { - r.EncodeString(`AUi64slice`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AnonInTestStruc.AUi64slice, e) - } // end block: if x.AnonInTestStruc.AUi64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF64slice\"") - } else { - r.EncodeString(`AF64slice`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.AnonInTestStruc.AF64slice, e) - } // end block: if x.AnonInTestStruc.AF64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF32slice\"") - } else { - r.EncodeString(`AF32slice`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.AnonInTestStruc.AF32slice, e) - } // end block: if x.AnonInTestStruc.AF32slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16\"") - } else { - r.EncodeString(`AMSU16`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AnonInTestStruc.AMSU16), e) - } // end block: if x.AnonInTestStruc.AMSU16 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64arr0\"") - } else { - r.EncodeString(`AI64arr0`) - } - z.EncWriteMapElemValue() - yy155 := &x.AnonInTestStruc.AI64arr0 - h.encArray0int64((*[0]int64)(yy155), e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice0\"") - } else { - r.EncodeString(`AI64slice0`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.AnonInTestStruc.AI64slice0, e) - } // end block: if x.AnonInTestStruc.AI64slice0 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64sliceN\"") - } else { - r.EncodeString(`AUi64sliceN`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.AnonInTestStruc.AUi64sliceN, e) - } // end block: if x.AnonInTestStruc.AUi64sliceN slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16N\"") - } else { - r.EncodeString(`AMSU16N`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AnonInTestStruc.AMSU16N), e) - } // end block: if x.AnonInTestStruc.AMSU16N map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16E\"") - } else { - r.EncodeString(`AMSU16E`) - } - z.EncWriteMapElemValue() - if x.AnonInTestStruc.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.AnonInTestStruc.AMSU16E), e) - } // end block: if x.AnonInTestStruc.AMSU16E map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"NotAnon\"") - } else { - r.EncodeString(`NotAnon`) - } - z.EncWriteMapElemValue() - yy161 := &x.NotAnon - yy161.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nmap\"") - } else { - r.EncodeString(`Nmap`) - } - z.EncWriteMapElemValue() - if x.Nmap == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.Nmap, e) - } // end block: if x.Nmap map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nslice\"") - } else { - r.EncodeString(`Nslice`) - } - z.EncWriteMapElemValue() - if x.Nslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.Nslice)) - } // end block: if x.Nslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nint64\"") - } else { - r.EncodeString(`Nint64`) - } - z.EncWriteMapElemValue() - if yyn54 { - r.EncodeNil() - } else { - yy165 := *x.Nint64 - r.EncodeInt(int64(yy165)) - } - z.EncWriteMapEnd() - } - } -} - -func (x *TestStrucCommon) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestStrucCommon{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestStrucCommon) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - case "I64": - x.I64 = (int64)(r.DecodeInt64()) - case "I32": - x.I32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "I16": - x.I16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "I8": - x.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "I64n": - x.I64n = (int64)(r.DecodeInt64()) - case "I32n": - x.I32n = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "I16n": - x.I16n = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "I8n": - x.I8n = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "Ui64": - x.Ui64 = (uint64)(r.DecodeUint64()) - case "Ui32": - x.Ui32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - case "Ui16": - x.Ui16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - case "Ui8": - x.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "F64": - x.F64 = (float64)(r.DecodeFloat64()) - case "F32": - x.F32 = (float32)(z.DecDecodeFloat32()) - case "B": - x.B = (bool)(r.DecodeBool()) - case "By": - x.By = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "Sslice": - z.F.DecSliceStringX(&x.Sslice, d) - case "I64slice": - z.F.DecSliceInt64X(&x.I64slice, d) - case "I16slice": - z.F.DecSliceInt16X(&x.I16slice, d) - case "Ui64slice": - z.F.DecSliceUint64X(&x.Ui64slice, d) - case "Ui8slice": - x.Ui8slice = r.DecodeBytes(([]byte)(x.Ui8slice), false) - case "Bslice": - z.F.DecSliceBoolX(&x.Bslice, d) - case "Byslice": - x.Byslice = r.DecodeBytes(([]byte)(x.Byslice), false) - case "BytesSlice": - z.F.DecSliceBytesX(&x.BytesSlice, d) - case "Iptrslice": - h.decSlicePtrtoint64((*[]*int64)(&x.Iptrslice), d) - case "WrapSliceInt64": - x.WrapSliceInt64.CodecDecodeSelf(d) - case "WrapSliceString": - x.WrapSliceString.CodecDecodeSelf(d) - case "Msi64": - z.F.DecMapStringInt64X(&x.Msi64, d) - case "Msbytes": - z.F.DecMapStringBytesX(&x.Msbytes, d) - case "Simplef": - x.Simplef.CodecDecodeSelf(d) - case "SstrUi64T": - h.decSlicestringUint64T((*[]stringUint64T)(&x.SstrUi64T), d) - case "MstrUi64T": - h.decMapstringPtrtostringUint64T((*map[string]*stringUint64T)(&x.MstrUi64T), d) - case "AS": - x.AnonInTestStruc.AS = (string)(string(r.DecodeStringAsBytes())) - case "AI64": - x.AnonInTestStruc.AI64 = (int64)(r.DecodeInt64()) - case "AI16": - x.AnonInTestStruc.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "AUi64": - x.AnonInTestStruc.AUi64 = (uint64)(r.DecodeUint64()) - case "ASslice": - z.F.DecSliceStringX(&x.AnonInTestStruc.ASslice, d) - case "AI64slice": - z.F.DecSliceInt64X(&x.AnonInTestStruc.AI64slice, d) - case "AUi64slice": - z.F.DecSliceUint64X(&x.AnonInTestStruc.AUi64slice, d) - case "AF64slice": - z.F.DecSliceFloat64X(&x.AnonInTestStruc.AF64slice, d) - case "AF32slice": - z.F.DecSliceFloat32X(&x.AnonInTestStruc.AF32slice, d) - case "AMSU16": - h.decMapstringuint16((*map[string]uint16)(&x.AnonInTestStruc.AMSU16), d) - case "AI64arr0": - h.decArray0int64((*[0]int64)(&x.AnonInTestStruc.AI64arr0), d) - case "AI64slice0": - z.F.DecSliceInt64X(&x.AnonInTestStruc.AI64slice0, d) - case "AUi64sliceN": - z.F.DecSliceUint64X(&x.AnonInTestStruc.AUi64sliceN, d) - case "AMSU16N": - h.decMapstringuint16((*map[string]uint16)(&x.AnonInTestStruc.AMSU16N), d) - case "AMSU16E": - h.decMapstringuint16((*map[string]uint16)(&x.AnonInTestStruc.AMSU16E), d) - case "NotAnon": - x.NotAnon.CodecDecodeSelf(d) - case "Nmap": - z.F.DecMapStringBoolX(&x.Nmap, d) - case "Nslice": - x.Nslice = r.DecodeBytes(([]byte)(x.Nslice), false) - case "Nint64": - if r.TryNil() { - if x.Nint64 != nil { // remove the if-true - x.Nint64 = nil - } - } else { - if x.Nint64 == nil { - x.Nint64 = new(int64) - } - *x.Nint64 = (int64)(r.DecodeInt64()) - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestStrucCommon) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj83 int - var yyb83 bool - var yyhl83 bool = l >= 0 - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I64 = (int64)(r.DecodeInt64()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I64n = (int64)(r.DecodeInt64()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I32n = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I16n = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I8n = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui64 = (uint64)(r.DecodeUint64()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F64 = (float64)(r.DecodeFloat64()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F32 = (float32)(z.DecDecodeFloat32()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.By = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.Sslice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.I64slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt16X(&x.I16slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.Ui64slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ui8slice = r.DecodeBytes(([]byte)(x.Ui8slice), false) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBoolX(&x.Bslice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Byslice = r.DecodeBytes(([]byte)(x.Byslice), false) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBytesX(&x.BytesSlice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoint64((*[]*int64)(&x.Iptrslice), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.WrapSliceInt64.CodecDecodeSelf(d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.WrapSliceString.CodecDecodeSelf(d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringInt64X(&x.Msi64, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBytesX(&x.Msbytes, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Simplef.CodecDecodeSelf(d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicestringUint64T((*[]stringUint64T)(&x.SstrUi64T), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringPtrtostringUint64T((*map[string]*stringUint64T)(&x.MstrUi64T), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AnonInTestStruc.AS = (string)(string(r.DecodeStringAsBytes())) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AnonInTestStruc.AI64 = (int64)(r.DecodeInt64()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AnonInTestStruc.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AnonInTestStruc.AUi64 = (uint64)(r.DecodeUint64()) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.AnonInTestStruc.ASslice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.AnonInTestStruc.AI64slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.AnonInTestStruc.AUi64slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat64X(&x.AnonInTestStruc.AF64slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat32X(&x.AnonInTestStruc.AF32slice, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.AnonInTestStruc.AMSU16), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray0int64((*[0]int64)(&x.AnonInTestStruc.AI64arr0), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.AnonInTestStruc.AI64slice0, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.AnonInTestStruc.AUi64sliceN, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.AnonInTestStruc.AMSU16N), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.AnonInTestStruc.AMSU16E), d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.NotAnon.CodecDecodeSelf(d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBoolX(&x.Nmap, d) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Nslice = r.DecodeBytes(([]byte)(x.Nslice), false) - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Nint64 != nil { // remove the if-true - x.Nint64 = nil - } - } else { - if x.Nint64 == nil { - x.Nint64 = new(int64) - } - *x.Nint64 = (int64)(r.DecodeInt64()) - } - for { - yyj83++ - if yyhl83 { - yyb83 = yyj83 > l - } else { - yyb83 = z.DecCheckBreak() - } - if yyb83 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj83-1, "") - } -} - -func (x *TestStruc) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyn54 bool = x.TestStrucCommon.Nint64 == nil - var yyn58 bool = x.Nteststruc == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(56) - z.EncWriteArrayElem() - r.EncodeString(string(x.TestStrucCommon.S)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I64)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I32)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I16)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I8)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I64n)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I32n)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I16n)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.I8n)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.TestStrucCommon.Ui64)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.TestStrucCommon.Ui32)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.TestStrucCommon.Ui16)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.TestStrucCommon.Ui8)) - z.EncWriteArrayElem() - r.EncodeFloat64(float64(x.TestStrucCommon.F64)) - z.EncWriteArrayElem() - r.EncodeFloat32(float32(x.TestStrucCommon.F32)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.TestStrucCommon.B)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.TestStrucCommon.By)) - z.EncWriteArrayElem() - if x.TestStrucCommon.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.Sslice, e) - } // end block: if x.TestStrucCommon.Sslice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.I64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.I64slice, e) - } // end block: if x.TestStrucCommon.I64slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.TestStrucCommon.I16slice, e) - } // end block: if x.TestStrucCommon.I16slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.Ui64slice, e) - } // end block: if x.TestStrucCommon.Ui64slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Ui8slice)) - } // end block: if x.TestStrucCommon.Ui8slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.TestStrucCommon.Bslice, e) - } // end block: if x.TestStrucCommon.Bslice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Byslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Byslice)) - } // end block: if x.TestStrucCommon.Byslice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.BytesSlice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.TestStrucCommon.BytesSlice, e) - } // end block: if x.TestStrucCommon.BytesSlice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.TestStrucCommon.Iptrslice), e) - } // end block: if x.TestStrucCommon.Iptrslice slice == nil - z.EncWriteArrayElem() - x.TestStrucCommon.WrapSliceInt64.CodecEncodeSelf(e) - z.EncWriteArrayElem() - x.TestStrucCommon.WrapSliceString.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.TestStrucCommon.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.TestStrucCommon.Msi64, e) - } // end block: if x.TestStrucCommon.Msi64 map == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Msbytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.TestStrucCommon.Msbytes, e) - } // end block: if x.TestStrucCommon.Msbytes map == nil - z.EncWriteArrayElem() - yy89 := &x.TestStrucCommon.Simplef - yy89.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.TestStrucCommon.SstrUi64T == nil { - r.EncodeNil() - } else { - h.encSlicestringUint64T(([]stringUint64T)(x.TestStrucCommon.SstrUi64T), e) - } // end block: if x.TestStrucCommon.SstrUi64T slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.MstrUi64T == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtostringUint64T((map[string]*stringUint64T)(x.TestStrucCommon.MstrUi64T), e) - } // end block: if x.TestStrucCommon.MstrUi64T map == nil - z.EncWriteArrayElem() - r.EncodeString(string(x.TestStrucCommon.AnonInTestStruc.AS)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI64)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI16)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.TestStrucCommon.AnonInTestStruc.AUi64)) - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.AnonInTestStruc.ASslice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.ASslice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.TestStrucCommon.AnonInTestStruc.AF64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF64slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.TestStrucCommon.AnonInTestStruc.AF32slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF32slice slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16 map == nil - z.EncWriteArrayElem() - yy103 := &x.TestStrucCommon.AnonInTestStruc.AI64arr0 - h.encArray0int64((*[0]int64)(yy103), e) - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice0, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice0 slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN slice == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16N), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16N map == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.AnonInTestStruc.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16E), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16E map == nil - z.EncWriteArrayElem() - yy109 := &x.TestStrucCommon.NotAnon - yy109.CodecEncodeSelf(e) - z.EncWriteArrayElem() - if x.TestStrucCommon.Nmap == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.TestStrucCommon.Nmap, e) - } // end block: if x.TestStrucCommon.Nmap map == nil - z.EncWriteArrayElem() - if x.TestStrucCommon.Nslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Nslice)) - } // end block: if x.TestStrucCommon.Nslice slice == nil - if yyn54 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy113 := *x.TestStrucCommon.Nint64 - r.EncodeInt(int64(yy113)) - } - z.EncWriteArrayElem() - if x.Mtsptr == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtoTestStruc((map[string]*TestStruc)(x.Mtsptr), e) - } // end block: if x.Mtsptr map == nil - z.EncWriteArrayElem() - if x.Mts == nil { - r.EncodeNil() - } else { - h.encMapstringTestStruc((map[string]TestStruc)(x.Mts), e) - } // end block: if x.Mts map == nil - z.EncWriteArrayElem() - if x.Its == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoTestStruc(([]*TestStruc)(x.Its), e) - } // end block: if x.Its slice == nil - if yyn58 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Nteststruc.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(56) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.TestStrucCommon.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64\"") - } else { - r.EncodeString(`I64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I32\"") - } else { - r.EncodeString(`I32`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16\"") - } else { - r.EncodeString(`I16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8\"") - } else { - r.EncodeString(`I8`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64n\"") - } else { - r.EncodeString(`I64n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I64n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I32n\"") - } else { - r.EncodeString(`I32n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I32n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16n\"") - } else { - r.EncodeString(`I16n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I16n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8n\"") - } else { - r.EncodeString(`I8n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I8n)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64\"") - } else { - r.EncodeString(`Ui64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui32\"") - } else { - r.EncodeString(`Ui32`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui16\"") - } else { - r.EncodeString(`Ui16`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8\"") - } else { - r.EncodeString(`Ui8`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui8)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F64\"") - } else { - r.EncodeString(`F64`) - } - z.EncWriteMapElemValue() - r.EncodeFloat64(float64(x.TestStrucCommon.F64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F32\"") - } else { - r.EncodeString(`F32`) - } - z.EncWriteMapElemValue() - r.EncodeFloat32(float32(x.TestStrucCommon.F32)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.TestStrucCommon.B)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"By\"") - } else { - r.EncodeString(`By`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.By)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Sslice\"") - } else { - r.EncodeString(`Sslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.Sslice, e) - } // end block: if x.TestStrucCommon.Sslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64slice\"") - } else { - r.EncodeString(`I64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.I64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.I64slice, e) - } // end block: if x.TestStrucCommon.I64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16slice\"") - } else { - r.EncodeString(`I16slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.TestStrucCommon.I16slice, e) - } // end block: if x.TestStrucCommon.I16slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64slice\"") - } else { - r.EncodeString(`Ui64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.Ui64slice, e) - } // end block: if x.TestStrucCommon.Ui64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8slice\"") - } else { - r.EncodeString(`Ui8slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Ui8slice)) - } // end block: if x.TestStrucCommon.Ui8slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Bslice\"") - } else { - r.EncodeString(`Bslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.TestStrucCommon.Bslice, e) - } // end block: if x.TestStrucCommon.Bslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Byslice\"") - } else { - r.EncodeString(`Byslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Byslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Byslice)) - } // end block: if x.TestStrucCommon.Byslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"BytesSlice\"") - } else { - r.EncodeString(`BytesSlice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.BytesSlice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.TestStrucCommon.BytesSlice, e) - } // end block: if x.TestStrucCommon.BytesSlice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Iptrslice\"") - } else { - r.EncodeString(`Iptrslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.TestStrucCommon.Iptrslice), e) - } // end block: if x.TestStrucCommon.Iptrslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceInt64\"") - } else { - r.EncodeString(`WrapSliceInt64`) - } - z.EncWriteMapElemValue() - x.TestStrucCommon.WrapSliceInt64.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceString\"") - } else { - r.EncodeString(`WrapSliceString`) - } - z.EncWriteMapElemValue() - x.TestStrucCommon.WrapSliceString.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msi64\"") - } else { - r.EncodeString(`Msi64`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.TestStrucCommon.Msi64, e) - } // end block: if x.TestStrucCommon.Msi64 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msbytes\"") - } else { - r.EncodeString(`Msbytes`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Msbytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.TestStrucCommon.Msbytes, e) - } // end block: if x.TestStrucCommon.Msbytes map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Simplef\"") - } else { - r.EncodeString(`Simplef`) - } - z.EncWriteMapElemValue() - yy149 := &x.TestStrucCommon.Simplef - yy149.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"SstrUi64T\"") - } else { - r.EncodeString(`SstrUi64T`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.SstrUi64T == nil { - r.EncodeNil() - } else { - h.encSlicestringUint64T(([]stringUint64T)(x.TestStrucCommon.SstrUi64T), e) - } // end block: if x.TestStrucCommon.SstrUi64T slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"MstrUi64T\"") - } else { - r.EncodeString(`MstrUi64T`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.MstrUi64T == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtostringUint64T((map[string]*stringUint64T)(x.TestStrucCommon.MstrUi64T), e) - } // end block: if x.TestStrucCommon.MstrUi64T map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AS\"") - } else { - r.EncodeString(`AS`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.TestStrucCommon.AnonInTestStruc.AS)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64\"") - } else { - r.EncodeString(`AI64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI16\"") - } else { - r.EncodeString(`AI16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI16)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64\"") - } else { - r.EncodeString(`AUi64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.AnonInTestStruc.AUi64)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"ASslice\"") - } else { - r.EncodeString(`ASslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.AnonInTestStruc.ASslice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.ASslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice\"") - } else { - r.EncodeString(`AI64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64slice\"") - } else { - r.EncodeString(`AUi64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF64slice\"") - } else { - r.EncodeString(`AF64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.TestStrucCommon.AnonInTestStruc.AF64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF64slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF32slice\"") - } else { - r.EncodeString(`AF32slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.TestStrucCommon.AnonInTestStruc.AF32slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF32slice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16\"") - } else { - r.EncodeString(`AMSU16`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16 map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64arr0\"") - } else { - r.EncodeString(`AI64arr0`) - } - z.EncWriteMapElemValue() - yy163 := &x.TestStrucCommon.AnonInTestStruc.AI64arr0 - h.encArray0int64((*[0]int64)(yy163), e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice0\"") - } else { - r.EncodeString(`AI64slice0`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice0, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice0 slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64sliceN\"") - } else { - r.EncodeString(`AUi64sliceN`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16N\"") - } else { - r.EncodeString(`AMSU16N`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16N), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16N map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16E\"") - } else { - r.EncodeString(`AMSU16E`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16E), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16E map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"NotAnon\"") - } else { - r.EncodeString(`NotAnon`) - } - z.EncWriteMapElemValue() - yy169 := &x.TestStrucCommon.NotAnon - yy169.CodecEncodeSelf(e) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nmap\"") - } else { - r.EncodeString(`Nmap`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Nmap == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.TestStrucCommon.Nmap, e) - } // end block: if x.TestStrucCommon.Nmap map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nslice\"") - } else { - r.EncodeString(`Nslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Nslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Nslice)) - } // end block: if x.TestStrucCommon.Nslice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nint64\"") - } else { - r.EncodeString(`Nint64`) - } - z.EncWriteMapElemValue() - if yyn54 { - r.EncodeNil() - } else { - yy173 := *x.TestStrucCommon.Nint64 - r.EncodeInt(int64(yy173)) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mtsptr\"") - } else { - r.EncodeString(`Mtsptr`) - } - z.EncWriteMapElemValue() - if x.Mtsptr == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtoTestStruc((map[string]*TestStruc)(x.Mtsptr), e) - } // end block: if x.Mtsptr map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mts\"") - } else { - r.EncodeString(`Mts`) - } - z.EncWriteMapElemValue() - if x.Mts == nil { - r.EncodeNil() - } else { - h.encMapstringTestStruc((map[string]TestStruc)(x.Mts), e) - } // end block: if x.Mts map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Its\"") - } else { - r.EncodeString(`Its`) - } - z.EncWriteMapElemValue() - if x.Its == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoTestStruc(([]*TestStruc)(x.Its), e) - } // end block: if x.Its slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nteststruc\"") - } else { - r.EncodeString(`Nteststruc`) - } - z.EncWriteMapElemValue() - if yyn58 { - r.EncodeNil() - } else { - x.Nteststruc.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() - } - } -} - -func (x *TestStruc) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestStruc{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestStruc) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.TestStrucCommon.S = (string)(string(r.DecodeStringAsBytes())) - case "I64": - x.TestStrucCommon.I64 = (int64)(r.DecodeInt64()) - case "I32": - x.TestStrucCommon.I32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "I16": - x.TestStrucCommon.I16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "I8": - x.TestStrucCommon.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "I64n": - x.TestStrucCommon.I64n = (int64)(r.DecodeInt64()) - case "I32n": - x.TestStrucCommon.I32n = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "I16n": - x.TestStrucCommon.I16n = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "I8n": - x.TestStrucCommon.I8n = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "Ui64": - x.TestStrucCommon.Ui64 = (uint64)(r.DecodeUint64()) - case "Ui32": - x.TestStrucCommon.Ui32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - case "Ui16": - x.TestStrucCommon.Ui16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - case "Ui8": - x.TestStrucCommon.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "F64": - x.TestStrucCommon.F64 = (float64)(r.DecodeFloat64()) - case "F32": - x.TestStrucCommon.F32 = (float32)(z.DecDecodeFloat32()) - case "B": - x.TestStrucCommon.B = (bool)(r.DecodeBool()) - case "By": - x.TestStrucCommon.By = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "Sslice": - z.F.DecSliceStringX(&x.TestStrucCommon.Sslice, d) - case "I64slice": - z.F.DecSliceInt64X(&x.TestStrucCommon.I64slice, d) - case "I16slice": - z.F.DecSliceInt16X(&x.TestStrucCommon.I16slice, d) - case "Ui64slice": - z.F.DecSliceUint64X(&x.TestStrucCommon.Ui64slice, d) - case "Ui8slice": - x.TestStrucCommon.Ui8slice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Ui8slice), false) - case "Bslice": - z.F.DecSliceBoolX(&x.TestStrucCommon.Bslice, d) - case "Byslice": - x.TestStrucCommon.Byslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Byslice), false) - case "BytesSlice": - z.F.DecSliceBytesX(&x.TestStrucCommon.BytesSlice, d) - case "Iptrslice": - h.decSlicePtrtoint64((*[]*int64)(&x.TestStrucCommon.Iptrslice), d) - case "WrapSliceInt64": - x.TestStrucCommon.WrapSliceInt64.CodecDecodeSelf(d) - case "WrapSliceString": - x.TestStrucCommon.WrapSliceString.CodecDecodeSelf(d) - case "Msi64": - z.F.DecMapStringInt64X(&x.TestStrucCommon.Msi64, d) - case "Msbytes": - z.F.DecMapStringBytesX(&x.TestStrucCommon.Msbytes, d) - case "Simplef": - x.TestStrucCommon.Simplef.CodecDecodeSelf(d) - case "SstrUi64T": - h.decSlicestringUint64T((*[]stringUint64T)(&x.TestStrucCommon.SstrUi64T), d) - case "MstrUi64T": - h.decMapstringPtrtostringUint64T((*map[string]*stringUint64T)(&x.TestStrucCommon.MstrUi64T), d) - case "AS": - x.TestStrucCommon.AnonInTestStruc.AS = (string)(string(r.DecodeStringAsBytes())) - case "AI64": - x.TestStrucCommon.AnonInTestStruc.AI64 = (int64)(r.DecodeInt64()) - case "AI16": - x.TestStrucCommon.AnonInTestStruc.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "AUi64": - x.TestStrucCommon.AnonInTestStruc.AUi64 = (uint64)(r.DecodeUint64()) - case "ASslice": - z.F.DecSliceStringX(&x.TestStrucCommon.AnonInTestStruc.ASslice, d) - case "AI64slice": - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice, d) - case "AUi64slice": - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64slice, d) - case "AF64slice": - z.F.DecSliceFloat64X(&x.TestStrucCommon.AnonInTestStruc.AF64slice, d) - case "AF32slice": - z.F.DecSliceFloat32X(&x.TestStrucCommon.AnonInTestStruc.AF32slice, d) - case "AMSU16": - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16), d) - case "AI64arr0": - h.decArray0int64((*[0]int64)(&x.TestStrucCommon.AnonInTestStruc.AI64arr0), d) - case "AI64slice0": - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice0, d) - case "AUi64sliceN": - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, d) - case "AMSU16N": - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16N), d) - case "AMSU16E": - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16E), d) - case "NotAnon": - x.TestStrucCommon.NotAnon.CodecDecodeSelf(d) - case "Nmap": - z.F.DecMapStringBoolX(&x.TestStrucCommon.Nmap, d) - case "Nslice": - x.TestStrucCommon.Nslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Nslice), false) - case "Nint64": - if r.TryNil() { - if x.TestStrucCommon.Nint64 != nil { // remove the if-true - x.TestStrucCommon.Nint64 = nil - } - } else { - if x.TestStrucCommon.Nint64 == nil { - x.TestStrucCommon.Nint64 = new(int64) - } - *x.TestStrucCommon.Nint64 = (int64)(r.DecodeInt64()) - } - case "Mtsptr": - h.decMapstringPtrtoTestStruc((*map[string]*TestStruc)(&x.Mtsptr), d) - case "Mts": - h.decMapstringTestStruc((*map[string]TestStruc)(&x.Mts), d) - case "Its": - h.decSlicePtrtoTestStruc((*[]*TestStruc)(&x.Its), d) - case "Nteststruc": - if r.TryNil() { - if x.Nteststruc != nil { // remove the if-true - x.Nteststruc = nil - } - } else { - if x.Nteststruc == nil { - x.Nteststruc = new(TestStruc) - } - x.Nteststruc.CodecDecodeSelf(d) - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestStruc) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj90 int - var yyb90 bool - var yyhl90 bool = l >= 0 - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.S = (string)(string(r.DecodeStringAsBytes())) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I64 = (int64)(r.DecodeInt64()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I64n = (int64)(r.DecodeInt64()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I32n = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I16n = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I8n = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui64 = (uint64)(r.DecodeUint64()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.F64 = (float64)(r.DecodeFloat64()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.F32 = (float32)(z.DecDecodeFloat32()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.B = (bool)(r.DecodeBool()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.By = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.TestStrucCommon.Sslice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.TestStrucCommon.I64slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt16X(&x.TestStrucCommon.I16slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.TestStrucCommon.Ui64slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui8slice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Ui8slice), false) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBoolX(&x.TestStrucCommon.Bslice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Byslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Byslice), false) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBytesX(&x.TestStrucCommon.BytesSlice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoint64((*[]*int64)(&x.TestStrucCommon.Iptrslice), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.WrapSliceInt64.CodecDecodeSelf(d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.WrapSliceString.CodecDecodeSelf(d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringInt64X(&x.TestStrucCommon.Msi64, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBytesX(&x.TestStrucCommon.Msbytes, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Simplef.CodecDecodeSelf(d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicestringUint64T((*[]stringUint64T)(&x.TestStrucCommon.SstrUi64T), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringPtrtostringUint64T((*map[string]*stringUint64T)(&x.TestStrucCommon.MstrUi64T), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AS = (string)(string(r.DecodeStringAsBytes())) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AI64 = (int64)(r.DecodeInt64()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AUi64 = (uint64)(r.DecodeUint64()) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.TestStrucCommon.AnonInTestStruc.ASslice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat64X(&x.TestStrucCommon.AnonInTestStruc.AF64slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat32X(&x.TestStrucCommon.AnonInTestStruc.AF32slice, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray0int64((*[0]int64)(&x.TestStrucCommon.AnonInTestStruc.AI64arr0), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice0, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16N), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16E), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.NotAnon.CodecDecodeSelf(d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBoolX(&x.TestStrucCommon.Nmap, d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Nslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Nslice), false) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.TestStrucCommon.Nint64 != nil { // remove the if-true - x.TestStrucCommon.Nint64 = nil - } - } else { - if x.TestStrucCommon.Nint64 == nil { - x.TestStrucCommon.Nint64 = new(int64) - } - *x.TestStrucCommon.Nint64 = (int64)(r.DecodeInt64()) - } - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringPtrtoTestStruc((*map[string]*TestStruc)(&x.Mtsptr), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringTestStruc((*map[string]TestStruc)(&x.Mts), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoTestStruc((*[]*TestStruc)(&x.Its), d) - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Nteststruc != nil { // remove the if-true - x.Nteststruc = nil - } - } else { - if x.Nteststruc == nil { - x.Nteststruc = new(TestStruc) - } - x.Nteststruc.CodecDecodeSelf(d) - } - for { - yyj90++ - if yyhl90 { - yyb90 = yyj90 > l - } else { - yyb90 = z.DecCheckBreak() - } - if yyb90 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj90-1, "") - } -} - -func (x *codecgenA) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - if x.ZZ == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.ZZ)) - } // end block: if x.ZZ slice == nil - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"ZZ\"") - } else { - r.EncodeString(`ZZ`) - } - z.EncWriteMapElemValue() - if x.ZZ == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.ZZ)) - } // end block: if x.ZZ slice == nil - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenA) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenA{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenA) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "ZZ": - x.ZZ = r.DecodeBytes(([]byte)(x.ZZ), false) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenA) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.ZZ = r.DecodeBytes(([]byte)(x.ZZ), false) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *codecgenB) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - yy4 := &x.AA - yy4.CodecEncodeSelf(e) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AA\"") - } else { - r.EncodeString(`AA`) - } - z.EncWriteMapElemValue() - yy6 := &x.AA - yy6.CodecEncodeSelf(e) - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenB) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenB{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenB) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "AA": - x.AA.CodecDecodeSelf(d) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenB) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.AA.CodecDecodeSelf(d) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *codecgenC) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyq2 = [1]bool{ // should field at this index be written? - false || codecSelfer19780False() || len(x.BB.AA.ZZ) != 0, // BB - } - _ = yyq2 - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - if yyq2[0] { - yy4 := &x.BB - yy4.CodecEncodeSelf(e) - } else { - r.EncodeNil() - } - z.EncWriteArrayEnd() - } else { - var yynn2 int - for _, b := range yyq2 { - if b { - yynn2++ - } - } - z.EncWriteMapStart(yynn2) - yynn2 = 0 - if yyq2[0] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"BB\"") - } else { - r.EncodeString(`BB`) - } - z.EncWriteMapElemValue() - yy6 := &x.BB - yy6.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenC) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenC{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenC) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "BB": - x.BB.CodecDecodeSelf(d) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenC) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.BB.CodecDecodeSelf(d) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *TestCodecgenG) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestCodecgenG)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"TestCodecgenG\"") - } else { - r.EncodeString(`TestCodecgenG`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestCodecgenG)) - z.EncWriteMapEnd() - } - } -} - -func (x *TestCodecgenG) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestCodecgenG{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestCodecgenG) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "TestCodecgenG": - x.TestCodecgenG = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestCodecgenG) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestCodecgenG = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *codecgenH) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.TestCodecgenG.TestCodecgenG)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"TestCodecgenG\"") - } else { - r.EncodeString(`TestCodecgenG`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestCodecgenG.TestCodecgenG)) - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenH) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenH{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenH) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "TestCodecgenG": - x.TestCodecgenG.TestCodecgenG = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenH) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestCodecgenG.TestCodecgenG = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *codecgenI) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.codecgenH.TestCodecgenG.TestCodecgenG)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"TestCodecgenG\"") - } else { - r.EncodeString(`TestCodecgenG`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.codecgenH.TestCodecgenG.TestCodecgenG)) - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenI) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenI{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenI) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "TestCodecgenG": - x.codecgenH.TestCodecgenG.TestCodecgenG = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenI) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.codecgenH.TestCodecgenG.TestCodecgenG = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *codecgenK) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.X)) - z.EncWriteArrayElem() - r.EncodeString(string(x.Y)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"X\"") - } else { - r.EncodeString(`X`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.X)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Y\"") - } else { - r.EncodeString(`Y`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.Y)) - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenK) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenK{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenK) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "X": - x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - case "Y": - x.Y = (string)(string(r.DecodeStringAsBytes())) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenK) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Y = (string)(string(r.DecodeStringAsBytes())) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *codecgenL) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.X)) - z.EncWriteArrayElem() - r.EncodeUint(uint64(x.Y)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"X\"") - } else { - r.EncodeString(`X`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.X)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Y\"") - } else { - r.EncodeString(`Y`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.Y)) - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenL) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenL{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenL) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "X": - x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - case "Y": - x.Y = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenL) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Y = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *codecgenM) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.codecgenK.X)) - z.EncWriteArrayElem() - r.EncodeString(string(x.codecgenK.Y)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"X\"") - } else { - r.EncodeString(`X`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.codecgenK.X)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Y\"") - } else { - r.EncodeString(`Y`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.codecgenK.Y)) - z.EncWriteMapEnd() - } - } -} - -func (x *codecgenM) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = codecgenM{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *codecgenM) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "X": - x.codecgenK.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - case "Y": - x.codecgenK.Y = (string)(string(r.DecodeStringAsBytes())) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *codecgenM) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.codecgenK.X = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.codecgenK.Y = (string)(string(r.DecodeStringAsBytes())) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *testStrucKeyTypeT0) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.F)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F\"") - } else { - r.EncodeString(`F`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.F)) - z.EncWriteMapEnd() - } - } -} - -func (x *testStrucKeyTypeT0) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testStrucKeyTypeT0{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testStrucKeyTypeT0) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "F": - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testStrucKeyTypeT0) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *testStrucKeyTypeT1) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.F)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"FFFF\"") - } else { - r.EncodeString(`FFFF`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.F)) - z.EncWriteMapEnd() - } - } -} - -func (x *testStrucKeyTypeT1) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testStrucKeyTypeT1{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testStrucKeyTypeT1) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "FFFF": - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testStrucKeyTypeT1) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *testStrucKeyTypeT2) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.F)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - r.EncodeInt(z.M.Int(strconv.ParseInt(`-1`, 10, 64))) - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.F)) - z.EncWriteMapEnd() - } - } -} - -func (x *testStrucKeyTypeT2) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testStrucKeyTypeT2{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testStrucKeyTypeT2) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(strconv.AppendInt(z.DecScratchArrayBuffer()[:0], r.DecodeInt64(), 10)) - z.DecReadMapElemValue() - switch yys3 { - case "-1": - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testStrucKeyTypeT2) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *testStrucKeyTypeT3) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.F)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - r.EncodeUint(z.M.Uint(strconv.ParseUint(`1`, 10, 64))) - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.F)) - z.EncWriteMapEnd() - } - } -} - -func (x *testStrucKeyTypeT3) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testStrucKeyTypeT3{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testStrucKeyTypeT3) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(strconv.AppendUint(z.DecScratchArrayBuffer()[:0], r.DecodeUint64(), 10)) - z.DecReadMapElemValue() - switch yys3 { - case "1": - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testStrucKeyTypeT3) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *testStrucKeyTypeT4) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.F)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - r.EncodeFloat64(z.M.Float(strconv.ParseFloat(`2.5`, 64))) - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.F)) - z.EncWriteMapEnd() - } - } -} - -func (x *testStrucKeyTypeT4) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testStrucKeyTypeT4{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testStrucKeyTypeT4) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(strconv.AppendFloat(z.DecScratchArrayBuffer()[:0], r.DecodeFloat64(), 'f', -1, 64)) - z.DecReadMapElemValue() - switch yys3 { - case "2.5": - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testStrucKeyTypeT4) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x Bbool) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - r.EncodeBool(bool(x)) -} - -func (x *Bbool) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *x = (Bbool)(r.DecodeBool()) -} - -func (x *Aarray) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.encAarray((*Aarray)(x), e) - } -} - -func (x *Aarray) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.decAarray((*Aarray)(x), d) -} - -func (x Sstring) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - r.EncodeString(string(x)) -} - -func (x *Sstring) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *x = (Sstring)(string(r.DecodeStringAsBytes())) -} - -func (x *Sstructsmall) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(1) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.A)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(1) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"A\"") - } else { - r.EncodeString(`A`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.A)) - z.EncWriteMapEnd() - } - } -} - -func (x *Sstructsmall) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = Sstructsmall{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *Sstructsmall) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "A": - x.A = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *Sstructsmall) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj5 int - var yyb5 bool - var yyhl5 bool = l >= 0 - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.A = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - for { - yyj5++ - if yyhl5 { - yyb5 = yyj5 > l - } else { - yyb5 = z.DecCheckBreak() - } - if yyb5 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj5-1, "") - } -} - -func (x *Sstructbig) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyn5 bool = x.Ssmallptr == nil - var yyn6 bool = x.Ssmall == nil - var yyn7 bool = x.Sptr == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(5) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.A)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - if yyn5 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Ssmallptr.CodecEncodeSelf(e) - } - if yyn6 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Ssmall.CodecEncodeSelf(e) - } - if yyn7 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Sptr.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(5) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"A\"") - } else { - r.EncodeString(`A`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.A)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ssmallptr\"") - } else { - r.EncodeString(`Ssmallptr`) - } - z.EncWriteMapElemValue() - if yyn5 { - r.EncodeNil() - } else { - x.Ssmallptr.CodecEncodeSelf(e) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ssmall\"") - } else { - r.EncodeString(`Ssmall`) - } - z.EncWriteMapElemValue() - if yyn6 { - r.EncodeNil() - } else { - x.Ssmall.CodecEncodeSelf(e) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Sptr\"") - } else { - r.EncodeString(`Sptr`) - } - z.EncWriteMapElemValue() - if yyn7 { - r.EncodeNil() - } else { - x.Sptr.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() - } - } -} - -func (x *Sstructbig) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = Sstructbig{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *Sstructbig) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "A": - x.A = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - case "B": - x.B = (bool)(r.DecodeBool()) - case "Ssmallptr": - if r.TryNil() { - if x.Ssmallptr != nil { // remove the if-true - x.Ssmallptr = nil - } - } else { - if x.Ssmallptr == nil { - x.Ssmallptr = new(Sstructsmall) - } - x.Ssmallptr.CodecDecodeSelf(d) - } - case "Ssmall": - if r.TryNil() { - if x.Ssmall != nil { // remove the if-true - x.Ssmall = nil - } - } else { - if x.Ssmall == nil { - x.Ssmall = new(Sstructsmall) - } - x.Ssmall.CodecDecodeSelf(d) - } - case "Sptr": - if r.TryNil() { - if x.Sptr != nil { // remove the if-true - x.Sptr = nil - } - } else { - if x.Sptr == nil { - x.Sptr = new(Sstructbig) - } - x.Sptr.CodecDecodeSelf(d) - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *Sstructbig) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj9 int - var yyb9 bool - var yyhl9 bool = l >= 0 - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.A = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Ssmallptr != nil { // remove the if-true - x.Ssmallptr = nil - } - } else { - if x.Ssmallptr == nil { - x.Ssmallptr = new(Sstructsmall) - } - x.Ssmallptr.CodecDecodeSelf(d) - } - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Ssmall != nil { // remove the if-true - x.Ssmall = nil - } - } else { - if x.Ssmall == nil { - x.Ssmall = new(Sstructsmall) - } - x.Ssmall.CodecDecodeSelf(d) - } - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Sptr != nil { // remove the if-true - x.Sptr = nil - } - } else { - if x.Sptr == nil { - x.Sptr = new(Sstructbig) - } - x.Sptr.CodecDecodeSelf(d) - } - for { - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj9-1, "") - } -} - -func (x *SstructbigMapBySlice) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = true // struct tag has 'toArray' - var yyn5 bool = x.Ssmallptr == nil - var yyn6 bool = x.Ssmall == nil - var yyn7 bool = x.Sptr == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(5) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.A)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - if yyn5 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Ssmallptr.CodecEncodeSelf(e) - } - if yyn6 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Ssmall.CodecEncodeSelf(e) - } - if yyn7 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - x.Sptr.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(5) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"A\"") - } else { - r.EncodeString(`A`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.A)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ssmallptr\"") - } else { - r.EncodeString(`Ssmallptr`) - } - z.EncWriteMapElemValue() - if yyn5 { - r.EncodeNil() - } else { - x.Ssmallptr.CodecEncodeSelf(e) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ssmall\"") - } else { - r.EncodeString(`Ssmall`) - } - z.EncWriteMapElemValue() - if yyn6 { - r.EncodeNil() - } else { - x.Ssmall.CodecEncodeSelf(e) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Sptr\"") - } else { - r.EncodeString(`Sptr`) - } - z.EncWriteMapElemValue() - if yyn7 { - r.EncodeNil() - } else { - x.Sptr.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() - } - } -} - -func (x *SstructbigMapBySlice) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = SstructbigMapBySlice{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *SstructbigMapBySlice) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "A": - x.A = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - case "B": - x.B = (bool)(r.DecodeBool()) - case "Ssmallptr": - if r.TryNil() { - if x.Ssmallptr != nil { // remove the if-true - x.Ssmallptr = nil - } - } else { - if x.Ssmallptr == nil { - x.Ssmallptr = new(Sstructsmall) - } - x.Ssmallptr.CodecDecodeSelf(d) - } - case "Ssmall": - if r.TryNil() { - if x.Ssmall != nil { // remove the if-true - x.Ssmall = nil - } - } else { - if x.Ssmall == nil { - x.Ssmall = new(Sstructsmall) - } - x.Ssmall.CodecDecodeSelf(d) - } - case "Sptr": - if r.TryNil() { - if x.Sptr != nil { // remove the if-true - x.Sptr = nil - } - } else { - if x.Sptr == nil { - x.Sptr = new(Sstructbig) - } - x.Sptr.CodecDecodeSelf(d) - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *SstructbigMapBySlice) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj9 int - var yyb9 bool - var yyhl9 bool = l >= 0 - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.A = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Ssmallptr != nil { // remove the if-true - x.Ssmallptr = nil - } - } else { - if x.Ssmallptr == nil { - x.Ssmallptr = new(Sstructsmall) - } - x.Ssmallptr.CodecDecodeSelf(d) - } - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Ssmall != nil { // remove the if-true - x.Ssmall = nil - } - } else { - if x.Ssmall == nil { - x.Ssmall = new(Sstructsmall) - } - x.Ssmall.CodecDecodeSelf(d) - } - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Sptr != nil { // remove the if-true - x.Sptr = nil - } - } else { - if x.Sptr == nil { - x.Sptr = new(Sstructbig) - } - x.Sptr.CodecDecodeSelf(d) - } - for { - yyj9++ - if yyhl9 { - yyb9 = yyj9 > l - } else { - yyb9 = z.DecCheckBreak() - } - if yyb9 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj9-1, "") - } -} - -func (x *tLowerFirstLetter) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I)) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I\"") - } else { - r.EncodeString(`I`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapEnd() - } - } -} - -func (x *tLowerFirstLetter) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = tLowerFirstLetter{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *tLowerFirstLetter) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "I": - x.I = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *tLowerFirstLetter) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x wrapInt64) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - r.EncodeInt(int64(x)) -} - -func (x *wrapInt64) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *x = (wrapInt64)(r.DecodeInt64()) -} - -func (x wrapUint8) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - r.EncodeUint(uint64(x)) -} - -func (x *wrapUint8) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *x = (wrapUint8)(z.C.UintV(r.DecodeUint64(), 8)) -} - -func (x wrapBytes) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - h.encwrapBytes((wrapBytes)(x), e) - } // end block: if x slice == nil -} - -func (x *wrapBytes) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - h.decwrapBytes((*wrapBytes)(x), d) -} - -func (x *AnonInTestStrucIntf) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyn7 bool = x.Tptr == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(5) - z.EncWriteArrayElem() - if x.Islice == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.Islice, e) - } // end block: if x.Islice slice == nil - z.EncWriteArrayElem() - if x.Ms == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(x.Ms, e) - } // end block: if x.Ms map == nil - z.EncWriteArrayElem() - z.EncFallback(x.Nintf) - z.EncWriteArrayElem() - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(x.T) - } else if yyxt11 := z.Extension(z.I2Rtid(x.T)); yyxt11 != nil { - z.EncExtension(x.T, yyxt11) - } else if z.EncBinary() { - z.EncBinaryMarshal(x.T) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(x.T) - } else { - z.EncFallback(x.T) - } - if yyn7 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - yy12 := *x.Tptr - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(yy12) - } else if yyxt13 := z.Extension(z.I2Rtid(yy12)); yyxt13 != nil { - z.EncExtension(yy12, yyxt13) - } else if z.EncBinary() { - z.EncBinaryMarshal(yy12) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(yy12) - } else { - z.EncFallback(yy12) - } - } - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(5) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Islice\"") - } else { - r.EncodeString(`Islice`) - } - z.EncWriteMapElemValue() - if x.Islice == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.Islice, e) - } // end block: if x.Islice slice == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ms\"") - } else { - r.EncodeString(`Ms`) - } - z.EncWriteMapElemValue() - if x.Ms == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(x.Ms, e) - } // end block: if x.Ms map == nil - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nintf\"") - } else { - r.EncodeString(`Nintf`) - } - z.EncWriteMapElemValue() - z.EncFallback(x.Nintf) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"T\"") - } else { - r.EncodeString(`T`) - } - z.EncWriteMapElemValue() - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(x.T) - } else if yyxt17 := z.Extension(z.I2Rtid(x.T)); yyxt17 != nil { - z.EncExtension(x.T, yyxt17) - } else if z.EncBinary() { - z.EncBinaryMarshal(x.T) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(x.T) - } else { - z.EncFallback(x.T) - } - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Tptr\"") - } else { - r.EncodeString(`Tptr`) - } - z.EncWriteMapElemValue() - if yyn7 { - r.EncodeNil() - } else { - yy18 := *x.Tptr - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(yy18) - } else if yyxt19 := z.Extension(z.I2Rtid(yy18)); yyxt19 != nil { - z.EncExtension(yy18, yyxt19) - } else if z.EncBinary() { - z.EncBinaryMarshal(yy18) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(yy18) - } else { - z.EncFallback(yy18) - } - } - z.EncWriteMapEnd() - } - } -} - -func (x *AnonInTestStrucIntf) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = AnonInTestStrucIntf{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *AnonInTestStrucIntf) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "Islice": - z.F.DecSliceIntfX(&x.Islice, d) - case "Ms": - z.F.DecMapStringIntfX(&x.Ms, d) - case "Nintf": - z.DecFallback(&x.Nintf, true) - case "T": - if !z.DecBasicHandle().TimeNotBuiltin { - x.T = r.DecodeTime() - } else if yyxt11 := z.Extension(z.I2Rtid(x.T)); yyxt11 != nil { - z.DecExtension(x.T, yyxt11) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(&x.T) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(&x.T) - } else { - z.DecFallback(&x.T, false) - } - case "Tptr": - if r.TryNil() { - if x.Tptr != nil { // remove the if-true - x.Tptr = nil - } - } else { - if x.Tptr == nil { - x.Tptr = new(time.Time) - } - if !z.DecBasicHandle().TimeNotBuiltin { - *x.Tptr = r.DecodeTime() - } else if yyxt13 := z.Extension(z.I2Rtid(x.Tptr)); yyxt13 != nil { - z.DecExtension(x.Tptr, yyxt13) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(x.Tptr) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(x.Tptr) - } else { - z.DecFallback(x.Tptr, false) - } - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *AnonInTestStrucIntf) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj14 int - var yyb14 bool - var yyhl14 bool = l >= 0 - yyj14++ - if yyhl14 { - yyb14 = yyj14 > l - } else { - yyb14 = z.DecCheckBreak() - } - if yyb14 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceIntfX(&x.Islice, d) - yyj14++ - if yyhl14 { - yyb14 = yyj14 > l - } else { - yyb14 = z.DecCheckBreak() - } - if yyb14 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringIntfX(&x.Ms, d) - yyj14++ - if yyhl14 { - yyb14 = yyj14 > l - } else { - yyb14 = z.DecCheckBreak() - } - if yyb14 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.DecFallback(&x.Nintf, true) - yyj14++ - if yyhl14 { - yyb14 = yyj14 > l - } else { - yyb14 = z.DecCheckBreak() - } - if yyb14 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if !z.DecBasicHandle().TimeNotBuiltin { - x.T = r.DecodeTime() - } else if yyxt22 := z.Extension(z.I2Rtid(x.T)); yyxt22 != nil { - z.DecExtension(x.T, yyxt22) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(&x.T) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(&x.T) - } else { - z.DecFallback(&x.T, false) - } - yyj14++ - if yyhl14 { - yyb14 = yyj14 > l - } else { - yyb14 = z.DecCheckBreak() - } - if yyb14 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Tptr != nil { // remove the if-true - x.Tptr = nil - } - } else { - if x.Tptr == nil { - x.Tptr = new(time.Time) - } - if !z.DecBasicHandle().TimeNotBuiltin { - *x.Tptr = r.DecodeTime() - } else if yyxt24 := z.Extension(z.I2Rtid(x.Tptr)); yyxt24 != nil { - z.DecExtension(x.Tptr, yyxt24) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(x.Tptr) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(x.Tptr) - } else { - z.DecFallback(x.Tptr, false) - } - } - for { - yyj14++ - if yyhl14 { - yyb14 = yyj14 > l - } else { - yyb14 = z.DecCheckBreak() - } - if yyb14 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj14-1, "") - } -} - -func (x *missingFielderT1) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapEnd() - } - } -} - -func (x *missingFielderT1) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = missingFielderT1{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *missingFielderT1) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - case "B": - x.B = (bool)(r.DecodeBool()) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *missingFielderT1) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *missingFielderT2) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(4) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - z.EncWriteArrayElem() - r.EncodeFloat64(float64(x.F)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(4) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F\"") - } else { - r.EncodeString(`F`) - } - z.EncWriteMapElemValue() - r.EncodeFloat64(float64(x.F)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I\"") - } else { - r.EncodeString(`I`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I)) - z.EncWriteMapEnd() - } - } -} - -func (x *missingFielderT2) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = missingFielderT2{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *missingFielderT2) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - case "B": - x.B = (bool)(r.DecodeBool()) - case "F": - x.F = (float64)(r.DecodeFloat64()) - case "I": - x.I = (int64)(r.DecodeInt64()) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *missingFielderT2) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj8 int - var yyb8 bool - var yyhl8 bool = l >= 0 - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.F = (float64)(r.DecodeFloat64()) - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I = (int64)(r.DecodeInt64()) - for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj8-1, "") - } -} - -func (x *testSelfExtHelper) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(3) - z.EncWriteArrayElem() - r.EncodeString(string(x.S)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.I)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.B)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(3) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I\"") - } else { - r.EncodeString(`I`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.I)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.B)) - z.EncWriteMapEnd() - } - } -} - -func (x *testSelfExtHelper) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = testSelfExtHelper{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *testSelfExtHelper) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.S = (string)(string(r.DecodeStringAsBytes())) - case "I": - x.I = (int64)(r.DecodeInt64()) - case "B": - x.B = (bool)(r.DecodeBool()) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *testSelfExtHelper) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj7 int - var yyb7 bool - var yyhl7 bool = l >= 0 - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.S = (string)(string(r.DecodeStringAsBytes())) - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.I = (int64)(r.DecodeInt64()) - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.B = (bool)(r.DecodeBool()) - for { - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj7-1, "") - } -} - -func (x *TestSelfExtImpl) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(3) - z.EncWriteArrayElem() - r.EncodeString(string(x.testSelfExtHelper.S)) - z.EncWriteArrayElem() - r.EncodeInt(int64(x.testSelfExtHelper.I)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.testSelfExtHelper.B)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(3) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.testSelfExtHelper.S)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I\"") - } else { - r.EncodeString(`I`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.testSelfExtHelper.I)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.testSelfExtHelper.B)) - z.EncWriteMapEnd() - } - } -} - -func (x *TestSelfExtImpl) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestSelfExtImpl{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestSelfExtImpl) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.testSelfExtHelper.S = (string)(string(r.DecodeStringAsBytes())) - case "I": - x.testSelfExtHelper.I = (int64)(r.DecodeInt64()) - case "B": - x.testSelfExtHelper.B = (bool)(r.DecodeBool()) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestSelfExtImpl) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj7 int - var yyb7 bool - var yyhl7 bool = l >= 0 - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.testSelfExtHelper.S = (string)(string(r.DecodeStringAsBytes())) - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.testSelfExtHelper.I = (int64)(r.DecodeInt64()) - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.testSelfExtHelper.B = (bool)(r.DecodeBool()) - for { - yyj7++ - if yyhl7 { - yyb7 = yyj7 > l - } else { - yyb7 = z.DecCheckBreak() - } - if yyb7 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj7-1, "") - } -} - -func (x *TestSelfExtImpl2) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - r.EncodeString(string(x.M)) - z.EncWriteArrayElem() - r.EncodeBool(bool(x.O)) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"M\"") - } else { - r.EncodeString(`M`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.M)) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"O\"") - } else { - r.EncodeString(`O`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.O)) - z.EncWriteMapEnd() - } - } -} - -func (x *TestSelfExtImpl2) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestSelfExtImpl2{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestSelfExtImpl2) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "M": - x.M = (string)(string(r.DecodeStringAsBytes())) - case "O": - x.O = (bool)(r.DecodeBool()) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestSelfExtImpl2) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj6 int - var yyb6 bool - var yyhl6 bool = l >= 0 - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.M = (string)(string(r.DecodeStringAsBytes())) - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.O = (bool)(r.DecodeBool()) - for { - yyj6++ - if yyhl6 { - yyb6 = yyj6 > l - } else { - yyb6 = z.DecCheckBreak() - } - if yyb6 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj6-1, "") - } -} - -func (x *TestTwoNakedInterfaces) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(2) - z.EncWriteArrayElem() - z.EncFallback(x.A) - z.EncWriteArrayElem() - z.EncFallback(x.B) - z.EncWriteArrayEnd() - } else { - z.EncWriteMapStart(2) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"A\"") - } else { - r.EncodeString(`A`) - } - z.EncWriteMapElemValue() - z.EncFallback(x.A) - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - z.EncFallback(x.B) - z.EncWriteMapEnd() - } - } -} - -func (x *TestTwoNakedInterfaces) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestTwoNakedInterfaces{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestTwoNakedInterfaces) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "A": - z.DecFallback(&x.A, true) - case "B": - z.DecFallback(&x.B, true) - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestTwoNakedInterfaces) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj8 int - var yyb8 bool - var yyhl8 bool = l >= 0 - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.DecFallback(&x.A, true) - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.DecFallback(&x.B, true) - for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = z.DecCheckBreak() - } - if yyb8 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj8-1, "") - } -} - -func (x *TestStrucFlex) CodecEncodeSelf(e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if x == nil { - r.EncodeNil() - } else { - yysep2 := !z.EncBinary() - yy2arr2 := z.EncBasicHandle().StructToArray - _, _ = yysep2, yy2arr2 - const yyr2 bool = false // struct tag has 'toArray' - var yyq2 = [77]bool{ // should field at this index be written? - x.S != "", // S - x.I64 != 0, // I64 - x.I32 != 0, // I32 - x.I16 != 0, // I16 - x.I8 != 0, // I8 - x.I64n != 0, // I64n - x.I32n != 0, // I32n - x.I16n != 0, // I16n - x.I8n != 0, // I8n - x.Ui64 != 0, // Ui64 - x.Ui32 != 0, // Ui32 - x.Ui16 != 0, // Ui16 - x.Ui8 != 0, // Ui8 - x.F64 != 0, // F64 - x.F32 != 0, // F32 - x.B, // B - x.By != 0, // By - len(x.Sslice) != 0, // Sslice - len(x.I64slice) != 0, // I64slice - len(x.I16slice) != 0, // I16slice - len(x.Ui64slice) != 0, // Ui64slice - len(x.Ui8slice) != 0, // Ui8slice - len(x.Bslice) != 0, // Bslice - len(x.Byslice) != 0, // Byslice - len(x.BytesSlice) != 0, // BytesSlice - len(x.Iptrslice) != 0, // Iptrslice - len(x.WrapSliceInt64) != 0, // WrapSliceInt64 - len(x.WrapSliceString) != 0, // WrapSliceString - len(x.Msi64) != 0, // Msi64 - len(x.Msbytes) != 0, // Msbytes - false || x.Simplef.S != "" || x.Simplef.I64 != 0 || x.Simplef.I8 != 0 || x.Simplef.Ui64 != 0 || x.Simplef.Ui8 != 0 || x.Simplef.F64 != 0 || x.Simplef.F32 != 0 || x.Simplef.B || len(x.Simplef.Sslice) != 0 || len(x.Simplef.I16slice) != 0 || len(x.Simplef.Ui64slice) != 0 || len(x.Simplef.Ui8slice) != 0 || len(x.Simplef.Bslice) != 0 || len(x.Simplef.Iptrslice) != 0 || len(x.Simplef.WrapSliceInt64) != 0 || len(x.Simplef.WrapSliceString) != 0 || len(x.Simplef.Msi64) != 0, // Simplef - len(x.SstrUi64T) != 0, // SstrUi64T - len(x.MstrUi64T) != 0, // MstrUi64T - x.AS != "", // AS - x.AI64 != 0, // AI64 - x.AI16 != 0, // AI16 - x.AUi64 != 0, // AUi64 - len(x.ASslice) != 0, // ASslice - len(x.AI64slice) != 0, // AI64slice - len(x.AUi64slice) != 0, // AUi64slice - len(x.AF64slice) != 0, // AF64slice - len(x.AF32slice) != 0, // AF32slice - len(x.AMSU16) != 0, // AMSU16 - len(x.AI64arr0) != 0, // AI64arr0 - len(x.AI64slice0) != 0, // AI64slice0 - len(x.AUi64sliceN) != 0, // AUi64sliceN - len(x.AMSU16N) != 0, // AMSU16N - len(x.AMSU16E) != 0, // AMSU16E - false || x.NotAnon.AS != "" || x.NotAnon.AI64 != 0 || x.NotAnon.AI16 != 0 || x.NotAnon.AUi64 != 0 || len(x.NotAnon.ASslice) != 0 || len(x.NotAnon.AI64slice) != 0 || len(x.NotAnon.AUi64slice) != 0 || len(x.NotAnon.AF64slice) != 0 || len(x.NotAnon.AF32slice) != 0 || len(x.NotAnon.AMSU16) != 0 || len(x.NotAnon.AI64arr0) != 0 || len(x.NotAnon.AI64slice0) != 0 || len(x.NotAnon.AUi64sliceN) != 0 || len(x.NotAnon.AMSU16N) != 0 || len(x.NotAnon.AMSU16E) != 0, // NotAnon - len(x.Nmap) != 0, // Nmap - len(x.Nslice) != 0, // Nslice - x.Nint64 != nil, // Nint64 - len(x.Chstr) != 0, // Chstr - len(x.Mis) != 0, // Mis - len(x.Mbu64) != 0, // Mbu64 - len(x.Miwu64s) != 0, // Miwu64s - len(x.Mfwss) != 0, // Mfwss - len(x.Mf32wss) != 0, // Mf32wss - len(x.Mui2wss) != 0, // Mui2wss - len(x.Msu2wss) != 0, // Msu2wss - x.Ci64 != 0, // Ci64 - len(x.Swrapbytes) != 0, // Swrapbytes - len(x.Swrapuint8) != 0, // Swrapuint8 - len(x.ArrStrUi64T) != 0, // ArrStrUi64T - len(x.Ui64array) != 0, // Ui64array - len(x.Ui64slicearray) != 0, // Ui64slicearray - len(x.SintfAarray) != 0, // SintfAarray - len(x.MstrUi64TSelf) != 0, // MstrUi64TSelf - x.AnonInTestStrucIntf != nil && len(x.Islice) != 0, // Islice - x.AnonInTestStrucIntf != nil && len(x.Ms) != 0, // Ms - x.AnonInTestStrucIntf != nil && x.Nintf != nil, // Nintf - x.AnonInTestStrucIntf != nil && !(x.T.IsZero()), // T - x.AnonInTestStrucIntf != nil && x.Tptr != nil, // Tptr - len(x.Mtsptr) != 0, // Mtsptr - len(x.Mts) != 0, // Mts - len(x.Its) != 0, // Its - x.Nteststruc != nil, // Nteststruc - } - _ = yyq2 - var yyn54 bool = x.TestStrucCommon.Nint64 == nil - var yyn71 bool = x.AnonInTestStrucIntf == nil - var yyn72 bool = x.AnonInTestStrucIntf == nil - var yyn73 bool = x.AnonInTestStrucIntf == nil - var yyn74 bool = x.AnonInTestStrucIntf == nil - var yyn75 bool = x.AnonInTestStrucIntf == nil || x.AnonInTestStrucIntf.Tptr == nil - var yyn79 bool = x.Nteststruc == nil - if yyr2 || yy2arr2 { - z.EncWriteArrayStart(77) - z.EncWriteArrayElem() - if yyq2[0] { - r.EncodeString(string(x.TestStrucCommon.S)) - } else { - r.EncodeString("") - } - z.EncWriteArrayElem() - if yyq2[1] { - r.EncodeInt(int64(x.TestStrucCommon.I64)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[2] { - r.EncodeInt(int64(x.TestStrucCommon.I32)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[3] { - r.EncodeInt(int64(x.TestStrucCommon.I16)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[4] { - r.EncodeInt(int64(x.TestStrucCommon.I8)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[5] { - r.EncodeInt(int64(x.TestStrucCommon.I64n)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[6] { - r.EncodeInt(int64(x.TestStrucCommon.I32n)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[7] { - r.EncodeInt(int64(x.TestStrucCommon.I16n)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[8] { - r.EncodeInt(int64(x.TestStrucCommon.I8n)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[9] { - r.EncodeUint(uint64(x.TestStrucCommon.Ui64)) - } else { - r.EncodeUint(0) - } - z.EncWriteArrayElem() - if yyq2[10] { - r.EncodeUint(uint64(x.TestStrucCommon.Ui32)) - } else { - r.EncodeUint(0) - } - z.EncWriteArrayElem() - if yyq2[11] { - r.EncodeUint(uint64(x.TestStrucCommon.Ui16)) - } else { - r.EncodeUint(0) - } - z.EncWriteArrayElem() - if yyq2[12] { - r.EncodeUint(uint64(x.TestStrucCommon.Ui8)) - } else { - r.EncodeUint(0) - } - z.EncWriteArrayElem() - if yyq2[13] { - r.EncodeFloat64(float64(x.TestStrucCommon.F64)) - } else { - r.EncodeFloat64(0) - } - z.EncWriteArrayElem() - if yyq2[14] { - r.EncodeFloat32(float32(x.TestStrucCommon.F32)) - } else { - r.EncodeFloat32(0) - } - z.EncWriteArrayElem() - if yyq2[15] { - r.EncodeBool(bool(x.TestStrucCommon.B)) - } else { - r.EncodeBool(false) - } - z.EncWriteArrayElem() - if yyq2[16] { - r.EncodeUint(uint64(x.TestStrucCommon.By)) - } else { - r.EncodeUint(0) - } - z.EncWriteArrayElem() - if yyq2[17] { - if x.TestStrucCommon.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.Sslice, e) - } // end block: if x.TestStrucCommon.Sslice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[18] { - if x.TestStrucCommon.I64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.I64slice, e) - } // end block: if x.TestStrucCommon.I64slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[19] { - if x.TestStrucCommon.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.TestStrucCommon.I16slice, e) - } // end block: if x.TestStrucCommon.I16slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[20] { - if x.TestStrucCommon.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.Ui64slice, e) - } // end block: if x.TestStrucCommon.Ui64slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[21] { - if x.TestStrucCommon.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Ui8slice)) - } // end block: if x.TestStrucCommon.Ui8slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[22] { - if x.TestStrucCommon.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.TestStrucCommon.Bslice, e) - } // end block: if x.TestStrucCommon.Bslice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[23] { - if x.TestStrucCommon.Byslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Byslice)) - } // end block: if x.TestStrucCommon.Byslice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[24] { - if x.TestStrucCommon.BytesSlice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.TestStrucCommon.BytesSlice, e) - } // end block: if x.TestStrucCommon.BytesSlice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[25] { - if x.TestStrucCommon.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.TestStrucCommon.Iptrslice), e) - } // end block: if x.TestStrucCommon.Iptrslice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[26] { - x.TestStrucCommon.WrapSliceInt64.CodecEncodeSelf(e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[27] { - x.TestStrucCommon.WrapSliceString.CodecEncodeSelf(e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[28] { - if x.TestStrucCommon.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.TestStrucCommon.Msi64, e) - } // end block: if x.TestStrucCommon.Msi64 map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[29] { - if x.TestStrucCommon.Msbytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.TestStrucCommon.Msbytes, e) - } // end block: if x.TestStrucCommon.Msbytes map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[30] { - yy110 := &x.TestStrucCommon.Simplef - yy110.CodecEncodeSelf(e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[31] { - if x.TestStrucCommon.SstrUi64T == nil { - r.EncodeNil() - } else { - h.encSlicestringUint64T(([]stringUint64T)(x.TestStrucCommon.SstrUi64T), e) - } // end block: if x.TestStrucCommon.SstrUi64T slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[32] { - if x.TestStrucCommon.MstrUi64T == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtostringUint64T((map[string]*stringUint64T)(x.TestStrucCommon.MstrUi64T), e) - } // end block: if x.TestStrucCommon.MstrUi64T map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[33] { - r.EncodeString(string(x.TestStrucCommon.AnonInTestStruc.AS)) - } else { - r.EncodeString("") - } - z.EncWriteArrayElem() - if yyq2[34] { - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI64)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[35] { - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI16)) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[36] { - r.EncodeUint(uint64(x.TestStrucCommon.AnonInTestStruc.AUi64)) - } else { - r.EncodeUint(0) - } - z.EncWriteArrayElem() - if yyq2[37] { - if x.TestStrucCommon.AnonInTestStruc.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.AnonInTestStruc.ASslice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.ASslice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[38] { - if x.TestStrucCommon.AnonInTestStruc.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[39] { - if x.TestStrucCommon.AnonInTestStruc.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[40] { - if x.TestStrucCommon.AnonInTestStruc.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.TestStrucCommon.AnonInTestStruc.AF64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF64slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[41] { - if x.TestStrucCommon.AnonInTestStruc.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.TestStrucCommon.AnonInTestStruc.AF32slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF32slice slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[42] { - if x.TestStrucCommon.AnonInTestStruc.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16 map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[43] { - yy124 := &x.TestStrucCommon.AnonInTestStruc.AI64arr0 - h.encArray0int64((*[0]int64)(yy124), e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[44] { - if x.TestStrucCommon.AnonInTestStruc.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice0, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice0 slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[45] { - if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[46] { - if x.TestStrucCommon.AnonInTestStruc.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16N), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16N map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[47] { - if x.TestStrucCommon.AnonInTestStruc.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16E), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16E map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[48] { - yy130 := &x.TestStrucCommon.NotAnon - yy130.CodecEncodeSelf(e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[49] { - if x.TestStrucCommon.Nmap == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.TestStrucCommon.Nmap, e) - } // end block: if x.TestStrucCommon.Nmap map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[50] { - if x.TestStrucCommon.Nslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Nslice)) - } // end block: if x.TestStrucCommon.Nslice slice == nil - } else { - r.EncodeNil() - } - if yyn54 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[51] { - yy134 := *x.TestStrucCommon.Nint64 - r.EncodeInt(int64(yy134)) - } else { - r.EncodeNil() - } - } - z.EncWriteArrayElem() - if yyq2[52] { - h.encChanstring((chan string)(x.Chstr), e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[53] { - if x.Mis == nil { - r.EncodeNil() - } else { - z.F.EncMapIntStringV(x.Mis, e) - } // end block: if x.Mis map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[54] { - if x.Mbu64 == nil { - r.EncodeNil() - } else { - h.encMapboolc3RydWN0IHt9((map[bool]struct{})(x.Mbu64), e) - } // end block: if x.Mbu64 map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[55] { - if x.Miwu64s == nil { - r.EncodeNil() - } else { - h.encMapintwrapUint64Slice((map[int]wrapUint64Slice)(x.Miwu64s), e) - } // end block: if x.Miwu64s map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[56] { - if x.Mfwss == nil { - r.EncodeNil() - } else { - h.encMapfloat64wrapStringSlice((map[float64]wrapStringSlice)(x.Mfwss), e) - } // end block: if x.Mfwss map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[57] { - if x.Mf32wss == nil { - r.EncodeNil() - } else { - h.encMapfloat32wrapStringSlice((map[float32]wrapStringSlice)(x.Mf32wss), e) - } // end block: if x.Mf32wss map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[58] { - if x.Mui2wss == nil { - r.EncodeNil() - } else { - h.encMapuint64wrapStringSlice((map[uint64]wrapStringSlice)(x.Mui2wss), e) - } // end block: if x.Mui2wss map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[59] { - if x.Msu2wss == nil { - r.EncodeNil() - } else { - h.encMapstringUint64TwrapStringSlice((map[stringUint64T]wrapStringSlice)(x.Msu2wss), e) - } // end block: if x.Msu2wss map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[60] { - x.Ci64.CodecEncodeSelf(e) - } else { - r.EncodeInt(0) - } - z.EncWriteArrayElem() - if yyq2[61] { - if x.Swrapbytes == nil { - r.EncodeNil() - } else { - h.encSlicewrapBytes(([]wrapBytes)(x.Swrapbytes), e) - } // end block: if x.Swrapbytes slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[62] { - if x.Swrapuint8 == nil { - r.EncodeNil() - } else { - h.encSlicewrapUint8(([]wrapUint8)(x.Swrapuint8), e) - } // end block: if x.Swrapuint8 slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[63] { - yy147 := &x.ArrStrUi64T - h.encArray4stringUint64T((*[4]stringUint64T)(yy147), e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[64] { - yy149 := &x.Ui64array - h.encArray4uint64((*[4]uint64)(yy149), e) - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[65] { - if x.Ui64slicearray == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoArray4uint64(([]*[4]uint64)(x.Ui64slicearray), e) - } // end block: if x.Ui64slicearray slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[66] { - if x.SintfAarray == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.SintfAarray, e) - } // end block: if x.SintfAarray slice == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[67] { - if x.MstrUi64TSelf == nil { - r.EncodeNil() - } else { - h.encMapstringUint64TPtrtostringUint64T((map[stringUint64T]*stringUint64T)(x.MstrUi64TSelf), e) - } // end block: if x.MstrUi64TSelf map == nil - } else { - r.EncodeNil() - } - if yyn71 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[68] { - if x.AnonInTestStrucIntf.Islice == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.AnonInTestStrucIntf.Islice, e) - } // end block: if x.AnonInTestStrucIntf.Islice slice == nil - } else { - r.EncodeNil() - } - } - if yyn72 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[69] { - if x.AnonInTestStrucIntf.Ms == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(x.AnonInTestStrucIntf.Ms, e) - } // end block: if x.AnonInTestStrucIntf.Ms map == nil - } else { - r.EncodeNil() - } - } - if yyn73 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[70] { - z.EncFallback(x.AnonInTestStrucIntf.Nintf) - } else { - r.EncodeNil() - } - } - if yyn74 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[71] { - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(x.AnonInTestStrucIntf.T) - } else if yyxt157 := z.Extension(z.I2Rtid(x.AnonInTestStrucIntf.T)); yyxt157 != nil { - z.EncExtension(x.AnonInTestStrucIntf.T, yyxt157) - } else if z.EncBinary() { - z.EncBinaryMarshal(x.AnonInTestStrucIntf.T) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(x.AnonInTestStrucIntf.T) - } else { - z.EncFallback(x.AnonInTestStrucIntf.T) - } - } else { - r.EncodeNil() - } - } - if yyn75 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[72] { - yy158 := *x.AnonInTestStrucIntf.Tptr - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(yy158) - } else if yyxt159 := z.Extension(z.I2Rtid(yy158)); yyxt159 != nil { - z.EncExtension(yy158, yyxt159) - } else if z.EncBinary() { - z.EncBinaryMarshal(yy158) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(yy158) - } else { - z.EncFallback(yy158) - } - } else { - r.EncodeNil() - } - } - z.EncWriteArrayElem() - if yyq2[73] { - if x.Mtsptr == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtoTestStrucFlex((map[string]*TestStrucFlex)(x.Mtsptr), e) - } // end block: if x.Mtsptr map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[74] { - if x.Mts == nil { - r.EncodeNil() - } else { - h.encMapstringTestStrucFlex((map[string]TestStrucFlex)(x.Mts), e) - } // end block: if x.Mts map == nil - } else { - r.EncodeNil() - } - z.EncWriteArrayElem() - if yyq2[75] { - if x.Its == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoTestStrucFlex(([]*TestStrucFlex)(x.Its), e) - } // end block: if x.Its slice == nil - } else { - r.EncodeNil() - } - if yyn79 { - z.EncWriteArrayElem() - r.EncodeNil() - } else { - z.EncWriteArrayElem() - if yyq2[76] { - x.Nteststruc.CodecEncodeSelf(e) - } else { - r.EncodeNil() - } - } - z.EncWriteArrayEnd() - } else { - var yynn2 int - for _, b := range yyq2 { - if b { - yynn2++ - } - } - z.EncWriteMapStart(yynn2) - yynn2 = 0 - if yyq2[0] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"S\"") - } else { - r.EncodeString(`S`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.TestStrucCommon.S)) - } - if yyq2[1] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64\"") - } else { - r.EncodeString(`I64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I64)) - } - if yyq2[2] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I32\"") - } else { - r.EncodeString(`I32`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I32)) - } - if yyq2[3] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16\"") - } else { - r.EncodeString(`I16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I16)) - } - if yyq2[4] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8\"") - } else { - r.EncodeString(`I8`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I8)) - } - if yyq2[5] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64n\"") - } else { - r.EncodeString(`I64n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I64n)) - } - if yyq2[6] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I32n\"") - } else { - r.EncodeString(`I32n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I32n)) - } - if yyq2[7] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16n\"") - } else { - r.EncodeString(`I16n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I16n)) - } - if yyq2[8] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I8n\"") - } else { - r.EncodeString(`I8n`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.I8n)) - } - if yyq2[9] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64\"") - } else { - r.EncodeString(`Ui64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui64)) - } - if yyq2[10] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui32\"") - } else { - r.EncodeString(`Ui32`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui32)) - } - if yyq2[11] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui16\"") - } else { - r.EncodeString(`Ui16`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui16)) - } - if yyq2[12] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8\"") - } else { - r.EncodeString(`Ui8`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.Ui8)) - } - if yyq2[13] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F64\"") - } else { - r.EncodeString(`F64`) - } - z.EncWriteMapElemValue() - r.EncodeFloat64(float64(x.TestStrucCommon.F64)) - } - if yyq2[14] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"F32\"") - } else { - r.EncodeString(`F32`) - } - z.EncWriteMapElemValue() - r.EncodeFloat32(float32(x.TestStrucCommon.F32)) - } - if yyq2[15] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"B\"") - } else { - r.EncodeString(`B`) - } - z.EncWriteMapElemValue() - r.EncodeBool(bool(x.TestStrucCommon.B)) - } - if yyq2[16] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"By\"") - } else { - r.EncodeString(`By`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.By)) - } - if yyq2[17] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Sslice\"") - } else { - r.EncodeString(`Sslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Sslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.Sslice, e) - } // end block: if x.TestStrucCommon.Sslice slice == nil - } - if yyq2[18] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I64slice\"") - } else { - r.EncodeString(`I64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.I64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.I64slice, e) - } // end block: if x.TestStrucCommon.I64slice slice == nil - } - if yyq2[19] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"I16slice\"") - } else { - r.EncodeString(`I16slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.I16slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt16V(x.TestStrucCommon.I16slice, e) - } // end block: if x.TestStrucCommon.I16slice slice == nil - } - if yyq2[20] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64slice\"") - } else { - r.EncodeString(`Ui64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Ui64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.Ui64slice, e) - } // end block: if x.TestStrucCommon.Ui64slice slice == nil - } - if yyq2[21] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui8slice\"") - } else { - r.EncodeString(`Ui8slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Ui8slice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Ui8slice)) - } // end block: if x.TestStrucCommon.Ui8slice slice == nil - } - if yyq2[22] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Bslice\"") - } else { - r.EncodeString(`Bslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Bslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBoolV(x.TestStrucCommon.Bslice, e) - } // end block: if x.TestStrucCommon.Bslice slice == nil - } - if yyq2[23] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Byslice\"") - } else { - r.EncodeString(`Byslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Byslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Byslice)) - } // end block: if x.TestStrucCommon.Byslice slice == nil - } - if yyq2[24] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"BytesSlice\"") - } else { - r.EncodeString(`BytesSlice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.BytesSlice == nil { - r.EncodeNil() - } else { - z.F.EncSliceBytesV(x.TestStrucCommon.BytesSlice, e) - } // end block: if x.TestStrucCommon.BytesSlice slice == nil - } - if yyq2[25] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Iptrslice\"") - } else { - r.EncodeString(`Iptrslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Iptrslice == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoint64(([]*int64)(x.TestStrucCommon.Iptrslice), e) - } // end block: if x.TestStrucCommon.Iptrslice slice == nil - } - if yyq2[26] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceInt64\"") - } else { - r.EncodeString(`WrapSliceInt64`) - } - z.EncWriteMapElemValue() - x.TestStrucCommon.WrapSliceInt64.CodecEncodeSelf(e) - } - if yyq2[27] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"WrapSliceString\"") - } else { - r.EncodeString(`WrapSliceString`) - } - z.EncWriteMapElemValue() - x.TestStrucCommon.WrapSliceString.CodecEncodeSelf(e) - } - if yyq2[28] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msi64\"") - } else { - r.EncodeString(`Msi64`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Msi64 == nil { - r.EncodeNil() - } else { - z.F.EncMapStringInt64V(x.TestStrucCommon.Msi64, e) - } // end block: if x.TestStrucCommon.Msi64 map == nil - } - if yyq2[29] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msbytes\"") - } else { - r.EncodeString(`Msbytes`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Msbytes == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBytesV(x.TestStrucCommon.Msbytes, e) - } // end block: if x.TestStrucCommon.Msbytes map == nil - } - if yyq2[30] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Simplef\"") - } else { - r.EncodeString(`Simplef`) - } - z.EncWriteMapElemValue() - yy194 := &x.TestStrucCommon.Simplef - yy194.CodecEncodeSelf(e) - } - if yyq2[31] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"SstrUi64T\"") - } else { - r.EncodeString(`SstrUi64T`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.SstrUi64T == nil { - r.EncodeNil() - } else { - h.encSlicestringUint64T(([]stringUint64T)(x.TestStrucCommon.SstrUi64T), e) - } // end block: if x.TestStrucCommon.SstrUi64T slice == nil - } - if yyq2[32] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"MstrUi64T\"") - } else { - r.EncodeString(`MstrUi64T`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.MstrUi64T == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtostringUint64T((map[string]*stringUint64T)(x.TestStrucCommon.MstrUi64T), e) - } // end block: if x.TestStrucCommon.MstrUi64T map == nil - } - if yyq2[33] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AS\"") - } else { - r.EncodeString(`AS`) - } - z.EncWriteMapElemValue() - r.EncodeString(string(x.TestStrucCommon.AnonInTestStruc.AS)) - } - if yyq2[34] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64\"") - } else { - r.EncodeString(`AI64`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI64)) - } - if yyq2[35] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI16\"") - } else { - r.EncodeString(`AI16`) - } - z.EncWriteMapElemValue() - r.EncodeInt(int64(x.TestStrucCommon.AnonInTestStruc.AI16)) - } - if yyq2[36] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64\"") - } else { - r.EncodeString(`AUi64`) - } - z.EncWriteMapElemValue() - r.EncodeUint(uint64(x.TestStrucCommon.AnonInTestStruc.AUi64)) - } - if yyq2[37] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"ASslice\"") - } else { - r.EncodeString(`ASslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.ASslice == nil { - r.EncodeNil() - } else { - z.F.EncSliceStringV(x.TestStrucCommon.AnonInTestStruc.ASslice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.ASslice slice == nil - } - if yyq2[38] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice\"") - } else { - r.EncodeString(`AI64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AI64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice slice == nil - } - if yyq2[39] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64slice\"") - } else { - r.EncodeString(`AUi64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AUi64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64slice slice == nil - } - if yyq2[40] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF64slice\"") - } else { - r.EncodeString(`AF64slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AF64slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat64V(x.TestStrucCommon.AnonInTestStruc.AF64slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF64slice slice == nil - } - if yyq2[41] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AF32slice\"") - } else { - r.EncodeString(`AF32slice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AF32slice == nil { - r.EncodeNil() - } else { - z.F.EncSliceFloat32V(x.TestStrucCommon.AnonInTestStruc.AF32slice, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AF32slice slice == nil - } - if yyq2[42] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16\"") - } else { - r.EncodeString(`AMSU16`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AMSU16 == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16 map == nil - } - if yyq2[43] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64arr0\"") - } else { - r.EncodeString(`AI64arr0`) - } - z.EncWriteMapElemValue() - yy208 := &x.TestStrucCommon.AnonInTestStruc.AI64arr0 - h.encArray0int64((*[0]int64)(yy208), e) - } - if yyq2[44] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AI64slice0\"") - } else { - r.EncodeString(`AI64slice0`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AI64slice0 == nil { - r.EncodeNil() - } else { - z.F.EncSliceInt64V(x.TestStrucCommon.AnonInTestStruc.AI64slice0, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AI64slice0 slice == nil - } - if yyq2[45] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AUi64sliceN\"") - } else { - r.EncodeString(`AUi64sliceN`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN == nil { - r.EncodeNil() - } else { - z.F.EncSliceUint64V(x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AUi64sliceN slice == nil - } - if yyq2[46] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16N\"") - } else { - r.EncodeString(`AMSU16N`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AMSU16N == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16N), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16N map == nil - } - if yyq2[47] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"AMSU16E\"") - } else { - r.EncodeString(`AMSU16E`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.AnonInTestStruc.AMSU16E == nil { - r.EncodeNil() - } else { - h.encMapstringuint16((map[string]uint16)(x.TestStrucCommon.AnonInTestStruc.AMSU16E), e) - } // end block: if x.TestStrucCommon.AnonInTestStruc.AMSU16E map == nil - } - if yyq2[48] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"NotAnon\"") - } else { - r.EncodeString(`NotAnon`) - } - z.EncWriteMapElemValue() - yy214 := &x.TestStrucCommon.NotAnon - yy214.CodecEncodeSelf(e) - } - if yyq2[49] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nmap\"") - } else { - r.EncodeString(`Nmap`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Nmap == nil { - r.EncodeNil() - } else { - z.F.EncMapStringBoolV(x.TestStrucCommon.Nmap, e) - } // end block: if x.TestStrucCommon.Nmap map == nil - } - if yyq2[50] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nslice\"") - } else { - r.EncodeString(`Nslice`) - } - z.EncWriteMapElemValue() - if x.TestStrucCommon.Nslice == nil { - r.EncodeNil() - } else { - r.EncodeStringBytesRaw([]byte(x.TestStrucCommon.Nslice)) - } // end block: if x.TestStrucCommon.Nslice slice == nil - } - if yyq2[51] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nint64\"") - } else { - r.EncodeString(`Nint64`) - } - z.EncWriteMapElemValue() - if yyn54 { - r.EncodeNil() - } else { - yy218 := *x.TestStrucCommon.Nint64 - r.EncodeInt(int64(yy218)) - } - } - if yyq2[52] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Chstr\"") - } else { - r.EncodeString(`Chstr`) - } - z.EncWriteMapElemValue() - h.encChanstring((chan string)(x.Chstr), e) - } - if yyq2[53] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mis\"") - } else { - r.EncodeString(`Mis`) - } - z.EncWriteMapElemValue() - if x.Mis == nil { - r.EncodeNil() - } else { - z.F.EncMapIntStringV(x.Mis, e) - } // end block: if x.Mis map == nil - } - if yyq2[54] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mbu64\"") - } else { - r.EncodeString(`Mbu64`) - } - z.EncWriteMapElemValue() - if x.Mbu64 == nil { - r.EncodeNil() - } else { - h.encMapboolc3RydWN0IHt9((map[bool]struct{})(x.Mbu64), e) - } // end block: if x.Mbu64 map == nil - } - if yyq2[55] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Miwu64s\"") - } else { - r.EncodeString(`Miwu64s`) - } - z.EncWriteMapElemValue() - if x.Miwu64s == nil { - r.EncodeNil() - } else { - h.encMapintwrapUint64Slice((map[int]wrapUint64Slice)(x.Miwu64s), e) - } // end block: if x.Miwu64s map == nil - } - if yyq2[56] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mfwss\"") - } else { - r.EncodeString(`Mfwss`) - } - z.EncWriteMapElemValue() - if x.Mfwss == nil { - r.EncodeNil() - } else { - h.encMapfloat64wrapStringSlice((map[float64]wrapStringSlice)(x.Mfwss), e) - } // end block: if x.Mfwss map == nil - } - if yyq2[57] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mf32wss\"") - } else { - r.EncodeString(`Mf32wss`) - } - z.EncWriteMapElemValue() - if x.Mf32wss == nil { - r.EncodeNil() - } else { - h.encMapfloat32wrapStringSlice((map[float32]wrapStringSlice)(x.Mf32wss), e) - } // end block: if x.Mf32wss map == nil - } - if yyq2[58] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mui2wss\"") - } else { - r.EncodeString(`Mui2wss`) - } - z.EncWriteMapElemValue() - if x.Mui2wss == nil { - r.EncodeNil() - } else { - h.encMapuint64wrapStringSlice((map[uint64]wrapStringSlice)(x.Mui2wss), e) - } // end block: if x.Mui2wss map == nil - } - if yyq2[59] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Msu2wss\"") - } else { - r.EncodeString(`Msu2wss`) - } - z.EncWriteMapElemValue() - if x.Msu2wss == nil { - r.EncodeNil() - } else { - h.encMapstringUint64TwrapStringSlice((map[stringUint64T]wrapStringSlice)(x.Msu2wss), e) - } // end block: if x.Msu2wss map == nil - } - if yyq2[60] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ci64\"") - } else { - r.EncodeString(`Ci64`) - } - z.EncWriteMapElemValue() - x.Ci64.CodecEncodeSelf(e) - } - if yyq2[61] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Swrapbytes\"") - } else { - r.EncodeString(`Swrapbytes`) - } - z.EncWriteMapElemValue() - if x.Swrapbytes == nil { - r.EncodeNil() - } else { - h.encSlicewrapBytes(([]wrapBytes)(x.Swrapbytes), e) - } // end block: if x.Swrapbytes slice == nil - } - if yyq2[62] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Swrapuint8\"") - } else { - r.EncodeString(`Swrapuint8`) - } - z.EncWriteMapElemValue() - if x.Swrapuint8 == nil { - r.EncodeNil() - } else { - h.encSlicewrapUint8(([]wrapUint8)(x.Swrapuint8), e) - } // end block: if x.Swrapuint8 slice == nil - } - if yyq2[63] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"ArrStrUi64T\"") - } else { - r.EncodeString(`ArrStrUi64T`) - } - z.EncWriteMapElemValue() - yy231 := &x.ArrStrUi64T - h.encArray4stringUint64T((*[4]stringUint64T)(yy231), e) - } - if yyq2[64] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64array\"") - } else { - r.EncodeString(`Ui64array`) - } - z.EncWriteMapElemValue() - yy233 := &x.Ui64array - h.encArray4uint64((*[4]uint64)(yy233), e) - } - if yyq2[65] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ui64slicearray\"") - } else { - r.EncodeString(`Ui64slicearray`) - } - z.EncWriteMapElemValue() - if x.Ui64slicearray == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoArray4uint64(([]*[4]uint64)(x.Ui64slicearray), e) - } // end block: if x.Ui64slicearray slice == nil - } - if yyq2[66] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"SintfAarray\"") - } else { - r.EncodeString(`SintfAarray`) - } - z.EncWriteMapElemValue() - if x.SintfAarray == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.SintfAarray, e) - } // end block: if x.SintfAarray slice == nil - } - if yyq2[67] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"MstrUi64TSelf\"") - } else { - r.EncodeString(`MstrUi64TSelf`) - } - z.EncWriteMapElemValue() - if x.MstrUi64TSelf == nil { - r.EncodeNil() - } else { - h.encMapstringUint64TPtrtostringUint64T((map[stringUint64T]*stringUint64T)(x.MstrUi64TSelf), e) - } // end block: if x.MstrUi64TSelf map == nil - } - if yyq2[68] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Islice\"") - } else { - r.EncodeString(`Islice`) - } - z.EncWriteMapElemValue() - if yyn71 { - r.EncodeNil() - } else { - if x.AnonInTestStrucIntf.Islice == nil { - r.EncodeNil() - } else { - z.F.EncSliceIntfV(x.AnonInTestStrucIntf.Islice, e) - } // end block: if x.AnonInTestStrucIntf.Islice slice == nil - } - } - if yyq2[69] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Ms\"") - } else { - r.EncodeString(`Ms`) - } - z.EncWriteMapElemValue() - if yyn72 { - r.EncodeNil() - } else { - if x.AnonInTestStrucIntf.Ms == nil { - r.EncodeNil() - } else { - z.F.EncMapStringIntfV(x.AnonInTestStrucIntf.Ms, e) - } // end block: if x.AnonInTestStrucIntf.Ms map == nil - } - } - if yyq2[70] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nintf\"") - } else { - r.EncodeString(`Nintf`) - } - z.EncWriteMapElemValue() - if yyn73 { - r.EncodeNil() - } else { - z.EncFallback(x.AnonInTestStrucIntf.Nintf) - } - } - if yyq2[71] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"T\"") - } else { - r.EncodeString(`T`) - } - z.EncWriteMapElemValue() - if yyn74 { - r.EncodeNil() - } else { - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(x.AnonInTestStrucIntf.T) - } else if yyxt241 := z.Extension(z.I2Rtid(x.AnonInTestStrucIntf.T)); yyxt241 != nil { - z.EncExtension(x.AnonInTestStrucIntf.T, yyxt241) - } else if z.EncBinary() { - z.EncBinaryMarshal(x.AnonInTestStrucIntf.T) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(x.AnonInTestStrucIntf.T) - } else { - z.EncFallback(x.AnonInTestStrucIntf.T) - } - } - } - if yyq2[72] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Tptr\"") - } else { - r.EncodeString(`Tptr`) - } - z.EncWriteMapElemValue() - if yyn75 { - r.EncodeNil() - } else { - yy242 := *x.AnonInTestStrucIntf.Tptr - if !z.EncBasicHandle().TimeNotBuiltin { - r.EncodeTime(yy242) - } else if yyxt243 := z.Extension(z.I2Rtid(yy242)); yyxt243 != nil { - z.EncExtension(yy242, yyxt243) - } else if z.EncBinary() { - z.EncBinaryMarshal(yy242) - } else if !z.EncBinary() && z.IsJSONHandle() { - z.EncJSONMarshal(yy242) - } else { - z.EncFallback(yy242) - } - } - } - if yyq2[73] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mtsptr\"") - } else { - r.EncodeString(`Mtsptr`) - } - z.EncWriteMapElemValue() - if x.Mtsptr == nil { - r.EncodeNil() - } else { - h.encMapstringPtrtoTestStrucFlex((map[string]*TestStrucFlex)(x.Mtsptr), e) - } // end block: if x.Mtsptr map == nil - } - if yyq2[74] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Mts\"") - } else { - r.EncodeString(`Mts`) - } - z.EncWriteMapElemValue() - if x.Mts == nil { - r.EncodeNil() - } else { - h.encMapstringTestStrucFlex((map[string]TestStrucFlex)(x.Mts), e) - } // end block: if x.Mts map == nil - } - if yyq2[75] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Its\"") - } else { - r.EncodeString(`Its`) - } - z.EncWriteMapElemValue() - if x.Its == nil { - r.EncodeNil() - } else { - h.encSlicePtrtoTestStrucFlex(([]*TestStrucFlex)(x.Its), e) - } // end block: if x.Its slice == nil - } - if yyq2[76] { - z.EncWriteMapElemKey() - if z.IsJSONHandle() { - z.WriteStr("\"Nteststruc\"") - } else { - r.EncodeString(`Nteststruc`) - } - z.EncWriteMapElemValue() - if yyn79 { - r.EncodeNil() - } else { - x.Nteststruc.CodecEncodeSelf(e) - } - } - z.EncWriteMapEnd() - } - } -} - -func (x *TestStrucFlex) CodecDecodeSelf(d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - yyct2 := r.ContainerType() - if yyct2 == codecSelferValueTypeNil19780 { - *(x) = TestStrucFlex{} - } else if yyct2 == codecSelferValueTypeMap19780 { - yyl2 := z.DecReadMapStart() - if yyl2 == 0 { - } else { - x.codecDecodeSelfFromMap(yyl2, d) - } - z.DecReadMapEnd() - } else if yyct2 == codecSelferValueTypeArray19780 { - yyl2 := z.DecReadArrayStart() - if yyl2 != 0 { - x.codecDecodeSelfFromArray(yyl2, d) - } - z.DecReadArrayEnd() - } else { - panic(errCodecSelferOnlyMapOrArrayEncodeToStruct19780) - } -} - -func (x *TestStrucFlex) codecDecodeSelfFromMap(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyhl3 bool = l >= 0 - for yyj3 := 0; ; yyj3++ { - if yyhl3 { - if yyj3 >= l { - break - } - } else { - if z.DecCheckBreak() { - break - } - } - z.DecReadMapElemKey() - yys3 := z.StringView(r.DecodeStringAsBytes()) - z.DecReadMapElemValue() - switch yys3 { - case "S": - x.TestStrucCommon.S = (string)(string(r.DecodeStringAsBytes())) - case "I64": - x.TestStrucCommon.I64 = (int64)(r.DecodeInt64()) - case "I32": - x.TestStrucCommon.I32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "I16": - x.TestStrucCommon.I16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "I8": - x.TestStrucCommon.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "I64n": - x.TestStrucCommon.I64n = (int64)(r.DecodeInt64()) - case "I32n": - x.TestStrucCommon.I32n = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - case "I16n": - x.TestStrucCommon.I16n = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "I8n": - x.TestStrucCommon.I8n = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - case "Ui64": - x.TestStrucCommon.Ui64 = (uint64)(r.DecodeUint64()) - case "Ui32": - x.TestStrucCommon.Ui32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - case "Ui16": - x.TestStrucCommon.Ui16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - case "Ui8": - x.TestStrucCommon.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "F64": - x.TestStrucCommon.F64 = (float64)(r.DecodeFloat64()) - case "F32": - x.TestStrucCommon.F32 = (float32)(z.DecDecodeFloat32()) - case "B": - x.TestStrucCommon.B = (bool)(r.DecodeBool()) - case "By": - x.TestStrucCommon.By = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - case "Sslice": - z.F.DecSliceStringX(&x.TestStrucCommon.Sslice, d) - case "I64slice": - z.F.DecSliceInt64X(&x.TestStrucCommon.I64slice, d) - case "I16slice": - z.F.DecSliceInt16X(&x.TestStrucCommon.I16slice, d) - case "Ui64slice": - z.F.DecSliceUint64X(&x.TestStrucCommon.Ui64slice, d) - case "Ui8slice": - x.TestStrucCommon.Ui8slice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Ui8slice), false) - case "Bslice": - z.F.DecSliceBoolX(&x.TestStrucCommon.Bslice, d) - case "Byslice": - x.TestStrucCommon.Byslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Byslice), false) - case "BytesSlice": - z.F.DecSliceBytesX(&x.TestStrucCommon.BytesSlice, d) - case "Iptrslice": - h.decSlicePtrtoint64((*[]*int64)(&x.TestStrucCommon.Iptrslice), d) - case "WrapSliceInt64": - x.TestStrucCommon.WrapSliceInt64.CodecDecodeSelf(d) - case "WrapSliceString": - x.TestStrucCommon.WrapSliceString.CodecDecodeSelf(d) - case "Msi64": - z.F.DecMapStringInt64X(&x.TestStrucCommon.Msi64, d) - case "Msbytes": - z.F.DecMapStringBytesX(&x.TestStrucCommon.Msbytes, d) - case "Simplef": - x.TestStrucCommon.Simplef.CodecDecodeSelf(d) - case "SstrUi64T": - h.decSlicestringUint64T((*[]stringUint64T)(&x.TestStrucCommon.SstrUi64T), d) - case "MstrUi64T": - h.decMapstringPtrtostringUint64T((*map[string]*stringUint64T)(&x.TestStrucCommon.MstrUi64T), d) - case "AS": - x.TestStrucCommon.AnonInTestStruc.AS = (string)(string(r.DecodeStringAsBytes())) - case "AI64": - x.TestStrucCommon.AnonInTestStruc.AI64 = (int64)(r.DecodeInt64()) - case "AI16": - x.TestStrucCommon.AnonInTestStruc.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - case "AUi64": - x.TestStrucCommon.AnonInTestStruc.AUi64 = (uint64)(r.DecodeUint64()) - case "ASslice": - z.F.DecSliceStringX(&x.TestStrucCommon.AnonInTestStruc.ASslice, d) - case "AI64slice": - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice, d) - case "AUi64slice": - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64slice, d) - case "AF64slice": - z.F.DecSliceFloat64X(&x.TestStrucCommon.AnonInTestStruc.AF64slice, d) - case "AF32slice": - z.F.DecSliceFloat32X(&x.TestStrucCommon.AnonInTestStruc.AF32slice, d) - case "AMSU16": - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16), d) - case "AI64arr0": - h.decArray0int64((*[0]int64)(&x.TestStrucCommon.AnonInTestStruc.AI64arr0), d) - case "AI64slice0": - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice0, d) - case "AUi64sliceN": - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, d) - case "AMSU16N": - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16N), d) - case "AMSU16E": - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16E), d) - case "NotAnon": - x.TestStrucCommon.NotAnon.CodecDecodeSelf(d) - case "Nmap": - z.F.DecMapStringBoolX(&x.TestStrucCommon.Nmap, d) - case "Nslice": - x.TestStrucCommon.Nslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Nslice), false) - case "Nint64": - if r.TryNil() { - if x.TestStrucCommon.Nint64 != nil { // remove the if-true - x.TestStrucCommon.Nint64 = nil - } - } else { - if x.TestStrucCommon.Nint64 == nil { - x.TestStrucCommon.Nint64 = new(int64) - } - *x.TestStrucCommon.Nint64 = (int64)(r.DecodeInt64()) - } - case "Chstr": - h.decChanstring((*chan string)(&x.Chstr), d) - case "Mis": - z.F.DecMapIntStringX(&x.Mis, d) - case "Mbu64": - h.decMapboolc3RydWN0IHt9((*map[bool]struct{})(&x.Mbu64), d) - case "Miwu64s": - h.decMapintwrapUint64Slice((*map[int]wrapUint64Slice)(&x.Miwu64s), d) - case "Mfwss": - h.decMapfloat64wrapStringSlice((*map[float64]wrapStringSlice)(&x.Mfwss), d) - case "Mf32wss": - h.decMapfloat32wrapStringSlice((*map[float32]wrapStringSlice)(&x.Mf32wss), d) - case "Mui2wss": - h.decMapuint64wrapStringSlice((*map[uint64]wrapStringSlice)(&x.Mui2wss), d) - case "Msu2wss": - h.decMapstringUint64TwrapStringSlice((*map[stringUint64T]wrapStringSlice)(&x.Msu2wss), d) - case "Ci64": - x.Ci64.CodecDecodeSelf(d) - case "Swrapbytes": - h.decSlicewrapBytes((*[]wrapBytes)(&x.Swrapbytes), d) - case "Swrapuint8": - h.decSlicewrapUint8((*[]wrapUint8)(&x.Swrapuint8), d) - case "ArrStrUi64T": - h.decArray4stringUint64T((*[4]stringUint64T)(&x.ArrStrUi64T), d) - case "Ui64array": - h.decArray4uint64((*[4]uint64)(&x.Ui64array), d) - case "Ui64slicearray": - h.decSlicePtrtoArray4uint64((*[]*[4]uint64)(&x.Ui64slicearray), d) - case "SintfAarray": - z.F.DecSliceIntfX(&x.SintfAarray, d) - case "MstrUi64TSelf": - h.decMapstringUint64TPtrtostringUint64T((*map[stringUint64T]*stringUint64T)(&x.MstrUi64TSelf), d) - case "Islice": - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.Islice = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - z.F.DecSliceIntfX(&x.AnonInTestStrucIntf.Islice, d) - } - case "Ms": - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.Ms = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - z.F.DecMapStringIntfX(&x.AnonInTestStrucIntf.Ms, d) - } - case "Nintf": - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.Nintf = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - z.DecFallback(&x.AnonInTestStrucIntf.Nintf, true) - } - case "T": - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.T = time.Time{} - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - if !z.DecBasicHandle().TimeNotBuiltin { - x.AnonInTestStrucIntf.T = r.DecodeTime() - } else if yyxt121 := z.Extension(z.I2Rtid(x.AnonInTestStrucIntf.T)); yyxt121 != nil { - z.DecExtension(x.AnonInTestStrucIntf.T, yyxt121) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(&x.AnonInTestStrucIntf.T) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(&x.AnonInTestStrucIntf.T) - } else { - z.DecFallback(&x.AnonInTestStrucIntf.T, false) - } - } - case "Tptr": - if r.TryNil() { - if x.AnonInTestStrucIntf != nil && x.AnonInTestStrucIntf.Tptr != nil { // remove the if-true - x.AnonInTestStrucIntf.Tptr = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - if x.AnonInTestStrucIntf.Tptr == nil { - x.AnonInTestStrucIntf.Tptr = new(time.Time) - } - if !z.DecBasicHandle().TimeNotBuiltin { - *x.AnonInTestStrucIntf.Tptr = r.DecodeTime() - } else if yyxt123 := z.Extension(z.I2Rtid(x.AnonInTestStrucIntf.Tptr)); yyxt123 != nil { - z.DecExtension(x.AnonInTestStrucIntf.Tptr, yyxt123) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(x.AnonInTestStrucIntf.Tptr) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(x.AnonInTestStrucIntf.Tptr) - } else { - z.DecFallback(x.AnonInTestStrucIntf.Tptr, false) - } - } - case "Mtsptr": - h.decMapstringPtrtoTestStrucFlex((*map[string]*TestStrucFlex)(&x.Mtsptr), d) - case "Mts": - h.decMapstringTestStrucFlex((*map[string]TestStrucFlex)(&x.Mts), d) - case "Its": - h.decSlicePtrtoTestStrucFlex((*[]*TestStrucFlex)(&x.Its), d) - case "Nteststruc": - if r.TryNil() { - if x.Nteststruc != nil { // remove the if-true - x.Nteststruc = nil - } - } else { - if x.Nteststruc == nil { - x.Nteststruc = new(TestStrucFlex) - } - x.Nteststruc.CodecDecodeSelf(d) - } - default: - z.DecStructFieldNotFound(-1, yys3) - } // end switch yys3 - } // end for yyj3 -} - -func (x *TestStrucFlex) codecDecodeSelfFromArray(l int, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - var yyj131 int - var yyb131 bool - var yyhl131 bool = l >= 0 - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.S = (string)(string(r.DecodeStringAsBytes())) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I64 = (int64)(r.DecodeInt64()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I32 = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I8 = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I64n = (int64)(r.DecodeInt64()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I32n = (int32)(z.C.IntV(r.DecodeInt64(), 32)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I16n = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.I8n = (int8)(z.C.IntV(r.DecodeInt64(), 8)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui64 = (uint64)(r.DecodeUint64()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui32 = (uint32)(z.C.UintV(r.DecodeUint64(), 32)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui16 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui8 = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.F64 = (float64)(r.DecodeFloat64()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.F32 = (float32)(z.DecDecodeFloat32()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.B = (bool)(r.DecodeBool()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.By = (uint8)(z.C.UintV(r.DecodeUint64(), 8)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.TestStrucCommon.Sslice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.TestStrucCommon.I64slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt16X(&x.TestStrucCommon.I16slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.TestStrucCommon.Ui64slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Ui8slice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Ui8slice), false) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBoolX(&x.TestStrucCommon.Bslice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Byslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Byslice), false) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceBytesX(&x.TestStrucCommon.BytesSlice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoint64((*[]*int64)(&x.TestStrucCommon.Iptrslice), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.WrapSliceInt64.CodecDecodeSelf(d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.WrapSliceString.CodecDecodeSelf(d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringInt64X(&x.TestStrucCommon.Msi64, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBytesX(&x.TestStrucCommon.Msbytes, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Simplef.CodecDecodeSelf(d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicestringUint64T((*[]stringUint64T)(&x.TestStrucCommon.SstrUi64T), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringPtrtostringUint64T((*map[string]*stringUint64T)(&x.TestStrucCommon.MstrUi64T), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AS = (string)(string(r.DecodeStringAsBytes())) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AI64 = (int64)(r.DecodeInt64()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AI16 = (int16)(z.C.IntV(r.DecodeInt64(), 16)) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.AnonInTestStruc.AUi64 = (uint64)(r.DecodeUint64()) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceStringX(&x.TestStrucCommon.AnonInTestStruc.ASslice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat64X(&x.TestStrucCommon.AnonInTestStruc.AF64slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceFloat32X(&x.TestStrucCommon.AnonInTestStruc.AF32slice, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray0int64((*[0]int64)(&x.TestStrucCommon.AnonInTestStruc.AI64arr0), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceInt64X(&x.TestStrucCommon.AnonInTestStruc.AI64slice0, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceUint64X(&x.TestStrucCommon.AnonInTestStruc.AUi64sliceN, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16N), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringuint16((*map[string]uint16)(&x.TestStrucCommon.AnonInTestStruc.AMSU16E), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.NotAnon.CodecDecodeSelf(d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapStringBoolX(&x.TestStrucCommon.Nmap, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.TestStrucCommon.Nslice = r.DecodeBytes(([]byte)(x.TestStrucCommon.Nslice), false) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.TestStrucCommon.Nint64 != nil { // remove the if-true - x.TestStrucCommon.Nint64 = nil - } - } else { - if x.TestStrucCommon.Nint64 == nil { - x.TestStrucCommon.Nint64 = new(int64) - } - *x.TestStrucCommon.Nint64 = (int64)(r.DecodeInt64()) - } - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decChanstring((*chan string)(&x.Chstr), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecMapIntStringX(&x.Mis, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapboolc3RydWN0IHt9((*map[bool]struct{})(&x.Mbu64), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapintwrapUint64Slice((*map[int]wrapUint64Slice)(&x.Miwu64s), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapfloat64wrapStringSlice((*map[float64]wrapStringSlice)(&x.Mfwss), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapfloat32wrapStringSlice((*map[float32]wrapStringSlice)(&x.Mf32wss), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapuint64wrapStringSlice((*map[uint64]wrapStringSlice)(&x.Mui2wss), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringUint64TwrapStringSlice((*map[stringUint64T]wrapStringSlice)(&x.Msu2wss), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - x.Ci64.CodecDecodeSelf(d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicewrapBytes((*[]wrapBytes)(&x.Swrapbytes), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicewrapUint8((*[]wrapUint8)(&x.Swrapuint8), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray4stringUint64T((*[4]stringUint64T)(&x.ArrStrUi64T), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decArray4uint64((*[4]uint64)(&x.Ui64array), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoArray4uint64((*[]*[4]uint64)(&x.Ui64slicearray), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - z.F.DecSliceIntfX(&x.SintfAarray, d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringUint64TPtrtostringUint64T((*map[stringUint64T]*stringUint64T)(&x.MstrUi64TSelf), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.Islice = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - z.F.DecSliceIntfX(&x.AnonInTestStrucIntf.Islice, d) - } - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.Ms = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - z.F.DecMapStringIntfX(&x.AnonInTestStrucIntf.Ms, d) - } - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.Nintf = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - z.DecFallback(&x.AnonInTestStrucIntf.Nintf, true) - } - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.AnonInTestStrucIntf != nil { // remove the if-true - x.AnonInTestStrucIntf.T = time.Time{} - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - if !z.DecBasicHandle().TimeNotBuiltin { - x.AnonInTestStrucIntf.T = r.DecodeTime() - } else if yyxt249 := z.Extension(z.I2Rtid(x.AnonInTestStrucIntf.T)); yyxt249 != nil { - z.DecExtension(x.AnonInTestStrucIntf.T, yyxt249) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(&x.AnonInTestStrucIntf.T) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(&x.AnonInTestStrucIntf.T) - } else { - z.DecFallback(&x.AnonInTestStrucIntf.T, false) - } - } - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.AnonInTestStrucIntf != nil && x.AnonInTestStrucIntf.Tptr != nil { // remove the if-true - x.AnonInTestStrucIntf.Tptr = nil - } - } else { - if x.AnonInTestStrucIntf == nil { - x.AnonInTestStrucIntf = new(AnonInTestStrucIntf) - } - if x.AnonInTestStrucIntf.Tptr == nil { - x.AnonInTestStrucIntf.Tptr = new(time.Time) - } - if !z.DecBasicHandle().TimeNotBuiltin { - *x.AnonInTestStrucIntf.Tptr = r.DecodeTime() - } else if yyxt251 := z.Extension(z.I2Rtid(x.AnonInTestStrucIntf.Tptr)); yyxt251 != nil { - z.DecExtension(x.AnonInTestStrucIntf.Tptr, yyxt251) - } else if z.DecBinary() { - z.DecBinaryUnmarshal(x.AnonInTestStrucIntf.Tptr) - } else if !z.DecBinary() && z.IsJSONHandle() { - z.DecJSONUnmarshal(x.AnonInTestStrucIntf.Tptr) - } else { - z.DecFallback(x.AnonInTestStrucIntf.Tptr, false) - } - } - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringPtrtoTestStrucFlex((*map[string]*TestStrucFlex)(&x.Mtsptr), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decMapstringTestStrucFlex((*map[string]TestStrucFlex)(&x.Mts), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - h.decSlicePtrtoTestStrucFlex((*[]*TestStrucFlex)(&x.Its), d) - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - z.DecReadArrayEnd() - return - } - z.DecReadArrayElem() - if r.TryNil() { - if x.Nteststruc != nil { // remove the if-true - x.Nteststruc = nil - } - } else { - if x.Nteststruc == nil { - x.Nteststruc = new(TestStrucFlex) - } - x.Nteststruc.CodecDecodeSelf(d) - } - for { - yyj131++ - if yyhl131 { - yyb131 = yyj131 > l - } else { - yyb131 = z.DecCheckBreak() - } - if yyb131 { - break - } - z.DecReadArrayElem() - z.DecStructFieldNotFound(yyj131-1, "") - } -} - -func (x codecSelfer19780) encwrapSliceUint64(v wrapSliceUint64, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeUint(uint64(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decwrapSliceUint64(v *wrapSliceUint64, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []uint64{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]uint64, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - } else { - yyrl1 = 8 - } - yyv1 = make([]uint64, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, 0) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (uint64)(r.DecodeUint64()) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]uint64, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encwrapSliceString(v wrapSliceString, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeString(string(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decwrapSliceString(v *wrapSliceString, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []string{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]string, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) - } else { - yyrl1 = 8 - } - yyv1 = make([]string, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, "") - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (string)(string(r.DecodeStringAsBytes())) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]string, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encwrapUint64Slice(v wrapUint64Slice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decwrapUint64Slice(v *wrapUint64Slice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []wrapUint64{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]wrapUint64, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - } else { - yyrl1 = 8 - } - yyv1 = make([]wrapUint64, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, 0) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]wrapUint64, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encwrapStringSlice(v wrapStringSlice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decwrapStringSlice(v *wrapStringSlice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []wrapString{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]wrapString, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) - } else { - yyrl1 = 8 - } - yyv1 = make([]wrapString, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, "") - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]wrapString, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encMapstringuint16(v map[string]uint16, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeString(string(yyk1)) - z.EncWriteMapElemValue() - r.EncodeUint(uint64(yyv1)) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringuint16(v *map[string]uint16, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 18) - yyv1 = make(map[string]uint16, yyrl1) - *v = yyv1 - } - var yymk1 string - var yymv1 uint16 - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (string)(string(r.DecodeStringAsBytes())) - if yymg1 { - yymv1 = yyv1[yymk1] - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1 = (uint16)(z.C.UintV(r.DecodeUint64(), 16)) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = 0 - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encArray0int64(v *[0]int64, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeInt(int64(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decArray0int64(v *[0]int64, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := v - yyh1, yyl1 := z.DecSliceHelperStart() - if yyl1 == 0 { - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - z.DecArrayCannotExpand(len(v), yyj1+1) - yydb1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (int64)(r.DecodeInt64()) - } - } - } - yyh1.End() -} - -func (x codecSelfer19780) encSlicePtrtoint64(v []*int64, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - if yyv1 == nil { - r.EncodeNil() - } else { - yy2 := *yyv1 - r.EncodeInt(int64(yy2)) - } - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicePtrtoint64(v *[]*int64, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []*int64{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]*int64, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - } else { - yyrl1 = 8 - } - yyv1 = make([]*int64, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, nil) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - if r.TryNil() { - yyv1[yyj1] = nil - } else { - if yyv1[yyj1] == nil { - yyv1[yyj1] = new(int64) - } - *yyv1[yyj1] = (int64)(r.DecodeInt64()) - } - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]*int64, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encSlicestringUint64T(v []stringUint64T, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yy2 := &yyv1 - yy2.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicestringUint64T(v *[]stringUint64T, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []stringUint64T{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]stringUint64T, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - } else { - yyrl1 = 8 - } - yyv1 = make([]stringUint64T, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, stringUint64T{}) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]stringUint64T, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encMapstringPtrtostringUint64T(v map[string]*stringUint64T, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeString(string(yyk1)) - z.EncWriteMapElemValue() - if yyv1 == nil { - r.EncodeNil() - } else { - yyv1.CodecEncodeSelf(e) - } - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringPtrtostringUint64T(v *map[string]*stringUint64T, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - yyv1 = make(map[string]*stringUint64T, yyrl1) - *v = yyv1 - } - var yymk1 string - var yymv1 *stringUint64T - var yymg1, yymdn1, yyms1, yymok1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (string)(string(r.DecodeStringAsBytes())) - yyms1 = true - if yymg1 { - yymv1, yymok1 = yyv1[yymk1] - if yymok1 { - yyms1 = false - } - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - if r.TryNil() { - yymdn1 = true - } else { - if yymv1 == nil { - yymv1 = new(stringUint64T) - } - yymv1.CodecDecodeSelf(d) - } - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyms1 && yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapstringPtrtoTestStruc(v map[string]*TestStruc, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeString(string(yyk1)) - z.EncWriteMapElemValue() - if yyv1 == nil { - r.EncodeNil() - } else { - yyv1.CodecEncodeSelf(e) - } - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringPtrtoTestStruc(v *map[string]*TestStruc, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - yyv1 = make(map[string]*TestStruc, yyrl1) - *v = yyv1 - } - var yymk1 string - var yymv1 *TestStruc - var yymg1, yymdn1, yyms1, yymok1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (string)(string(r.DecodeStringAsBytes())) - yyms1 = true - if yymg1 { - yymv1, yymok1 = yyv1[yymk1] - if yymok1 { - yyms1 = false - } - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - if r.TryNil() { - yymdn1 = true - } else { - if yymv1 == nil { - yymv1 = new(TestStruc) - } - yymv1.CodecDecodeSelf(d) - } - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyms1 && yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapstringTestStruc(v map[string]TestStruc, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeString(string(yyk1)) - z.EncWriteMapElemValue() - yy3 := &yyv1 - yy3.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringTestStruc(v *map[string]TestStruc, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1224) - yyv1 = make(map[string]TestStruc, yyrl1) - *v = yyv1 - } - var yymk1 string - var yymv1 TestStruc - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (string)(string(r.DecodeStringAsBytes())) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = TestStruc{} - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = TestStruc{} - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encSlicePtrtoTestStruc(v []*TestStruc, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - if yyv1 == nil { - r.EncodeNil() - } else { - yyv1.CodecEncodeSelf(e) - } - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicePtrtoTestStruc(v *[]*TestStruc, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []*TestStruc{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]*TestStruc, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - } else { - yyrl1 = 8 - } - yyv1 = make([]*TestStruc, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, nil) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - if r.TryNil() { - yyv1[yyj1] = nil - } else { - if yyv1[yyj1] == nil { - yyv1[yyj1] = new(TestStruc) - } - yyv1[yyj1].CodecDecodeSelf(d) - } - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]*TestStruc, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encAarray(v *Aarray, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeString(string(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decAarray(v *Aarray, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := v - yyh1, yyl1 := z.DecSliceHelperStart() - if yyl1 == 0 { - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - z.DecArrayCannotExpand(len(v), yyj1+1) - yydb1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (string)(string(r.DecodeStringAsBytes())) - } - } - } - yyh1.End() -} - -func (x codecSelfer19780) encwrapBytes(v wrapBytes, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - r.EncodeStringBytesRaw([]byte(v)) -} - -func (x codecSelfer19780) decwrapBytes(v *wrapBytes, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - *v = r.DecodeBytes(*((*[]byte)(v)), false) -} - -func (x codecSelfer19780) encChanstring(v chan string, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - if v == nil { - r.EncodeNil() - } else { - var sch1 []string - - Lsch1: - switch timeout1 := z.EncBasicHandle().ChanRecvTimeout; { - case timeout1 == 0: // only consume available - for { - select { - case b1 := <-v: - sch1 = append(sch1, b1) - default: - break Lsch1 - } - } - case timeout1 > 0: // consume until timeout - tt1 := time.NewTimer(timeout1) - for { - select { - case b1 := <-v: - sch1 = append(sch1, b1) - case <-tt1.C: - // close(tt.C) - break Lsch1 - } - } - default: // consume until close - for b1 := range v { - sch1 = append(sch1, b1) - } - } - z.EncWriteArrayStart(len(sch1)) - for _, yyv1 := range sch1 { - z.EncWriteArrayElem() - r.EncodeString(string(yyv1)) - } - z.EncWriteArrayEnd() - } -} - -func (x codecSelfer19780) decChanstring(v *chan string, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = make(chan string, 0) - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 16) - } else { - yyrl1 = 64 - } - yyv1 = make(chan string, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yyvcx1 string - yyvcx1 = (string)(string(r.DecodeStringAsBytes())) - yyv1 <- yyvcx1 - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encMapboolc3RydWN0IHt9(v map[bool]struct{}, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeBool(bool(yyk1)) - z.EncWriteMapElemValue() - yy3 := &yyv1 - z.EncFallback(yy3) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapboolc3RydWN0IHt9(v *map[bool]struct{}, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1) - yyv1 = make(map[bool]struct{}, yyrl1) - *v = yyv1 - } - var yymk1 bool - var yymv1 struct{} - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (bool)(r.DecodeBool()) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = struct{}{} - } - z.DecReadMapElemValue() - yymdn1 = false - z.DecFallback(&yymv1, false) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = struct{}{} - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapintwrapUint64Slice(v map[int]wrapUint64Slice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeInt(int64(yyk1)) - z.EncWriteMapElemValue() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapintwrapUint64Slice(v *map[int]wrapUint64Slice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 32) - yyv1 = make(map[int]wrapUint64Slice, yyrl1) - *v = yyv1 - } - var yymk1 int - var yymv1 wrapUint64Slice - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (int)(z.C.IntV(r.DecodeInt64(), codecSelferBitsize19780)) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapfloat64wrapStringSlice(v map[float64]wrapStringSlice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeFloat64(float64(yyk1)) - z.EncWriteMapElemValue() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapfloat64wrapStringSlice(v *map[float64]wrapStringSlice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 32) - yyv1 = make(map[float64]wrapStringSlice, yyrl1) - *v = yyv1 - } - var yymk1 float64 - var yymv1 wrapStringSlice - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (float64)(r.DecodeFloat64()) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapfloat32wrapStringSlice(v map[float32]wrapStringSlice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeFloat32(float32(yyk1)) - z.EncWriteMapElemValue() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapfloat32wrapStringSlice(v *map[float32]wrapStringSlice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 28) - yyv1 = make(map[float32]wrapStringSlice, yyrl1) - *v = yyv1 - } - var yymk1 float32 - var yymv1 wrapStringSlice - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (float32)(z.DecDecodeFloat32()) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapuint64wrapStringSlice(v map[uint64]wrapStringSlice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeUint(uint64(yyk1)) - z.EncWriteMapElemValue() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapuint64wrapStringSlice(v *map[uint64]wrapStringSlice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 32) - yyv1 = make(map[uint64]wrapStringSlice, yyrl1) - *v = yyv1 - } - var yymk1 uint64 - var yymv1 wrapStringSlice - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (uint64)(r.DecodeUint64()) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapstringUint64TwrapStringSlice(v map[stringUint64T]wrapStringSlice, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - yy2 := &yyk1 - yy2.CodecEncodeSelf(e) - z.EncWriteMapElemValue() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringUint64TwrapStringSlice(v *map[stringUint64T]wrapStringSlice, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 48) - yyv1 = make(map[stringUint64T]wrapStringSlice, yyrl1) - *v = yyv1 - } - var yymk1 stringUint64T - var yymv1 wrapStringSlice - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1.CodecDecodeSelf(d) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encSlicewrapBytes(v []wrapBytes, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicewrapBytes(v *[]wrapBytes, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []wrapBytes{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]wrapBytes, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - } else { - yyrl1 = 8 - } - yyv1 = make([]wrapBytes, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, nil) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]wrapBytes, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encSlicewrapUint8(v []wrapUint8, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yyv1.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicewrapUint8(v *[]wrapUint8, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []wrapUint8{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]wrapUint8, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1) - } else { - yyrl1 = 8 - } - yyv1 = make([]wrapUint8, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, 0) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]wrapUint8, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encArray4stringUint64T(v *[4]stringUint64T, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - yy2 := &yyv1 - yy2.CodecEncodeSelf(e) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decArray4stringUint64T(v *[4]stringUint64T, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := v - yyh1, yyl1 := z.DecSliceHelperStart() - if yyl1 == 0 { - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - z.DecArrayCannotExpand(len(v), yyj1+1) - yydb1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1].CodecDecodeSelf(d) - } - } - } - yyh1.End() -} - -func (x codecSelfer19780) encArray4uint64(v *[4]uint64, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - r.EncodeUint(uint64(yyv1)) - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decArray4uint64(v *[4]uint64, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := v - yyh1, yyl1 := z.DecSliceHelperStart() - if yyl1 == 0 { - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - z.DecArrayCannotExpand(len(v), yyj1+1) - yydb1 = true - } - if yydb1 { - z.DecSwallow() - } else { - yyv1[yyj1] = (uint64)(r.DecodeUint64()) - } - } - } - yyh1.End() -} - -func (x codecSelfer19780) encSlicePtrtoArray4uint64(v []*[4]uint64, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - if yyv1 == nil { - r.EncodeNil() - } else { - h.encArray4uint64((*[4]uint64)(yyv1), e) - } - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicePtrtoArray4uint64(v *[]*[4]uint64, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []*[4]uint64{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]*[4]uint64, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - } else { - yyrl1 = 8 - } - yyv1 = make([]*[4]uint64, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, nil) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - if r.TryNil() { - yyv1[yyj1] = nil - } else { - if yyv1[yyj1] == nil { - yyv1[yyj1] = new([4]uint64) - } - h.decArray4uint64((*[4]uint64)(yyv1[yyj1]), d) - } - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]*[4]uint64, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} - -func (x codecSelfer19780) encMapstringUint64TPtrtostringUint64T(v map[stringUint64T]*stringUint64T, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - yy2 := &yyk1 - yy2.CodecEncodeSelf(e) - z.EncWriteMapElemValue() - if yyv1 == nil { - r.EncodeNil() - } else { - yyv1.CodecEncodeSelf(e) - } - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringUint64TPtrtostringUint64T(v *map[stringUint64T]*stringUint64T, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 32) - yyv1 = make(map[stringUint64T]*stringUint64T, yyrl1) - *v = yyv1 - } - var yymk1 stringUint64T - var yymv1 *stringUint64T - var yymg1, yymdn1, yyms1, yymok1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1.CodecDecodeSelf(d) - yyms1 = true - if yymg1 { - yymv1, yymok1 = yyv1[yymk1] - if yymok1 { - yyms1 = false - } - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - if r.TryNil() { - yymdn1 = true - } else { - if yymv1 == nil { - yymv1 = new(stringUint64T) - } - yymv1.CodecDecodeSelf(d) - } - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyms1 && yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapstringPtrtoTestStrucFlex(v map[string]*TestStrucFlex, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeString(string(yyk1)) - z.EncWriteMapElemValue() - if yyv1 == nil { - r.EncodeNil() - } else { - yyv1.CodecEncodeSelf(e) - } - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringPtrtoTestStrucFlex(v *map[string]*TestStrucFlex, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 24) - yyv1 = make(map[string]*TestStrucFlex, yyrl1) - *v = yyv1 - } - var yymk1 string - var yymv1 *TestStrucFlex - var yymg1, yymdn1, yyms1, yymok1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (string)(string(r.DecodeStringAsBytes())) - yyms1 = true - if yymg1 { - yymv1, yymok1 = yyv1[yymk1] - if yymok1 { - yyms1 = false - } - } else { - yymv1 = nil - } - z.DecReadMapElemValue() - yymdn1 = false - if r.TryNil() { - yymdn1 = true - } else { - if yymv1 == nil { - yymv1 = new(TestStrucFlex) - } - yymv1.CodecDecodeSelf(d) - } - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = nil - } - } else if yyms1 && yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encMapstringTestStrucFlex(v map[string]TestStrucFlex, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteMapStart(len(v)) - for yyk1, yyv1 := range v { - z.EncWriteMapElemKey() - r.EncodeString(string(yyk1)) - z.EncWriteMapElemValue() - yy3 := &yyv1 - yy3.CodecEncodeSelf(e) - } - z.EncWriteMapEnd() -} - -func (x codecSelfer19780) decMapstringTestStrucFlex(v *map[string]TestStrucFlex, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyl1 := z.DecReadMapStart() - if yyl1 == codecSelferDecContainerLenNil19780 { - *v = nil - } else { - if yyv1 == nil { - yyrl1 := z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 1536) - yyv1 = make(map[string]TestStrucFlex, yyrl1) - *v = yyv1 - } - var yymk1 string - var yymv1 TestStrucFlex - var yymg1, yymdn1 bool - if z.DecBasicHandle().MapValueReset { - yymg1 = true - } - if yyl1 != 0 { - yyhl1 := yyl1 > 0 - for yyj1 := 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { - z.DecReadMapElemKey() - yymk1 = (string)(string(r.DecodeStringAsBytes())) - if yymg1 { - yymv1 = yyv1[yymk1] - } else { - yymv1 = TestStrucFlex{} - } - z.DecReadMapElemValue() - yymdn1 = false - yymv1.CodecDecodeSelf(d) - if yymdn1 { - if z.DecBasicHandle().DeleteOnNilMapValue { - delete(yyv1, yymk1) - } else { - yyv1[yymk1] = TestStrucFlex{} - } - } else if yyv1 != nil { - yyv1[yymk1] = yymv1 - } - } - } // else len==0: TODO: Should we clear map entries? - z.DecReadMapEnd() - } -} - -func (x codecSelfer19780) encSlicePtrtoTestStrucFlex(v []*TestStrucFlex, e *Encoder) { - var h codecSelfer19780 - z, r := GenHelperEncoder(e) - _, _, _ = h, z, r - if v == nil { - r.EncodeNil() - return - } - z.EncWriteArrayStart(len(v)) - for _, yyv1 := range v { - z.EncWriteArrayElem() - if yyv1 == nil { - r.EncodeNil() - } else { - yyv1.CodecEncodeSelf(e) - } - } - z.EncWriteArrayEnd() -} - -func (x codecSelfer19780) decSlicePtrtoTestStrucFlex(v *[]*TestStrucFlex, d *Decoder) { - var h codecSelfer19780 - z, r := GenHelperDecoder(d) - _, _, _ = h, z, r - - yyv1 := *v - yyh1, yyl1 := z.DecSliceHelperStart() - var yyc1 bool - _ = yyc1 - if yyh1.IsNil { - if yyv1 != nil { - yyv1 = nil - yyc1 = true - } - } else if yyl1 == 0 { - if yyv1 == nil { - yyv1 = []*TestStrucFlex{} - yyc1 = true - } else if len(yyv1) != 0 { - yyv1 = yyv1[:0] - yyc1 = true - } - } else { - yyhl1 := yyl1 > 0 - var yyrl1 int - _ = yyrl1 - if yyhl1 { - if yyl1 > cap(yyv1) { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - if yyrl1 <= cap(yyv1) { - yyv1 = yyv1[:yyrl1] - } else { - yyv1 = make([]*TestStrucFlex, yyrl1) - } - yyc1 = true - } else if yyl1 != len(yyv1) { - yyv1 = yyv1[:yyl1] - yyc1 = true - } - } - var yyj1 int - for yyj1 = 0; (yyhl1 && yyj1 < yyl1) || !(yyhl1 || z.DecCheckBreak()); yyj1++ { // bounds-check-elimination - if yyj1 == 0 && yyv1 == nil { - if yyhl1 { - yyrl1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 8) - } else { - yyrl1 = 8 - } - yyv1 = make([]*TestStrucFlex, yyrl1) - yyc1 = true - } - yyh1.ElemContainerState(yyj1) - var yydb1 bool - if yyj1 >= len(yyv1) { - yyv1 = append(yyv1, nil) - yyc1 = true - } - if yydb1 { - z.DecSwallow() - } else { - if r.TryNil() { - yyv1[yyj1] = nil - } else { - if yyv1[yyj1] == nil { - yyv1[yyj1] = new(TestStrucFlex) - } - yyv1[yyj1].CodecDecodeSelf(d) - } - } - } - if yyj1 < len(yyv1) { - yyv1 = yyv1[:yyj1] - yyc1 = true - } else if yyj1 == 0 && yyv1 == nil { - yyv1 = make([]*TestStrucFlex, 0) - yyc1 = true - } - } - yyh1.End() - if yyc1 { - *v = yyv1 - } -} diff --git a/vendor/github.com/ugorji/go/codec/values_flex_test.go b/vendor/github.com/ugorji/go/codec/values_flex_test.go deleted file mode 100644 index 47b67f39d..000000000 --- a/vendor/github.com/ugorji/go/codec/values_flex_test.go +++ /dev/null @@ -1,346 +0,0 @@ -// comment this out // // + build testing - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import ( - "strconv" - "strings" - "time" -) - -const teststrucflexChanCap = 64 - -// This file contains values used by tests alone. -// This is where we may try out different things, -// that other engines may not support or may barf upon -// e.g. custom extensions for wrapped types, maps with non-string keys, etc. - -// some funky types to test codecgen - -type codecgenA struct { - ZZ []byte -} -type codecgenB struct { - AA codecgenA -} -type codecgenC struct { - _struct struct{} `codec:",omitempty"` - BB codecgenB -} - -type TestCodecgenG struct { - TestCodecgenG int -} -type codecgenH struct { - TestCodecgenG -} -type codecgenI struct { - codecgenH -} - -type codecgenK struct { - X int - Y string -} -type codecgenL struct { - X int - Y uint32 -} -type codecgenM struct { - codecgenK - codecgenL -} - -// some types to test struct keytype - -type testStrucKeyTypeT0 struct { - _struct struct{} - F int -} -type testStrucKeyTypeT1 struct { - _struct struct{} `codec:",string"` - F int `codec:"FFFF"` -} -type testStrucKeyTypeT2 struct { - _struct struct{} `codec:",int"` - F int `codec:"-1"` -} -type testStrucKeyTypeT3 struct { - _struct struct{} `codec:",uint"` - F int `codec:"1"` -} -type testStrucKeyTypeT4 struct { - _struct struct{} `codec:",float"` - F int `codec:"2.5"` -} - -// Some unused types just stored here - -type Bbool bool -type Aarray [1]string -type Sstring string -type Sstructsmall struct { - A int -} - -type Sstructbig struct { - A int - B bool - c string - // Sval Sstruct - Ssmallptr *Sstructsmall - Ssmall *Sstructsmall - Sptr *Sstructbig -} - -type SstructbigMapBySlice struct { - _struct struct{} `codec:",toarray"` - A int - B bool - c string - // Sval Sstruct - Ssmallptr *Sstructsmall - Ssmall *Sstructsmall - Sptr *Sstructbig -} - -// small struct for testing that codecgen works for unexported types -type tLowerFirstLetter struct { - I int - u uint64 - S string - b []byte -} - -// Some used types -type wrapInt64 int64 -type wrapUint8 uint8 -type wrapBytes []uint8 - -type AnonInTestStrucIntf struct { - Islice []interface{} - Ms map[string]interface{} - Nintf interface{} //don't set this, so we can test for nil - T time.Time - Tptr *time.Time -} - -type missingFielderT1 struct { - S string - B bool - f float64 - i int64 -} - -func (t *missingFielderT1) CodecMissingField(field []byte, value interface{}) bool { - switch string(field) { - case "F": - t.f = value.(float64) - case "I": - t.i = value.(int64) - default: - return false - } - return true -} - -func (t *missingFielderT1) CodecMissingFields() map[string]interface{} { - return map[string]interface{}{"F": t.f, "I": t.i} -} - -type missingFielderT2 struct { - S string - B bool - F float64 - I int64 -} - -type testSelfExtHelper struct { - S string - I int64 - B bool -} - -type TestSelfExtImpl struct { - testSelfExtHelper -} - -type TestSelfExtImpl2 struct { - M string - O bool -} - -type TestTwoNakedInterfaces struct { - A interface{} - B interface{} -} - -var testWRepeated512 wrapBytes -var testStrucTime = time.Date(2012, 2, 2, 2, 2, 2, 2000, time.UTC).UTC() - -func init() { - var testARepeated512 [512]byte - for i := range testARepeated512 { - testARepeated512[i] = 'A' - } - testWRepeated512 = wrapBytes(testARepeated512[:]) -} - -type TestStrucFlex struct { - _struct struct{} `codec:",omitempty"` //set omitempty for every field - TestStrucCommon - - Chstr chan string - - Mis map[int]string - Mbu64 map[bool]struct{} - Miwu64s map[int]wrapUint64Slice - Mfwss map[float64]wrapStringSlice - Mf32wss map[float32]wrapStringSlice - Mui2wss map[uint64]wrapStringSlice - - // DecodeNaked bombs because stringUint64T is decoded as a map, - // and a map cannot be the key type of a map. - // Ensure this is set to nil if decoding into a nil interface{}. - Msu2wss map[stringUint64T]wrapStringSlice - - Ci64 wrapInt64 - Swrapbytes []wrapBytes - Swrapuint8 []wrapUint8 - - ArrStrUi64T [4]stringUint64T - - Ui64array [4]uint64 - Ui64slicearray []*[4]uint64 - - SintfAarray []interface{} - - // Ensure this is set to nil if decoding into a nil interface{}. - MstrUi64TSelf map[stringUint64T]*stringUint64T - - // make this a ptr, so that it could be set or not. - // for comparison (e.g. with msgp), give it a struct tag (so it is not inlined), - // make this one omitempty (so it is excluded if nil). - *AnonInTestStrucIntf `json:",omitempty"` - - //M map[interface{}]interface{} `json:"-",bson:"-"` - Mtsptr map[string]*TestStrucFlex - Mts map[string]TestStrucFlex - Its []*TestStrucFlex - Nteststruc *TestStrucFlex -} - -func emptyTestStrucFlex() *TestStrucFlex { - var ts TestStrucFlex - // we initialize and start draining the chan, so that we can decode into it without it blocking due to no consumer - ts.Chstr = make(chan string, teststrucflexChanCap) - go func() { - for range ts.Chstr { - } - }() // drain it - return &ts -} - -func newTestStrucFlex(depth, n int, bench, useInterface, useStringKeyOnly bool) (ts *TestStrucFlex) { - ts = &TestStrucFlex{ - Chstr: make(chan string, teststrucflexChanCap), - - Miwu64s: map[int]wrapUint64Slice{ - 5: []wrapUint64{1, 2, 3, 4, 5}, - 3: []wrapUint64{1, 2, 3}, - }, - - Mf32wss: map[float32]wrapStringSlice{ - 5.0: []wrapString{"1.0", "2.0", "3.0", "4.0", "5.0"}, - 3.0: []wrapString{"1.0", "2.0", "3.0"}, - }, - - Mui2wss: map[uint64]wrapStringSlice{ - 5: []wrapString{"1.0", "2.0", "3.0", "4.0", "5.0"}, - 3: []wrapString{"1.0", "2.0", "3.0"}, - }, - - Mfwss: map[float64]wrapStringSlice{ - 5.0: []wrapString{"1.0", "2.0", "3.0", "4.0", "5.0"}, - 3.0: []wrapString{"1.0", "2.0", "3.0"}, - }, - - // DecodeNaked bombs here, because the stringUint64T is decoded as a map, - // and a map cannot be the key type of a map. - // Ensure this is set to nil if decoding into a nil interface{}. - Msu2wss: map[stringUint64T]wrapStringSlice{ - stringUint64T{"5", 5}: []wrapString{"1", "2", "3", "4", "5"}, - stringUint64T{"3", 3}: []wrapString{"1", "2", "3"}, - }, - - Mis: map[int]string{ - 1: "one", - 22: "twenty two", - -44: "minus forty four", - }, - Mbu64: map[bool]struct{}{false: {}, true: {}}, - - Ci64: -22, - Swrapbytes: []wrapBytes{ // lengths of 1, 2, 4, 8, 16, 32, 64, 128, 256, - testWRepeated512[:1], - testWRepeated512[:2], - testWRepeated512[:4], - testWRepeated512[:8], - testWRepeated512[:16], - testWRepeated512[:32], - testWRepeated512[:64], - testWRepeated512[:128], - testWRepeated512[:256], - testWRepeated512[:512], - }, - Swrapuint8: []wrapUint8{ - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', - }, - Ui64array: [4]uint64{4, 16, 64, 256}, - ArrStrUi64T: [4]stringUint64T{{"4", 4}, {"3", 3}, {"2", 2}, {"1", 1}}, - SintfAarray: []interface{}{Aarray{"s"}}, - MstrUi64TSelf: make(map[stringUint64T]*stringUint64T, numStrUi64T), - } - - for i := uint64(0); i < numStrUi64T; i++ { - ss := stringUint64T{S: strings.Repeat(strconv.FormatUint(i, 10), 4), U: i} - // Ensure this is set to nil if decoding into a nil interface{}. - ts.MstrUi64TSelf[ss] = &ss - } - - numChanSend := cap(ts.Chstr) / 4 // 8 - for i := 0; i < numChanSend; i++ { - ts.Chstr <- strings.Repeat("A", i+1) - } - - ts.Ui64slicearray = []*[4]uint64{&ts.Ui64array, &ts.Ui64array} - - if useInterface { - ts.AnonInTestStrucIntf = &AnonInTestStrucIntf{ - Islice: []interface{}{strRpt(n, "true"), true, strRpt(n, "no"), false, uint64(288), float64(0.4)}, - Ms: map[string]interface{}{ - strRpt(n, "true"): strRpt(n, "true"), - strRpt(n, "int64(9)"): false, - }, - T: testStrucTime, - } - } - - populateTestStrucCommon(&ts.TestStrucCommon, n, bench, useInterface, useStringKeyOnly) - if depth > 0 { - depth-- - if ts.Mtsptr == nil { - ts.Mtsptr = make(map[string]*TestStrucFlex) - } - if ts.Mts == nil { - ts.Mts = make(map[string]TestStrucFlex) - } - ts.Mtsptr["0"] = newTestStrucFlex(depth, n, bench, useInterface, useStringKeyOnly) - ts.Mts["0"] = *(ts.Mtsptr["0"]) - ts.Its = append(ts.Its, ts.Mtsptr["0"]) - } - return -} diff --git a/vendor/github.com/ugorji/go/codec/values_test.go b/vendor/github.com/ugorji/go/codec/values_test.go deleted file mode 100644 index a5b8461ef..000000000 --- a/vendor/github.com/ugorji/go/codec/values_test.go +++ /dev/null @@ -1,418 +0,0 @@ -// comment this out // + build testing - -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -// This file contains values used by tests and benchmarks. -// The benchmarks will test performance against other libraries -// (encoding/json, json-iterator, bson, gob, etc). -// Consequently, we only use values that will parse well in all engines, -// and only leverage features that work across multiple libraries for a truer comparison. -// For example, -// - JSON/BSON do not like maps with keys that are not strings, -// so we only use maps with string keys here. -// - _struct options are not honored by other libraries, -// so we don't use them in this file. - -import ( - "math" - "strconv" - "strings" -) - -// func init() { -// rt := reflect.TypeOf((*TestStruc)(nil)).Elem() -// defTypeInfos.get(rt2id(rt), rt) -// } - -const numStrUi64T = 32 // use 8, prefer 32, test with 1024 - -type wrapSliceUint64 []uint64 -type wrapSliceString []string -type wrapUint64 uint64 -type wrapString string -type wrapUint64Slice []wrapUint64 -type wrapStringSlice []wrapString - -// some other types - -type stringUint64T struct { - S string - U uint64 -} - -type AnonInTestStruc struct { - AS string - AI64 int64 - AI16 int16 - AUi64 uint64 - ASslice []string - AI64slice []int64 - AUi64slice []uint64 - AF64slice []float64 - AF32slice []float32 - - // AMI32U32 map[int32]uint32 - // AMU32F64 map[uint32]float64 // json/bson do not like it - AMSU16 map[string]uint16 - - // use these to test 0-len or nil slices/maps/arrays - AI64arr0 [0]int64 - AI64slice0 []int64 - AUi64sliceN []uint64 - AMSU16N map[string]uint16 - AMSU16E map[string]uint16 -} - -// testSimpleFields is a sub-set of TestStrucCommon -type testSimpleFields struct { - S string - - I64 int64 - I8 int8 - - Ui64 uint64 - Ui8 uint8 - - F64 float64 - F32 float32 - - B bool - - Sslice []string - I16slice []int16 - Ui64slice []uint64 - Ui8slice []uint8 - Bslice []bool - - Iptrslice []*int64 - - WrapSliceInt64 wrapSliceUint64 - WrapSliceString wrapSliceString - - Msi64 map[string]int64 -} - -type TestStrucCommon struct { - S string - - I64 int64 - I32 int32 - I16 int16 - I8 int8 - - I64n int64 - I32n int32 - I16n int16 - I8n int8 - - Ui64 uint64 - Ui32 uint32 - Ui16 uint16 - Ui8 uint8 - - F64 float64 - F32 float32 - - B bool - By uint8 // byte: msgp doesn't like byte - - Sslice []string - I64slice []int64 - I16slice []int16 - Ui64slice []uint64 - Ui8slice []uint8 - Bslice []bool - Byslice []byte - - BytesSlice [][]byte - - Iptrslice []*int64 - - WrapSliceInt64 wrapSliceUint64 - WrapSliceString wrapSliceString - - Msi64 map[string]int64 - - Msbytes map[string][]byte - - Simplef testSimpleFields - - SstrUi64T []stringUint64T - MstrUi64T map[string]*stringUint64T - - AnonInTestStruc - - NotAnon AnonInTestStruc - - // R Raw // Testing Raw must be explicitly turned on, so use standalone test - // Rext RawExt // Testing RawExt is tricky, so use standalone test - - Nmap map[string]bool //don't set this, so we can test for nil - Nslice []byte //don't set this, so we can test for nil - Nint64 *int64 //don't set this, so we can test for nil -} - -type TestStruc struct { - // _struct struct{} `json:",omitempty"` //set omitempty for every field - - TestStrucCommon - - Mtsptr map[string]*TestStruc - Mts map[string]TestStruc - Its []*TestStruc - Nteststruc *TestStruc -} - -func populateTestStrucCommon(ts *TestStrucCommon, n int, bench, useInterface, useStringKeyOnly bool) { - var i64a, i64b, i64c, i64d int64 = 64, 6464, 646464, 64646464 - - // if bench, do not use uint64 values > math.MaxInt64, as bson, etc cannot decode them - - var a = AnonInTestStruc{ - // There's more leeway in altering this. - AS: strRpt(n, "A-String"), - AI64: -64646464, - AI16: 1616, - AUi64: 64646464, - // (U+1D11E)G-clef character may be represented in json as "\uD834\uDD1E". - // single reverse solidus character may be represented in json as "\u005C". - // include these in ASslice below. - ASslice: []string{ - strRpt(n, "Aone"), - strRpt(n, "Atwo"), - strRpt(n, "Athree"), - strRpt(n, "Afour.reverse_solidus.\u005c"), - strRpt(n, "Afive.Gclef.\U0001d11E\"ugorji\"done.")}, - AI64slice: []int64{ - 0, 1, -1, -22, 333, -4444, 55555, -666666, - // msgpack ones - -48, -32, -24, -8, 32, 127, 192, 255, - // standard ones - 0, -1, 1, - math.MaxInt8, math.MaxInt8 + 4, math.MaxInt8 - 4, - math.MaxInt16, math.MaxInt16 + 4, math.MaxInt16 - 4, - math.MaxInt32, math.MaxInt32 + 4, math.MaxInt32 - 4, - math.MaxInt64, math.MaxInt64 - 4, - math.MinInt8, math.MinInt8 + 4, math.MinInt8 - 4, - math.MinInt16, math.MinInt16 + 4, math.MinInt16 - 4, - math.MinInt32, math.MinInt32 + 4, math.MinInt32 - 4, - math.MinInt64, math.MinInt64 + 4, - }, - AUi64slice: []uint64{ - 0, 1, 22, 333, 4444, 55555, 666666, - // standard ones - math.MaxUint8, math.MaxUint8 + 4, math.MaxUint8 - 4, - math.MaxUint16, math.MaxUint16 + 4, math.MaxUint16 - 4, - math.MaxUint32, math.MaxUint32 + 4, math.MaxUint32 - 4, - }, - AMSU16: map[string]uint16{strRpt(n, "1"): 1, strRpt(n, "22"): 2, strRpt(n, "333"): 3, strRpt(n, "4444"): 4}, - - // Note: +/- inf, NaN, and other non-representable numbers should not be explicitly tested here - - AF64slice: []float64{ - 11.11e-11, -11.11e+11, - 2.222E+12, -2.222E-12, - -555.55E-5, 555.55E+5, - 666.66E-6, -666.66E+6, - 7777.7777E-7, -7777.7777E-7, - -8888.8888E+8, 8888.8888E+8, - -99999.9999E+9, 99999.9999E+9, - // these below are hairy enough to need strconv.ParseFloat - 33.33E-33, -33.33E+33, - 44.44e+44, -44.44e-44, - // standard ones - 0, -1, 1, - // math.Inf(1), math.Inf(-1), - math.Pi, math.Phi, math.E, - math.MaxFloat64, math.SmallestNonzeroFloat64, - }, - AF32slice: []float32{ - 11.11e-1, -11.11e+1, - 2.222E+2, -2.222E-2, - -55.55E-5, 55.55E+5, - 66.66E-6, -66.66E+6, - 777.777E-7, -777.777E-7, - -8.88E+8, 8.88E-8, - -99999.9999E+9, 99999.9999E+9, - // these below are hairy enough to need strconv.ParseFloat - 33.33E-33, -33.33E+33, - // standard ones - 0, -1, 1, - // math.Float32frombits(0x7FF00000), math.Float32frombits(0xFFF00000), //+inf and -inf - math.MaxFloat32, math.SmallestNonzeroFloat32, - }, - - AI64slice0: []int64{}, - AUi64sliceN: nil, - AMSU16N: nil, - AMSU16E: map[string]uint16{}, - } - - if !bench { - a.AUi64slice = append(a.AUi64slice, math.MaxUint64, math.MaxUint64-4) - } - *ts = TestStrucCommon{ - S: strRpt(n, `some really really cool names that are nigerian and american like "ugorji melody nwoke" - get it? `), - - // set the numbers close to the limits - I8: math.MaxInt8 * 2 / 3, // 8, - I8n: math.MinInt8 * 2 / 3, // 8, - I16: math.MaxInt16 * 2 / 3, // 16, - I16n: math.MinInt16 * 2 / 3, // 16, - I32: math.MaxInt32 * 2 / 3, // 32, - I32n: math.MinInt32 * 2 / 3, // 32, - I64: math.MaxInt64 * 2 / 3, // 64, - I64n: math.MinInt64 * 2 / 3, // 64, - - Ui64: math.MaxUint64 * 2 / 3, // 64 - Ui32: math.MaxUint32 * 2 / 3, // 32 - Ui16: math.MaxUint16 * 2 / 3, // 16 - Ui8: math.MaxUint8 * 2 / 3, // 8 - - F32: 3.402823e+38, // max representable float32 without losing precision - F64: 3.40281991833838838338e+53, - - B: true, - By: 5, - - Sslice: []string{strRpt(n, "one"), strRpt(n, "two"), strRpt(n, "three")}, - I64slice: []int64{1111, 2222, 3333}, - I16slice: []int16{44, 55, 66}, - Ui64slice: []uint64{12121212, 34343434, 56565656}, - Ui8slice: []uint8{210, 211, 212}, - Bslice: []bool{true, false, true, false}, - Byslice: []byte{13, 14, 15}, - BytesSlice: [][]byte{ - []byte(strRpt(n, "one")), - []byte(strRpt(n, "two")), - []byte(strRpt(n, "\"three\"")), - }, - Msi64: map[string]int64{ - strRpt(n, "one"): 1, - strRpt(n, "two"): 2, - strRpt(n, "\"three\""): 3, - }, - Msbytes: map[string][]byte{ - strRpt(n, "one"): []byte(strRpt(n, "one")), - strRpt(n, "two"): []byte(strRpt(n, "two")), - strRpt(n, "\"three\""): []byte(strRpt(n, "\"three\"")), - }, - WrapSliceInt64: []uint64{4, 16, 64, 256}, - WrapSliceString: []string{strRpt(n, "4"), strRpt(n, "16"), strRpt(n, "64"), strRpt(n, "256")}, - - // R: Raw([]byte("goodbye")), - // Rext: RawExt{ 120, []byte("hello"), }, // TODO: don't set this - it's hard to test - - // make Simplef same as top-level - // TODO: should this have slightly different values??? - Simplef: testSimpleFields{ - S: strRpt(n, `some really really cool names that are nigerian and american like "ugorji melody nwoke" - get it? `), - - // set the numbers close to the limits - I8: math.MaxInt8 * 2 / 3, // 8, - I64: math.MaxInt64 * 2 / 3, // 64, - - Ui64: math.MaxUint64 * 2 / 3, // 64 - Ui8: math.MaxUint8 * 2 / 3, // 8 - - F32: 3.402823e+38, // max representable float32 without losing precision - F64: 3.40281991833838838338e+53, - - B: true, - - Sslice: []string{strRpt(n, "one"), strRpt(n, "two"), strRpt(n, "three")}, - I16slice: []int16{44, 55, 66}, - Ui64slice: []uint64{12121212, 34343434, 56565656}, - Ui8slice: []uint8{210, 211, 212}, - Bslice: []bool{true, false, true, false}, - - Msi64: map[string]int64{ - strRpt(n, "one"): 1, - strRpt(n, "two"): 2, - strRpt(n, "\"three\""): 3, - }, - - WrapSliceInt64: []uint64{4, 16, 64, 256}, - WrapSliceString: []string{strRpt(n, "4"), strRpt(n, "16"), strRpt(n, "64"), strRpt(n, "256")}, - }, - - SstrUi64T: make([]stringUint64T, numStrUi64T), // {{"1", 1}, {"2", 2}, {"3", 3}, {"4", 4}}, - MstrUi64T: make(map[string]*stringUint64T, numStrUi64T), - AnonInTestStruc: a, - NotAnon: a, - } - - for i := uint64(0); i < numStrUi64T; i++ { - ss := strings.Repeat(strconv.FormatUint(i, 10), int(i)) // 4) - ts.SstrUi64T[i] = stringUint64T{S: ss, U: i} - ts.MstrUi64T[ss] = &ts.SstrUi64T[i] - } - - if bench { - ts.Ui64 = math.MaxInt64 * 2 / 3 - ts.Simplef.Ui64 = ts.Ui64 - } - - //For benchmarks, some things will not work. - if !bench { - //json and bson require string keys in maps - //ts.M = map[interface{}]interface{}{ - // true: "true", - // int8(9): false, - //} - //gob cannot encode nil in element in array (encodeArray: nil element) - ts.Iptrslice = []*int64{nil, &i64a, nil, &i64b, nil, &i64c, nil, &i64d, nil} - // ts.Iptrslice = nil - } - if !useStringKeyOnly { - var _ byte = 0 // so this empty branch doesn't flag a warning - // ts.AnonInTestStruc.AMU32F64 = map[uint32]float64{1: 1, 2: 2, 3: 3} // Json/Bson barf - } -} - -func newTestStruc(depth, n int, bench, useInterface, useStringKeyOnly bool) (ts *TestStruc) { - ts = &TestStruc{} - populateTestStrucCommon(&ts.TestStrucCommon, n, bench, useInterface, useStringKeyOnly) - if depth > 0 { - depth-- - if ts.Mtsptr == nil { - ts.Mtsptr = make(map[string]*TestStruc) - } - if ts.Mts == nil { - ts.Mts = make(map[string]TestStruc) - } - ts.Mtsptr[strRpt(n, "0")] = newTestStruc(depth, n, bench, useInterface, useStringKeyOnly) - ts.Mts[strRpt(n, "0")] = *(ts.Mtsptr[strRpt(n, "0")]) - ts.Its = append(ts.Its, ts.Mtsptr[strRpt(n, "0")]) - } - return -} - -var testStrRptMap = make(map[int]map[string]string) - -func strRpt(n int, s string) string { - if false { - // fmt.Printf(">>>> calling strings.Repeat on n: %d, key: %s\n", n, s) - return strings.Repeat(s, n) - } - m1, ok := testStrRptMap[n] - if !ok { - // fmt.Printf(">>>> making new map for n: %v\n", n) - m1 = make(map[string]string) - testStrRptMap[n] = m1 - } - v1, ok := m1[s] - if !ok { - // fmt.Printf(">>>> creating new entry for key: %s\n", s) - v1 = strings.Repeat(s, n) - m1[s] = v1 - } - return v1 -} - -// func wstrRpt(n int, s string) wrapBytes { -// return wrapBytes(bytes.Repeat([]byte(s), n)) -// } diff --git a/vendor/github.com/ugorji/go/codec/writer.go b/vendor/github.com/ugorji/go/codec/writer.go deleted file mode 100644 index 76ad59fb2..000000000 --- a/vendor/github.com/ugorji/go/codec/writer.go +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -package codec - -import "io" - -// encWriter abstracts writing to a byte array or to an io.Writer. -type encWriter interface { - writeb([]byte) - writestr(string) - writeqstr(string) // write string wrapped in quotes ie "..." - writen1(byte) - writen2(byte, byte) - // writen will write up to 7 bytes at a time. - writen(b [rwNLen]byte, num uint8) - end() -} - -// --------------------------------------------- - -// bufioEncWriter -type bufioEncWriter struct { - w io.Writer - - buf []byte - - n int - - b [16]byte // scratch buffer and padding (cache-aligned) -} - -func (z *bufioEncWriter) reset(w io.Writer, bufsize int, blist *bytesFreelist) { - z.w = w - z.n = 0 - if bufsize <= 0 { - bufsize = defEncByteBufSize - } - // bufsize must be >= 8, to accomodate writen methods (where n <= 8) - if bufsize <= 8 { - bufsize = 8 - } - if cap(z.buf) < bufsize { - if len(z.buf) > 0 && &z.buf[0] != &z.b[0] { - blist.put(z.buf) - } - if len(z.b) > bufsize { - z.buf = z.b[:] - } else { - z.buf = blist.get(bufsize) - } - } - z.buf = z.buf[:cap(z.buf)] -} - -//go:noinline - flush only called intermittently -func (z *bufioEncWriter) flushErr() (err error) { - n, err := z.w.Write(z.buf[:z.n]) - z.n -= n - if z.n > 0 && err == nil { - err = io.ErrShortWrite - } - if n > 0 && z.n > 0 { - copy(z.buf, z.buf[n:z.n+n]) - } - return err -} - -func (z *bufioEncWriter) flush() { - if err := z.flushErr(); err != nil { - panic(err) - } -} - -func (z *bufioEncWriter) writeb(s []byte) { -LOOP: - a := len(z.buf) - z.n - if len(s) > a { - z.n += copy(z.buf[z.n:], s[:a]) - s = s[a:] - z.flush() - goto LOOP - } - z.n += copy(z.buf[z.n:], s) -} - -func (z *bufioEncWriter) writestr(s string) { - // z.writeb(bytesView(s)) // inlined below -LOOP: - a := len(z.buf) - z.n - if len(s) > a { - z.n += copy(z.buf[z.n:], s[:a]) - s = s[a:] - z.flush() - goto LOOP - } - z.n += copy(z.buf[z.n:], s) -} - -func (z *bufioEncWriter) writeqstr(s string) { - // z.writen1('"') - // z.writestr(s) - // z.writen1('"') - - if z.n+len(s)+2 > len(z.buf) { - z.flush() - } - z.buf[z.n] = '"' - z.n++ -LOOP: - a := len(z.buf) - z.n - if len(s)+1 > a { - z.n += copy(z.buf[z.n:], s[:a]) - s = s[a:] - z.flush() - goto LOOP - } - z.n += copy(z.buf[z.n:], s) - z.buf[z.n] = '"' - z.n++ -} - -func (z *bufioEncWriter) writen1(b1 byte) { - if 1 > len(z.buf)-z.n { - z.flush() - } - z.buf[z.n] = b1 - z.n++ -} - -func (z *bufioEncWriter) writen2(b1, b2 byte) { - if 2 > len(z.buf)-z.n { - z.flush() - } - z.buf[z.n+1] = b2 - z.buf[z.n] = b1 - z.n += 2 -} - -func (z *bufioEncWriter) writen(b [rwNLen]byte, num uint8) { - if int(num) > len(z.buf)-z.n { - z.flush() - } - copy(z.buf[z.n:], b[:num]) - z.n += int(num) -} - -func (z *bufioEncWriter) endErr() (err error) { - if z.n > 0 { - err = z.flushErr() - } - return -} - -// --------------------------------------------- - -// bytesEncAppender implements encWriter and can write to an byte slice. -type bytesEncAppender struct { - b []byte - out *[]byte -} - -func (z *bytesEncAppender) writeb(s []byte) { - z.b = append(z.b, s...) -} -func (z *bytesEncAppender) writestr(s string) { - z.b = append(z.b, s...) -} -func (z *bytesEncAppender) writeqstr(s string) { - z.b = append(append(append(z.b, '"'), s...), '"') - - // z.b = append(z.b, '"') - // z.b = append(z.b, s...) - // z.b = append(z.b, '"') -} -func (z *bytesEncAppender) writen1(b1 byte) { - z.b = append(z.b, b1) -} -func (z *bytesEncAppender) writen2(b1, b2 byte) { - z.b = append(z.b, b1, b2) // cost: 81 -} -func (z *bytesEncAppender) writen(s [rwNLen]byte, num uint8) { - // if num <= rwNLen { - if int(num) <= len(s) { - z.b = append(z.b, s[:num]...) - } -} -func (z *bytesEncAppender) endErr() error { - *(z.out) = z.b - return nil -} -func (z *bytesEncAppender) reset(in []byte, out *[]byte) { - z.b = in[:0] - z.out = out -} - -// -------------------------------------------------- - -type encWr struct { - bytes bool // encoding to []byte - js bool // is json encoder? - be bool // is binary encoder? - - c containerState - - calls uint16 - - wb bytesEncAppender - wf *bufioEncWriter -} - -func (z *encWr) writeb(s []byte) { - if z.bytes { - z.wb.writeb(s) - } else { - z.wf.writeb(s) - } -} -func (z *encWr) writeqstr(s string) { - if z.bytes { - // unfortunately, calling the function prevents inlining it here. - // explicitly writing it here will allow it inline. - // NOTE: Keep in sync with function implementation. - // - // z.wb.writeqstr(s) - - z.wb.b = append(append(append(z.wb.b, '"'), s...), '"') - } else { - z.wf.writeqstr(s) - } -} -func (z *encWr) writestr(s string) { - if z.bytes { - z.wb.writestr(s) - } else { - z.wf.writestr(s) - } -} -func (z *encWr) writen1(b1 byte) { - if z.bytes { - z.wb.writen1(b1) - } else { - z.wf.writen1(b1) - } -} -func (z *encWr) writen2(b1, b2 byte) { - if z.bytes { - // unfortunately, calling the function prevents inlining it here. - // explicitly writing it here will allow it inline. - // NOTE: Keep in sync with function implementation. - // - // z.wb.writen2(b1, b2) - z.wb.b = append(z.wb.b, b1, b2) - } else { - z.wf.writen2(b1, b2) - } -} -func (z *encWr) writen(b [rwNLen]byte, num uint8) { - if z.bytes { - z.wb.writen(b, num) - } else { - z.wf.writen(b, num) - } -} -func (z *encWr) endErr() error { - if z.bytes { - return z.wb.endErr() - } - return z.wf.endErr() -} - -func (z *encWr) end() { - if err := z.endErr(); err != nil { - panic(err) - } -} - -var _ encWriter = (*encWr)(nil) diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go deleted file mode 100644 index 63fcdfca2..000000000 --- a/vendor/github.com/ugorji/go/codec/xml.go +++ /dev/null @@ -1,502 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build ignore - -package codec - -/* - -A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder. - -We are attempting this due to perceived issues with encoding/xml: - - Complicated. It tried to do too much, and is not as simple to use as json. - - Due to over-engineering, reflection is over-used AND performance suffers: - java is 6X faster:http://fabsk.eu/blog/category/informatique/dev/golang/ - even PYTHON performs better: http://outgoing.typepad.com/outgoing/2014/07/exploring-golang.html - -codec framework will offer the following benefits - - VASTLY improved performance (when using reflection-mode or codecgen) - - simplicity and consistency: with the rest of the supported formats - - all other benefits of codec framework (streaming, codegeneration, etc) - -codec is not a drop-in replacement for encoding/xml. -It is a replacement, based on the simplicity and performance of codec. -Look at it like JAXB for Go. - -Challenges: - - Need to output XML preamble, with all namespaces at the right location in the output. - - Each "end" block is dynamic, so we need to maintain a context-aware stack - - How to decide when to use an attribute VS an element - - How to handle chardata, attr, comment EXPLICITLY. - - Should it output fragments? - e.g. encoding a bool should just output true OR false, which is not well-formed XML. - -Extend the struct tag. See representative example: - type X struct { - ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"` - // format: [namespace-uri ][namespace-prefix ]local-name, ... - } - -Based on this, we encode - - fields as elements, BUT - encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string) - - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata". - -To handle namespaces: - - XMLHandle is denoted as being namespace-aware. - Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name. - - *Encoder and *Decoder know whether the Handle "prefers" namespaces. - - add *Encoder.getEncName(*structFieldInfo). - No one calls *structFieldInfo.indexForEncName directly anymore - - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware - indexForEncName takes a parameter of the form namespace:local-name OR local-name - - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc - by being a method on *Decoder, or maybe a method on the Handle itself. - No one accesses .encName anymore - - let encode.go and decode.go use these (for consistency) - - only problem exists for gen.go, where we create a big switch on encName. - Now, we also have to add a switch on strings.endsWith(kName, encNsName) - - gen.go will need to have many more methods, and then double-on the 2 switch loops like: - switch k { - case "abc" : x.abc() - case "def" : x.def() - default { - switch { - case !nsAware: panic(...) - case strings.endsWith(":abc"): x.abc() - case strings.endsWith(":def"): x.def() - default: panic(...) - } - } - } - -The structure below accommodates this: - - type typeInfo struct { - sfi []*structFieldInfo // sorted by encName - sfins // sorted by namespace - sfia // sorted, to have those with attributes at the top. Needed to write XML appropriately. - sfip // unsorted - } - type structFieldInfo struct { - encName - nsEncName - ns string - attr bool - cdata bool - } - -indexForEncName is now an internal helper function that takes a sorted array -(one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...) - -There will be a separate parser from the builder. -The parser will have a method: next() xmlToken method. It has lookahead support, -so you can pop multiple tokens, make a determination, and push them back in the order popped. -This will be needed to determine whether we are "nakedly" decoding a container or not. -The stack will be implemented using a slice and push/pop happens at the [0] element. - -xmlToken has fields: - - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text - - value string - - ns string - -SEE: http://www.xml.com/pub/a/98/10/guide0.html?page=3#ENTDECL - -The following are skipped when parsing: - - External Entities (from external file) - - Notation Declaration e.g. - - Entity Declarations & References - - XML Declaration (assume UTF-8) - - XML Directive i.e. - - Other Declarations: Notation, etc. - - Comment - - Processing Instruction - - schema / DTD for validation: - We are not a VALIDATING parser. Validation is done elsewhere. - However, some parts of the DTD internal subset are used (SEE BELOW). - For Attribute List Declarations e.g. - - We considered using the ATTLIST to get "default" value, but not to validate the contents. (VETOED) - -The following XML features are supported - - Namespace - - Element - - Attribute - - cdata - - Unicode escape - -The following DTD (when as an internal sub-set) features are supported: - - Internal Entities e.g. - AND entities for the set: [<>&"'] - - Parameter entities e.g. - - -At decode time, a structure containing the following is kept - - namespace mapping - - default attribute values - - all internal entities (<>&"' and others written in the document) - -When decode starts, it parses XML namespace declarations and creates a map in the -xmlDecDriver. While parsing, that map continuously gets updated. -The only problem happens when a namespace declaration happens on the node that it defines. -e.g. -To handle this, each Element must be fully parsed at a time, -even if it amounts to multiple tokens which are returned one at a time on request. - -xmlns is a special attribute name. - - It is used to define namespaces, including the default - - It is never returned as an AttrKey or AttrVal. - *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.* - -Number, bool, null, mapKey, etc can all be decoded from any xmlToken. -This accommodates map[int]string for example. - -It should be possible to create a schema from the types, -or vice versa (generate types from schema with appropriate tags). -This is however out-of-scope from this parsing project. - -We should write all namespace information at the first point that it is referenced in the tree, -and use the mapping for all child nodes and attributes. This means that state is maintained -at a point in the tree. This also means that calls to Decode or MustDecode will reset some state. - -When decoding, it is important to keep track of entity references and default attribute values. -It seems these can only be stored in the DTD components. We should honor them when decoding. - -Configuration for XMLHandle will look like this: - - XMLHandle - DefaultNS string - // Encoding: - NS map[string]string // ns URI to key, used for encoding - // Decoding: in case ENTITY declared in external schema or dtd, store info needed here - Entities map[string]string // map of entity rep to character - - -During encode, if a namespace mapping is not defined for a namespace found on a struct, -then we create a mapping for it using nsN (where N is 1..1000000, and doesn't conflict -with any other namespace mapping). - -Note that different fields in a struct can have different namespaces. -However, all fields will default to the namespace on the _struct field (if defined). - -An XML document is a name, a map of attributes and a list of children. -Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example). -We have to "DecodeNaked" into something that resembles XML data. - -To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types: - type Name struct { // Preferred. Less allocations due to conversions. - Local string - Space string - } - type Element struct { - Name Name - Attrs map[Name]string - Children []interface{} // each child is either *Element or string - } -Only two "supporting" types are exposed for XML: Name and Element. - -// ------------------ - -We considered 'type Name string' where Name is like "Space Local" (space-separated). -We decided against it, because each creation of a name would lead to -double allocation (first convert []byte to string, then concatenate them into a string). -The benefit is that it is faster to read Attrs from a map. But given that Element is a value -object, we want to eschew methods and have public exposed variables. - -We also considered the following, where xml types were not value objects, and we used -intelligent accessor methods to extract information and for performance. -*** WE DECIDED AGAINST THIS. *** - type Attr struct { - Name Name - Value string - } - // Element is a ValueObject: There are no accessor methods. - // Make element self-contained. - type Element struct { - Name Name - attrsMap map[string]string // where key is "Space Local" - attrs []Attr - childrenT []string - childrenE []Element - childrenI []int // each child is a index into T or E. - } - func (x *Element) child(i) interface{} // returns string or *Element - -// ------------------ - -Per XML spec and our default handling, white space is always treated as -insignificant between elements, except in a text node. The xml:space='preserve' -attribute is ignored. - -**Note: there is no xml: namespace. The xml: attributes were defined before namespaces.** -**So treat them as just "directives" that should be interpreted to mean something**. - -On encoding, we support indenting aka prettifying markup in the same way we support it for json. - -A document or element can only be encoded/decoded from/to a struct. In this mode: - - struct name maps to element name (or tag-info from _struct field) - - fields are mapped to child elements or attributes - -A map is either encoded as attributes on current element, or as a set of child elements. -Maps are encoded as attributes iff their keys and values are primitives (number, bool, string). - -A list is encoded as a set of child elements. - -Primitives (number, bool, string) are encoded as an element, attribute or text -depending on the context. - -Extensions must encode themselves as a text string. - -Encoding is tough, specifically when encoding mappings, because we need to encode -as either attribute or element. To do this, we need to default to encoding as attributes, -and then let Encoder inform the Handle when to start encoding as nodes. -i.e. Encoder does something like: - - h.EncodeMapStart() - h.Encode(), h.Encode(), ... - h.EncodeMapNotAttrSignal() // this is not a bool, because it's a signal - h.Encode(), h.Encode(), ... - h.EncodeEnd() - -Only XMLHandle understands this, and will set itself to start encoding as elements. - -This support extends to maps. For example, if a struct field is a map, and it has -the struct tag signifying it should be attr, then all its fields are encoded as attributes. -e.g. - - type X struct { - M map[string]int `codec:"m,attr"` // encode keys as attributes named - } - -Question: - - if encoding a map, what if map keys have spaces in them??? - Then they cannot be attributes or child elements. Error. - -Options to consider adding later: - - For attribute values, normalize by trimming beginning and ending white space, - and converting every white space sequence to a single space. - - ATTLIST restrictions are enforced. - e.g. default value of xml:space, skipping xml:XYZ style attributes, etc. - - Consider supporting NON-STRICT mode (e.g. to handle HTML parsing). - Some elements e.g. br, hr, etc need not close and should be auto-closed - ... (see http://www.w3.org/TR/html4/loose.dtd) - An expansive set of entities are pre-defined. - - Have easy way to create a HTML parser: - add a HTML() method to XMLHandle, that will set Strict=false, specify AutoClose, - and add HTML Entities to the list. - - Support validating element/attribute XMLName before writing it. - Keep this behind a flag, which is set to false by default (for performance). - type XMLHandle struct { - CheckName bool - } - -Misc: - -ROADMAP (1 weeks): - - build encoder (1 day) - - build decoder (based off xmlParser) (1 day) - - implement xmlParser (2 days). - Look at encoding/xml for inspiration. - - integrate and TEST (1 days) - - write article and post it (1 day) - -// ---------- MORE NOTES FROM 2017-11-30 ------------ - -when parsing -- parse the attributes first -- then parse the nodes - -basically: -- if encoding a field: we use the field name for the wrapper -- if encoding a non-field, then just use the element type name - - map[string]string ==> abcval... or - val... OR - val1val2... <- PREFERED - []string ==> v1v2... - string v1 ==> v1 - bool true ==> true - float 1.0 ==> 1.0 - ... - - F1 map[string]string ==> abcval... OR - val... OR - val... <- PREFERED - F2 []string ==> v1v2... - F3 bool ==> true - ... - -- a scalar is encoded as: - (value) of type T ==> - (value) of field F ==> -- A kv-pair is encoded as: - (key,value) ==> OR - (key,value) of field F ==> OR -- A map or struct is just a list of kv-pairs -- A list is encoded as sequences of same node e.g. - - - value21 - value22 -- we may have to singularize the field name, when entering into xml, - and pluralize them when encoding. -- bi-directional encode->decode->encode is not a MUST. - even encoding/xml cannot decode correctly what was encoded: - - see https://play.golang.org/p/224V_nyhMS - func main() { - fmt.Println("Hello, playground") - v := []interface{}{"hello", 1, true, nil, time.Now()} - s, err := xml.Marshal(v) - fmt.Printf("err: %v, \ns: %s\n", err, s) - var v2 []interface{} - err = xml.Unmarshal(s, &v2) - fmt.Printf("err: %v, \nv2: %v\n", err, v2) - type T struct { - V []interface{} - } - v3 := T{V: v} - s, err = xml.Marshal(v3) - fmt.Printf("err: %v, \ns: %s\n", err, s) - var v4 T - err = xml.Unmarshal(s, &v4) - fmt.Printf("err: %v, \nv4: %v\n", err, v4) - } - Output: - err: , - s: hello1true - err: , - v2: [] - err: , - s: hello1true2009-11-10T23:00:00Z - err: , - v4: {[ ]} -- -*/ - -// ----------- PARSER ------------------- - -type xmlTokenType uint8 - -const ( - _ xmlTokenType = iota << 1 - xmlTokenElemStart - xmlTokenElemEnd - xmlTokenAttrKey - xmlTokenAttrVal - xmlTokenText -) - -type xmlToken struct { - Type xmlTokenType - Value string - Namespace string // blank for AttrVal and Text -} - -type xmlParser struct { - r decReader - toks []xmlToken // list of tokens. - ptr int // ptr into the toks slice - done bool // nothing else to parse. r now returns EOF. -} - -func (x *xmlParser) next() (t *xmlToken) { - // once x.done, or x.ptr == len(x.toks) == 0, then return nil (to signify finish) - if !x.done && len(x.toks) == 0 { - x.nextTag() - } - // parses one element at a time (into possible many tokens) - if x.ptr < len(x.toks) { - t = &(x.toks[x.ptr]) - x.ptr++ - if x.ptr == len(x.toks) { - x.ptr = 0 - x.toks = x.toks[:0] - } - } - return -} - -// nextTag will parses the next element and fill up toks. -// It set done flag if/once EOF is reached. -func (x *xmlParser) nextTag() { - // ... -} - -// ----------- ENCODER ------------------- - -type xmlEncDriver struct { - e *Encoder - w encWriter - h *XMLHandle - b [64]byte // scratch - bs []byte // scratch - // s jsonStack - noBuiltInTypes -} - -// ----------- DECODER ------------------- - -type xmlDecDriver struct { - d *Decoder - h *XMLHandle - r decReader // *bytesDecReader decReader - ct valueType // container type. one of unset, array or map. - bstr [8]byte // scratch used for string \UXXX parsing - b [64]byte // scratch - - // wsSkipped bool // whitespace skipped - - // s jsonStack - - noBuiltInTypes -} - -// DecodeNaked will decode into an XMLNode - -// XMLName is a value object representing a namespace-aware NAME -type XMLName struct { - Local string - Space string -} - -// XMLNode represents a "union" of the different types of XML Nodes. -// Only one of fields (Text or *Element) is set. -type XMLNode struct { - Element *Element - Text string -} - -// XMLElement is a value object representing an fully-parsed XML element. -type XMLElement struct { - Name Name - Attrs map[XMLName]string - // Children is a list of child nodes, each being a *XMLElement or string - Children []XMLNode -} - -// ----------- HANDLE ------------------- - -type XMLHandle struct { - BasicHandle - textEncodingType - - DefaultNS string - NS map[string]string // ns URI to key, for encoding - Entities map[string]string // entity representation to string, for encoding. -} - -func (h *XMLHandle) newEncDriver(e *Encoder) encDriver { - return &xmlEncDriver{e: e, w: e.w, h: h} -} - -func (h *XMLHandle) newDecDriver(d *Decoder) decDriver { - // d := xmlDecDriver{r: r.(*bytesDecReader), h: h} - hd := xmlDecDriver{d: d, r: d.r, h: h} - hd.n.bytes = d.b[:] - return &hd -} - -var _ decDriver = (*xmlDecDriver)(nil) -var _ encDriver = (*xmlEncDriver)(nil) diff --git a/vendor/github.com/ugorji/go/codec/z_all_test.go b/vendor/github.com/ugorji/go/codec/z_all_test.go deleted file mode 100644 index 46253213f..000000000 --- a/vendor/github.com/ugorji/go/codec/z_all_test.go +++ /dev/null @@ -1,458 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build alltests -// +build go1.7 - -package codec - -// Run this using: -// go test -tags=alltests -run=Suite -coverprofile=cov.out -// go tool cover -html=cov.out -// -// Because build tags are a build time parameter, we will have to test out the -// different tags separately. -// Tags: x codecgen safe appengine notfastpath -// -// These tags should be added to alltests, e.g. -// go test '-tags=alltests x codecgen' -run=Suite -coverprofile=cov.out -// -// To run all tests before submitting code, run: -// a=( "" "safe" "codecgen" "notfastpath" "codecgen notfastpath" "codecgen safe" "safe notfastpath" ) -// for i in "${a[@]}"; do echo ">>>> TAGS: $i"; go test "-tags=alltests $i" -run=Suite; done -// -// This only works on go1.7 and above. This is when subtests and suites were supported. - -import "testing" - -// func TestMain(m *testing.M) { -// println("calling TestMain") -// // set some parameters -// exitcode := m.Run() -// os.Exit(exitcode) -// } - -func testGroupResetFlags() { - testUseMust = false - testUseIoEncDec = -1 - testUseReset = false - testMaxInitLen = 0 - testUseIoWrapper = false - testNumRepeatString = 8 - testDepth = 0 - testDecodeOptions = DecodeOptions{} - testEncodeOptions = EncodeOptions{} -} - -func testSuite(t *testing.T, f func(t *testing.T)) { - // find . -name "*_test.go" | xargs grep -e 'flag.' | cut -d '&' -f 2 | cut -d ',' -f 1 | grep -e '^test' - // Disregard the following: testInitDebug, testSkipIntf, testJsonIndent (Need a test for it) - - testReinit() // so flag.Parse() is called first, and never called again - - testGroupResetFlags() - - testReinit() - t.Run("optionsFalse", f) - - testUseMust = true - testUseIoEncDec = 0 - testUseReset = true - - // xdebugf("with StructToArray=true") - testDecodeOptions.ZeroCopy = true - testDecodeOptions.InternString = true - testDecodeOptions.MapValueReset = true - // testDecodeOptions.SignedInteger = true - // testDecodeOptions.SliceElementReset = true - // testDecodeOptions.InterfaceReset = true - // testDecodeOptions.PreferArrayOverSlice = true - // testDecodeOptions.DeleteOnNilMapValue = true - // testDecodeOptions.RawToString = true - - testEncodeOptions.StructToArray = true - testEncodeOptions.Canonical = true - testEncodeOptions.CheckCircularRef = true - testEncodeOptions.RecursiveEmptyCheck = true - // testEncodeOptions.Raw = true - // testEncodeOptions.StringToRaw = true - - testReinit() - t.Run("optionsTrue", f) - - // xdebugf("setting StructToArray=false") - testEncodeOptions.StructToArray = false - testDepth = 6 - testReinit() - t.Run("optionsTrue-deepstruct", f) - testDepth = 0 - - // testEncodeOptions.AsSymbols = AsSymbolAll - testUseIoWrapper = true - testReinit() - t.Run("optionsTrue-ioWrapper", f) - - // testUseIoEncDec = -1 - - // make buffer small enough so that we have to re-fill multiple times. - testSkipRPCTests = true - testUseIoEncDec = 128 - // testDecodeOptions.ReaderBufferSize = 128 - // testEncodeOptions.WriterBufferSize = 128 - testReinit() - t.Run("optionsTrue-bufio", f) - // testDecodeOptions.ReaderBufferSize = 0 - // testEncodeOptions.WriterBufferSize = 0 - testUseIoEncDec = -1 - testSkipRPCTests = false - - testNumRepeatString = 32 - testReinit() - t.Run("optionsTrue-largestrings", f) - - // The following here MUST be tested individually, as they create - // side effects i.e. the decoded value is different. - // testDecodeOptions.MapValueReset = true // ok - no side effects - // testDecodeOptions.InterfaceReset = true // error??? because we do deepEquals to verify - // testDecodeOptions.ErrorIfNoField = true // error, as expected, as fields not there - // testDecodeOptions.ErrorIfNoArrayExpand = true // no error, but no error case either - // testDecodeOptions.PreferArrayOverSlice = true // error??? because slice != array. - // .... however, update deepEqual to take this option - // testReinit() - // t.Run("optionsTrue-resetOptions", f) - - testGroupResetFlags() -} - -/* -find . -name "codec_test.go" | xargs grep -e '^func Test' | \ - cut -d '(' -f 1 | cut -d ' ' -f 2 | \ - while read f; do echo "t.Run(\"$f\", $f)"; done -*/ - -func testCodecGroup(t *testing.T) { - // println("running testcodecsuite") - // - - testJsonGroup(t) - testBincGroup(t) - testCborGroup(t) - testMsgpackGroup(t) - testSimpleGroup(t) - // testSimpleMammothGroup(t) - // testRpcGroup(t) - testNonHandlesGroup(t) - - // -} - -func testJsonGroup(t *testing.T) { - t.Run("TestJsonCodecsTable", TestJsonCodecsTable) - t.Run("TestJsonCodecsMisc", TestJsonCodecsMisc) - t.Run("TestJsonCodecsEmbeddedPointer", TestJsonCodecsEmbeddedPointer) - t.Run("TestJsonCodecChan", TestJsonCodecChan) - t.Run("TestJsonStdEncIntf", TestJsonStdEncIntf) - t.Run("TestJsonMammothA", TestJsonMammothA) - t.Run("TestJsonRaw", TestJsonRaw) - t.Run("TestJsonRpcGo", TestJsonRpcGo) - t.Run("TestJsonLargeInteger", TestJsonLargeInteger) - t.Run("TestJsonDecodeNonStringScalarInStringContext", TestJsonDecodeNonStringScalarInStringContext) - t.Run("TestJsonEncodeIndent", TestJsonEncodeIndent) - - t.Run("TestJsonSwallowAndZero", TestJsonSwallowAndZero) - t.Run("TestJsonRawExt", TestJsonRawExt) - t.Run("TestJsonMapStructKey", TestJsonMapStructKey) - t.Run("TestJsonDecodeNilMapValue", TestJsonDecodeNilMapValue) - t.Run("TestJsonEmbeddedFieldPrecedence", TestJsonEmbeddedFieldPrecedence) - t.Run("TestJsonLargeContainerLen", TestJsonLargeContainerLen) - t.Run("TestJsonMammothMapsAndSlices", TestJsonMammothMapsAndSlices) - t.Run("TestJsonTime", TestJsonTime) - t.Run("TestJsonUintToInt", TestJsonUintToInt) - t.Run("TestJsonDifferentMapOrSliceType", TestJsonDifferentMapOrSliceType) - t.Run("TestJsonScalars", TestJsonScalars) - t.Run("TestJsonOmitempty", TestJsonOmitempty) - t.Run("TestJsonIntfMapping", TestJsonIntfMapping) - t.Run("TestJsonMissingFields", TestJsonMissingFields) - t.Run("TestJsonMaxDepth", TestJsonMaxDepth) - t.Run("TestJsonSelfExt", TestJsonSelfExt) - t.Run("TestJsonBytesEncodedAsArray", TestJsonBytesEncodedAsArray) - t.Run("TestJsonStrucEncDec", TestJsonStrucEncDec) - t.Run("TestJsonMapEncodeForCanonical", TestJsonMapEncodeForCanonical) - t.Run("TestJsonRawToStringToRawEtc", TestJsonRawToStringToRawEtc) - t.Run("TestJsonStructKeyType", TestJsonStructKeyType) - t.Run("TestJsonPreferArrayOverSlice", TestJsonPreferArrayOverSlice) - t.Run("TestJsonZeroCopyBytes", TestJsonZeroCopyBytes) - - t.Run("TestJsonInvalidUnicode", TestJsonInvalidUnicode) -} - -func testBincGroup(t *testing.T) { - t.Run("TestBincCodecsTable", TestBincCodecsTable) - t.Run("TestBincCodecsMisc", TestBincCodecsMisc) - t.Run("TestBincCodecsEmbeddedPointer", TestBincCodecsEmbeddedPointer) - t.Run("TestBincStdEncIntf", TestBincStdEncIntf) - t.Run("TestBincMammoth", TestBincMammoth) - t.Run("TestBincRaw", TestBincRaw) - t.Run("TestBincRpcGo", TestBincRpcGo) - t.Run("TestBincUnderlyingType", TestBincUnderlyingType) - - t.Run("TestBincSwallowAndZero", TestBincSwallowAndZero) - t.Run("TestBincRawExt", TestBincRawExt) - t.Run("TestBincMapStructKey", TestBincMapStructKey) - t.Run("TestBincDecodeNilMapValue", TestBincDecodeNilMapValue) - t.Run("TestBincEmbeddedFieldPrecedence", TestBincEmbeddedFieldPrecedence) - t.Run("TestBincLargeContainerLen", TestBincLargeContainerLen) - t.Run("TestBincMammothMapsAndSlices", TestBincMammothMapsAndSlices) - t.Run("TestBincTime", TestBincTime) - t.Run("TestBincUintToInt", TestBincUintToInt) - t.Run("TestBincDifferentMapOrSliceType", TestBincDifferentMapOrSliceType) - t.Run("TestBincScalars", TestBincScalars) - t.Run("TestBincOmitempty", TestBincOmitempty) - t.Run("TestBincIntfMapping", TestBincIntfMapping) - t.Run("TestBincMissingFields", TestBincMissingFields) - t.Run("TestBincMaxDepth", TestBincMaxDepth) - t.Run("TestBincSelfExt", TestBincSelfExt) - t.Run("TestBincBytesEncodedAsArray", TestBincBytesEncodedAsArray) - t.Run("TestBincStrucEncDec", TestBincStrucEncDec) - t.Run("TestBincMapEncodeForCanonical", TestBincMapEncodeForCanonical) - t.Run("TestBincRawToStringToRawEtc", TestBincRawToStringToRawEtc) - t.Run("TestBincStructKeyType", TestBincStructKeyType) - t.Run("TestBincPreferArrayOverSlice", TestBincPreferArrayOverSlice) - t.Run("TestBincZeroCopyBytes", TestBincZeroCopyBytes) -} - -func testCborGroup(t *testing.T) { - t.Run("TestCborCodecsTable", TestCborCodecsTable) - t.Run("TestCborCodecsMisc", TestCborCodecsMisc) - t.Run("TestCborCodecsEmbeddedPointer", TestCborCodecsEmbeddedPointer) - t.Run("TestCborCodecChan", TestCborCodecChan) - t.Run("TestCborStdEncIntf", TestCborStdEncIntf) - t.Run("TestCborMammoth", TestCborMammoth) - t.Run("TestCborRaw", TestCborRaw) - t.Run("TestCborRpcGo", TestCborRpcGo) - - t.Run("TestCborSwallowAndZero", TestCborSwallowAndZero) - t.Run("TestCborRawExt", TestCborRawExt) - t.Run("TestCborMapStructKey", TestCborMapStructKey) - t.Run("TestCborDecodeNilMapValue", TestCborDecodeNilMapValue) - t.Run("TestCborEmbeddedFieldPrecedence", TestCborEmbeddedFieldPrecedence) - t.Run("TestCborLargeContainerLen", TestCborLargeContainerLen) - t.Run("TestCborMammothMapsAndSlices", TestCborMammothMapsAndSlices) - t.Run("TestCborTime", TestCborTime) - t.Run("TestCborUintToInt", TestCborUintToInt) - t.Run("TestCborDifferentMapOrSliceType", TestCborDifferentMapOrSliceType) - t.Run("TestCborScalars", TestCborScalars) - t.Run("TestCborOmitempty", TestCborOmitempty) - t.Run("TestCborIntfMapping", TestCborIntfMapping) - t.Run("TestCborMissingFields", TestCborMissingFields) - t.Run("TestCborMaxDepth", TestCborMaxDepth) - t.Run("TestCborSelfExt", TestCborSelfExt) - t.Run("TestCborBytesEncodedAsArray", TestCborBytesEncodedAsArray) - t.Run("TestCborStrucEncDec", TestCborStrucEncDec) - t.Run("TestCborMapEncodeForCanonical", TestCborMapEncodeForCanonical) - t.Run("TestCborRawToStringToRawEtc", TestCborRawToStringToRawEtc) - t.Run("TestCborStructKeyType", TestCborStructKeyType) - t.Run("TestCborPreferArrayOverSlice", TestCborPreferArrayOverSlice) - t.Run("TestCborZeroCopyBytes", TestCborZeroCopyBytes) - - t.Run("TestCborHalfFloat", TestCborHalfFloat) - t.Run("TestCborSkipTags", TestCborSkipTags) -} - -func testMsgpackGroup(t *testing.T) { - t.Run("TestMsgpackCodecsTable", TestMsgpackCodecsTable) - t.Run("TestMsgpackCodecsMisc", TestMsgpackCodecsMisc) - t.Run("TestMsgpackCodecsEmbeddedPointer", TestMsgpackCodecsEmbeddedPointer) - t.Run("TestMsgpackStdEncIntf", TestMsgpackStdEncIntf) - t.Run("TestMsgpackMammoth", TestMsgpackMammoth) - t.Run("TestMsgpackRaw", TestMsgpackRaw) - t.Run("TestMsgpackRpcGo", TestMsgpackRpcGo) - t.Run("TestMsgpackRpcSpec", TestMsgpackRpcSpec) - t.Run("TestMsgpackSwallowAndZero", TestMsgpackSwallowAndZero) - t.Run("TestMsgpackRawExt", TestMsgpackRawExt) - t.Run("TestMsgpackMapStructKey", TestMsgpackMapStructKey) - t.Run("TestMsgpackDecodeNilMapValue", TestMsgpackDecodeNilMapValue) - t.Run("TestMsgpackEmbeddedFieldPrecedence", TestMsgpackEmbeddedFieldPrecedence) - t.Run("TestMsgpackLargeContainerLen", TestMsgpackLargeContainerLen) - t.Run("TestMsgpackMammothMapsAndSlices", TestMsgpackMammothMapsAndSlices) - t.Run("TestMsgpackTime", TestMsgpackTime) - t.Run("TestMsgpackUintToInt", TestMsgpackUintToInt) - t.Run("TestMsgpackDifferentMapOrSliceType", TestMsgpackDifferentMapOrSliceType) - t.Run("TestMsgpackScalars", TestMsgpackScalars) - t.Run("TestMsgpackOmitempty", TestMsgpackOmitempty) - t.Run("TestMsgpackIntfMapping", TestMsgpackIntfMapping) - t.Run("TestMsgpackMissingFields", TestMsgpackMissingFields) - t.Run("TestMsgpackMaxDepth", TestMsgpackMaxDepth) - t.Run("TestMsgpackSelfExt", TestMsgpackSelfExt) - t.Run("TestMsgpackBytesEncodedAsArray", TestMsgpackBytesEncodedAsArray) - t.Run("TestMsgpackStrucEncDec", TestMsgpackStrucEncDec) - t.Run("TestMsgpackMapEncodeForCanonical", TestMsgpackMapEncodeForCanonical) - t.Run("TestMsgpackRawToStringToRawEtc", TestMsgpackRawToStringToRawEtc) - t.Run("TestMsgpackStructKeyType", TestMsgpackStructKeyType) - t.Run("TestMsgpackPreferArrayOverSlice", TestMsgpackPreferArrayOverSlice) - t.Run("TestMsgpackZeroCopyBytes", TestMsgpackZeroCopyBytes) - - t.Run("TestMsgpackDecodeMapAndExtSizeMismatch", TestMsgpackDecodeMapAndExtSizeMismatch) -} - -func testSimpleGroup(t *testing.T) { - t.Run("TestSimpleCodecsTable", TestSimpleCodecsTable) - t.Run("TestSimpleCodecsMisc", TestSimpleCodecsMisc) - t.Run("TestSimpleCodecsEmbeddedPointer", TestSimpleCodecsEmbeddedPointer) - t.Run("TestSimpleStdEncIntf", TestSimpleStdEncIntf) - t.Run("TestSimpleMammoth", TestSimpleMammoth) - t.Run("TestSimpleRaw", TestSimpleRaw) - t.Run("TestSimpleRpcGo", TestSimpleRpcGo) - t.Run("TestSimpleSwallowAndZero", TestSimpleSwallowAndZero) - t.Run("TestSimpleRawExt", TestSimpleRawExt) - t.Run("TestSimpleMapStructKey", TestSimpleMapStructKey) - t.Run("TestSimpleDecodeNilMapValue", TestSimpleDecodeNilMapValue) - t.Run("TestSimpleEmbeddedFieldPrecedence", TestSimpleEmbeddedFieldPrecedence) - t.Run("TestSimpleLargeContainerLen", TestSimpleLargeContainerLen) - t.Run("TestSimpleMammothMapsAndSlices", TestSimpleMammothMapsAndSlices) - t.Run("TestSimpleTime", TestSimpleTime) - t.Run("TestSimpleUintToInt", TestSimpleUintToInt) - t.Run("TestSimpleDifferentMapOrSliceType", TestSimpleDifferentMapOrSliceType) - t.Run("TestSimpleScalars", TestSimpleScalars) - t.Run("TestSimpleOmitempty", TestSimpleOmitempty) - t.Run("TestSimpleIntfMapping", TestSimpleIntfMapping) - t.Run("TestSimpleMissingFields", TestSimpleMissingFields) - t.Run("TestSimpleMaxDepth", TestSimpleMaxDepth) - t.Run("TestSimpleSelfExt", TestSimpleSelfExt) - t.Run("TestSimpleBytesEncodedAsArray", TestSimpleBytesEncodedAsArray) - t.Run("TestSimpleStrucEncDec", TestSimpleStrucEncDec) - t.Run("TestSimpleMapEncodeForCanonical", TestSimpleMapEncodeForCanonical) - t.Run("TestSimpleRawToStringToRawEtc", TestSimpleRawToStringToRawEtc) - t.Run("TestSimpleStructKeyType", TestSimpleStructKeyType) - t.Run("TestSimplePreferArrayOverSlice", TestSimplePreferArrayOverSlice) - t.Run("TestSimpleZeroCopyBytes", TestSimpleZeroCopyBytes) -} - -func testSimpleMammothGroup(t *testing.T) { - t.Run("TestSimpleMammothMapsAndSlices", TestSimpleMammothMapsAndSlices) -} - -func testRpcGroup(t *testing.T) { - t.Run("TestBincRpcGo", TestBincRpcGo) - t.Run("TestSimpleRpcGo", TestSimpleRpcGo) - t.Run("TestMsgpackRpcGo", TestMsgpackRpcGo) - t.Run("TestCborRpcGo", TestCborRpcGo) - t.Run("TestJsonRpcGo", TestJsonRpcGo) - t.Run("TestMsgpackRpcSpec", TestMsgpackRpcSpec) -} - -func testNonHandlesGroup(t *testing.T) { - // grep "func Test" codec_test.go | grep -v -E '(Cbor|Json|Simple|Msgpack|Binc)' - t.Run("TestBufioDecReader", TestBufioDecReader) - t.Run("TestAtomic", TestAtomic) - t.Run("TestAllEncCircularRef", TestAllEncCircularRef) - t.Run("TestAllAnonCycle", TestAllAnonCycle) - t.Run("TestMultipleEncDec", TestMultipleEncDec) - t.Run("TestAllErrWriter", TestAllErrWriter) - t.Run("TestMapRangeIndex", TestMapRangeIndex) -} - -func TestCodecSuite(t *testing.T) { - testSuite(t, testCodecGroup) - - testGroupResetFlags() - - oldIndent, oldCharsAsis, oldPreferFloat, oldMapKeyAsString := - testJsonH.Indent, testJsonH.HTMLCharsAsIs, testJsonH.PreferFloat, testJsonH.MapKeyAsString - - testMaxInitLen = 10 - testJsonH.Indent = 8 - testJsonH.HTMLCharsAsIs = true - testJsonH.MapKeyAsString = true - // testJsonH.PreferFloat = true - testReinit() - t.Run("json-spaces-htmlcharsasis-initLen10", testJsonGroup) - - testMaxInitLen = 10 - testJsonH.Indent = -1 - testJsonH.HTMLCharsAsIs = false - testJsonH.MapKeyAsString = true - // testJsonH.PreferFloat = false - testReinit() - t.Run("json-tabs-initLen10", testJsonGroup) - - testJsonH.Indent, testJsonH.HTMLCharsAsIs, testJsonH.PreferFloat, testJsonH.MapKeyAsString = - oldIndent, oldCharsAsis, oldPreferFloat, oldMapKeyAsString - - oldIndefLen := testCborH.IndefiniteLength - testCborH.IndefiniteLength = true - testReinit() - t.Run("cbor-indefinitelength", testCborGroup) - testCborH.IndefiniteLength = oldIndefLen - - oldTimeRFC3339 := testCborH.TimeRFC3339 - testCborH.TimeRFC3339 = !testCborH.TimeRFC3339 - testReinit() - t.Run("cbor-rfc3339", testCborGroup) - testCborH.TimeRFC3339 = oldTimeRFC3339 - - oldSkipUnexpectedTags := testCborH.SkipUnexpectedTags - testCborH.SkipUnexpectedTags = !testCborH.SkipUnexpectedTags - testReinit() - t.Run("cbor-skip-tags", testCborGroup) - testCborH.SkipUnexpectedTags = oldSkipUnexpectedTags - - oldSymbols := testBincH.AsSymbols - - testBincH.AsSymbols = 2 // AsSymbolNone - testReinit() - t.Run("binc-no-symbols", testBincGroup) - - testBincH.AsSymbols = 1 // AsSymbolAll - testReinit() - t.Run("binc-all-symbols", testBincGroup) - - testBincH.AsSymbols = oldSymbols - - oldWriteExt := testMsgpackH.WriteExt - oldNoFixedNum := testMsgpackH.NoFixedNum - - testMsgpackH.WriteExt = !testMsgpackH.WriteExt - testReinit() - t.Run("msgpack-inverse-writeext", testMsgpackGroup) - - testMsgpackH.WriteExt = oldWriteExt - - testMsgpackH.NoFixedNum = !testMsgpackH.NoFixedNum - testReinit() - t.Run("msgpack-fixednum", testMsgpackGroup) - - testMsgpackH.NoFixedNum = oldNoFixedNum - - oldEncZeroValuesAsNil := testSimpleH.EncZeroValuesAsNil - testSimpleH.EncZeroValuesAsNil = !testSimpleH.EncZeroValuesAsNil - testUseMust = true - testReinit() - t.Run("simple-enczeroasnil", testSimpleMammothGroup) // testSimpleGroup - testSimpleH.EncZeroValuesAsNil = oldEncZeroValuesAsNil - - oldRpcBufsize := testRpcBufsize - testRpcBufsize = 0 - t.Run("rpc-buf-0", testRpcGroup) - testRpcBufsize = 0 - t.Run("rpc-buf-00", testRpcGroup) - testRpcBufsize = 0 - t.Run("rpc-buf-000", testRpcGroup) - testRpcBufsize = 16 - t.Run("rpc-buf-16", testRpcGroup) - testRpcBufsize = 2048 - t.Run("rpc-buf-2048", testRpcGroup) - testRpcBufsize = oldRpcBufsize - - testGroupResetFlags() -} - -// func TestCodecSuite(t *testing.T) { -// testReinit() // so flag.Parse() is called first, and never called again -// testDecodeOptions, testEncodeOptions = DecodeOptions{}, EncodeOptions{} -// testGroupResetFlags() -// testReinit() -// t.Run("optionsFalse", func(t *testing.T) { -// t.Run("TestJsonMammothMapsAndSlices", TestJsonMammothMapsAndSlices) -// }) -// } diff --git a/vendor/github.com/ugorji/go/go.mod b/vendor/github.com/ugorji/go/go.mod deleted file mode 100644 index 57eaa2abf..000000000 --- a/vendor/github.com/ugorji/go/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/ugorji/go - -require github.com/ugorji/go/codec v1.1.7 diff --git a/vendor/github.com/ugorji/go/msgpack.org.md b/vendor/github.com/ugorji/go/msgpack.org.md deleted file mode 100644 index d5ebe71d6..000000000 --- a/vendor/github.com/ugorji/go/msgpack.org.md +++ /dev/null @@ -1,47 +0,0 @@ -**MessagePack and [Binc](http://github.com/ugorji/binc) Codec for [Go](http://golang.org) Language.** - -*A High Performance, Feature-Rich, Idiomatic encode/decode and rpc library*. - -To install: - - go get github.com/ugorji/go/codec - -Source: [http://github.com/ugorji/go] -Online documentation: [http://godoc.org/github.com/ugorji/go/codec] - -Typical usage: - -```go - // create and use decoder/encoder - var ( - v interface{} // value to decode/encode into - r io.Reader - w io.Writer - b []byte - mh codec.MsgpackHandle - ) - - dec = codec.NewDecoder(r, &mh) - dec = codec.NewDecoderBytes(b, &mh) - err = dec.Decode(&v) - - enc = codec.NewEncoder(w, &mh) - enc = codec.NewEncoderBytes(&b, &mh) - err = enc.Encode(v) - - //RPC Server - go func() { - for { - conn, err := listener.Accept() - rpcCodec := codec.GoRpc.ServerCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ServerCodec(conn, h) - rpc.ServeCodec(rpcCodec) - } - }() - - //RPC Communication (client side) - conn, err = net.Dial("tcp", "localhost:5555") - rpcCodec := codec.GoRpc.ClientCodec(conn, h) - //OR rpcCodec := codec.MsgpackSpecRpc.ClientCodec(conn, h) - client := rpc.NewClientWithCodec(rpcCodec) -```