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
8cad1d77
Commit
8cad1d77
authored
Jan 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
63dfa906
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
260 additions
and
116 deletions
+260
-116
t/neo/marshal.go
t/neo/marshal.go
+188
-83
t/neo/proto.go
t/neo/proto.go
+7
-0
t/neo/protogen.go
t/neo/protogen.go
+65
-33
No files found.
t/neo/marshal.go
View file @
8cad1d77
...
@@ -192,7 +192,112 @@ overflow:
...
@@ -192,7 +192,112 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4. Notify
// 4. XXXTest
func
(
p
*
XXXTest
)
NEOEncodedLen
()
int
{
var
size0
int
for
i
:=
0
;
i
<
len
(
p
.
Zzz
);
i
++
{
a
:=
&
p
.
Zzz
[
i
]
var
size1
int
for
i
:=
0
;
i
<
len
((
*
a
));
i
++
{
a
:=
&
(
*
a
)[
i
]
size1
+=
4
+
len
((
*
a
))
}
size0
+=
4
+
size1
}
return
12
+
size0
}
func
(
p
*
XXXTest
)
NEOEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
p
.
qqq
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
p
.
aaa
)
{
l
:=
uint32
(
len
(
p
.
Zzz
))
binary
.
BigEndian
.
PutUint32
(
data
[
8
:
],
l
)
data
=
data
[
12
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
Zzz
[
i
]
{
l
:=
uint32
(
len
((
*
a
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
(
*
a
)[
i
]
{
l
:=
uint32
(
len
((
*
a
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
l
)
data
=
data
[
4
:
]
copy
(
data
,
(
*
a
))
data
=
data
[
l
:
]
}
data
=
data
[
0
:
]
}
}
data
=
data
[
0
:
]
}
}
}
func
(
p
*
XXXTest
)
NEODecode
(
data
[]
byte
)
(
int
,
error
)
{
var
nread0
uint32
if
len
(
data
)
<
4
{
goto
overflow
}
p
.
qqq
=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
if
len
(
data
)
<
8
{
goto
overflow
}
p
.
aaa
=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
{
if
len
(
data
)
<
12
{
goto
overflow
}
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
8
:
])
data
=
data
[
12
:
]
nread0
+=
12
p
.
Zzz
=
make
([][]
string
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
Zzz
[
i
]
{
if
len
(
data
)
<
4
{
goto
overflow
}
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
data
=
data
[
4
:
]
nread0
+=
4
(
*
a
)
=
make
([]
string
,
l
)
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
(
*
a
)[
i
]
{
if
len
(
data
)
<
4
{
goto
overflow
}
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])
data
=
data
[
4
:
]
if
uint32
(
len
(
data
))
<
l
{
goto
overflow
}
(
*
a
)
=
string
(
data
[
:
l
])
data
=
data
[
l
:
]
nread0
+=
4
+
l
}
data
=
data
[
0
:
]
nread0
+=
0
}
}
data
=
data
[
0
:
]
nread0
+=
0
}
}
return
0
+
int
(
nread0
),
nil
overflow
:
return
0
,
ErrDecodeOverflow
}
// 5. Notify
func
(
p
*
Notify
)
NEOEncodedLen
()
int
{
func
(
p
*
Notify
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
Message
)
return
4
+
len
(
p
.
Message
)
...
@@ -229,7 +334,7 @@ overflow:
...
@@ -229,7 +334,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
5
. Error
//
6
. Error
func
(
p
*
Error
)
NEOEncodedLen
()
int
{
func
(
p
*
Error
)
NEOEncodedLen
()
int
{
return
8
+
len
(
p
.
Message
)
return
8
+
len
(
p
.
Message
)
...
@@ -271,7 +376,7 @@ overflow:
...
@@ -271,7 +376,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
6
. Ping
//
7
. Ping
func
(
p
*
Ping
)
NEOEncodedLen
()
int
{
func
(
p
*
Ping
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -284,7 +389,7 @@ func (p *Ping) NEODecode(data []byte) (int, error) {
...
@@ -284,7 +389,7 @@ func (p *Ping) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
//
7
. CloseClient
//
8
. CloseClient
func
(
p
*
CloseClient
)
NEOEncodedLen
()
int
{
func
(
p
*
CloseClient
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -297,7 +402,7 @@ func (p *CloseClient) NEODecode(data []byte) (int, error) {
...
@@ -297,7 +402,7 @@ func (p *CloseClient) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
//
8
. RequestIdentification
//
9
. RequestIdentification
func
(
p
*
RequestIdentification
)
NEOEncodedLen
()
int
{
func
(
p
*
RequestIdentification
)
NEOEncodedLen
()
int
{
return
30
+
len
(
p
.
Address
.
Host
)
+
len
(
p
.
Name
)
return
30
+
len
(
p
.
Address
.
Host
)
+
len
(
p
.
Name
)
...
@@ -379,7 +484,7 @@ overflow:
...
@@ -379,7 +484,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
9
. AcceptIdentification
//
10
. AcceptIdentification
func
(
p
*
AcceptIdentification
)
NEOEncodedLen
()
int
{
func
(
p
*
AcceptIdentification
)
NEOEncodedLen
()
int
{
var
size0
int
var
size0
int
...
@@ -508,7 +613,7 @@ overflow:
...
@@ -508,7 +613,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 1
0
. PrimaryMaster
// 1
1
. PrimaryMaster
func
(
p
*
PrimaryMaster
)
NEOEncodedLen
()
int
{
func
(
p
*
PrimaryMaster
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -521,7 +626,7 @@ func (p *PrimaryMaster) NEODecode(data []byte) (int, error) {
...
@@ -521,7 +626,7 @@ func (p *PrimaryMaster) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 1
1
. AnswerPrimary
// 1
2
. AnswerPrimary
func
(
p
*
AnswerPrimary
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerPrimary
)
NEOEncodedLen
()
int
{
return
4
return
4
...
@@ -542,7 +647,7 @@ overflow:
...
@@ -542,7 +647,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 1
2
. AnnouncePrimary
// 1
3
. AnnouncePrimary
func
(
p
*
AnnouncePrimary
)
NEOEncodedLen
()
int
{
func
(
p
*
AnnouncePrimary
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -555,7 +660,7 @@ func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) {
...
@@ -555,7 +660,7 @@ func (p *AnnouncePrimary) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 1
3
. ReelectPrimary
// 1
4
. ReelectPrimary
func
(
p
*
ReelectPrimary
)
NEOEncodedLen
()
int
{
func
(
p
*
ReelectPrimary
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -568,7 +673,7 @@ func (p *ReelectPrimary) NEODecode(data []byte) (int, error) {
...
@@ -568,7 +673,7 @@ func (p *ReelectPrimary) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 1
4
. Recovery
// 1
5
. Recovery
func
(
p
*
Recovery
)
NEOEncodedLen
()
int
{
func
(
p
*
Recovery
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -581,7 +686,7 @@ func (p *Recovery) NEODecode(data []byte) (int, error) {
...
@@ -581,7 +686,7 @@ func (p *Recovery) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 1
5
. AnswerRecovery
// 1
6
. AnswerRecovery
func
(
p
*
AnswerRecovery
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerRecovery
)
NEOEncodedLen
()
int
{
return
24
return
24
...
@@ -612,7 +717,7 @@ overflow:
...
@@ -612,7 +717,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 1
6
. LastIDs
// 1
7
. LastIDs
func
(
p
*
LastIDs
)
NEOEncodedLen
()
int
{
func
(
p
*
LastIDs
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -625,7 +730,7 @@ func (p *LastIDs) NEODecode(data []byte) (int, error) {
...
@@ -625,7 +730,7 @@ func (p *LastIDs) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 1
7
. AnswerLastIDs
// 1
8
. AnswerLastIDs
func
(
p
*
AnswerLastIDs
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerLastIDs
)
NEOEncodedLen
()
int
{
return
16
return
16
...
@@ -651,7 +756,7 @@ overflow:
...
@@ -651,7 +756,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 1
8
. PartitionTable
// 1
9
. PartitionTable
func
(
p
*
PartitionTable
)
NEOEncodedLen
()
int
{
func
(
p
*
PartitionTable
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -664,7 +769,7 @@ func (p *PartitionTable) NEODecode(data []byte) (int, error) {
...
@@ -664,7 +769,7 @@ func (p *PartitionTable) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
//
19
. AnswerPartitionTable
//
20
. AnswerPartitionTable
func
(
p
*
AnswerPartitionTable
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerPartitionTable
)
NEOEncodedLen
()
int
{
var
size0
int
var
size0
int
...
@@ -753,7 +858,7 @@ overflow:
...
@@ -753,7 +858,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 2
0
. NotifyPartitionTable
// 2
1
. NotifyPartitionTable
func
(
p
*
NotifyPartitionTable
)
NEOEncodedLen
()
int
{
func
(
p
*
NotifyPartitionTable
)
NEOEncodedLen
()
int
{
var
size0
int
var
size0
int
...
@@ -842,7 +947,7 @@ overflow:
...
@@ -842,7 +947,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 2
1
. PartitionChanges
// 2
2
. PartitionChanges
func
(
p
*
PartitionChanges
)
NEOEncodedLen
()
int
{
func
(
p
*
PartitionChanges
)
NEOEncodedLen
()
int
{
return
12
+
len
(
p
.
CellList
)
*
12
return
12
+
len
(
p
.
CellList
)
*
12
...
@@ -906,7 +1011,7 @@ overflow:
...
@@ -906,7 +1011,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 2
2
. StartOperation
// 2
3
. StartOperation
func
(
p
*
StartOperation
)
NEOEncodedLen
()
int
{
func
(
p
*
StartOperation
)
NEOEncodedLen
()
int
{
return
1
return
1
...
@@ -927,7 +1032,7 @@ overflow:
...
@@ -927,7 +1032,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 2
3
. StopOperation
// 2
4
. StopOperation
func
(
p
*
StopOperation
)
NEOEncodedLen
()
int
{
func
(
p
*
StopOperation
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -940,7 +1045,7 @@ func (p *StopOperation) NEODecode(data []byte) (int, error) {
...
@@ -940,7 +1045,7 @@ func (p *StopOperation) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 2
4
. UnfinishedTransactions
// 2
5
. UnfinishedTransactions
func
(
p
*
UnfinishedTransactions
)
NEOEncodedLen
()
int
{
func
(
p
*
UnfinishedTransactions
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -953,7 +1058,7 @@ func (p *UnfinishedTransactions) NEODecode(data []byte) (int, error) {
...
@@ -953,7 +1058,7 @@ func (p *UnfinishedTransactions) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 2
5
. AnswerUnfinishedTransactions
// 2
6
. AnswerUnfinishedTransactions
func
(
p
*
AnswerUnfinishedTransactions
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerUnfinishedTransactions
)
NEOEncodedLen
()
int
{
return
12
+
len
(
p
.
TidList
)
*
8
return
12
+
len
(
p
.
TidList
)
*
8
...
@@ -1003,7 +1108,7 @@ overflow:
...
@@ -1003,7 +1108,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 2
6
. LockedTransactions
// 2
7
. LockedTransactions
func
(
p
*
LockedTransactions
)
NEOEncodedLen
()
int
{
func
(
p
*
LockedTransactions
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -1016,7 +1121,7 @@ func (p *LockedTransactions) NEODecode(data []byte) (int, error) {
...
@@ -1016,7 +1121,7 @@ func (p *LockedTransactions) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 2
7
. AnswerLockedTransactions
// 2
8
. AnswerLockedTransactions
func
(
p
*
AnswerLockedTransactions
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerLockedTransactions
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
TidDict
)
*
16
return
4
+
len
(
p
.
TidDict
)
*
16
...
@@ -1070,7 +1175,7 @@ overflow:
...
@@ -1070,7 +1175,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 2
8
. FinalTID
// 2
9
. FinalTID
func
(
p
*
FinalTID
)
NEOEncodedLen
()
int
{
func
(
p
*
FinalTID
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1091,7 +1196,7 @@ overflow:
...
@@ -1091,7 +1196,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
29
. AnswerFinalTID
//
30
. AnswerFinalTID
func
(
p
*
AnswerFinalTID
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerFinalTID
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1112,7 +1217,7 @@ overflow:
...
@@ -1112,7 +1217,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
0
. ValidateTransaction
// 3
1
. ValidateTransaction
func
(
p
*
ValidateTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
ValidateTransaction
)
NEOEncodedLen
()
int
{
return
16
return
16
...
@@ -1138,7 +1243,7 @@ overflow:
...
@@ -1138,7 +1243,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
1
. BeginTransaction
// 3
2
. BeginTransaction
func
(
p
*
BeginTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
BeginTransaction
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1159,7 +1264,7 @@ overflow:
...
@@ -1159,7 +1264,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
2
. AnswerBeginTransaction
// 3
3
. AnswerBeginTransaction
func
(
p
*
AnswerBeginTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerBeginTransaction
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1180,7 +1285,7 @@ overflow:
...
@@ -1180,7 +1285,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
3
. FinishTransaction
// 3
4
. FinishTransaction
func
(
p
*
FinishTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
FinishTransaction
)
NEOEncodedLen
()
int
{
return
16
+
len
(
p
.
OIDList
)
*
8
+
len
(
p
.
CheckedList
)
*
8
return
16
+
len
(
p
.
OIDList
)
*
8
+
len
(
p
.
CheckedList
)
*
8
...
@@ -1258,7 +1363,7 @@ overflow:
...
@@ -1258,7 +1363,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
4
. AnswerFinishTransaction
// 3
5
. AnswerFinishTransaction
func
(
p
*
AnswerFinishTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerFinishTransaction
)
NEOEncodedLen
()
int
{
return
16
return
16
...
@@ -1284,7 +1389,7 @@ overflow:
...
@@ -1284,7 +1389,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
5
. NotifyTransactionFinished
// 3
6
. NotifyTransactionFinished
func
(
p
*
NotifyTransactionFinished
)
NEOEncodedLen
()
int
{
func
(
p
*
NotifyTransactionFinished
)
NEOEncodedLen
()
int
{
return
16
return
16
...
@@ -1310,7 +1415,7 @@ overflow:
...
@@ -1310,7 +1415,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
6
. LockInformation
// 3
7
. LockInformation
func
(
p
*
LockInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
LockInformation
)
NEOEncodedLen
()
int
{
return
16
return
16
...
@@ -1336,7 +1441,7 @@ overflow:
...
@@ -1336,7 +1441,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
7
. AnswerLockInformation
// 3
8
. AnswerLockInformation
func
(
p
*
AnswerLockInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerLockInformation
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1357,7 +1462,7 @@ overflow:
...
@@ -1357,7 +1462,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 3
8
. InvalidateObjects
// 3
9
. InvalidateObjects
func
(
p
*
InvalidateObjects
)
NEOEncodedLen
()
int
{
func
(
p
*
InvalidateObjects
)
NEOEncodedLen
()
int
{
return
12
+
len
(
p
.
OidList
)
*
8
return
12
+
len
(
p
.
OidList
)
*
8
...
@@ -1407,7 +1512,7 @@ overflow:
...
@@ -1407,7 +1512,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
39
. UnlockInformation
//
40
. UnlockInformation
func
(
p
*
UnlockInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
UnlockInformation
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1428,7 +1533,7 @@ overflow:
...
@@ -1428,7 +1533,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
0
. GenerateOIDs
// 4
1
. GenerateOIDs
func
(
p
*
GenerateOIDs
)
NEOEncodedLen
()
int
{
func
(
p
*
GenerateOIDs
)
NEOEncodedLen
()
int
{
return
4
return
4
...
@@ -1449,7 +1554,7 @@ overflow:
...
@@ -1449,7 +1554,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
1
. AnswerGenerateOIDs
// 4
2
. AnswerGenerateOIDs
func
(
p
*
AnswerGenerateOIDs
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerGenerateOIDs
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
OidList
)
*
8
return
4
+
len
(
p
.
OidList
)
*
8
...
@@ -1494,7 +1599,7 @@ overflow:
...
@@ -1494,7 +1599,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
2
. StoreObject
// 4
3
. StoreObject
func
(
p
*
StoreObject
)
NEOEncodedLen
()
int
{
func
(
p
*
StoreObject
)
NEOEncodedLen
()
int
{
return
58
+
len
(
p
.
Data
)
*
1
return
58
+
len
(
p
.
Data
)
*
1
...
@@ -1669,7 +1774,7 @@ overflow:
...
@@ -1669,7 +1774,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
3
. AnswerStoreObject
// 4
4
. AnswerStoreObject
func
(
p
*
AnswerStoreObject
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerStoreObject
)
NEOEncodedLen
()
int
{
return
17
return
17
...
@@ -1700,7 +1805,7 @@ overflow:
...
@@ -1700,7 +1805,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
4
. AbortTransaction
// 4
5
. AbortTransaction
func
(
p
*
AbortTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
AbortTransaction
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1721,7 +1826,7 @@ overflow:
...
@@ -1721,7 +1826,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
5
. StoreTransaction
// 4
6
. StoreTransaction
func
(
p
*
StoreTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
StoreTransaction
)
NEOEncodedLen
()
int
{
return
24
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
return
24
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
...
@@ -1831,7 +1936,7 @@ overflow:
...
@@ -1831,7 +1936,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
6
. VoteTransaction
// 4
7
. VoteTransaction
func
(
p
*
VoteTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
VoteTransaction
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -1852,7 +1957,7 @@ overflow:
...
@@ -1852,7 +1957,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
7
. GetObject
// 4
8
. GetObject
func
(
p
*
GetObject
)
NEOEncodedLen
()
int
{
func
(
p
*
GetObject
)
NEOEncodedLen
()
int
{
return
24
return
24
...
@@ -1883,7 +1988,7 @@ overflow:
...
@@ -1883,7 +1988,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 4
8
. AnswerGetObject
// 4
9
. AnswerGetObject
func
(
p
*
AnswerGetObject
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerGetObject
)
NEOEncodedLen
()
int
{
return
57
+
len
(
p
.
Data
)
*
1
return
57
+
len
(
p
.
Data
)
*
1
...
@@ -2053,7 +2158,7 @@ overflow:
...
@@ -2053,7 +2158,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
49
. TIDList
//
50
. TIDList
func
(
p
*
TIDList
)
NEOEncodedLen
()
int
{
func
(
p
*
TIDList
)
NEOEncodedLen
()
int
{
return
20
return
20
...
@@ -2084,7 +2189,7 @@ overflow:
...
@@ -2084,7 +2189,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
0
. AnswerTIDList
// 5
1
. AnswerTIDList
func
(
p
*
AnswerTIDList
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerTIDList
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
TIDList
)
*
8
return
4
+
len
(
p
.
TIDList
)
*
8
...
@@ -2129,7 +2234,7 @@ overflow:
...
@@ -2129,7 +2234,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
1
. TIDListFrom
// 5
2
. TIDListFrom
func
(
p
*
TIDListFrom
)
NEOEncodedLen
()
int
{
func
(
p
*
TIDListFrom
)
NEOEncodedLen
()
int
{
return
24
return
24
...
@@ -2165,7 +2270,7 @@ overflow:
...
@@ -2165,7 +2270,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
2
. AnswerTIDListFrom
// 5
3
. AnswerTIDListFrom
func
(
p
*
AnswerTIDListFrom
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerTIDListFrom
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
TidList
)
*
8
return
4
+
len
(
p
.
TidList
)
*
8
...
@@ -2210,7 +2315,7 @@ overflow:
...
@@ -2210,7 +2315,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
3
. TransactionInformation
// 5
4
. TransactionInformation
func
(
p
*
TransactionInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
TransactionInformation
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -2231,7 +2336,7 @@ overflow:
...
@@ -2231,7 +2336,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
4
. AnswerTransactionInformation
// 5
5
. AnswerTransactionInformation
func
(
p
*
AnswerTransactionInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerTransactionInformation
)
NEOEncodedLen
()
int
{
return
25
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
return
25
+
len
(
p
.
User
)
+
len
(
p
.
Description
)
+
len
(
p
.
Extension
)
+
len
(
p
.
OidList
)
*
8
...
@@ -2346,7 +2451,7 @@ overflow:
...
@@ -2346,7 +2451,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
5
. ObjectHistory
// 5
6
. ObjectHistory
func
(
p
*
ObjectHistory
)
NEOEncodedLen
()
int
{
func
(
p
*
ObjectHistory
)
NEOEncodedLen
()
int
{
return
24
return
24
...
@@ -2377,7 +2482,7 @@ overflow:
...
@@ -2377,7 +2482,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
6
. AnswerObjectHistory
// 5
7
. AnswerObjectHistory
func
(
p
*
AnswerObjectHistory
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerObjectHistory
)
NEOEncodedLen
()
int
{
return
12
+
len
(
p
.
HistoryList
)
*
12
return
12
+
len
(
p
.
HistoryList
)
*
12
...
@@ -2435,7 +2540,7 @@ overflow:
...
@@ -2435,7 +2540,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
7
. PartitionList
// 5
8
. PartitionList
func
(
p
*
PartitionList
)
NEOEncodedLen
()
int
{
func
(
p
*
PartitionList
)
NEOEncodedLen
()
int
{
return
12
return
12
...
@@ -2466,7 +2571,7 @@ overflow:
...
@@ -2466,7 +2571,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 5
8
. AnswerPartitionList
// 5
9
. AnswerPartitionList
func
(
p
*
AnswerPartitionList
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerPartitionList
)
NEOEncodedLen
()
int
{
var
size0
int
var
size0
int
...
@@ -2555,7 +2660,7 @@ overflow:
...
@@ -2555,7 +2660,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
59
. X_NodeList
//
60
. X_NodeList
func
(
p
*
X_NodeList
)
NEOEncodedLen
()
int
{
func
(
p
*
X_NodeList
)
NEOEncodedLen
()
int
{
return
4
return
4
...
@@ -2576,7 +2681,7 @@ overflow:
...
@@ -2576,7 +2681,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
0
. AnswerNodeList
// 6
1
. AnswerNodeList
func
(
p
*
AnswerNodeList
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerNodeList
)
NEOEncodedLen
()
int
{
var
size0
int
var
size0
int
...
@@ -2667,7 +2772,7 @@ overflow:
...
@@ -2667,7 +2772,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
1
. SetNodeState
// 6
2
. SetNodeState
func
(
p
*
SetNodeState
)
NEOEncodedLen
()
int
{
func
(
p
*
SetNodeState
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -2693,7 +2798,7 @@ overflow:
...
@@ -2693,7 +2798,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
2
. AddPendingNodes
// 6
3
. AddPendingNodes
func
(
p
*
AddPendingNodes
)
NEOEncodedLen
()
int
{
func
(
p
*
AddPendingNodes
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
UUIDList
)
*
4
return
4
+
len
(
p
.
UUIDList
)
*
4
...
@@ -2738,7 +2843,7 @@ overflow:
...
@@ -2738,7 +2843,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
3
. TweakPartitionTable
// 6
4
. TweakPartitionTable
func
(
p
*
TweakPartitionTable
)
NEOEncodedLen
()
int
{
func
(
p
*
TweakPartitionTable
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
UUIDList
)
*
4
return
4
+
len
(
p
.
UUIDList
)
*
4
...
@@ -2783,7 +2888,7 @@ overflow:
...
@@ -2783,7 +2888,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
4
. NotifyNodeInformation
// 6
5
. NotifyNodeInformation
func
(
p
*
NotifyNodeInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
NotifyNodeInformation
)
NEOEncodedLen
()
int
{
var
size0
int
var
size0
int
...
@@ -2874,7 +2979,7 @@ overflow:
...
@@ -2874,7 +2979,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
5
. NodeInformation
// 6
6
. NodeInformation
func
(
p
*
NodeInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
NodeInformation
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -2887,7 +2992,7 @@ func (p *NodeInformation) NEODecode(data []byte) (int, error) {
...
@@ -2887,7 +2992,7 @@ func (p *NodeInformation) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 6
6
. SetClusterState
// 6
7
. SetClusterState
func
(
p
*
SetClusterState
)
NEOEncodedLen
()
int
{
func
(
p
*
SetClusterState
)
NEOEncodedLen
()
int
{
return
4
return
4
...
@@ -2908,7 +3013,7 @@ overflow:
...
@@ -2908,7 +3013,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
7
. ClusterInformation
// 6
8
. ClusterInformation
func
(
p
*
ClusterInformation
)
NEOEncodedLen
()
int
{
func
(
p
*
ClusterInformation
)
NEOEncodedLen
()
int
{
return
4
return
4
...
@@ -2929,7 +3034,7 @@ overflow:
...
@@ -2929,7 +3034,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 6
8
. X_ClusterState
// 6
9
. X_ClusterState
func
(
p
*
X_ClusterState
)
NEOEncodedLen
()
int
{
func
(
p
*
X_ClusterState
)
NEOEncodedLen
()
int
{
return
4
return
4
...
@@ -2950,7 +3055,7 @@ overflow:
...
@@ -2950,7 +3055,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
69
. ObjectUndoSerial
//
70
. ObjectUndoSerial
func
(
p
*
ObjectUndoSerial
)
NEOEncodedLen
()
int
{
func
(
p
*
ObjectUndoSerial
)
NEOEncodedLen
()
int
{
return
28
+
len
(
p
.
OidList
)
*
8
return
28
+
len
(
p
.
OidList
)
*
8
...
@@ -3010,7 +3115,7 @@ overflow:
...
@@ -3010,7 +3115,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
0
. AnswerObjectUndoSerial
// 7
1
. AnswerObjectUndoSerial
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerObjectUndoSerial
)
NEOEncodedLen
()
int
{
return
4
+
len
(
p
.
ObjectTIDDict
)
*
25
return
4
+
len
(
p
.
ObjectTIDDict
)
*
25
...
@@ -3084,7 +3189,7 @@ overflow:
...
@@ -3084,7 +3189,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
1
. HasLock
// 7
2
. HasLock
func
(
p
*
HasLock
)
NEOEncodedLen
()
int
{
func
(
p
*
HasLock
)
NEOEncodedLen
()
int
{
return
16
return
16
...
@@ -3110,7 +3215,7 @@ overflow:
...
@@ -3110,7 +3215,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
2
. AnswerHasLock
// 7
3
. AnswerHasLock
func
(
p
*
AnswerHasLock
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerHasLock
)
NEOEncodedLen
()
int
{
return
12
return
12
...
@@ -3136,7 +3241,7 @@ overflow:
...
@@ -3136,7 +3241,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
3
. CheckCurrentSerial
// 7
4
. CheckCurrentSerial
func
(
p
*
CheckCurrentSerial
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckCurrentSerial
)
NEOEncodedLen
()
int
{
return
24
return
24
...
@@ -3167,7 +3272,7 @@ overflow:
...
@@ -3167,7 +3272,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
4
. AnswerCheckCurrentSerial
// 7
5
. AnswerCheckCurrentSerial
func
(
p
*
AnswerCheckCurrentSerial
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerCheckCurrentSerial
)
NEOEncodedLen
()
int
{
return
17
return
17
...
@@ -3198,7 +3303,7 @@ overflow:
...
@@ -3198,7 +3303,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
5
. Pack
// 7
6
. Pack
func
(
p
*
Pack
)
NEOEncodedLen
()
int
{
func
(
p
*
Pack
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -3219,7 +3324,7 @@ overflow:
...
@@ -3219,7 +3324,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
6
. AnswerPack
// 7
7
. AnswerPack
func
(
p
*
AnswerPack
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerPack
)
NEOEncodedLen
()
int
{
return
1
return
1
...
@@ -3240,7 +3345,7 @@ overflow:
...
@@ -3240,7 +3345,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
7
. CheckReplicas
// 7
8
. CheckReplicas
func
(
p
*
CheckReplicas
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckReplicas
)
NEOEncodedLen
()
int
{
return
20
+
len
(
p
.
PartitionDict
)
*
8
return
20
+
len
(
p
.
PartitionDict
)
*
8
...
@@ -3304,7 +3409,7 @@ overflow:
...
@@ -3304,7 +3409,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 7
8
. CheckPartition
// 7
9
. CheckPartition
func
(
p
*
CheckPartition
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckPartition
)
NEOEncodedLen
()
int
{
return
30
+
len
(
p
.
Source
.
UpstreamName
)
+
len
(
p
.
Source
.
Address
.
Host
)
return
30
+
len
(
p
.
Source
.
UpstreamName
)
+
len
(
p
.
Source
.
Address
.
Host
)
...
@@ -3381,7 +3486,7 @@ overflow:
...
@@ -3381,7 +3486,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
//
79
. CheckTIDRange
//
80
. CheckTIDRange
func
(
p
*
CheckTIDRange
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckTIDRange
)
NEOEncodedLen
()
int
{
return
24
return
24
...
@@ -3417,7 +3522,7 @@ overflow:
...
@@ -3417,7 +3522,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 8
0
. AnswerCheckTIDRange
// 8
1
. AnswerCheckTIDRange
func
(
p
*
AnswerCheckTIDRange
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerCheckTIDRange
)
NEOEncodedLen
()
int
{
return
32
return
32
...
@@ -3543,7 +3648,7 @@ overflow:
...
@@ -3543,7 +3648,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 8
1
. CheckSerialRange
// 8
2
. CheckSerialRange
func
(
p
*
CheckSerialRange
)
NEOEncodedLen
()
int
{
func
(
p
*
CheckSerialRange
)
NEOEncodedLen
()
int
{
return
32
return
32
...
@@ -3584,7 +3689,7 @@ overflow:
...
@@ -3584,7 +3689,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 8
2
. AnswerCheckSerialRange
// 8
3
. AnswerCheckSerialRange
func
(
p
*
AnswerCheckSerialRange
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerCheckSerialRange
)
NEOEncodedLen
()
int
{
return
60
return
60
...
@@ -3815,7 +3920,7 @@ overflow:
...
@@ -3815,7 +3920,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 8
3
. PartitionCorrupted
// 8
4
. PartitionCorrupted
func
(
p
*
PartitionCorrupted
)
NEOEncodedLen
()
int
{
func
(
p
*
PartitionCorrupted
)
NEOEncodedLen
()
int
{
return
8
+
len
(
p
.
CellList
)
*
4
return
8
+
len
(
p
.
CellList
)
*
4
...
@@ -3865,7 +3970,7 @@ overflow:
...
@@ -3865,7 +3970,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 8
4
. LastTransaction
// 8
5
. LastTransaction
func
(
p
*
LastTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
LastTransaction
)
NEOEncodedLen
()
int
{
return
0
return
0
...
@@ -3878,7 +3983,7 @@ func (p *LastTransaction) NEODecode(data []byte) (int, error) {
...
@@ -3878,7 +3983,7 @@ func (p *LastTransaction) NEODecode(data []byte) (int, error) {
return
0
,
nil
return
0
,
nil
}
}
// 8
5
. AnswerLastTransaction
// 8
6
. AnswerLastTransaction
func
(
p
*
AnswerLastTransaction
)
NEOEncodedLen
()
int
{
func
(
p
*
AnswerLastTransaction
)
NEOEncodedLen
()
int
{
return
8
return
8
...
@@ -3899,7 +4004,7 @@ overflow:
...
@@ -3899,7 +4004,7 @@ overflow:
return
0
,
ErrDecodeOverflow
return
0
,
ErrDecodeOverflow
}
}
// 8
6
. NotifyReady
// 8
7
. NotifyReady
func
(
p
*
NotifyReady
)
NEOEncodedLen
()
int
{
func
(
p
*
NotifyReady
)
NEOEncodedLen
()
int
{
return
0
return
0
...
...
t/neo/proto.go
View file @
8cad1d77
...
@@ -195,6 +195,13 @@ type RowInfo struct {
...
@@ -195,6 +195,13 @@ type RowInfo struct {
}
}
type
XXXTest
struct
{
qqq
uint32
aaa
uint32
Zzz
[][]
string
}
// // XXX link request <-> answer ?
// // XXX link request <-> answer ?
// // XXX naming -> PktHeader ?
// // XXX naming -> PktHeader ?
...
...
t/neo/protogen.go
View file @
8cad1d77
...
@@ -208,11 +208,13 @@ func (b *Buffer) emit(format string, a ...interface{}) {
...
@@ -208,11 +208,13 @@ func (b *Buffer) emit(format string, a ...interface{}) {
fmt
.
Fprintf
(
b
,
format
+
"
\n
"
,
a
...
)
fmt
.
Fprintf
(
b
,
format
+
"
\n
"
,
a
...
)
}
}
// interface of codegenerator for coder/decoder
// interface of codegenerator for
sizer/
coder/decoder
type
CodecCodeGen
interface
{
type
CodecCodeGen
interface
{
// tell codegen it should generate code for top-level function
// tell codegen it should generate code for top-level function
setFunc
(
recvName
,
typeName
string
,
typ
types
.
Type
)
setFunc
(
recvName
,
typeName
string
,
typ
types
.
Type
)
// TODO gen*() -> visit*() ?
// emit code to process basic fixed types (not string)
// emit code to process basic fixed types (not string)
// userType is type actually used in source (for which typ is underlying), or nil
// userType is type actually used in source (for which typ is underlying), or nil
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
...
@@ -233,13 +235,13 @@ type CodecCodeGen interface {
...
@@ -233,13 +235,13 @@ type CodecCodeGen interface {
resultExpr
()
string
resultExpr
()
string
}
}
//
sizer/encode/decode codegen
//
common part of codegenerators
type
commonCoder
struct
{
type
commonCoder
struct
{
recvName
string
// receiver/type for top-level func
recvName
string
// receiver/type for top-level func
typeName
string
// or empty
typeName
string
// or empty
typ
types
.
Type
typ
types
.
Type
varN
int
// suffix to add to variables (size0, size1, ...) - for nested computations
varN
int
// suffix to add to variables (size0, size1, ...) - for nested computations
varUsed
map
[
string
]
bool
// whether a variable was used
varUsed
map
[
string
]
bool
// whether a variable was used
}
}
...
@@ -263,20 +265,40 @@ func (c *commonCoder) var_(varname string) string {
...
@@ -263,20 +265,40 @@ func (c *commonCoder) var_(varname string) string {
return
varnameX
return
varnameX
}
}
// information about a size
// consists of numeric & symbolic parts
// size is <num> + expr1 + expr2 + ...
type
size
struct
{
num
int
// numeric part of size
exprv
[]
string
// symbolic part of size
}
func
(
s
*
size
)
Add
(
n
int
)
{
s
.
num
+=
n
}
func
(
s
*
size
)
AddExpr
(
expr
string
)
{
s
.
exprv
=
append
(
s
.
exprv
,
expr
)
}
func
(
s
*
size
)
String
()
string
{
sizeExpr
:=
fmt
.
Sprintf
(
"%v"
,
s
.
num
)
if
len
(
s
.
exprv
)
!=
0
{
sizeExpr
+=
" + "
+
strings
.
Join
(
s
.
exprv
,
" + "
)
}
return
sizeExpr
}
// sizer generates code to compute endoded size of a packet
type
sizer
struct
{
type
sizer
struct
{
Buffer
// buffer for code
Buffer
// buffer for code
n
int
// fixed part of size
size
size
symLenv
[]
string
// symbolic part of size
commonCoder
commonCoder
}
}
// create new sizer for subsize calculation (e.g. for loop)
// encoder generates code to encode a packet
func
(
s
*
sizer
)
subSizer
()
*
sizer
{
return
&
sizer
{
commonCoder
:
commonCoder
{
varN
:
s
.
varN
+
1
}}
}
type
encoder
struct
{
type
encoder
struct
{
Buffer
// XXX
Buffer
// XXX
n
int
n
int
...
@@ -284,6 +306,7 @@ type encoder struct {
...
@@ -284,6 +306,7 @@ type encoder struct {
commonCoder
commonCoder
}
}
// decoder generates code to decode a packet
type
decoder
struct
{
type
decoder
struct
{
Buffer
// buffer for generated code
Buffer
// buffer for generated code
n
int
// current decode position in data
n
int
// current decode position in data
...
@@ -295,11 +318,14 @@ var _ CodecCodeGen = (*sizer)(nil)
...
@@ -295,11 +318,14 @@ var _ CodecCodeGen = (*sizer)(nil)
var
_
CodecCodeGen
=
(
*
encoder
)(
nil
)
var
_
CodecCodeGen
=
(
*
encoder
)(
nil
)
var
_
CodecCodeGen
=
(
*
decoder
)(
nil
)
var
_
CodecCodeGen
=
(
*
decoder
)(
nil
)
// create new sizer for subsize calculation (e.g. inside loop)
func
(
s
*
sizer
)
subSizer
()
*
sizer
{
return
&
sizer
{
commonCoder
:
commonCoder
{
varN
:
s
.
varN
+
1
}}
}
func
(
s
*
sizer
)
resultExpr
()
string
{
func
(
s
*
sizer
)
resultExpr
()
string
{
size
:=
fmt
.
Sprintf
(
"%v"
,
s
.
n
)
size
:=
s
.
size
.
String
()
if
len
(
s
.
symLenv
)
>
0
{
size
+=
" + "
+
strings
.
Join
(
s
.
symLenv
,
" + "
)
}
if
s
.
varUsed
[
"size"
]
{
if
s
.
varUsed
[
"size"
]
{
size
+=
" + "
+
s
.
var__
(
"size"
)
size
+=
" + "
+
s
.
var__
(
"size"
)
}
}
...
@@ -328,7 +354,7 @@ func (s *sizer) generatedCode() string {
...
@@ -328,7 +354,7 @@ func (s *sizer) generatedCode() string {
}
}
func
(
e
*
encoder
)
resultExpr
()
string
{
func
(
e
*
encoder
)
resultExpr
()
string
{
panic
(
"should not be called (?)"
)
panic
(
"should not be called (?)"
)
// XXX
}
}
func
(
e
*
encoder
)
generatedCode
()
string
{
func
(
e
*
encoder
)
generatedCode
()
string
{
...
@@ -347,7 +373,7 @@ func (e *encoder) generatedCode() string {
...
@@ -347,7 +373,7 @@ func (e *encoder) generatedCode() string {
}
}
func
(
d
*
decoder
)
resultExpr
()
string
{
func
(
d
*
decoder
)
resultExpr
()
string
{
panic
(
"should not be called (?)"
)
panic
(
"should not be called (?)"
)
// XXX
}
}
func
(
d
*
decoder
)
generatedCode
()
string
{
func
(
d
*
decoder
)
generatedCode
()
string
{
...
@@ -382,7 +408,7 @@ func (d *decoder) generatedCode() string {
...
@@ -382,7 +408,7 @@ func (d *decoder) generatedCode() string {
func
(
s
*
sizer
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
{
func
(
s
*
sizer
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
{
basic
:=
basicTypes
[
typ
.
Kind
()]
basic
:=
basicTypes
[
typ
.
Kind
()]
s
.
n
+=
basic
.
wireSize
s
.
size
.
Add
(
basic
.
wireSize
)
}
}
func
(
e
*
encoder
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
{
func
(
e
*
encoder
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
{
...
@@ -420,8 +446,8 @@ func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Typ
...
@@ -420,8 +446,8 @@ func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Typ
// [len]byte
// [len]byte
// TODO []byte support
// TODO []byte support
func
(
s
*
sizer
)
genStrBytes
(
path
string
)
{
func
(
s
*
sizer
)
genStrBytes
(
path
string
)
{
s
.
n
+=
4
s
.
size
.
Add
(
4
)
s
.
s
ymLenv
=
append
(
s
.
symLenv
,
fmt
.
Sprintf
(
"len(%s)"
,
path
))
s
.
s
ize
.
AddExpr
(
fmt
.
Sprintf
(
"len(%s)"
,
path
))
}
}
func
(
e
*
encoder
)
genStrBytes
(
path
string
)
{
func
(
e
*
encoder
)
genStrBytes
(
path
string
)
{
...
@@ -450,28 +476,26 @@ func (d *decoder) genStrBytes(assignto string) {
...
@@ -450,28 +476,26 @@ func (d *decoder) genStrBytes(assignto string) {
// emit code to encode/decode slice
// emit code to encode/decode slice
// len u32
// len u32
// [len]item
// [len]item
// TODO optimize for []byte
func
(
s
*
sizer
)
genSlice
(
path
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
func
(
s
*
sizer
)
genSlice
(
path
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
// if size(item)==const - size update in one go
// if size(item)==const - size update in one go
elemSize
,
ok
:=
typeSizeFixed
(
typ
.
Elem
())
elemSize
,
ok
:=
typeSizeFixed
(
typ
.
Elem
())
if
ok
{
if
ok
{
s
.
n
+=
4
s
.
size
.
Add
(
4
)
s
.
s
ymLenv
=
append
(
s
.
symLenv
,
fmt
.
Sprintf
(
"len(%v) * %v"
,
path
,
elemSize
))
s
.
s
ize
.
AddExpr
(
fmt
.
Sprintf
(
"len(%v) * %v"
,
path
,
elemSize
))
return
return
}
}
s
.
n
+=
4
s
.
size
.
Add
(
4
)
s
.
emit
(
"for i := 0; i < len(%v); i++ {"
,
path
)
s
.
emit
(
"for i := 0; i < len(%v); i++ {"
,
path
)
s
.
emit
(
"a := &%s[i]"
,
path
)
s
.
emit
(
"a := &%s[i]"
,
path
)
//codegenType("(*a)", typ.Elem(), obj, s)
sloop
:=
s
.
subSizer
()
sloop
:=
s
.
subSizer
()
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
sloop
)
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
sloop
)
// FIXME vvv if symLenv is ø; -> turn into "result" function
s
.
emit
(
sloop
.
generatedCode
())
s
.
emit
(
sloop
.
generatedCode
())
s
.
emit
(
"%v += %v"
,
s
.
var_
(
"size"
),
sloop
.
resultExpr
())
s
.
emit
(
"%v += %v"
,
s
.
var_
(
"size"
),
sloop
.
resultExpr
())
s
.
emit
(
"}"
)
s
.
emit
(
"}"
)
}
}
// TODO optimize for []byte
func
(
e
*
encoder
)
genSlice
(
path
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
func
(
e
*
encoder
)
genSlice
(
path
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
e
.
emit
(
"{"
)
e
.
emit
(
"{"
)
e
.
emit
(
"l := uint32(len(%s))"
,
path
)
e
.
emit
(
"l := uint32(len(%s))"
,
path
)
...
@@ -488,19 +512,27 @@ func (e *encoder) genSlice(path string, typ *types.Slice, obj types.Object) {
...
@@ -488,19 +512,27 @@ func (e *encoder) genSlice(path string, typ *types.Slice, obj types.Object) {
e
.
n
=
0
e
.
n
=
0
}
}
// TODO optimize for []byte
func
(
d
*
decoder
)
genSlice
(
assignto
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
func
(
d
*
decoder
)
genSlice
(
assignto
string
,
typ
*
types
.
Slice
,
obj
types
.
Object
)
{
d
.
emit
(
"{"
)
d
.
emit
(
"{"
)
d
.
genBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
)
d
.
genBasic
(
"l:"
,
types
.
Typ
[
types
.
Uint32
],
nil
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
d
.
n
=
0
d
.
n
=
0
/*
elemSize, elemFixed := typeSizeFixed(typ.Elem())
// if size(item)==const - check l in one go
if elemFixed {
d.emit("if len(data) < l*%v { goto overflow }", elemSize)
}
// TODO ^^^ then skip inner overflow checks
*/
d
.
emit
(
"%v= make(%v, l)"
,
assignto
,
typeName
(
typ
))
d
.
emit
(
"%v= make(%v, l)"
,
assignto
,
typeName
(
typ
))
// TODO size check
// TODO if size(item)==const - check l in one go
//d.emit("if len(data) < l { goto overflow }")
d
.
emit
(
"for i := 0; uint32(i) < l; i++ {"
)
d
.
emit
(
"for i := 0; uint32(i) < l; i++ {"
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
d
.
emit
(
"a := &%s[i]"
,
assignto
)
// XXX try to avoid (*) in a
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
d
)
codegenType
(
"(*a)"
,
typ
.
Elem
(),
obj
,
d
)
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"data = data[%v:]"
,
d
.
n
)
// FIXME wrt slice of slice ?
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
d
.
emit
(
"%v += %v"
,
d
.
var_
(
"nread"
),
d
.
n
)
...
@@ -518,17 +550,17 @@ func (s *sizer) genMap(path string, typ *types.Map, obj types.Object) {
...
@@ -518,17 +550,17 @@ func (s *sizer) genMap(path string, typ *types.Map, obj types.Object) {
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
typ
.
Elem
())
if
keyFixed
&&
elemFixed
{
if
keyFixed
&&
elemFixed
{
s
.
n
+=
4
s
.
size
.
Add
(
4
)
s
.
s
ymLenv
=
append
(
s
.
symLenv
,
fmt
.
Sprintf
(
"len(%v) * %v"
,
path
,
keySize
+
elemSize
))
s
.
s
ize
.
AddExpr
(
fmt
.
Sprintf
(
"len(%v) * %v"
,
path
,
keySize
+
elemSize
))
return
return
}
}
panic
(
"UNTESTED"
)
panic
(
"UNTESTED"
)
s
.
n
+=
4
s
.
size
.
Add
(
4
)
s
.
emit
(
"for key := range %s {"
,
path
)
s
.
emit
(
"for key := range %s {"
,
path
)
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
s
)
codegenType
(
"key"
,
typ
.
Key
(),
obj
,
s
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
s
)
codegenType
(
fmt
.
Sprintf
(
"%s[key]"
,
path
),
typ
.
Elem
(),
obj
,
s
)
s
.
emit
(
"%v += %v"
,
s
.
var_
(
"size"
),
s
.
n
)
s
.
emit
(
"%v += %v"
,
s
.
var_
(
"size"
),
s
.
size
)
s
.
emit
(
"}"
)
s
.
emit
(
"}"
)
}
}
...
...
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