Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
056ef49c
Commit
056ef49c
authored
Feb 06, 2016
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump(github.com/ugorji/go): 1e4b55517031c729d47ad7397bbc4ce36646166e
parent
524aaa2f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
207 additions
and
43 deletions
+207
-43
Godeps.json
Godeps/Godeps.json
+1
-1
0doc.go
Godeps/_workspace/src/github.com/ugorji/go/codec/0doc.go
+1
-1
cbor.go
Godeps/_workspace/src/github.com/ugorji/go/codec/cbor.go
+1
-1
decode.go
Godeps/_workspace/src/github.com/ugorji/go/codec/decode.go
+11
-8
encode.go
Godeps/_workspace/src/github.com/ugorji/go/codec/encode.go
+4
-3
fast-path.generated.go
...ace/src/github.com/ugorji/go/codec/fast-path.generated.go
+0
-0
fast-path.go.tmpl
...orkspace/src/github.com/ugorji/go/codec/fast-path.go.tmpl
+30
-1
gen-dec-array.go.tmpl
...pace/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
+4
-1
gen.generated.go
...workspace/src/github.com/ugorji/go/codec/gen.generated.go
+4
-1
gen.go
Godeps/_workspace/src/github.com/ugorji/go/codec/gen.go
+96
-19
json.go
Godeps/_workspace/src/github.com/ugorji/go/codec/json.go
+42
-0
prebuild.sh
Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh
+1
-1
test.py
Godeps/_workspace/src/github.com/ugorji/go/codec/test.py
+12
-6
No files found.
Godeps/Godeps.json
View file @
056ef49c
...
@@ -926,7 +926,7 @@
...
@@ -926,7 +926,7 @@
},
},
{
{
"ImportPath"
:
"github.com/ugorji/go/codec"
,
"ImportPath"
:
"github.com/ugorji/go/codec"
,
"Rev"
:
"
4a79e5b7b21e51ae8d61641bca20399b79735a32
"
"Rev"
:
"
f4485b318aadd133842532f841dc205a8e339d74
"
},
},
{
{
"ImportPath"
:
"github.com/vishvananda/netlink"
,
"ImportPath"
:
"github.com/vishvananda/netlink"
,
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/0doc.go
View file @
056ef49c
...
@@ -186,7 +186,7 @@ package codec
...
@@ -186,7 +186,7 @@ package codec
// Name string
// Name string
// Ys []Y
// Ys []Y
// Ys chan <- Y
// Ys chan <- Y
// Ys func(
interface{}) -> call this interface for each entry in there.
// Ys func(
Y) -> call this function for each entry
// }
// }
// - Consider adding a isZeroer interface { isZero() bool }
// - Consider adding a isZeroer interface { isZero() bool }
// It is used within isEmpty, for omitEmpty support.
// It is used within isEmpty, for omitEmpty support.
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/cbor.go
View file @
056ef49c
...
@@ -508,7 +508,7 @@ func (d *cborDecDriver) DecodeNaked() {
...
@@ -508,7 +508,7 @@ func (d *cborDecDriver) DecodeNaked() {
n
.
v
=
valueTypeExt
n
.
v
=
valueTypeExt
n
.
u
=
d
.
decUint
()
n
.
u
=
d
.
decUint
()
n
.
l
=
nil
n
.
l
=
nil
d
.
bdRead
=
false
//
d.bdRead = false
// d.d.decode(&re.Value) // handled by decode itself.
// d.d.decode(&re.Value) // handled by decode itself.
// decodeFurther = true
// decodeFurther = true
default
:
default
:
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/decode.go
View file @
056ef49c
...
@@ -583,14 +583,16 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
...
@@ -583,14 +583,16 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
if
d
.
mtid
==
0
||
d
.
mtid
==
mapIntfIntfTypId
{
if
d
.
mtid
==
0
||
d
.
mtid
==
mapIntfIntfTypId
{
l
:=
len
(
n
.
ms
)
l
:=
len
(
n
.
ms
)
n
.
ms
=
append
(
n
.
ms
,
nil
)
n
.
ms
=
append
(
n
.
ms
,
nil
)
d
.
decode
(
&
n
.
ms
[
l
])
var
v2
interface
{}
=
&
n
.
ms
[
l
]
rvn
=
reflect
.
ValueOf
(
&
n
.
ms
[
l
])
.
Elem
()
d
.
decode
(
v2
)
rvn
=
reflect
.
ValueOf
(
v2
)
.
Elem
()
n
.
ms
=
n
.
ms
[
:
l
]
n
.
ms
=
n
.
ms
[
:
l
]
}
else
if
d
.
mtid
==
mapStrIntfTypId
{
// for json performance
}
else
if
d
.
mtid
==
mapStrIntfTypId
{
// for json performance
l
:=
len
(
n
.
ns
)
l
:=
len
(
n
.
ns
)
n
.
ns
=
append
(
n
.
ns
,
nil
)
n
.
ns
=
append
(
n
.
ns
,
nil
)
d
.
decode
(
&
n
.
ns
[
l
])
var
v2
interface
{}
=
&
n
.
ns
[
l
]
rvn
=
reflect
.
ValueOf
(
&
n
.
ns
[
l
])
.
Elem
()
d
.
decode
(
v2
)
rvn
=
reflect
.
ValueOf
(
v2
)
.
Elem
()
n
.
ns
=
n
.
ns
[
:
l
]
n
.
ns
=
n
.
ns
[
:
l
]
}
else
{
}
else
{
rvn
=
reflect
.
New
(
d
.
h
.
MapType
)
.
Elem
()
rvn
=
reflect
.
New
(
d
.
h
.
MapType
)
.
Elem
()
...
@@ -601,8 +603,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
...
@@ -601,8 +603,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
if
d
.
stid
==
0
||
d
.
stid
==
intfSliceTypId
{
if
d
.
stid
==
0
||
d
.
stid
==
intfSliceTypId
{
l
:=
len
(
n
.
ss
)
l
:=
len
(
n
.
ss
)
n
.
ss
=
append
(
n
.
ss
,
nil
)
n
.
ss
=
append
(
n
.
ss
,
nil
)
d
.
decode
(
&
n
.
ss
[
l
])
var
v2
interface
{}
=
&
n
.
ss
[
l
]
rvn
=
reflect
.
ValueOf
(
&
n
.
ss
[
l
])
.
Elem
()
d
.
decode
(
v2
)
rvn
=
reflect
.
ValueOf
(
v2
)
.
Elem
()
n
.
ss
=
n
.
ss
[
:
l
]
n
.
ss
=
n
.
ss
[
:
l
]
}
else
{
}
else
{
rvn
=
reflect
.
New
(
d
.
h
.
SliceType
)
.
Elem
()
rvn
=
reflect
.
New
(
d
.
h
.
SliceType
)
.
Elem
()
...
@@ -615,9 +618,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
...
@@ -615,9 +618,9 @@ func (f *decFnInfo) kInterfaceNaked() (rvn reflect.Value) {
l
:=
len
(
n
.
is
)
l
:=
len
(
n
.
is
)
n
.
is
=
append
(
n
.
is
,
nil
)
n
.
is
=
append
(
n
.
is
,
nil
)
v2
:=
&
n
.
is
[
l
]
v2
:=
&
n
.
is
[
l
]
n
.
is
=
n
.
is
[
:
l
]
d
.
decode
(
v2
)
d
.
decode
(
v2
)
v
=
*
v2
v
=
*
v2
n
.
is
=
n
.
is
[
:
l
]
}
}
bfn
:=
d
.
h
.
getExtForTag
(
tag
)
bfn
:=
d
.
h
.
getExtForTag
(
tag
)
if
bfn
==
nil
{
if
bfn
==
nil
{
...
@@ -1453,8 +1456,8 @@ func (d *Decoder) swallow() {
...
@@ -1453,8 +1456,8 @@ func (d *Decoder) swallow() {
l
:=
len
(
n
.
is
)
l
:=
len
(
n
.
is
)
n
.
is
=
append
(
n
.
is
,
nil
)
n
.
is
=
append
(
n
.
is
,
nil
)
v2
:=
&
n
.
is
[
l
]
v2
:=
&
n
.
is
[
l
]
n
.
is
=
n
.
is
[
:
l
]
d
.
decode
(
v2
)
d
.
decode
(
v2
)
n
.
is
=
n
.
is
[
:
l
]
}
}
}
}
}
}
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/encode.go
View file @
056ef49c
...
@@ -473,7 +473,7 @@ func (f *encFnInfo) kSlice(rv reflect.Value) {
...
@@ -473,7 +473,7 @@ func (f *encFnInfo) kSlice(rv reflect.Value) {
for
j
:=
0
;
j
<
l
;
j
++
{
for
j
:=
0
;
j
<
l
;
j
++
{
if
cr
!=
nil
{
if
cr
!=
nil
{
if
ti
.
mbs
{
if
ti
.
mbs
{
if
l
%
2
==
0
{
if
j
%
2
==
0
{
cr
.
sendContainerState
(
containerMapKey
)
cr
.
sendContainerState
(
containerMapKey
)
}
else
{
}
else
{
cr
.
sendContainerState
(
containerMapValue
)
cr
.
sendContainerState
(
containerMapValue
)
...
@@ -1188,7 +1188,8 @@ func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr,
...
@@ -1188,7 +1188,8 @@ func (e *Encoder) doEncodeValue(rv reflect.Value, fn *encFn, sptr uintptr,
if
fn
==
nil
{
if
fn
==
nil
{
rt
:=
rv
.
Type
()
rt
:=
rv
.
Type
()
rtid
:=
reflect
.
ValueOf
(
rt
)
.
Pointer
()
rtid
:=
reflect
.
ValueOf
(
rt
)
.
Pointer
()
fn
=
e
.
getEncFn
(
rtid
,
rt
,
true
,
true
)
// fn = e.getEncFn(rtid, rt, true, true)
fn
=
e
.
getEncFn
(
rtid
,
rt
,
checkFastpath
,
checkCodecSelfer
)
}
}
fn
.
f
(
&
fn
.
i
,
rv
)
fn
.
f
(
&
fn
.
i
,
rv
)
if
sptr
!=
0
{
if
sptr
!=
0
{
...
@@ -1265,7 +1266,7 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo
...
@@ -1265,7 +1266,7 @@ func (e *Encoder) getEncFn(rtid uintptr, rt reflect.Type, checkFastpath, checkCo
}
else
{
}
else
{
rk
:=
rt
.
Kind
()
rk
:=
rt
.
Kind
()
if
fastpathEnabled
&&
checkFastpath
&&
(
rk
==
reflect
.
Map
||
rk
==
reflect
.
Slice
)
{
if
fastpathEnabled
&&
checkFastpath
&&
(
rk
==
reflect
.
Map
||
rk
==
reflect
.
Slice
)
{
if
rt
.
PkgPath
()
==
""
{
if
rt
.
PkgPath
()
==
""
{
// un-named slice or map
if
idx
:=
fastpathAV
.
index
(
rtid
);
idx
!=
-
1
{
if
idx
:=
fastpathAV
.
index
(
rtid
);
idx
!=
-
1
{
fn
.
f
=
fastpathAV
[
idx
]
.
encfn
fn
.
f
=
fastpathAV
[
idx
]
.
encfn
}
}
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.generated.go
View file @
056ef49c
This diff is collapsed.
Click to expand it.
Godeps/_workspace/src/github.com/ugorji/go/codec/fast-path.go.tmpl
View file @
056ef49c
...
@@ -165,7 +165,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
...
@@ -165,7 +165,11 @@ func fastpathEncodeTypeSwitchMap(iv interface{}, e *Encoder) bool {
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
not
.
MapKey
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
not
.
MapKey
}}
func
(
f
*
encFnInfo
)
{{
.
MethodNamePfx
"fastpathEnc"
false
}}
R
(
rv
reflect
.
Value
)
{
func
(
f
*
encFnInfo
)
{{
.
MethodNamePfx
"fastpathEnc"
false
}}
R
(
rv
reflect
.
Value
)
{
fastpathTV
.{{
.
MethodNamePfx
"Enc"
false
}}
V
(
rv
.
Interface
().([]{{
.
Elem
}}),
fastpathCheckNilFalse
,
f
.
e
)
if
f
.
ti
.
mbs
{
fastpathTV
.{{
.
MethodNamePfx
"EncAsMap"
false
}}
V
(
rv
.
Interface
().([]{{
.
Elem
}}),
fastpathCheckNilFalse
,
f
.
e
)
}
else
{
fastpathTV
.{{
.
MethodNamePfx
"Enc"
false
}}
V
(
rv
.
Interface
().([]{{
.
Elem
}}),
fastpathCheckNilFalse
,
f
.
e
)
}
}
}
func
(
_
fastpathT
)
{{
.
MethodNamePfx
"Enc"
false
}}
V
(
v
[]{{
.
Elem
}},
checkNil
bool
,
e
*
Encoder
)
{
func
(
_
fastpathT
)
{{
.
MethodNamePfx
"Enc"
false
}}
V
(
v
[]{{
.
Elem
}},
checkNil
bool
,
e
*
Encoder
)
{
ee
:=
e
.
e
ee
:=
e
.
e
...
@@ -182,6 +186,31 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil b
...
@@ -182,6 +186,31 @@ func (_ fastpathT) {{ .MethodNamePfx "Enc" false }}V(v []{{ .Elem }}, checkNil b
if
cr
!= nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}}
if
cr
!= nil { cr.sendContainerState(containerArrayEnd) }{{/* ee.EncodeEnd() */}}
}
}
func
(
_
fastpathT
)
{{
.
MethodNamePfx
"EncAsMap"
false
}}
V
(
v
[]{{
.
Elem
}},
checkNil
bool
,
e
*
Encoder
)
{
ee
:=
e
.
e
cr
:=
e
.
cr
if
checkNil
&&
v
==
nil
{
ee
.
EncodeNil
()
return
}
if
len
(
v
)%
2
==
1
{
e
.
errorf
(
"mapBySlice requires even slice length, but got %v"
,
len
(
v
))
return
}
ee
.
EncodeMapStart
(
len
(
v
)
/
2
)
for
j
,
v2
:=
range
v
{
if
cr
!= nil {
if
j
%
2
==
0
{
cr
.
sendContainerState
(
containerMapKey
)
}
else
{
cr
.
sendContainerState
(
containerMapValue
)
}
}
{{
encmd
.
Elem
"v2"
}}
}
if
cr
!= nil { cr.sendContainerState(containerMapEnd) }
}
{{
end
}}{{
end
}}{{
end
}}
{{
end
}}{{
end
}}{{
end
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
.
MapKey
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
.
MapKey
}}
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/gen-dec-array.go.tmpl
View file @
056ef49c
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}
{{if not isArray}}
var {{var "c"}} bool {{/* // changed */}}
var {{var "c"}} bool {{/* // changed */}}
_ = {{var "c"}}{{end}}
if {{var "l"}} == 0 {
if {{var "l"}} == 0 {
{{if isSlice }}if {{var "v"}} == nil {
{{if isSlice }}if {{var "v"}} == nil {
{{var "v"}} = []{{ .Typ }}{}
{{var "v"}} = []{{ .Typ }}{}
...
@@ -26,6 +27,8 @@ if {{var "l"}} == 0 {
...
@@ -26,6 +27,8 @@ if {{var "l"}} == 0 {
}
}
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
var {{var "rt"}} bool {{/* truncated */}}
var {{var "rt"}} bool {{/* truncated */}}
_, _ = {{var "rl"}}, {{var "rt"}}
{{var "rr"}} = {{var "l"}} // len({{var "v"}})
if {{var "l"}} > cap({{var "v"}}) {
if {{var "l"}} > cap({{var "v"}}) {
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
{{ else }}{{if not .Immutable }}
{{ else }}{{if not .Immutable }}
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/gen.generated.go
View file @
056ef49c
...
@@ -68,8 +68,9 @@ z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }})
...
@@ -68,8 +68,9 @@ z.DecSendContainerState(codecSelfer_containerMapEnd{{ .Sfx }})
const
genDecListTmpl
=
`
const
genDecListTmpl
=
`
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
{{var "v"}} := {{if not isArray}}*{{end}}{{ .Varname }}
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}
{{var "h"}}, {{var "l"}} := z.DecSliceHelperStart() {{/* // helper, containerLenS */}}
{{if not isArray}}
var {{var "c"}} bool {{/* // changed */}}
var {{var "c"}} bool {{/* // changed */}}
_ = {{var "c"}}{{end}}
if {{var "l"}} == 0 {
if {{var "l"}} == 0 {
{{if isSlice }}if {{var "v"}} == nil {
{{if isSlice }}if {{var "v"}} == nil {
{{var "v"}} = []{{ .Typ }}{}
{{var "v"}} = []{{ .Typ }}{}
...
@@ -95,6 +96,8 @@ if {{var "l"}} == 0 {
...
@@ -95,6 +96,8 @@ if {{var "l"}} == 0 {
}
}
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
{{ else }} var {{var "rr"}}, {{var "rl"}} int {{/* // num2read, length of slice/array/chan */}}
var {{var "rt"}} bool {{/* truncated */}}
var {{var "rt"}} bool {{/* truncated */}}
_, _ = {{var "rl"}}, {{var "rt"}}
{{var "rr"}} = {{var "l"}} // len({{var "v"}})
if {{var "l"}} > cap({{var "v"}}) {
if {{var "l"}} > cap({{var "v"}}) {
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
{{if isArray }}z.DecArrayCannotExpand(len({{var "v"}}), {{var "l"}})
{{ else }}{{if not .Immutable }}
{{ else }}{{if not .Immutable }}
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/gen.go
View file @
056ef49c
...
@@ -21,6 +21,8 @@ import (
...
@@ -21,6 +21,8 @@ import (
"sync"
"sync"
"text/template"
"text/template"
"time"
"time"
"unicode"
"unicode/utf8"
)
)
// ---------------------------------------------------
// ---------------------------------------------------
...
@@ -266,6 +268,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
...
@@ -266,6 +268,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
x
.
line
(
"type "
+
x
.
hn
+
" struct{}"
)
x
.
line
(
"type "
+
x
.
hn
+
" struct{}"
)
x
.
line
(
""
)
x
.
line
(
""
)
x
.
varsfxreset
()
x
.
line
(
"func init() {"
)
x
.
line
(
"func init() {"
)
x
.
linef
(
"if %sGenVersion != %v {"
,
x
.
cpfx
,
GenVersion
)
x
.
linef
(
"if %sGenVersion != %v {"
,
x
.
cpfx
,
GenVersion
)
x
.
line
(
"_, file, _, _ := runtime.Caller(0)"
)
x
.
line
(
"_, file, _, _ := runtime.Caller(0)"
)
...
@@ -309,6 +312,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
...
@@ -309,6 +312,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
for
_
,
t
:=
range
x
.
ts
{
for
_
,
t
:=
range
x
.
ts
{
rtid
:=
reflect
.
ValueOf
(
t
)
.
Pointer
()
rtid
:=
reflect
.
ValueOf
(
t
)
.
Pointer
()
// generate enc functions for all these slice/map types.
// 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
.
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
)
x
.
genRequiredMethodVars
(
true
)
switch
t
.
Kind
()
{
switch
t
.
Kind
()
{
...
@@ -323,6 +327,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
...
@@ -323,6 +327,7 @@ func Gen(w io.Writer, buildTags, pkgName, uid string, useUnsafe bool, ti *TypeIn
x
.
line
(
""
)
x
.
line
(
""
)
// generate dec functions for all these slice/map types.
// 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
.
linef
(
"func (x %s) dec%s(v *%s, d *%sDecoder) {"
,
x
.
hn
,
x
.
genMethodNameT
(
t
),
x
.
genTypeName
(
t
),
x
.
cpfx
)
x
.
genRequiredMethodVars
(
false
)
x
.
genRequiredMethodVars
(
false
)
switch
t
.
Kind
()
{
switch
t
.
Kind
()
{
...
@@ -377,7 +382,7 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
...
@@ -377,7 +382,7 @@ func (x *genRunner) genRefPkgs(t reflect.Type) {
x
.
imn
[
tpkg
]
=
tpkg
x
.
imn
[
tpkg
]
=
tpkg
}
else
{
}
else
{
x
.
imc
++
x
.
imc
++
x
.
imn
[
tpkg
]
=
"pkg"
+
strconv
.
FormatUint
(
x
.
imc
,
10
)
+
"_"
+
tpkg
[
idx
+
1
:
]
x
.
imn
[
tpkg
]
=
"pkg"
+
strconv
.
FormatUint
(
x
.
imc
,
10
)
+
"_"
+
genGoIdentifier
(
tpkg
[
idx
+
1
:
],
false
)
}
}
}
}
}
}
...
@@ -408,6 +413,10 @@ func (x *genRunner) varsfx() string {
...
@@ -408,6 +413,10 @@ func (x *genRunner) varsfx() string {
return
strconv
.
FormatUint
(
x
.
c
,
10
)
return
strconv
.
FormatUint
(
x
.
c
,
10
)
}
}
func
(
x
*
genRunner
)
varsfxreset
()
{
x
.
c
=
0
}
func
(
x
*
genRunner
)
out
(
s
string
)
{
func
(
x
*
genRunner
)
out
(
s
string
)
{
if
_
,
err
:=
io
.
WriteString
(
x
.
w
,
s
);
err
!=
nil
{
if
_
,
err
:=
io
.
WriteString
(
x
.
w
,
s
);
err
!=
nil
{
panic
(
err
)
panic
(
err
)
...
@@ -494,6 +503,7 @@ func (x *genRunner) selfer(encode bool) {
...
@@ -494,6 +503,7 @@ func (x *genRunner) selfer(encode bool) {
// always make decode use a pointer receiver,
// always make decode use a pointer receiver,
// and structs always use a ptr receiver (encode|decode)
// and structs always use a ptr receiver (encode|decode)
isptr
:=
!
encode
||
t
.
Kind
()
==
reflect
.
Struct
isptr
:=
!
encode
||
t
.
Kind
()
==
reflect
.
Struct
x
.
varsfxreset
()
fnSigPfx
:=
"func (x "
fnSigPfx
:=
"func (x "
if
isptr
{
if
isptr
{
fnSigPfx
+=
"*"
fnSigPfx
+=
"*"
...
@@ -566,9 +576,28 @@ func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) {
...
@@ -566,9 +576,28 @@ func (x *genRunner) xtraSM(varname string, encode bool, t reflect.Type) {
}
else
{
}
else
{
x
.
linef
(
"h.dec%s((*%s)(%s), d)"
,
x
.
genMethodNameT
(
t
),
x
.
genTypeName
(
t
),
varname
)
x
.
linef
(
"h.dec%s((*%s)(%s), d)"
,
x
.
genMethodNameT
(
t
),
x
.
genTypeName
(
t
),
varname
)
}
}
if
_
,
ok
:=
x
.
tm
[
t
];
!
ok
{
x
.
registerXtraT
(
t
)
x
.
tm
[
t
]
=
struct
{}{}
}
x
.
ts
=
append
(
x
.
ts
,
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
)
}
}
}
}
...
@@ -608,22 +637,33 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
...
@@ -608,22 +637,33 @@ func (x *genRunner) encVar(varname string, t reflect.Type) {
}
}
// enc will encode a variable (varname) of type
T
,
// enc will encode a variable (varname) of type
t
,
// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type
*T
(to prevent copying)
// except t is of kind reflect.Struct or reflect.Array, wherein varname is of type
ptrTo(T)
(to prevent copying)
func
(
x
*
genRunner
)
enc
(
varname
string
,
t
reflect
.
Type
)
{
func
(
x
*
genRunner
)
enc
(
varname
string
,
t
reflect
.
Type
)
{
// varName here must be to a pointer to a struct/array, or to a value directly.
rtid
:=
reflect
.
ValueOf
(
t
)
.
Pointer
()
rtid
:=
reflect
.
ValueOf
(
t
)
.
Pointer
()
// We call CodecEncodeSelf if one of the following are honored:
// We call CodecEncodeSelf if one of the following are honored:
// - the type already implements Selfer, call that
// - the type already implements Selfer, call that
// - the type has a Selfer implementation just created, use 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
// - 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
)
tptr
:=
reflect
.
PtrTo
(
t
)
tk
:=
t
.
Kind
()
tk
:=
t
.
Kind
()
if
x
.
checkForSelfer
(
t
,
varname
)
{
if
x
.
checkForSelfer
(
t
,
varname
)
{
if
t
.
Implements
(
selferTyp
)
||
(
tptr
.
Implements
(
selferTyp
)
&&
(
tk
==
reflect
.
Array
||
tk
==
reflect
.
Struct
))
{
if
tk
==
reflect
.
Array
||
tk
==
reflect
.
Struct
{
// varname is of type *T
x
.
line
(
varname
+
".CodecEncodeSelf(e)"
)
if
tptr
.
Implements
(
selferTyp
)
||
t
.
Implements
(
selferTyp
)
{
return
x
.
line
(
varname
+
".CodecEncodeSelf(e)"
)
return
}
}
else
{
// varname is of type T
if
t
.
Implements
(
selferTyp
)
{
x
.
line
(
varname
+
".CodecEncodeSelf(e)"
)
return
}
else
if
tptr
.
Implements
(
selferTyp
)
{
x
.
linef
(
"%ssf%s := &%s"
,
genTempVarPfx
,
mi
,
varname
)
x
.
linef
(
"%ssf%s.CodecEncodeSelf(e)"
,
genTempVarPfx
,
mi
)
return
}
}
}
if
_
,
ok
:=
x
.
te
[
rtid
];
ok
{
if
_
,
ok
:=
x
.
te
[
rtid
];
ok
{
...
@@ -653,7 +693,6 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
...
@@ -653,7 +693,6 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// check if
// check if
// - type is RawExt
// - type is RawExt
// - the type implements (Text|JSON|Binary)(Unm|M)arshal
// - the type implements (Text|JSON|Binary)(Unm|M)arshal
mi
:=
x
.
varsfx
()
x
.
linef
(
"%sm%s := z.EncBinary()"
,
genTempVarPfx
,
mi
)
x
.
linef
(
"%sm%s := z.EncBinary()"
,
genTempVarPfx
,
mi
)
x
.
linef
(
"_ = %sm%s"
,
genTempVarPfx
,
mi
)
x
.
linef
(
"_ = %sm%s"
,
genTempVarPfx
,
mi
)
x
.
line
(
"if false {"
)
//start if block
x
.
line
(
"if false {"
)
//start if block
...
@@ -676,15 +715,31 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
...
@@ -676,15 +715,31 @@ func (x *genRunner) enc(varname string, t reflect.Type) {
// first check if extensions are configued, before doing the interface conversion
// first check if extensions are configued, before doing the interface conversion
x
.
linef
(
"} else if z.HasExtensions() && z.EncExt(%s) {"
,
varname
)
x
.
linef
(
"} else if z.HasExtensions() && z.EncExt(%s) {"
,
varname
)
}
}
if
t
.
Implements
(
binaryMarshalerTyp
)
||
tptr
.
Implements
(
binaryMarshalerTyp
)
{
if
tk
==
reflect
.
Array
||
tk
==
reflect
.
Struct
{
// varname is of type *T
x
.
linef
(
"} else if %sm%s { z.EncBinaryMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
if
t
.
Implements
(
binaryMarshalerTyp
)
||
tptr
.
Implements
(
binaryMarshalerTyp
)
{
}
x
.
linef
(
"} else if %sm%s { z.EncBinaryMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
if
t
.
Implements
(
jsonMarshalerTyp
)
||
tptr
.
Implements
(
jsonMarshalerTyp
)
{
}
x
.
linef
(
"} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
if
t
.
Implements
(
jsonMarshalerTyp
)
||
tptr
.
Implements
(
jsonMarshalerTyp
)
{
}
else
if
t
.
Implements
(
textMarshalerTyp
)
||
tptr
.
Implements
(
textMarshalerTyp
)
{
x
.
linef
(
"} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
x
.
linef
(
"} else if !%sm%s { z.EncTextMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
else
if
t
.
Implements
(
textMarshalerTyp
)
||
tptr
.
Implements
(
textMarshalerTyp
)
{
x
.
linef
(
"} else if !%sm%s { z.EncTextMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
}
else
{
// varname is of type T
if
t
.
Implements
(
binaryMarshalerTyp
)
{
x
.
linef
(
"} else if %sm%s { z.EncBinaryMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
else
if
tptr
.
Implements
(
binaryMarshalerTyp
)
{
x
.
linef
(
"} else if %sm%s { z.EncBinaryMarshal(&%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
if
t
.
Implements
(
jsonMarshalerTyp
)
{
x
.
linef
(
"} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
else
if
tptr
.
Implements
(
jsonMarshalerTyp
)
{
x
.
linef
(
"} else if !%sm%s && z.IsJSONHandle() { z.EncJSONMarshal(&%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
else
if
t
.
Implements
(
textMarshalerTyp
)
{
x
.
linef
(
"} else if !%sm%s { z.EncTextMarshal(%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
else
if
tptr
.
Implements
(
textMarshalerTyp
)
{
x
.
linef
(
"} else if !%sm%s { z.EncTextMarshal(&%v) "
,
genTempVarPfx
,
mi
,
varname
)
}
}
}
x
.
line
(
"} else {"
)
x
.
line
(
"} else {"
)
switch
t
.
Kind
()
{
switch
t
.
Kind
()
{
...
@@ -1020,6 +1075,8 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) {
...
@@ -1020,6 +1075,8 @@ func (x *genRunner) decVar(varname string, t reflect.Type, canBeNil bool) {
}
}
}
}
// dec will decode a variable (varname) of type ptrTo(t).
// t is always a basetype (i.e. not of kind reflect.Ptr).
func
(
x
*
genRunner
)
dec
(
varname
string
,
t
reflect
.
Type
)
{
func
(
x
*
genRunner
)
dec
(
varname
string
,
t
reflect
.
Type
)
{
// assumptions:
// assumptions:
// - the varname is to a pointer already. No need to take address of it
// - the varname is to a pointer already. No need to take address of it
...
@@ -1592,6 +1649,26 @@ func genImportPath(t reflect.Type) (s string) {
...
@@ -1592,6 +1649,26 @@ func genImportPath(t reflect.Type) (s string) {
return
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
{
func
genNonPtr
(
t
reflect
.
Type
)
reflect
.
Type
{
for
t
.
Kind
()
==
reflect
.
Ptr
{
for
t
.
Kind
()
==
reflect
.
Ptr
{
t
=
t
.
Elem
()
t
=
t
.
Elem
()
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/json.go
View file @
056ef49c
...
@@ -206,10 +206,22 @@ func (e *jsonEncDriver) EncodeFloat64(f float64) {
...
@@ -206,10 +206,22 @@ func (e *jsonEncDriver) EncodeFloat64(f float64) {
}
}
func
(
e
*
jsonEncDriver
)
EncodeInt
(
v
int64
)
{
func
(
e
*
jsonEncDriver
)
EncodeInt
(
v
int64
)
{
if
x
:=
e
.
h
.
IntegerAsString
;
x
==
'A'
||
x
==
'L'
&&
(
v
>
1
<<
53
||
v
<
-
(
1
<<
53
))
{
e
.
w
.
writen1
(
'"'
)
e
.
w
.
writeb
(
strconv
.
AppendInt
(
e
.
b
[
:
0
],
v
,
10
))
e
.
w
.
writen1
(
'"'
)
return
}
e
.
w
.
writeb
(
strconv
.
AppendInt
(
e
.
b
[
:
0
],
v
,
10
))
e
.
w
.
writeb
(
strconv
.
AppendInt
(
e
.
b
[
:
0
],
v
,
10
))
}
}
func
(
e
*
jsonEncDriver
)
EncodeUint
(
v
uint64
)
{
func
(
e
*
jsonEncDriver
)
EncodeUint
(
v
uint64
)
{
if
x
:=
e
.
h
.
IntegerAsString
;
x
==
'A'
||
x
==
'L'
&&
v
>
1
<<
53
{
e
.
w
.
writen1
(
'"'
)
e
.
w
.
writeb
(
strconv
.
AppendUint
(
e
.
b
[
:
0
],
v
,
10
))
e
.
w
.
writen1
(
'"'
)
return
}
e
.
w
.
writeb
(
strconv
.
AppendUint
(
e
.
b
[
:
0
],
v
,
10
))
e
.
w
.
writeb
(
strconv
.
AppendUint
(
e
.
b
[
:
0
],
v
,
10
))
}
}
...
@@ -636,6 +648,11 @@ func (d *jsonDecDriver) decNum(storeBytes bool) {
...
@@ -636,6 +648,11 @@ func (d *jsonDecDriver) decNum(storeBytes bool) {
d
.
tok
=
b
d
.
tok
=
b
}
}
b
:=
d
.
tok
b
:=
d
.
tok
var
str
bool
if
b
==
'"'
{
str
=
true
b
=
d
.
r
.
readn1
()
}
if
!
(
b
==
'+'
||
b
==
'-'
||
b
==
'.'
||
(
b
>=
'0'
&&
b
<=
'9'
))
{
if
!
(
b
==
'+'
||
b
==
'-'
||
b
==
'.'
||
(
b
>=
'0'
&&
b
<=
'9'
))
{
d
.
d
.
errorf
(
"json: decNum: got first char '%c'"
,
b
)
d
.
d
.
errorf
(
"json: decNum: got first char '%c'"
,
b
)
return
return
...
@@ -650,6 +667,10 @@ func (d *jsonDecDriver) decNum(storeBytes bool) {
...
@@ -650,6 +667,10 @@ func (d *jsonDecDriver) decNum(storeBytes bool) {
n
.
reset
()
n
.
reset
()
d
.
bs
=
d
.
bs
[
:
0
]
d
.
bs
=
d
.
bs
[
:
0
]
if
str
&&
storeBytes
{
d
.
bs
=
append
(
d
.
bs
,
'"'
)
}
// The format of a number is as below:
// The format of a number is as below:
// parsing: sign? digit* dot? digit* e? sign? digit*
// parsing: sign? digit* dot? digit* e? sign? digit*
// states: 0 1* 2 3* 4 5* 6 7
// states: 0 1* 2 3* 4 5* 6 7
...
@@ -740,6 +761,14 @@ LOOP:
...
@@ -740,6 +761,14 @@ LOOP:
default
:
default
:
break
LOOP
break
LOOP
}
}
case
'"'
:
if
str
{
if
storeBytes
{
d
.
bs
=
append
(
d
.
bs
,
'"'
)
}
b
,
eof
=
r
.
readn1eof
()
}
break
LOOP
default
:
default
:
break
LOOP
break
LOOP
}
}
...
@@ -1110,6 +1139,19 @@ type JsonHandle struct {
...
@@ -1110,6 +1139,19 @@ type JsonHandle struct {
// - If positive, indent by that number of spaces.
// - If positive, indent by that number of spaces.
// - If negative, indent by that number of tabs.
// - If negative, indent by that number of tabs.
Indent
int8
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
uint8
}
}
func
(
h
*
JsonHandle
)
SetInterfaceExt
(
rt
reflect
.
Type
,
tag
uint64
,
ext
InterfaceExt
)
(
err
error
)
{
func
(
h
*
JsonHandle
)
SetInterfaceExt
(
rt
reflect
.
Type
,
tag
uint64
,
ext
InterfaceExt
)
(
err
error
)
{
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh
View file @
056ef49c
...
@@ -171,7 +171,7 @@ do
...
@@ -171,7 +171,7 @@ do
'xf'
)
zforce
=
1
;;
'xf'
)
zforce
=
1
;;
'xb'
)
zbak
=
1
;;
'xb'
)
zbak
=
1
;;
'xx'
)
zexternal
=
1
;;
'xx'
)
zexternal
=
1
;;
*
)
echo
"prebuild.sh accepts [-fb] only"
;
return
1
;;
*
)
echo
"prebuild.sh accepts [-fb
x
] only"
;
return
1
;;
esac
esac
done
done
shift
$((
OPTIND-1
))
shift
$((
OPTIND-1
))
...
...
Godeps/_workspace/src/github.com/ugorji/go/codec/test.py
View file @
056ef49c
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
# sudo apt-get install python-pip
# sudo apt-get install python-pip
# pip install --user msgpack-python msgpack-rpc-python cbor
# pip install --user msgpack-python msgpack-rpc-python cbor
# Ensure all "string" keys are utf strings (else encoded as bytes)
import
cbor
,
msgpack
,
msgpackrpc
,
sys
,
os
,
threading
import
cbor
,
msgpack
,
msgpackrpc
,
sys
,
os
,
threading
def
get_test_data_list
():
def
get_test_data_list
():
...
@@ -26,35 +28,39 @@ def get_test_data_list():
...
@@ -26,35 +28,39 @@ def get_test_data_list():
-
3232.0
,
-
3232.0
,
-
6464646464.0
,
-
6464646464.0
,
3232.0
,
3232.0
,
6464.0
,
6464646464.0
,
6464646464.0
,
False
,
False
,
True
,
True
,
u"null"
,
None
,
None
,
u"someday"
,
u"someday"
,
u""
,
u"bytestring"
,
1328176922000002000
,
1328176922000002000
,
u""
,
-
2206187877999998000
,
-
2206187877999998000
,
u"bytestring"
,
270
,
270
,
u"none"
,
-
2013855847999995777
,
-
2013855847999995777
,
#-6795364578871345152,
#-6795364578871345152,
]
]
l1
=
[
l1
=
[
{
"true"
:
True
,
{
"true"
:
True
,
"false"
:
False
},
"false"
:
False
},
{
"true"
:
"True"
,
{
"true"
:
u
"True"
,
"false"
:
False
,
"false"
:
False
,
"uint16(1616)"
:
1616
},
"uint16(1616)"
:
1616
},
{
"list"
:
[
1616
,
32323232
,
True
,
-
3232.0
,
{
"TRUE"
:
True
,
"FALSE"
:
False
},
[
True
,
False
]
],
{
"list"
:
[
1616
,
32323232
,
True
,
-
3232.0
,
{
"TRUE"
:
True
,
"FALSE"
:
False
},
[
True
,
False
]
],
"int32"
:
32323232
,
"bool"
:
True
,
"int32"
:
32323232
,
"bool"
:
True
,
"LONG STRING"
:
"123456789012345678901234567890123456789012345678901234567890"
,
"LONG STRING"
:
u
"123456789012345678901234567890123456789012345678901234567890"
,
"SHORT STRING"
:
"1234567890"
},
"SHORT STRING"
:
u"1234567890"
},
{
True
:
"true"
,
8
:
False
,
"false"
:
0
}
{
True
:
"true"
,
138
:
False
,
"false"
:
20
0
}
]
]
l
=
[]
l
=
[]
l
.
extend
(
l0
)
l
.
extend
(
l0
)
l
.
append
(
l0
)
l
.
append
(
l0
)
l
.
append
(
1
)
l
.
extend
(
l1
)
l
.
extend
(
l1
)
return
l
return
l
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment