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
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
Stefane Fermigier
neo
Commits
2ed6cfd8
Commit
2ed6cfd8
authored
Sep 04, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
171422b2
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
100 additions
and
121 deletions
+100
-121
go/neo/proto-misc.go
go/neo/proto-misc.go
+2
-1
go/neo/proto.go
go/neo/proto.go
+4
-4
go/neo/protogen.go
go/neo/protogen.go
+7
-4
go/neo/zproto-marshal.go
go/neo/zproto-marshal.go
+86
-111
go/neo/zproto-str.go
go/neo/zproto-str.go
+1
-1
No files found.
go/neo/proto-misc.go
View file @
2ed6cfd8
...
@@ -16,7 +16,8 @@
...
@@ -16,7 +16,8 @@
//
//
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// See https://www.nexedi.com/licensing for rationale and options.
//go:generate stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState proto.go
//go:generate stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState proto.go packed.go
package
neo
package
neo
// supporting code for types defined in proto.go
// supporting code for types defined in proto.go
...
...
go/neo/proto.go
View file @
2ed6cfd8
...
@@ -243,7 +243,7 @@ func (a *Address) neoEncode(b []byte) int {
...
@@ -243,7 +243,7 @@ func (a *Address) neoEncode(b []byte) int {
return
n
return
n
}
}
func
(
a
*
Address
)
neoDecode
(
b
[]
byte
)
(
int
,
bool
)
{
func
(
a
*
Address
)
neoDecode
(
b
[]
byte
)
(
uint32
,
bool
)
{
n
,
ok
:=
string_neoDecode
(
&
a
.
Host
,
b
)
n
,
ok
:=
string_neoDecode
(
&
a
.
Host
,
b
)
if
!
ok
{
if
!
ok
{
return
0
,
false
return
0
,
false
...
@@ -1025,7 +1025,7 @@ type Truncate struct {
...
@@ -1025,7 +1025,7 @@ type Truncate struct {
type
customCodec
interface
{
type
customCodec
interface
{
neoEncodedLen
()
int
neoEncodedLen
()
int
neoEncode
(
buf
[]
byte
)
(
nwrote
int
)
neoEncode
(
buf
[]
byte
)
(
nwrote
int
)
neoDecode
(
data
[]
byte
)
(
nread
int
,
ok
bool
)
neoDecode
(
data
[]
byte
)
(
nread
uint32
,
ok
bool
)
// XXX uint32 or int here?
}
}
func
byte2bool
(
b
byte
)
bool
{
func
byte2bool
(
b
byte
)
bool
{
...
@@ -1074,7 +1074,7 @@ func string_neoEncode(s string, data []byte) int {
...
@@ -1074,7 +1074,7 @@ func string_neoEncode(s string, data []byte) int {
return
4
+
l
return
4
+
l
}
}
func
string_neoDecode
(
sp
*
string
,
data
[]
byte
)
(
nread
int
,
ok
bool
)
{
func
string_neoDecode
(
sp
*
string
,
data
[]
byte
)
(
nread
uint32
,
ok
bool
)
{
if
len
(
data
)
<
4
{
if
len
(
data
)
<
4
{
return
0
,
false
return
0
,
false
}
}
...
@@ -1085,5 +1085,5 @@ func string_neoDecode(sp *string, data []byte) (nread int, ok bool) {
...
@@ -1085,5 +1085,5 @@ func string_neoDecode(sp *string, data []byte) (nread int, ok bool) {
}
}
*
sp
=
string
(
data
[
:
l
])
*
sp
=
string
(
data
[
:
l
])
return
4
+
int
(
l
)
,
true
return
4
+
l
,
true
}
}
go/neo/protogen.go
View file @
2ed6cfd8
...
@@ -1091,21 +1091,23 @@ func (s *sizer) genCustom(path string) {
...
@@ -1091,21 +1091,23 @@ func (s *sizer) genCustom(path string) {
func
(
e
*
encoder
)
genCustom
(
path
string
)
{
func
(
e
*
encoder
)
genCustom
(
path
string
)
{
e
.
emit
(
"{"
)
e
.
emit
(
"{"
)
e
.
emit
(
"n := %s.neoEncode(data[%v:])"
,
e
.
n
)
e
.
emit
(
"n := %s.neoEncode(data[%v:])"
,
path
,
e
.
n
)
e
.
emit
(
"data = data[%v + n:]"
,
e
.
n
)
e
.
emit
(
"data = data[%v + n:]"
,
e
.
n
)
e
.
emit
(
"}"
)
e
.
emit
(
"}"
)
e
.
n
=
0
e
.
n
=
0
}
}
func
(
d
*
decoder
)
genCustom
(
path
string
)
{
func
(
d
*
decoder
)
genCustom
(
path
string
)
{
d
.
resetPos
()
// make sure we check for overflow previous-code before proceeding to custom decoder.
// make sure we check for overflow previous-code before proceeding to custom decoder.
d
.
overflowCheck
()
d
.
overflowCheck
()
d
.
resetPos
()
d
.
emit
(
"{"
)
d
.
emit
(
"{"
)
d
.
emit
(
"n, ok := %s.neoDecode(data)"
)
d
.
emit
(
"n, ok := %s.neoDecode(data)"
,
path
)
d
.
emit
(
"if !ok { goto overflow }"
)
d
.
emit
(
"if !ok { goto overflow }"
)
d
.
emit
(
"data = data[n:]"
)
d
.
emit
(
"data = data[n:]"
)
d
.
emit
(
"%v += n"
,
d
.
var_
(
"nread"
))
d
.
emit
(
"}"
)
d
.
emit
(
"}"
)
// insert overflow checkpoint after custom decoder so that overflow
// insert overflow checkpoint after custom decoder so that overflow
...
@@ -1118,7 +1120,8 @@ func (d *decoder) genCustom(path string) {
...
@@ -1118,7 +1120,8 @@ func (d *decoder) genCustom(path string) {
// obj is object that uses this type in source program (so in case of an error
// obj is object that uses this type in source program (so in case of an error
// we can point to source location for where it happened)
// we can point to source location for where it happened)
func
codegenType
(
path
string
,
typ
types
.
Type
,
obj
types
.
Object
,
codegen
CodeGenerator
)
{
func
codegenType
(
path
string
,
typ
types
.
Type
,
obj
types
.
Object
,
codegen
CodeGenerator
)
{
if
types
.
Implements
(
typ
,
neo_customCodec
)
{
if
types
.
Implements
(
typ
,
neo_customCodec
)
||
types
.
Implements
(
types
.
NewPointer
(
typ
),
neo_customCodec
)
{
codegen
.
genCustom
(
path
)
codegen
.
genCustom
(
path
)
return
return
}
}
...
...
go/neo/zproto-marshal.go
View file @
2ed6cfd8
This diff is collapsed.
Click to expand it.
go/neo/zproto-str.go
View file @
2ed6cfd8
// Code generated by "stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState proto.go"; DO NOT EDIT.
// Code generated by "stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState proto.go
packed.go
"; DO NOT EDIT.
package
neo
package
neo
...
...
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