Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
541e343f
Commit
541e343f
authored
Dec 27, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
86c21792
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
3 deletions
+35
-3
t/neo/marshal.go
t/neo/marshal.go
+14
-0
t/neo/proto.go
t/neo/proto.go
+1
-1
t/neo/protogen.go
t/neo/protogen.go
+20
-2
No files found.
t/neo/marshal.go
View file @
541e343f
...
...
@@ -35,3 +35,17 @@ func (p *CellInfo) NEODecode(data []byte) (int, error) {
p
.
CellState
=
int32
(
BigEndian
.
Uint32
(
data
[
4
:
]))
return
8
/* + TODO variable part */
,
nil
}
func
(
p
*
RowInfo
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
p
.
Offset
=
BigEndian
.
Uint32
(
data
[
0
:
])
{
l
:=
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
p
.
CellList
=
make
([]
neo
.
CellInfo
,
l
)
for
i
:=
0
;
i
<
l
;
i
++
{
p
.
CellList
[
i
]
.
UUID
=
int32
(
BigEndian
.
Uint32
(
data
[
0
:
]))
p
.
CellList
[
i
]
.
CellState
=
int32
(
BigEndian
.
Uint32
(
data
[
4
:
]))
data
=
data
[
8
:
]
}
}
return
0
/* + TODO variable part */
,
nil
}
t/neo/proto.go
View file @
541e343f
...
...
@@ -169,7 +169,6 @@ type CellInfo struct {
CellState
}
/*
//type RowList []struct {
type
RowInfo
struct
{
Offset
uint32
// PNumber
...
...
@@ -178,6 +177,7 @@ type RowInfo struct {
/*
// // XXX link request <-> answer ?
// // XXX naming -> PktHeader ?
// type PktHead struct {
...
...
t/neo/protogen.go
View file @
541e343f
...
...
@@ -203,6 +203,24 @@ func (d *decoder) emitstrbytes(assignto string) {
d
.
n
=
0
}
func
(
d
*
decoder
)
emitslice
(
assignto
string
,
obj
types
.
Object
,
typ
*
types
.
Slice
)
{
// len u32
// [len]item
d
.
emit
(
"{ l := %v"
,
d
.
decodedBasic
(
nil
,
types
.
Typ
[
types
.
Uint32
]))
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"%v = make(%v, l)"
,
assignto
,
typ
)
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { return 0, ErrDecodeOverflow }")
d
.
emit
(
"for i := 0; i < l; i++ {"
)
d
.
n
=
0
d
.
emitobjtype
(
assignto
+
"[i]"
,
obj
,
typ
.
Elem
())
// XXX also obj.Elem() ?
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"}"
)
//d.emit("%v = string(data[:l])", assignto)
d
.
emit
(
"}"
)
d
.
n
=
0
}
// top-level driver for emitting decode code for obj/type
func
(
d
*
decoder
)
emitobjtype
(
assignto
string
,
obj
types
.
Object
,
typ
types
.
Type
)
{
switch
u
:=
typ
.
Underlying
()
.
(
type
)
{
...
...
@@ -214,8 +232,8 @@ func (d *decoder) emitobjtype(assignto string, obj types.Object, typ types.Type)
d
.
emit
(
"%s = %s"
,
assignto
,
d
.
decodedBasic
(
obj
,
u
))
//
case *types.Slice:
// // TODO
case
*
types
.
Slice
:
d
.
emitslice
(
assignto
,
obj
,
u
)
//case *types.Map:
// // TODO
...
...
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