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
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
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
Hide 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:
...
@@ -170,10 +170,7 @@ overflow:
func
(
p
*
XXXTest
)
NEOEncodedLen
()
int
{
func
(
p
*
XXXTest
)
NEOEncodedLen
()
int
{
var
size
int
var
size
int
for
key
:=
range
p
.
Zzz
{
for
key
:=
range
p
.
Zzz
{
for
key
:=
range
p
.
Zzz
[
key
]
{
size
+=
len
(
p
.
Zzz
[
key
])
size
+=
len
(
p
.
Zzz
[
key
][
key
])
}
size
+=
len
(
p
.
Zzz
[
key
])
*
8
}
}
return
12
+
len
(
p
.
Zzz
)
*
8
+
size
return
12
+
len
(
p
.
Zzz
)
*
8
+
size
}
}
...
@@ -196,22 +193,8 @@ func (p *XXXTest) NEOEncode(data []byte) {
...
@@ -196,22 +193,8 @@ func (p *XXXTest) NEOEncode(data []byte) {
l
:=
uint32
(
len
(
p
.
Zzz
[
key
]))
l
:=
uint32
(
len
(
p
.
Zzz
[
key
]))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
data
=
data
[
8
:
]
data
=
data
[
8
:
]
keyv
:=
make
([]
int32
,
0
,
l
)
copy
(
data
,
p
.
Zzz
[
key
])
for
key
:=
range
p
.
Zzz
[
key
]
{
data
=
data
[
l
:
]
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
])
data
=
data
[
l
:
]
}
data
=
data
[
0
:
]
}
}
}
data
=
data
[
0
:
]
data
=
data
[
0
:
]
}
}
...
@@ -229,38 +212,23 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
...
@@ -229,38 +212,23 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
data
=
data
[
12
:
]
nread
+=
12
nread
+=
12
p
.
Zzz
=
make
(
map
[
int32
]
map
[
int32
]
string
,
l
)
p
.
Zzz
=
make
(
map
[
int32
]
string
,
l
)
m
:=
p
.
Zzz
m
:=
p
.
Zzz
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
key
:=
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
]))
key
:=
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
]))
var
v
map
[
int32
]
string
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
data
=
data
[
8
:
]
nread
+=
8
nread
+=
8
+
l
v
=
make
(
map
[
int32
]
string
,
l
)
if
uint32
(
len
(
data
))
<
l
{
m
:=
v
goto
overflow
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
}
key
:=
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
]))
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
nread
+=
8
+
l
if
uint32
(
len
(
data
))
<
l
{
goto
overflow
}
m
[
key
]
=
string
(
data
[
:
l
])
data
=
data
[
l
:
]
}
}
}
m
[
key
]
=
string
(
data
[
:
l
])
data
=
data
[
l
:
]
}
}
m
[
key
]
=
v
}
}
}
}
return
0
+
int
(
nread
),
nil
return
0
+
int
(
nread
),
nil
...
...
t/neo/proto.go
View file @
f24296e3
...
@@ -198,7 +198,7 @@ type RowInfo struct {
...
@@ -198,7 +198,7 @@ type RowInfo struct {
type
XXXTest
struct
{
type
XXXTest
struct
{
qqq
uint32
qqq
uint32
aaa
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) {
...
@@ -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
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
e
)
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt map of map?
e
.
emit
(
"data = data[%v:]"
,
e
.
n
)
// XXX wrt map of map?
e
.
emit
(
"}"
)
e
.
emit
(
"}"
)
// XXX vvv ?
e
.
emit
(
"}"
)
e
.
emit
(
"}"
)
e
.
n
=
0
e
.
n
=
0
}
}
...
@@ -782,7 +781,6 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
...
@@ -782,7 +781,6 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
switch
typ
.
Elem
()
.
Underlying
()
.
(
type
)
{
switch
typ
.
Elem
()
.
Underlying
()
.
(
type
)
{
// basic types can be directly assigned to map entry
// basic types can be directly assigned to map entry
case
*
types
.
Basic
:
case
*
types
.
Basic
:
// XXX handle string
codegenType
(
"m[key]"
,
typ
.
Elem
(),
obj
,
d
)
codegenType
(
"m[key]"
,
typ
.
Elem
(),
obj
,
d
)
// otherwise assign via temporary
// otherwise assign via temporary
...
@@ -795,7 +793,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
...
@@ -795,7 +793,7 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
// d.resetPos() with nread update optionally skipped
// d.resetPos() with nread update optionally skipped
if
d
.
n
!=
0
{
if
d
.
n
!=
0
{
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
if
!
el
emFixed
{
if
!
it
emFixed
{
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
}
}
d
.
n
=
0
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