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
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 @@
//
// See COPYING file for full licensing terms.
// 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
// 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 {
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
)
if
!
ok
{
return
0
,
false
...
...
@@ -1025,7 +1025,7 @@ type Truncate struct {
type
customCodec
interface
{
neoEncodedLen
()
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
{
...
...
@@ -1074,7 +1074,7 @@ func string_neoEncode(s string, data []byte) int {
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
{
return
0
,
false
}
...
...
@@ -1085,5 +1085,5 @@ func string_neoDecode(sp *string, data []byte) (nread int, ok bool) {
}
*
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) {
func
(
e
*
encoder
)
genCustom
(
path
string
)
{
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
(
"}"
)
e
.
n
=
0
}
func
(
d
*
decoder
)
genCustom
(
path
string
)
{
d
.
resetPos
()
// make sure we check for overflow previous-code before proceeding to custom decoder.
d
.
overflowCheck
()
d
.
resetPos
()
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
(
"data = data[n:]"
)
d
.
emit
(
"%v += n"
,
d
.
var_
(
"nread"
))
d
.
emit
(
"}"
)
// insert overflow checkpoint after custom decoder so that overflow
...
...
@@ -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
// we can point to source location for where it happened)
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
)
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
...
...
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