Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
1b738098
Commit
1b738098
authored
Jan 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
27467089
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
t/neo/protogen.go
t/neo/protogen.go
+8
-8
No files found.
t/neo/protogen.go
View file @
1b738098
...
...
@@ -175,13 +175,13 @@ func (d *decoder) emit(format string, a ...interface{}) {
// emit code to decode basic fixed types (not string)
// userType is type actually used in source (for which typ is underlying), or nil
func
(
d
*
decoder
)
decodeBasic
(
assignto
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
,
obj
types
.
Object
)
{
b
de
c
,
ok
:=
basicTypes
[
typ
.
Kind
()]
b
asi
c
,
ok
:=
basicTypes
[
typ
.
Kind
()]
if
!
ok
{
log
.
Fatalf
(
"%v: %v: basic type %v not supported"
,
pos
(
obj
),
obj
.
Name
(),
typ
)
}
dataptr
:=
fmt
.
Sprintf
(
"data[%v:]"
,
d
.
n
)
decoded
:=
fmt
.
Sprintf
(
b
de
c
.
decode
,
dataptr
)
d
.
n
+=
b
de
c
.
wireSize
decoded
:=
fmt
.
Sprintf
(
b
asi
c
.
decode
,
dataptr
)
d
.
n
+=
b
asi
c
.
wireSize
if
userType
!=
nil
&&
userType
!=
typ
{
// userType is a named type over some basic, like
// type ClusterState int32
...
...
@@ -202,7 +202,7 @@ func (d *decoder) decodeStrBytes(assignto string) {
d
.
decodeBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
,
nil
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"if uint32(len(data)) < l { return 0, ErrDecodeOverflow }"
)
d
.
emit
(
"%v
= string(data[:l])"
,
assignto
)
d
.
emit
(
"%v= string(data[:l])"
,
assignto
)
d
.
emit
(
"data = data[l:]"
)
d
.
emit
(
"nread += %v + l"
,
d
.
n
)
d
.
emit
(
"}"
)
...
...
@@ -218,7 +218,7 @@ func (d *decoder) decodeSlice(assignto string, typ *types.Slice, obj types.Objec
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v
= make(%v, l)"
,
assignto
,
typeName
(
typ
))
d
.
emit
(
"%v= make(%v, l)"
,
assignto
,
typeName
(
typ
))
// TODO size check
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
...
...
@@ -229,7 +229,7 @@ func (d *decoder) decodeSlice(assignto string, typ *types.Slice, obj types.Objec
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
emit
(
"}"
)
//d.emit("%v
= string(data[:l])", assignto)
//d.emit("%v= string(data[:l])", assignto)
d
.
emit
(
"}"
)
d
.
n
=
0
}
...
...
@@ -242,7 +242,7 @@ func (d *decoder) decodeMap(assignto string, typ *types.Map, obj types.Object) {
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
n
=
0
d
.
emit
(
"%v
= make(%v, l)"
,
assignto
,
typeName
(
typ
))
d
.
emit
(
"%v= make(%v, l)"
,
assignto
,
typeName
(
typ
))
// TODO size check
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
...
...
@@ -266,7 +266,7 @@ func (d *decoder) decodeMap(assignto string, typ *types.Map, obj types.Object) {
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt map of map ?
d
.
emit
(
"nread += %v"
,
d
.
n
)
d
.
emit
(
"}"
)
//d.emit("%v
= string(data[:l])", assignto)
//d.emit("%v= string(data[:l])", assignto)
d
.
emit
(
"}"
)
d
.
n
=
0
}
...
...
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