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
e1c25b29
Commit
e1c25b29
authored
Jan 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0e028e1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
go/neo/proto/protogen.go
go/neo/proto/protogen.go
+9
-19
No files found.
go/neo/proto/protogen.go
View file @
e1c25b29
...
...
@@ -452,19 +452,9 @@ var basicTypesN = map[types.BasicKind]basicCodecN{
types
.
Float64
:
{
8
,
"float64_neoEncode(%v, %v)"
,
"float64_neoDecode(%v)"
},
}
// does a type have fixed wire size when encoded and, if yes, what it is?
func
typeEncodingSizeFixed
(
encoding
byte
,
typ
types
.
Type
)
(
wireSize
int
,
ok
bool
)
{
return
typeRxTxSizeFixed
(
encoding
,
typ
,
false
)
}
// does a type always have fixed wire size when we are decoding it from
// a packet received from outside? if yes, what size it is?
func
typeDecodingSizeFixed
(
encoding
byte
,
typ
types
.
Type
)
(
wireSize
int
,
ok
bool
)
{
return
typeRxTxSizeFixed
(
encoding
,
typ
,
true
)
}
func
typeRxTxSizeFixed
(
encoding
byte
,
typ
types
.
Type
,
rx
bool
)
(
wireSize
int
,
ok
bool
)
{
// pass typ through sizerM and see if encoded size is fixed or not
// XXX make something not fixed when rx=true?
// does a type have fixed wire size and, if yes, what it is?
func
typeSizeFixed
(
encoding
byte
,
typ
types
.
Type
)
(
wireSize
int
,
ok
bool
)
{
// pass typ through sizer and see if encoded size is fixed or not
var
size
SymSize
switch
encoding
{
...
...
@@ -1396,7 +1386,7 @@ func (s *sizerCommon) genSliceCommon(xs CodeGenCustomize, path string, typ *type
xs
.
genSliceHead
(
path
,
typ
,
obj
)
// if size(item)==const - size update in one go
elemSize
,
ok
:=
type
Encoding
SizeFixed
(
xs
.
encoding
(),
typ
.
Elem
())
elemSize
,
ok
:=
typeSizeFixed
(
xs
.
encoding
(),
typ
.
Elem
())
if
ok
{
s
.
size
.
AddExpr
(
"len(%v) * %v"
,
path
,
elemSize
)
return
...
...
@@ -1457,7 +1447,7 @@ func (d *decoderCommon) genSliceCommon(xd CodeGenCustomize, assignto string, typ
d
.
resetPos
()
// if size(item)==const - check overflow in one go
elemSize
,
elemFixed
:=
type
Decoding
SizeFixed
(
xd
.
encoding
(),
typ
.
Elem
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
xd
.
encoding
(),
typ
.
Elem
())
if
elemFixed
{
d
.
overflowCheck
()
d
.
overflow
.
AddExpr
(
"uint64(l) * %v"
,
elemSize
)
...
...
@@ -1530,8 +1520,8 @@ func (s *sizerN) genMap(path string, typ *types.Map, obj types.Object) {
func
(
s
*
sizerCommon
)
genMapCommon
(
xs
CodeGenCustomize
,
path
string
,
typ
*
types
.
Map
,
obj
types
.
Object
)
{
xs
.
genMapHead
(
path
,
typ
,
obj
)
keySize
,
keyFixed
:=
type
Encoding
SizeFixed
(
xs
.
encoding
(),
typ
.
Key
())
elemSize
,
elemFixed
:=
type
Encoding
SizeFixed
(
xs
.
encoding
(),
typ
.
Elem
())
keySize
,
keyFixed
:=
typeSizeFixed
(
xs
.
encoding
(),
typ
.
Key
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
xs
.
encoding
(),
typ
.
Elem
())
if
keyFixed
&&
elemFixed
{
s
.
size
.
AddExpr
(
"len(%v) * %v"
,
path
,
keySize
+
elemSize
)
...
...
@@ -1602,8 +1592,8 @@ func (d *decoderCommon) genMapCommon(xd CodeGenCustomize, assignto string, typ *
d
.
resetPos
()
// if size(key,item)==const - check overflow in one go
keySize
,
keyFixed
:=
type
Decoding
SizeFixed
(
xd
.
encoding
(),
typ
.
Key
())
elemSize
,
elemFixed
:=
type
Decoding
SizeFixed
(
xd
.
encoding
(),
typ
.
Elem
())
keySize
,
keyFixed
:=
typeSizeFixed
(
xd
.
encoding
(),
typ
.
Key
())
elemSize
,
elemFixed
:=
typeSizeFixed
(
xd
.
encoding
(),
typ
.
Elem
())
if
keyFixed
&&
elemFixed
{
d
.
overflowCheck
()
d
.
overflow
.
AddExpr
(
"uint64(l) * %v"
,
keySize
+
elemSize
)
...
...
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