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
d8f0220c
Commit
d8f0220c
authored
Jan 25, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
620b5776
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
t/neo/protogen.go
t/neo/protogen.go
+12
-12
No files found.
t/neo/protogen.go
View file @
d8f0220c
...
...
@@ -289,24 +289,24 @@ func (c *commonCoder) var_(varname string) string {
return
varname
}
// information about
a
size
// information about
symbolic
size
// consists of numeric & symbolic parts
// size is num + expr1 + expr2 + ...
type
s
ize
struct
{
type
SymS
ize
struct
{
num
int
// numeric part of size
exprv
[]
string
// symbolic part of size
}
func
(
s
*
s
ize
)
Add
(
n
int
)
{
func
(
s
*
SymS
ize
)
Add
(
n
int
)
{
s
.
num
+=
n
}
func
(
s
*
s
ize
)
AddExpr
(
format
string
,
a
...
interface
{})
{
func
(
s
*
SymS
ize
)
AddExpr
(
format
string
,
a
...
interface
{})
{
expr
:=
fmt
.
Sprintf
(
format
,
a
...
)
s
.
exprv
=
append
(
s
.
exprv
,
expr
)
}
func
(
s
*
s
ize
)
String
()
string
{
func
(
s
*
SymS
ize
)
String
()
string
{
// num + expr1 + expr2 + ... (omitting what is possible)
sizev
:=
[]
string
{}
if
s
.
num
!=
0
{
...
...
@@ -323,11 +323,11 @@ func (s *size) String() string {
return
sizeStr
}
func
(
s
*
s
ize
)
ExprString
()
string
{
func
(
s
*
SymS
ize
)
ExprString
()
string
{
return
strings
.
Join
(
s
.
exprv
,
" + "
)
}
func
(
s
*
s
ize
)
IsZero
()
bool
{
func
(
s
*
SymS
ize
)
IsZero
()
bool
{
return
s
.
num
==
0
&&
len
(
s
.
exprv
)
==
0
}
...
...
@@ -335,7 +335,7 @@ func (s *size) IsZero() bool {
// sizer generates code to compute encoded size of a packet
type
sizer
struct
{
Buffer
// buffer for code
size
s
ize
size
SymS
ize
commonCoder
}
...
...
@@ -359,7 +359,7 @@ type decoder struct {
n
int
// size that will be checked for overflow at current overflow check point
overflowCheckSize
s
ize
overflowCheckSize
SymS
ize
// whether overflow was already checked for current decodings
overflowChecked
bool
...
...
@@ -442,7 +442,7 @@ func (d *decoder) overflowCheckpoint() {
d
.
buf
.
emit
(
"if uint32(len(data)) < %v { goto overflow }"
,
&
d
.
overflowCheckSize
)
}
d
.
overflowCheckSize
=
s
ize
{}
// zero
d
.
overflowCheckSize
=
SymS
ize
{}
// zero
d
.
buf
.
Write
(
d
.
bufCur
.
Bytes
())
d
.
bufCur
.
Reset
()
...
...
@@ -602,7 +602,7 @@ func (s *sizer) genSlice(path string, typ *types.Slice, obj types.Object) {
s
.
size
.
Add
(
4
)
curSize
:=
s
.
size
s
.
size
=
size
{}
// zero
s
.
size
=
SymSize
{}
// zero
s
.
emit
(
"for i := 0; i < len(%v); i++ {"
,
path
)
s
.
emit
(
"a := &%s[i]"
,
path
)
...
...
@@ -695,7 +695,7 @@ func (s *sizer) genMap(path string, typ *types.Map, obj types.Object) {
s
.
size
.
Add
(
4
)
curSize
:=
s
.
size
s
.
size
=
size
{}
// zero
s
.
size
=
SymSize
{}
// zero
// FIXME for map of map gives ...[key][key] => key -> different variables
s
.
emit
(
"for key := range %s {"
,
path
)
...
...
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