dep ensure -update (#1001)
* dep ensure -update Run "dep ensure -update` to update all dependencies. No code changes; just the dependencies. * dep prune * add new venderod
This commit is contained in:
parent
558f4bea41
commit
7e63bdbee8
407 changed files with 32999 additions and 24546 deletions
9
vendor/github.com/ugorji/go/codec/binc.go
generated
vendored
9
vendor/github.com/ugorji/go/codec/binc.go
generated
vendored
|
@ -356,6 +356,9 @@ func (d *bincDecDriver) uncacheRead() {
|
|||
}
|
||||
|
||||
func (d *bincDecDriver) ContainerType() (vt valueType) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
if d.vd == bincVdSpecial && d.vs == bincSpNil {
|
||||
return valueTypeNil
|
||||
} else if d.vd == bincVdByteArray {
|
||||
|
@ -580,6 +583,9 @@ func (d *bincDecDriver) DecodeBool() (b bool) {
|
|||
}
|
||||
|
||||
func (d *bincDecDriver) ReadMapStart() (length int) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
if d.vd != bincVdMap {
|
||||
d.d.errorf("Invalid d.vd for map. Expecting 0x%x. Got: 0x%x", bincVdMap, d.vd)
|
||||
return
|
||||
|
@ -590,6 +596,9 @@ func (d *bincDecDriver) ReadMapStart() (length int) {
|
|||
}
|
||||
|
||||
func (d *bincDecDriver) ReadArrayStart() (length int) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
if d.vd != bincVdArray {
|
||||
d.d.errorf("Invalid d.vd for array. Expecting 0x%x. Got: 0x%x", bincVdArray, d.vd)
|
||||
return
|
||||
|
|
9
vendor/github.com/ugorji/go/codec/cbor.go
generated
vendored
9
vendor/github.com/ugorji/go/codec/cbor.go
generated
vendored
|
@ -196,6 +196,9 @@ func (d *cborDecDriver) uncacheRead() {
|
|||
}
|
||||
|
||||
func (d *cborDecDriver) ContainerType() (vt valueType) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
if d.bd == cborBdNil {
|
||||
return valueTypeNil
|
||||
} else if d.bd == cborBdIndefiniteBytes || (d.bd >= cborBaseBytes && d.bd < cborBaseString) {
|
||||
|
@ -351,6 +354,9 @@ func (d *cborDecDriver) DecodeBool() (b bool) {
|
|||
}
|
||||
|
||||
func (d *cborDecDriver) ReadMapStart() (length int) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
d.bdRead = false
|
||||
if d.bd == cborBdIndefiniteMap {
|
||||
return -1
|
||||
|
@ -359,6 +365,9 @@ func (d *cborDecDriver) ReadMapStart() (length int) {
|
|||
}
|
||||
|
||||
func (d *cborDecDriver) ReadArrayStart() (length int) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
d.bdRead = false
|
||||
if d.bd == cborBdIndefiniteArray {
|
||||
return -1
|
||||
|
|
35
vendor/github.com/ugorji/go/codec/codec_test.go
generated
vendored
35
vendor/github.com/ugorji/go/codec/codec_test.go
generated
vendored
|
@ -22,7 +22,6 @@ package codec
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
|
@ -42,7 +41,6 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
testInitFlags()
|
||||
testPreInitFns = append(testPreInitFns, testInit)
|
||||
}
|
||||
|
||||
|
@ -92,24 +90,6 @@ var (
|
|||
testRpcInt = new(TestRpcInt)
|
||||
)
|
||||
|
||||
func testInitFlags() {
|
||||
// delete(testDecOpts.ExtFuncs, timeTyp)
|
||||
flag.BoolVar(&testVerbose, "tv", false, "Test Verbose")
|
||||
flag.BoolVar(&testInitDebug, "tg", false, "Test Init Debug")
|
||||
flag.BoolVar(&testUseIoEncDec, "ti", false, "Use IO Reader/Writer for Marshal/Unmarshal")
|
||||
flag.BoolVar(&testStructToArray, "ts", false, "Set StructToArray option")
|
||||
flag.BoolVar(&testWriteNoSymbols, "tn", false, "Set NoSymbols option")
|
||||
flag.BoolVar(&testCanonical, "tc", false, "Set Canonical option")
|
||||
flag.BoolVar(&testInternStr, "te", false, "Set InternStr option")
|
||||
flag.BoolVar(&testSkipIntf, "tf", false, "Skip Interfaces")
|
||||
flag.BoolVar(&testUseReset, "tr", false, "Use Reset")
|
||||
flag.IntVar(&testJsonIndent, "td", 0, "Use JSON Indent")
|
||||
flag.IntVar(&testMaxInitLen, "tx", 0, "Max Init Len")
|
||||
flag.BoolVar(&testUseMust, "tm", true, "Use Must(En|De)code")
|
||||
flag.BoolVar(&testCheckCircRef, "tl", false, "Use Check Circular Ref")
|
||||
flag.BoolVar(&testJsonHTMLCharsAsIs, "tas", false, "Set JSON HTMLCharsAsIs")
|
||||
}
|
||||
|
||||
func testByteBuf(in []byte) *bytes.Buffer {
|
||||
return bytes.NewBuffer(in)
|
||||
}
|
||||
|
@ -1490,6 +1470,21 @@ func TestJsonLargeInteger(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestJsonDecodeNonStringScalarInStringContext(t *testing.T) {
|
||||
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 {
|
||||
logT(t, "++++ match: decoded: %#v", m)
|
||||
} else {
|
||||
logT(t, "---- mismatch: %v ==> golden: %#v, decoded: %#v", err, golden, m)
|
||||
failT(t)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// Add Tests for:
|
||||
// - decoding empty list/map in stream into a nil slice/map
|
||||
|
|
29
vendor/github.com/ugorji/go/codec/decode.go
generated
vendored
29
vendor/github.com/ugorji/go/codec/decode.go
generated
vendored
|
@ -161,7 +161,9 @@ type DecodeOptions struct {
|
|||
// look them up from a map (than to allocate them afresh).
|
||||
//
|
||||
// Note: Handles will be smart when using the intern functionality.
|
||||
// So everything will not be interned.
|
||||
// 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.
|
||||
|
@ -740,7 +742,8 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
|
|||
if cr != nil {
|
||||
cr.sendContainerState(containerMapKey)
|
||||
}
|
||||
rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true))
|
||||
rvkencnameB := dd.DecodeBytes(f.d.b[:], true, true)
|
||||
rvkencname := stringView(rvkencnameB)
|
||||
// rvksi := ti.getForEncName(rvkencname)
|
||||
if cr != nil {
|
||||
cr.sendContainerState(containerMapValue)
|
||||
|
@ -755,6 +758,7 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
|
|||
} else {
|
||||
d.structFieldNotFound(-1, rvkencname)
|
||||
}
|
||||
keepAlive4StringView(rvkencnameB) // maintain ref 4 stringView
|
||||
}
|
||||
} else {
|
||||
for j := 0; !dd.CheckBreak(); j++ {
|
||||
|
@ -762,7 +766,8 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
|
|||
if cr != nil {
|
||||
cr.sendContainerState(containerMapKey)
|
||||
}
|
||||
rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true))
|
||||
rvkencnameB := dd.DecodeBytes(f.d.b[:], true, true)
|
||||
rvkencname := stringView(rvkencnameB)
|
||||
// rvksi := ti.getForEncName(rvkencname)
|
||||
if cr != nil {
|
||||
cr.sendContainerState(containerMapValue)
|
||||
|
@ -777,6 +782,7 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
|
|||
} else {
|
||||
d.structFieldNotFound(-1, rvkencname)
|
||||
}
|
||||
keepAlive4StringView(rvkencnameB) // maintain ref 4 stringView
|
||||
}
|
||||
}
|
||||
if cr != nil {
|
||||
|
@ -1873,11 +1879,14 @@ func (d *Decoder) errorf(format string, params ...interface{}) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
// Possibly get an interned version of a string
|
||||
//
|
||||
// This should mostly be used for map keys, where the key type is string
|
||||
func (d *Decoder) string(v []byte) (s string) {
|
||||
if d.is != nil {
|
||||
s, ok := d.is[string(v)] // no allocation here.
|
||||
s, ok := d.is[string(v)] // no allocation here, per go implementation
|
||||
if !ok {
|
||||
s = string(v)
|
||||
s = string(v) // new allocation here
|
||||
d.is[s] = s
|
||||
}
|
||||
return s
|
||||
|
@ -1885,11 +1894,11 @@ func (d *Decoder) string(v []byte) (s string) {
|
|||
return string(v) // don't return stringView, as we need a real string here.
|
||||
}
|
||||
|
||||
func (d *Decoder) intern(s string) {
|
||||
if d.is != nil {
|
||||
d.is[s] = s
|
||||
}
|
||||
}
|
||||
// func (d *Decoder) intern(s string) {
|
||||
// if d.is != nil {
|
||||
// d.is[s] = s
|
||||
// }
|
||||
// }
|
||||
|
||||
// nextValueBytes returns the next value in the stream as a set of bytes.
|
||||
func (d *Decoder) nextValueBytes() []byte {
|
||||
|
|
5
vendor/github.com/ugorji/go/codec/encode.go
generated
vendored
5
vendor/github.com/ugorji/go/codec/encode.go
generated
vendored
|
@ -1027,6 +1027,8 @@ func (e *Encoder) ResetBytes(out *[]byte) {
|
|||
// 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.
|
||||
//
|
||||
|
@ -1053,8 +1055,7 @@ func (e *Encoder) ResetBytes(out *[]byte) {
|
|||
// }
|
||||
//
|
||||
// type MyStruct struct {
|
||||
// _struct bool `codec:",omitempty,toarray"` //set omitempty for every field
|
||||
// //and encode struct as an array
|
||||
// _struct bool `codec:",toarray"` //encode struct as an array
|
||||
// }
|
||||
//
|
||||
// The mode of encoding is based on the type of the value. When a value is seen:
|
||||
|
|
24
vendor/github.com/ugorji/go/codec/gen.go
generated
vendored
24
vendor/github.com/ugorji/go/codec/gen.go
generated
vendored
|
@ -1653,15 +1653,8 @@ func (x *genV) MethodNamePfx(prefix string, prim bool) string {
|
|||
func genImportPath(t reflect.Type) (s string) {
|
||||
s = t.PkgPath()
|
||||
if genCheckVendor {
|
||||
// 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):]
|
||||
}
|
||||
// HACK: always handle vendoring. It should be typically on in go 1.6, 1.7
|
||||
s = stripVendor(s)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -1884,6 +1877,19 @@ func genInternalSortType(s string, elem bool) string {
|
|||
panic("sorttype: unexpected type: " + s)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// var genInternalMu sync.Mutex
|
||||
var genInternalV genInternal
|
||||
var genInternalTmplFuncs template.FuncMap
|
||||
|
|
16
vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
generated
vendored
16
vendor/github.com/ugorji/go/codec/helper_not_unsafe.go
generated
vendored
|
@ -8,6 +8,9 @@ package codec
|
|||
// 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)
|
||||
}
|
||||
|
@ -15,6 +18,19 @@ func stringView(v []byte) string {
|
|||
// 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)
|
||||
}
|
||||
|
||||
// keepAlive4BytesView maintains a reference to the input parameter for bytesView.
|
||||
//
|
||||
// Usage: call this at point where done with the bytes view.
|
||||
func keepAlive4BytesView(v string) {}
|
||||
|
||||
// keepAlive4BytesView maintains a reference to the input parameter for stringView.
|
||||
//
|
||||
// Usage: call this at point where done with the string view.
|
||||
func keepAlive4StringView(v []byte) {}
|
||||
|
|
160
vendor/github.com/ugorji/go/codec/helper_test.go
generated
vendored
160
vendor/github.com/ugorji/go/codec/helper_test.go
generated
vendored
|
@ -5,174 +5,14 @@ package codec
|
|||
|
||||
// All non-std package dependencies related to testing live in this file,
|
||||
// so porting to different environment is easy (just update functions).
|
||||
//
|
||||
// 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=. <other parameters ...>
|
||||
// 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 unsafe" -bench=. <other parameters ...>
|
||||
//
|
||||
// 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"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type testHED struct {
|
||||
H Handle
|
||||
E *Encoder
|
||||
D *Decoder
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
// variables used by tests
|
||||
var (
|
||||
testVerbose bool
|
||||
testInitDebug bool
|
||||
testUseIoEncDec bool
|
||||
testStructToArray bool
|
||||
testCanonical bool
|
||||
testUseReset bool
|
||||
testWriteNoSymbols bool
|
||||
testSkipIntf bool
|
||||
testInternStr bool
|
||||
testUseMust bool
|
||||
testCheckCircRef bool
|
||||
testJsonIndent int
|
||||
testMaxInitLen int
|
||||
|
||||
testJsonHTMLCharsAsIs bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
testHEDs = make([]testHED, 0, 32)
|
||||
testHandles = append(testHandles,
|
||||
testNoopH, testMsgpackH, testBincH, testSimpleH,
|
||||
testCborH, testJsonH)
|
||||
}
|
||||
|
||||
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 testInitAll() {
|
||||
flag.Parse()
|
||||
for _, f := range testPreInitFns {
|
||||
f()
|
||||
}
|
||||
for _, f := range testPostInitFns {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
func testCodecEncode(ts interface{}, bsIn []byte,
|
||||
fn func([]byte) *bytes.Buffer, h Handle) (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)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
buf = fn(bsIn)
|
||||
e.Reset(buf)
|
||||
} else {
|
||||
bs = bsIn
|
||||
e.ResetBytes(&bs)
|
||||
}
|
||||
if testUseMust {
|
||||
e.MustEncode(ts)
|
||||
} else {
|
||||
err = e.Encode(ts)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
bs = buf.Bytes()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func testCodecDecode(bs []byte, ts interface{}, h Handle) (err error) {
|
||||
var d *Decoder
|
||||
var buf *bytes.Reader
|
||||
if testUseReset {
|
||||
d = testHEDGet(h).D
|
||||
} else {
|
||||
d = NewDecoder(nil, h)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
buf = bytes.NewReader(bs)
|
||||
d.Reset(buf)
|
||||
} else {
|
||||
d.ResetBytes(bs)
|
||||
}
|
||||
if testUseMust {
|
||||
d.MustDecode(ts)
|
||||
} else {
|
||||
err = d.Decode(ts)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ----- functions below are used only by tests (not benchmarks)
|
||||
|
||||
const (
|
||||
|
|
16
vendor/github.com/ugorji/go/codec/helper_unsafe.go
generated
vendored
16
vendor/github.com/ugorji/go/codec/helper_unsafe.go
generated
vendored
|
@ -6,10 +6,12 @@
|
|||
package codec
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// This file has unsafe variants of some helper methods.
|
||||
// NOTE: See helper_not_unsafe.go for the usage information.
|
||||
|
||||
type unsafeString struct {
|
||||
Data uintptr
|
||||
|
@ -22,9 +24,6 @@ type unsafeSlice struct {
|
|||
Cap int
|
||||
}
|
||||
|
||||
// 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.
|
||||
func stringView(v []byte) string {
|
||||
if len(v) == 0 {
|
||||
return ""
|
||||
|
@ -35,9 +34,6 @@ func stringView(v []byte) string {
|
|||
return *(*string)(unsafe.Pointer(&sx))
|
||||
}
|
||||
|
||||
// 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.
|
||||
func bytesView(v string) []byte {
|
||||
if len(v) == 0 {
|
||||
return zeroByteSlice
|
||||
|
@ -47,3 +43,11 @@ func bytesView(v string) []byte {
|
|||
bx := unsafeSlice{sx.Data, sx.Len, sx.Len}
|
||||
return *(*[]byte)(unsafe.Pointer(&bx))
|
||||
}
|
||||
|
||||
func keepAlive4BytesView(v string) {
|
||||
runtime.KeepAlive(v)
|
||||
}
|
||||
|
||||
func keepAlive4StringView(v []byte) {
|
||||
runtime.KeepAlive(v)
|
||||
}
|
||||
|
|
35
vendor/github.com/ugorji/go/codec/json.go
generated
vendored
35
vendor/github.com/ugorji/go/codec/json.go
generated
vendored
|
@ -702,7 +702,9 @@ LOOP:
|
|||
switch state {
|
||||
case 0:
|
||||
state = 2
|
||||
// do not add sign to the slice ...
|
||||
if storeBytes {
|
||||
d.bs = append(d.bs, b)
|
||||
}
|
||||
b, eof = r.readn1eof()
|
||||
continue
|
||||
case 6: // typ = jsonNumFloat
|
||||
|
@ -715,7 +717,9 @@ LOOP:
|
|||
case 0:
|
||||
state = 2
|
||||
n.neg = true
|
||||
// do not add sign to the slice ...
|
||||
if storeBytes {
|
||||
d.bs = append(d.bs, b)
|
||||
}
|
||||
b, eof = r.readn1eof()
|
||||
continue
|
||||
case 6: // typ = jsonNumFloat
|
||||
|
@ -981,16 +985,28 @@ func (d *jsonDecDriver) appendStringAsBytes() {
|
|||
d.tok = b
|
||||
}
|
||||
|
||||
// handle null as a string
|
||||
if d.tok == 'n' {
|
||||
d.readStrIdx(10, 13) // ull
|
||||
d.bs = d.bs[:0]
|
||||
if d.tok != '"' {
|
||||
// d.d.errorf("json: 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.readStrIdx(10, 13) // ull
|
||||
d.bs = d.bs[:0]
|
||||
case 'f':
|
||||
d.readStrIdx(5, 9) // alse
|
||||
d.bs = d.bs[:5]
|
||||
copy(d.bs, "false")
|
||||
case 't':
|
||||
d.readStrIdx(1, 4) // rue
|
||||
d.bs = d.bs[:4]
|
||||
copy(d.bs, "true")
|
||||
default:
|
||||
// try to parse a valid number
|
||||
d.decNum(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if d.tok != '"' {
|
||||
d.d.errorf("json: expect char '%c' but got char '%c'", '"', d.tok)
|
||||
}
|
||||
d.tok = 0
|
||||
|
||||
v := d.bs[:0]
|
||||
|
@ -1159,6 +1175,7 @@ func (d *jsonDecDriver) DecodeNaked() {
|
|||
type JsonHandle struct {
|
||||
textEncodingType
|
||||
BasicHandle
|
||||
|
||||
// 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
|
||||
|
|
9
vendor/github.com/ugorji/go/codec/msgpack.go
generated
vendored
9
vendor/github.com/ugorji/go/codec/msgpack.go
generated
vendored
|
@ -569,6 +569,9 @@ func (d *msgpackDecDriver) uncacheRead() {
|
|||
}
|
||||
|
||||
func (d *msgpackDecDriver) ContainerType() (vt valueType) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
bd := d.bd
|
||||
if bd == mpNil {
|
||||
return valueTypeNil
|
||||
|
@ -621,10 +624,16 @@ func (d *msgpackDecDriver) readContainerLen(ct msgpackContainerType) (clen int)
|
|||
}
|
||||
|
||||
func (d *msgpackDecDriver) ReadMapStart() int {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
return d.readContainerLen(msgpackContainerMap)
|
||||
}
|
||||
|
||||
func (d *msgpackDecDriver) ReadArrayStart() int {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
return d.readContainerLen(msgpackContainerList)
|
||||
}
|
||||
|
||||
|
|
30
vendor/github.com/ugorji/go/codec/prebuild.sh
generated
vendored
30
vendor/github.com/ugorji/go/codec/prebuild.sh
generated
vendored
|
@ -38,7 +38,7 @@ _build() {
|
|||
return 0
|
||||
fi
|
||||
|
||||
# echo "Running prebuild"
|
||||
# echo "Running prebuild"
|
||||
if [ "${zbak}" == "1" ]
|
||||
then
|
||||
# echo "Backing up old generated files"
|
||||
|
@ -46,12 +46,13 @@ _build() {
|
|||
_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
|
||||
# [ -e "safe${_gg}" ] && mv safe${_gg} safe${_gg}__${_zts}.bak
|
||||
# [ -e "unsafe${_gg}" ] && mv unsafe${_gg} unsafe${_gg}__${_zts}.bak
|
||||
else
|
||||
rm -f fast-path.generated.go gen.generated.go gen-helper.generated.go \
|
||||
*safe.generated.go *_generated_test.go *.generated_ffjson_expose.go
|
||||
fi
|
||||
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 <<EOF
|
||||
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
|
||||
|
@ -93,7 +94,7 @@ EOF
|
|||
package main
|
||||
|
||||
//import "flag"
|
||||
import "ugorji.net/codec"
|
||||
import "${zpkg}"
|
||||
import "os"
|
||||
|
||||
func run(fnameIn, fnameOut string, safe bool) {
|
||||
|
@ -145,17 +146,17 @@ _codegenerators() {
|
|||
fi
|
||||
|
||||
echo "codecgen - !unsafe ... " && \
|
||||
codecgen -rt codecgen -t 'x,codecgen,!unsafe' -o values_codecgen${zsfx} -d 19780 $zfin &
|
||||
$zgobase/bin/codecgen -rt codecgen -t 'x,codecgen,!unsafe' -o values_codecgen${zsfx} -d 19780 $zfin &
|
||||
zzzIdC=$!
|
||||
echo "codecgen - unsafe ... " && \
|
||||
codecgen -u -rt codecgen -t 'x,codecgen,unsafe' -o values_codecgen_unsafe${zsfx} -d 19781 $zfin &
|
||||
$zgobase/bin/codecgen -u -rt codecgen -t 'x,codecgen,unsafe' -o values_codecgen_unsafe${zsfx} -d 19781 $zfin &
|
||||
zzzIdCU=$!
|
||||
wait $zzzIdC $zzzIdCU $zzzIdMsgp $zzzIdFF && \
|
||||
# remove (M|Unm)arshalJSON implementations, so they don't conflict with encoding/json bench \
|
||||
if [[ $zexternal == "1" ]]
|
||||
then
|
||||
sed -i 's+ MarshalJSON(+ _MarshalJSON(+g' values_ffjson${zsfx} && \
|
||||
sed -i 's+ UnmarshalJSON(+ _UnmarshalJSON(+g' values_ffjson${zsfx}
|
||||
sed -i '' -e 's+ MarshalJSON(+ _MarshalJSON(+g' values_ffjson${zsfx} && \
|
||||
sed -i '' -e 's+ UnmarshalJSON(+ _UnmarshalJSON(+g' values_ffjson${zsfx}
|
||||
fi && \
|
||||
echo "generators done!" && \
|
||||
true
|
||||
|
@ -165,13 +166,14 @@ _codegenerators() {
|
|||
# _init reads the arguments and sets up the flags
|
||||
_init() {
|
||||
OPTIND=1
|
||||
while getopts "fbx" flag
|
||||
while getopts "fbxp:" flag
|
||||
do
|
||||
case "x$flag" in
|
||||
'xf') zforce=1;;
|
||||
'xb') zbak=1;;
|
||||
'xx') zexternal=1;;
|
||||
*) echo "prebuild.sh accepts [-fbx] only"; return 1;;
|
||||
'xp') zpkg="${OPTARG}" ;;
|
||||
*) echo "prebuild.sh accepts [-fbx] [-p basepkgname] only"; return 1;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
@ -180,11 +182,15 @@ OPTIND=1
|
|||
|
||||
# main script.
|
||||
# First ensure that this is being run from the basedir (i.e. dirname of script is .)
|
||||
# Sample usage:
|
||||
if [ "." = `dirname $0` ]
|
||||
then
|
||||
zmydir=`pwd`
|
||||
zfin="test_values.generated.go"
|
||||
zsfx="_generated_test.go"
|
||||
# zpkg="ugorji.net/codec"
|
||||
zpkg=${zmydir##*/src/}
|
||||
zgobase=${zmydir%%/src/*}
|
||||
# rm -f *_generated_test.go
|
||||
rm -f codecgen-*.go && \
|
||||
_init "$@" && \
|
||||
|
|
228
vendor/github.com/ugorji/go/codec/shared_test.go
generated
vendored
Normal file
228
vendor/github.com/ugorji/go/codec/shared_test.go
generated
vendored
Normal file
|
@ -0,0 +1,228 @@
|
|||
// 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
|
||||
|
||||
// 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=. <other parameters ...>
|
||||
// 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 unsafe" -bench=. <other parameters ...>
|
||||
//
|
||||
// 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"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// DO NOT REMOVE - replacement line for go-codec-bench import declaration tag //
|
||||
|
||||
type testHED struct {
|
||||
H Handle
|
||||
E *Encoder
|
||||
D *Decoder
|
||||
}
|
||||
|
||||
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
|
||||
testInitDebug bool
|
||||
testUseIoEncDec bool
|
||||
testStructToArray bool
|
||||
testCanonical bool
|
||||
testUseReset bool
|
||||
testWriteNoSymbols bool
|
||||
testSkipIntf bool
|
||||
testInternStr bool
|
||||
testUseMust bool
|
||||
testCheckCircRef bool
|
||||
testJsonIndent int
|
||||
testMaxInitLen int
|
||||
|
||||
testJsonHTMLCharsAsIs bool
|
||||
)
|
||||
|
||||
// flag variables used by bench
|
||||
var (
|
||||
benchDoInitBench bool
|
||||
benchVerify bool
|
||||
benchUnscientificRes bool = false
|
||||
benchMapStringKeyOnly 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.
|
||||
benchDepth int
|
||||
benchInitDebug bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
testHEDs = make([]testHED, 0, 32)
|
||||
testHandles = append(testHandles,
|
||||
testNoopH, testMsgpackH, testBincH, testSimpleH,
|
||||
testCborH, testJsonH)
|
||||
testInitFlags()
|
||||
benchInitFlags()
|
||||
}
|
||||
|
||||
func testInitFlags() {
|
||||
// delete(testDecOpts.ExtFuncs, timeTyp)
|
||||
flag.BoolVar(&testVerbose, "tv", false, "Test Verbose")
|
||||
flag.BoolVar(&testInitDebug, "tg", false, "Test Init Debug")
|
||||
flag.BoolVar(&testUseIoEncDec, "ti", false, "Use IO Reader/Writer for Marshal/Unmarshal")
|
||||
flag.BoolVar(&testStructToArray, "ts", false, "Set StructToArray option")
|
||||
flag.BoolVar(&testWriteNoSymbols, "tn", false, "Set NoSymbols option")
|
||||
flag.BoolVar(&testCanonical, "tc", false, "Set Canonical option")
|
||||
flag.BoolVar(&testInternStr, "te", false, "Set InternStr option")
|
||||
flag.BoolVar(&testSkipIntf, "tf", false, "Skip Interfaces")
|
||||
flag.BoolVar(&testUseReset, "tr", false, "Use Reset")
|
||||
flag.IntVar(&testJsonIndent, "td", 0, "Use JSON Indent")
|
||||
flag.IntVar(&testMaxInitLen, "tx", 0, "Max Init Len")
|
||||
flag.BoolVar(&testUseMust, "tm", true, "Use Must(En|De)code")
|
||||
flag.BoolVar(&testCheckCircRef, "tl", false, "Use Check Circular Ref")
|
||||
flag.BoolVar(&testJsonHTMLCharsAsIs, "tas", false, "Set JSON HTMLCharsAsIs")
|
||||
}
|
||||
|
||||
func benchInitFlags() {
|
||||
flag.BoolVar(&benchMapStringKeyOnly, "bs", false, "Bench use maps with string keys only")
|
||||
flag.BoolVar(&benchInitDebug, "bg", false, "Bench Debug")
|
||||
flag.IntVar(&benchDepth, "bd", 1, "Bench Depth")
|
||||
flag.BoolVar(&benchDoInitBench, "bi", false, "Run Bench Init")
|
||||
flag.BoolVar(&benchVerify, "bv", false, "Verify Decoded Value during Benchmark")
|
||||
flag.BoolVar(&benchUnscientificRes, "bu", false, "Show Unscientific Results during Benchmark")
|
||||
}
|
||||
|
||||
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 testInitAll() {
|
||||
flag.Parse()
|
||||
for _, f := range testPreInitFns {
|
||||
f()
|
||||
}
|
||||
for _, f := range testPostInitFns {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
func testCodecEncode(ts interface{}, bsIn []byte,
|
||||
fn func([]byte) *bytes.Buffer, h Handle) (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)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
buf = fn(bsIn)
|
||||
e.Reset(buf)
|
||||
} else {
|
||||
bs = bsIn
|
||||
e.ResetBytes(&bs)
|
||||
}
|
||||
if testUseMust {
|
||||
e.MustEncode(ts)
|
||||
} else {
|
||||
err = e.Encode(ts)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
bs = buf.Bytes()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func testCodecDecode(bs []byte, ts interface{}, h Handle) (err error) {
|
||||
var d *Decoder
|
||||
var buf *bytes.Reader
|
||||
if testUseReset {
|
||||
d = testHEDGet(h).D
|
||||
} else {
|
||||
d = NewDecoder(nil, h)
|
||||
}
|
||||
if testUseIoEncDec {
|
||||
buf = bytes.NewReader(bs)
|
||||
d.Reset(buf)
|
||||
} else {
|
||||
d.ResetBytes(bs)
|
||||
}
|
||||
if testUseMust {
|
||||
d.MustDecode(ts)
|
||||
} else {
|
||||
err = d.Decode(ts)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ----- 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)
|
||||
}
|
9
vendor/github.com/ugorji/go/codec/simple.go
generated
vendored
9
vendor/github.com/ugorji/go/codec/simple.go
generated
vendored
|
@ -174,6 +174,9 @@ func (d *simpleDecDriver) uncacheRead() {
|
|||
}
|
||||
|
||||
func (d *simpleDecDriver) ContainerType() (vt valueType) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
if d.bd == simpleVdNil {
|
||||
return valueTypeNil
|
||||
} else if d.bd == simpleVdByteArray || d.bd == simpleVdByteArray+1 ||
|
||||
|
@ -315,11 +318,17 @@ func (d *simpleDecDriver) DecodeBool() (b bool) {
|
|||
}
|
||||
|
||||
func (d *simpleDecDriver) ReadMapStart() (length int) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
d.bdRead = false
|
||||
return d.decLen()
|
||||
}
|
||||
|
||||
func (d *simpleDecDriver) ReadArrayStart() (length int) {
|
||||
if !d.bdRead {
|
||||
d.readNextBd()
|
||||
}
|
||||
d.bdRead = false
|
||||
return d.decLen()
|
||||
}
|
||||
|
|
6
vendor/github.com/ugorji/go/codec/test.py
generated
vendored
6
vendor/github.com/ugorji/go/codec/test.py
generated
vendored
|
@ -84,7 +84,7 @@ def doRpcServer(port, stopTimeSec):
|
|||
def EchoStruct(self, msg):
|
||||
return ("%s" % msg)
|
||||
|
||||
addr = msgpackrpc.Address('localhost', port)
|
||||
addr = msgpackrpc.Address('127.0.0.1', port)
|
||||
server = msgpackrpc.Server(EchoHandler())
|
||||
server.listen(addr)
|
||||
# run thread to stop it after stopTimeSec seconds if > 0
|
||||
|
@ -96,14 +96,14 @@ def doRpcServer(port, stopTimeSec):
|
|||
server.start()
|
||||
|
||||
def doRpcClientToPythonSvc(port):
|
||||
address = msgpackrpc.Address('localhost', 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('localhost', 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"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue