Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Levin Zimmermann
neoppod
Commits
27467089
Commit
27467089
authored
Jan 19, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
653a4785
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
t/neo/protogen.go
t/neo/protogen.go
+20
-19
No files found.
t/neo/protogen.go
View file @
27467089
...
...
@@ -95,6 +95,10 @@ import (
continue
}
//fmt.Println(gendecl)
//ast.Print(fset, gendecl)
//continue
for
_
,
spec
:=
range
gendecl
.
Specs
{
typespec
:=
spec
.
(
*
ast
.
TypeSpec
)
// must be because tok = TYPE
typename
:=
typespec
.
Name
.
Name
...
...
@@ -106,9 +110,9 @@ import (
case
*
ast
.
StructType
:
//fmt.Printf("\n%s:\n", typename)
//fmt.Println(typespec)
//ast.Print(fset, typespec)
//continue
//fmt.Println(t)
//ast.Print(fset, t)
fmt
.
Fprintf
(
&
buf
,
"// %d. %s
\n\n
"
,
pktCode
,
typename
)
...
...
@@ -118,9 +122,6 @@ import (
pktCode
++
}
}
//fmt.Println(gdecl)
//ast.Print(fset, gdecl)
}
// format & emit bufferred code
...
...
@@ -136,28 +137,28 @@ import (
}
// info about
wire decode/encode of a basic
type
// info about
encode/decode of a basic fixed-size
type
type
basicCodec
struct
{
wireSize
int
decode
string
encode
string
decode
string
}
var
basicTypes
=
map
[
types
.
BasicKind
]
basicCodec
{
// decode: %v will be `data[n:]` (and made sure data has more enough bytes to read)
// encode: %v %v will be `data[n:]`, value
types
.
Bool
:
{
1
,
"
byte2bool((%v)[0])"
,
"(%v)[0] = bool2byte(%v
)"
},
types
.
Int8
:
{
1
,
"
int8((%v)[0])"
,
"(%v)[0] = uint8(%v)"
},
types
.
Int16
:
{
2
,
"
int16(binary.BigEndian.Uint16(%v))"
,
"binary.BigEndian.PutUint16(u
int16(%v))"
},
types
.
Int32
:
{
4
,
"
int32(binary.BigEndian.Uint32(%v))"
,
"binary.BigEndian.PutUint32(u
int32(%v))"
},
types
.
Int64
:
{
8
,
"
int64(binary.BigEndian.Uint64(%v))"
,
"binary.BigEndian.PutUint64(u
int64(%v))"
},
types
.
Uint8
:
{
1
,
"(%v)[0]
"
,
"(%v)[0] = %v
"
},
types
.
Uint16
:
{
2
,
"binary.BigEndian.
Uint16(%v)"
,
"binary.BigEndian.PutUint16(%v,
%v)"
},
types
.
Uint32
:
{
4
,
"binary.BigEndian.
Uint32(%v)"
,
"binary.BigEndian.PutUint32(%v,
%v)"
},
types
.
Uint64
:
{
8
,
"binary.BigEndian.
Uint64(%v)"
,
"binary.BigEndian.PutUint64(%v,
%v)"
},
types
.
Float64
:
{
8
,
"float64_NEO
Decode(%v)"
,
"float64_NEOEncode(%v,
%v)"
},
types
.
Bool
:
{
1
,
"
(%v)[0] = bool2byte(%v)"
,
"byte2bool((%v)[0]
)"
},
types
.
Int8
:
{
1
,
"
(%v)[0] = uint8(%v)"
,
"int8((%v)[0])"
},
types
.
Int16
:
{
2
,
"
binary.BigEndian.PutUint16(uint16(%v))"
,
"int16(binary.BigEndian.U
int16(%v))"
},
types
.
Int32
:
{
4
,
"
binary.BigEndian.PutUint32(uint32(%v))"
,
"int32(binary.BigEndian.U
int32(%v))"
},
types
.
Int64
:
{
8
,
"
binary.BigEndian.PutUint64(uint64(%v))"
,
"int64(binary.BigEndian.U
int64(%v))"
},
types
.
Uint8
:
{
1
,
"(%v)[0]
= %v"
,
"(%v)[0]
"
},
types
.
Uint16
:
{
2
,
"binary.BigEndian.
PutUint16(%v, %v)"
,
"binary.BigEndian.Uint16(
%v)"
},
types
.
Uint32
:
{
4
,
"binary.BigEndian.
PutUint32(%v, %v)"
,
"binary.BigEndian.Uint32(
%v)"
},
types
.
Uint64
:
{
8
,
"binary.BigEndian.
PutUint64(%v, %v)"
,
"binary.BigEndian.Uint64(
%v)"
},
types
.
Float64
:
{
8
,
"float64_NEO
Encode(%v, %v)"
,
"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