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
39ab6e94
Commit
39ab6e94
authored
Dec 28, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
77f2d94f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
241 additions
and
222 deletions
+241
-222
t/neo/marshal.go
t/neo/marshal.go
+220
-214
t/neo/pkt.go
t/neo/pkt.go
+7
-0
t/neo/proto.go
t/neo/proto.go
+1
-1
t/neo/protogen.go
t/neo/protogen.go
+13
-7
No files found.
t/neo/marshal.go
View file @
39ab6e94
This diff is collapsed.
Click to expand it.
t/neo/pkt.go
View file @
39ab6e94
...
...
@@ -25,6 +25,13 @@ type PktBuf struct {
Data
[]
byte
// whole packet data including all headers XXX -> Buf ?
}
// XXX naming -> PktHeader ?
type
PktHead
struct
{
ConnId
be32
// NOTE is .msgid in py
MsgCode
be16
Len
be32
// whole packet length (including header)
}
// Get pointer to packet header
func
(
pkt
*
PktBuf
)
Header
()
*
PktHead
{
// XXX check len(Data) < PktHead ? -> no, Data has to be allocated with cap >= PktHeadLen
...
...
t/neo/proto.go
View file @
39ab6e94
...
...
@@ -14,7 +14,7 @@ const (
PROTOCOL_VERSION
=
8
MIN_PACKET_SIZE
=
10
// XXX unsafe.Sizeof(PktHead{}) give _typed_ constant (uintptr)
PktHeadLen
=
MIN_PACKET_SIZE
// TODO link this to PktHead.Encode/Decode size ?
PktHeadLen
=
MIN_PACKET_SIZE
// TODO link this to PktHead.Encode/Decode size ?
XXX -> pkt.go ?
MAX_PACKET_SIZE
=
0x4000000
RESPONSE_MASK
=
0x8000
...
...
t/neo/protogen.go
View file @
39ab6e94
...
...
@@ -80,7 +80,13 @@ func main() {
f
:=
fv
[
0
]
// proto.go comes first
buf
:=
Buffer
{}
buf
.
WriteString
(
"package neo
\n
"
)
buf
.
WriteString
(
`// DO NOT EDIT - AUTOGENERATED (by protogen.go)
package neo
import (
"encoding/binary"
)
`
)
for
_
,
decl
:=
range
f
.
Decls
{
// we look for types (which can be only under GenDecl)
...
...
@@ -145,14 +151,14 @@ var basicDecode = map[types.BasicKind]basicXXX {
// %v will be `data[n:n+wireSize]` XXX or `data[n:]` ?
types
.
Bool
:
{
1
,
"bool((%v)[0])"
},
types
.
Int8
:
{
1
,
"int8((%v)[0])"
},
types
.
Int16
:
{
2
,
"int16(BigEndian.Uint16(%v))"
},
types
.
Int32
:
{
4
,
"int32(BigEndian.Uint32(%v))"
},
types
.
Int64
:
{
8
,
"int64(BigEndian.Uint64(%v))"
},
types
.
Int16
:
{
2
,
"int16(
binary.
BigEndian.Uint16(%v))"
},
types
.
Int32
:
{
4
,
"int32(
binary.
BigEndian.Uint32(%v))"
},
types
.
Int64
:
{
8
,
"int64(
binary.
BigEndian.Uint64(%v))"
},
types
.
Uint8
:
{
1
,
"(%v)[0]"
},
types
.
Uint16
:
{
2
,
"BigEndian.Uint16(%v)"
},
types
.
Uint32
:
{
4
,
"BigEndian.Uint32(%v)"
},
types
.
Uint64
:
{
8
,
"BigEndian.Uint64(%v)"
},
types
.
Uint16
:
{
2
,
"
binary.
BigEndian.Uint16(%v)"
},
types
.
Uint32
:
{
4
,
"
binary.
BigEndian.Uint32(%v)"
},
types
.
Uint64
:
{
8
,
"
binary.
BigEndian.Uint64(%v)"
},
types
.
Float64
:
{
8
,
"float64_NEODecode(%v)"
},
...
...
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