Commit 39ab6e94 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 77f2d94f
This diff is collapsed.
...@@ -25,6 +25,13 @@ type PktBuf struct { ...@@ -25,6 +25,13 @@ type PktBuf struct {
Data []byte // whole packet data including all headers XXX -> Buf ? 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 // Get pointer to packet header
func (pkt *PktBuf) Header() *PktHead { func (pkt *PktBuf) Header() *PktHead {
// XXX check len(Data) < PktHead ? -> no, Data has to be allocated with cap >= PktHeadLen // XXX check len(Data) < PktHead ? -> no, Data has to be allocated with cap >= PktHeadLen
......
...@@ -14,7 +14,7 @@ const ( ...@@ -14,7 +14,7 @@ const (
PROTOCOL_VERSION = 8 PROTOCOL_VERSION = 8
MIN_PACKET_SIZE = 10 // XXX unsafe.Sizeof(PktHead{}) give _typed_ constant (uintptr) 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 MAX_PACKET_SIZE = 0x4000000
RESPONSE_MASK = 0x8000 RESPONSE_MASK = 0x8000
......
...@@ -80,7 +80,13 @@ func main() { ...@@ -80,7 +80,13 @@ func main() {
f := fv[0] // proto.go comes first f := fv[0] // proto.go comes first
buf := Buffer{} 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 { for _, decl := range f.Decls {
// we look for types (which can be only under GenDecl) // we look for types (which can be only under GenDecl)
...@@ -145,14 +151,14 @@ var basicDecode = map[types.BasicKind]basicXXX { ...@@ -145,14 +151,14 @@ var basicDecode = map[types.BasicKind]basicXXX {
// %v will be `data[n:n+wireSize]` XXX or `data[n:]` ? // %v will be `data[n:n+wireSize]` XXX or `data[n:]` ?
types.Bool: {1, "bool((%v)[0])"}, types.Bool: {1, "bool((%v)[0])"},
types.Int8: {1, "int8((%v)[0])"}, types.Int8: {1, "int8((%v)[0])"},
types.Int16: {2, "int16(BigEndian.Uint16(%v))"}, types.Int16: {2, "int16(binary.BigEndian.Uint16(%v))"},
types.Int32: {4, "int32(BigEndian.Uint32(%v))"}, types.Int32: {4, "int32(binary.BigEndian.Uint32(%v))"},
types.Int64: {8, "int64(BigEndian.Uint64(%v))"}, types.Int64: {8, "int64(binary.BigEndian.Uint64(%v))"},
types.Uint8: {1, "(%v)[0]"}, types.Uint8: {1, "(%v)[0]"},
types.Uint16: {2, "BigEndian.Uint16(%v)"}, types.Uint16: {2, "binary.BigEndian.Uint16(%v)"},
types.Uint32: {4, "BigEndian.Uint32(%v)"}, types.Uint32: {4, "binary.BigEndian.Uint32(%v)"},
types.Uint64: {8, "BigEndian.Uint64(%v)"}, types.Uint64: {8, "binary.BigEndian.Uint64(%v)"},
types.Float64: {8, "float64_NEODecode(%v)"}, types.Float64: {8, "float64_NEODecode(%v)"},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment