Updates vendor directory to get code generation working correctly

This commit is contained in:
Preetha Appan
2017-10-25 12:15:31 -05:00
parent 26b1f1675a
commit 8f387d6e7b
15 changed files with 82 additions and 115 deletions

View File

@@ -2,7 +2,7 @@ ISC License
Copyright (c) 2012-2016 Dave Collins <dave@davec.name>
Permission to use, copy, modify, and distribute this software for any
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

View File

@@ -41,9 +41,9 @@ var (
// after commit 82f48826c6c7 which changed the format again to mirror
// the original format. Code in the init function updates these offsets
// as necessary.
offsetPtr = uintptr(ptrSize)
offsetPtr = ptrSize
offsetScalar = uintptr(0)
offsetFlag = uintptr(ptrSize * 2)
offsetFlag = ptrSize * 2
// flagKindWidth and flagKindShift indicate various bits that the
// reflect package uses internally to track kind information.
@@ -58,7 +58,7 @@ var (
// changed their positions. Code in the init function updates these
// flags as necessary.
flagKindWidth = uintptr(5)
flagKindShift = uintptr(flagKindWidth - 1)
flagKindShift = flagKindWidth - 1
flagRO = uintptr(1 << 0)
flagIndir = uintptr(1 << 1)
)

38
vendor/github.com/davecgh/go-spew/spew/bypasssafe.go generated vendored Normal file
View File

@@ -0,0 +1,38 @@
// Copyright (c) 2015-2016 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when the code is running on Google App Engine, compiled by GopherJS, or
// "-tags safe" is added to the go build command line. The "disableunsafe"
// tag is deprecated and thus should not be used.
// +build js appengine safe disableunsafe
package spew
import "reflect"
const (
// UnsafeDisabled is a build-time constant which specifies whether or
// not access to the unsafe package is available.
UnsafeDisabled = true
)
// unsafeReflectValue typically converts the passed reflect.Value into a one
// that bypasses the typical safety restrictions preventing access to
// unaddressable and unexported data. However, doing this relies on access to
// the unsafe package. This is a stub version which simply returns the passed
// reflect.Value when the unsafe package is not available.
func unsafeReflectValue(v reflect.Value) reflect.Value {
return v
}

View File

@@ -180,7 +180,7 @@ func printComplex(w io.Writer, c complex128, floatPrecision int) {
w.Write(closeParenBytes)
}
// printHexPtr outputs a uintptr formatted as hexidecimal with a leading '0x'
// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
// prefix to Writer w.
func printHexPtr(w io.Writer, p uintptr) {
// Null pointer.

View File

@@ -35,16 +35,16 @@ var (
// cCharRE is a regular expression that matches a cgo char.
// It is used to detect character arrays to hexdump them.
cCharRE = regexp.MustCompile("^.*\\._Ctype_char$")
cCharRE = regexp.MustCompile(`^.*\._Ctype_char$`)
// cUnsignedCharRE is a regular expression that matches a cgo unsigned
// char. It is used to detect unsigned character arrays to hexdump
// them.
cUnsignedCharRE = regexp.MustCompile("^.*\\._Ctype_unsignedchar$")
cUnsignedCharRE = regexp.MustCompile(`^.*\._Ctype_unsignedchar$`)
// cUint8tCharRE is a regular expression that matches a cgo uint8_t.
// It is used to detect uint8_t arrays to hexdump them.
cUint8tCharRE = regexp.MustCompile("^.*\\._Ctype_uint8_t$")
cUint8tCharRE = regexp.MustCompile(`^.*\._Ctype_uint8_t$`)
)
// dumpState contains information about the state of a dump operation.
@@ -143,10 +143,10 @@ func (d *dumpState) dumpPtr(v reflect.Value) {
// Display dereferenced value.
d.w.Write(openParenBytes)
switch {
case nilFound == true:
case nilFound:
d.w.Write(nilAngleBytes)
case cycleFound == true:
case cycleFound:
d.w.Write(circularBytes)
default:

View File

@@ -182,10 +182,10 @@ func (f *formatState) formatPtr(v reflect.Value) {
// Display dereferenced value.
switch {
case nilFound == true:
case nilFound:
f.fs.Write(nilAngleBytes)
case cycleFound == true:
case cycleFound:
f.fs.Write(circularShortBytes)
default:

View File

@@ -356,9 +356,6 @@ 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 {
@@ -583,9 +580,6 @@ 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
@@ -596,9 +590,6 @@ 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

View File

@@ -196,9 +196,6 @@ 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) {
@@ -354,9 +351,6 @@ 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
@@ -365,9 +359,6 @@ 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

View File

@@ -161,9 +161,7 @@ type DecodeOptions struct {
// 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.
// So everything will not be interned.
InternString bool
// PreferArrayOverSlice controls whether to decode to an array or a slice.
@@ -742,8 +740,7 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
if cr != nil {
cr.sendContainerState(containerMapKey)
}
rvkencnameB := dd.DecodeBytes(f.d.b[:], true, true)
rvkencname := stringView(rvkencnameB)
rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true))
// rvksi := ti.getForEncName(rvkencname)
if cr != nil {
cr.sendContainerState(containerMapValue)
@@ -758,7 +755,6 @@ 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++ {
@@ -766,8 +762,7 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
if cr != nil {
cr.sendContainerState(containerMapKey)
}
rvkencnameB := dd.DecodeBytes(f.d.b[:], true, true)
rvkencname := stringView(rvkencnameB)
rvkencname := stringView(dd.DecodeBytes(f.d.b[:], true, true))
// rvksi := ti.getForEncName(rvkencname)
if cr != nil {
cr.sendContainerState(containerMapValue)
@@ -782,7 +777,6 @@ func (f *decFnInfo) kStruct(rv reflect.Value) {
} else {
d.structFieldNotFound(-1, rvkencname)
}
keepAlive4StringView(rvkencnameB) // maintain ref 4 stringView
}
}
if cr != nil {
@@ -1879,14 +1873,11 @@ 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, per go implementation
s, ok := d.is[string(v)] // no allocation here.
if !ok {
s = string(v) // new allocation here
s = string(v)
d.is[s] = s
}
return s
@@ -1894,11 +1885,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 {

View File

@@ -8,9 +8,6 @@ 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)
}
@@ -18,19 +15,6 @@ 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) {}

View File

@@ -6,12 +6,10 @@
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
@@ -24,6 +22,9 @@ 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 ""
@@ -34,6 +35,9 @@ 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
@@ -43,11 +47,3 @@ 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)
}

View File

@@ -569,9 +569,6 @@ func (d *msgpackDecDriver) uncacheRead() {
}
func (d *msgpackDecDriver) ContainerType() (vt valueType) {
if !d.bdRead {
d.readNextBd()
}
bd := d.bd
if bd == mpNil {
return valueTypeNil
@@ -624,16 +621,10 @@ 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)
}

View File

@@ -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,13 +46,12 @@ _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
fi
rm -f gen-helper.generated.go fast-path.generated.go \
gen.generated.go \
*safe.generated.go *_generated_test.go *.generated_ffjson_expose.go
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
cat > gen.generated.go <<EOF
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
@@ -94,7 +93,7 @@ EOF
package main
//import "flag"
import "${zpkg}"
import "ugorji.net/codec"
import "os"
func run(fnameIn, fnameOut string, safe bool) {
@@ -146,10 +145,10 @@ _codegenerators() {
fi
echo "codecgen - !unsafe ... " && \
$zgobase/bin/codecgen -rt codecgen -t 'x,codecgen,!unsafe' -o values_codecgen${zsfx} -d 19780 $zfin &
codecgen -rt codecgen -t 'x,codecgen,!unsafe' -o values_codecgen${zsfx} -d 19780 $zfin &
zzzIdC=$!
echo "codecgen - unsafe ... " && \
$zgobase/bin/codecgen -u -rt codecgen -t 'x,codecgen,unsafe' -o values_codecgen_unsafe${zsfx} -d 19781 $zfin &
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 \
@@ -166,14 +165,13 @@ _codegenerators() {
# _init reads the arguments and sets up the flags
_init() {
OPTIND=1
while getopts "fbxp:" flag
while getopts "fbx" flag
do
case "x$flag" in
'xf') zforce=1;;
'xb') zbak=1;;
'xx') zexternal=1;;
'xp') zpkg="${OPTARG}" ;;
*) echo "prebuild.sh accepts [-fbx] [-p basepkgname] only"; return 1;;
*) echo "prebuild.sh accepts [-fbx] only"; return 1;;
esac
done
shift $((OPTIND-1))
@@ -182,15 +180,11 @@ 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 "$@" && \

View File

@@ -174,9 +174,6 @@ 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 ||
@@ -318,17 +315,11 @@ 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()
}

12
vendor/vendor.json vendored
View File

@@ -315,10 +315,10 @@
"revisionTime": "2017-06-13T09:22:38Z"
},
{
"checksumSHA1": "/5cvgU+J4l7EhMXTK76KaCAfOuU=",
"checksumSHA1": "mrz/kicZiUaHxkyfvC/DyQcr8Do=",
"path": "github.com/davecgh/go-spew/spew",
"revision": "346938d642f2ec3594ed81d874461961cd0faa76",
"revisionTime": "2016-10-29T20:57:26Z"
"revision": "ecdeabc65495df2dec95d7c4a4c3e021903035e5",
"revisionTime": "2017-10-02T20:02:53Z"
},
{
"checksumSHA1": "Gj+xR1VgFKKmFXYOJMnAczC3Znk=",
@@ -1394,10 +1394,10 @@
"revisionTime": "2017-06-01T20:57:54Z"
},
{
"checksumSHA1": "9Zw986fuQM/hCoVd8vmHoSM+8sU=",
"checksumSHA1": "8G1zvpE4gTtWQRuP/x2HPVDmflo=",
"path": "github.com/ugorji/go/codec",
"revision": "5efa3251c7f7d05e5d9704a69a984ec9f1386a40",
"revisionTime": "2017-06-20T10:48:52Z"
"revision": "0053ebfd9d0ee06ccefbfe17072021e1d4acebee",
"revisionTime": "2017-06-20T06:01:02Z"
},
{
"checksumSHA1": "OgParimNuU2CJqr3pcTympeQZUc=",