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
f24296e3
Commit
f24296e3
authored
Jan 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2d7a1229
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
45 deletions
+11
-45
t/neo/marshal.go
t/neo/marshal.go
+9
-41
t/neo/proto.go
t/neo/proto.go
+1
-1
t/neo/protogen.go
t/neo/protogen.go
+1
-3
No files found.
t/neo/marshal.go
View file @
f24296e3
...
...
@@ -170,10 +170,7 @@ overflow:
func
(
p
*
XXXTest
)
NEOEncodedLen
()
int
{
var
size
int
for
key
:=
range
p
.
Zzz
{
for
key
:=
range
p
.
Zzz
[
key
]
{
size
+=
len
(
p
.
Zzz
[
key
][
key
])
}
size
+=
len
(
p
.
Zzz
[
key
])
*
8
size
+=
len
(
p
.
Zzz
[
key
])
}
return
12
+
len
(
p
.
Zzz
)
*
8
+
size
}
...
...
@@ -196,26 +193,12 @@ func (p *XXXTest) NEOEncode(data []byte) {
l
:=
uint32
(
len
(
p
.
Zzz
[
key
]))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
data
=
data
[
8
:
]
keyv
:=
make
([]
int32
,
0
,
l
)
for
key
:=
range
p
.
Zzz
[
key
]
{
keyv
=
append
(
keyv
,
key
)
}
sort
.
Slice
(
keyv
,
func
(
i
,
j
int
)
bool
{
return
keyv
[
i
]
<
keyv
[
j
]
})
for
_
,
key
:=
range
keyv
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
key
))
{
l
:=
uint32
(
len
(
p
.
Zzz
[
key
][
key
]))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
data
=
data
[
8
:
]
copy
(
data
,
p
.
Zzz
[
key
][
key
])
copy
(
data
,
p
.
Zzz
[
key
])
data
=
data
[
l
:
]
}
data
=
data
[
0
:
]
}
}
data
=
data
[
0
:
]
}
}
}
func
(
p
*
XXXTest
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
...
...
@@ -229,20 +212,8 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
nread
+=
12
p
.
Zzz
=
make
(
map
[
int32
]
map
[
int32
]
string
,
l
)
p
.
Zzz
=
make
(
map
[
int32
]
string
,
l
)
m
:=
p
.
Zzz
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
}
key
:=
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
]))
var
v
map
[
int32
]
string
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
nread
+=
8
v
=
make
(
map
[
int32
]
string
,
l
)
m
:=
v
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
...
...
@@ -260,9 +231,6 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
}
}
}
m
[
key
]
=
v
}
}
return
0
+
int
(
nread
),
nil
overflow
:
...
...
t/neo/proto.go
View file @
f24296e3
...
...
@@ -198,7 +198,7 @@ type RowInfo struct {
type
XXXTest
struct
{
qqq
uint32
aaa
uint32
Zzz
map
[
int32
]
map
[
int32
]
string
Zzz
map
[
int32
]
string
}
...
...
t/neo/protogen.go
View file @
f24296e3
...
...
@@ -745,7 +745,6 @@ func (e *encoder) genMap(path string, typ *types.Map, obj types.Object) {
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
e
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt map of map?
e
.
emit
(
"}"
)
// XXX vvv ?
e
.
emit
(
"}"
)
e
.
n
=
0
}
...
...
@@ -782,7 +781,6 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
switch
typ
.
Elem
()
.
Underlying
()
.
(
type
)
{
// basic types can be directly assigned to map entry
case
*
types
.
Basic
:
// XXX handle string
codegenType
(
"m[key]"
,
typ
.
Elem
(),
obj
,
d
)
// otherwise assign via temporary
...
...
@@ -795,7 +793,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
// d.resetPos() with nread update optionally skipped
if
d
.
n
!=
0
{
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
if
!
el
emFixed
{
if
!
it
emFixed
{
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
}
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