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
ce030bd4
Commit
ce030bd4
authored
Jan 15, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0ba3696b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
18 deletions
+8
-18
go/neo/proto/protogen.go
go/neo/proto/protogen.go
+8
-18
No files found.
go/neo/proto/protogen.go
View file @
ce030bd4
...
...
@@ -362,13 +362,9 @@ import (
specAnnotation
.
parse
(
typespec
.
Doc
)
// remember enum types
// FIXME separate dedicated first pass to extract enums first
if
specAnnotation
.
enum
{
//typ := typeInfo.Types[typespec.Type].Type
typ
:=
typeInfo
.
Defs
[
typespec
.
Name
]
.
Type
()
// XXX verify typ is basic int XXX or byte?
enumRegistry
[
typ
]
=
enumSerial
//fmt.Printf("// enum %s #%d\n", typeName(typ), enumSerial)
enumSerial
++
}
...
...
@@ -400,7 +396,7 @@ import (
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
encoderN
{}))
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
decoderN
{}))
//
XXX keep all M routines separate from N for code locality
//
TODO keep all M routines separate from N for code locality ?
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
sizerM
{}))
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
encoderM
{}))
buf
.
WriteString
(
generateCodecCode
(
typespec
,
&
decoderM
{}))
...
...
@@ -429,12 +425,9 @@ import (
// format & output generated code
code
,
err
:=
format
.
Source
(
buf
.
Bytes
())
//code = buf.Bytes()
if
true
{
if
err
!=
nil
{
panic
(
err
)
// should not happen
}
}
_
,
err
=
os
.
Stdout
.
Write
(
code
)
if
err
!=
nil
{
...
...
@@ -560,12 +553,10 @@ type CodeGenerator interface {
// mem.Buf
genBuf
(
path
string
)
/*
// generate code for a custom type which implements its own
// encoding/decoding via implementing neo.customCodecN interface.
// XXX move out of common interface?
genCustomN(path string)
*/
// // generate code for a custom type which implements its own
// // encoding/decoding via implementing neo.customCodecN interface.
// // XXX move out of common interface?
// genCustomN(path string)
// get generated code.
generatedCode
()
string
...
...
@@ -940,7 +931,6 @@ func (d *decoderCommon) generatedCode() string {
code
.
Write
(
d
.
bufDone
.
Bytes
())
// epilogue
// XXX M: return `n + (len0 - len(data))` without nread updates after every decode
retexpr
:=
fmt
.
Sprintf
(
"%v"
,
d
.
nread
)
if
d
.
varUsed
[
"nread"
]
{
// casting nread to int is ok even on 32 bit arches:
...
...
@@ -1003,7 +993,7 @@ func (d *decoderN) genBasic(assignto string, typ *types.Basic, userType types.Ty
d
.
overflow
.
Add
(
basic
.
wireSize
)
}
// M:
XXX
// M:
emit code to size/encode/decode basic fixed type
func
(
s
*
sizerM
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
{
// upath casts path into basic type if needed
// e.g. p.x -> int32(p.x) if p.x is custom type with underlying int32
...
...
@@ -1039,10 +1029,10 @@ func (s *sizerM) genBasic(path string, typ *types.Basic, userType types.Type) {
case
types
.
Float64
:
s
.
size
.
Add
(
1
+
8
)
// mfloat64 + <value64>
}
}
func
(
e
*
encoderM
)
genBasic
(
path
string
,
typ
*
types
.
Basic
,
userType
types
.
Type
)
{
// upath casts path into basic type if needed
// e.g. p.x -> int32(p.x) if p.x is custom type with underlying int32
// XXX dup?
upath
:=
path
if
userType
.
Underlying
()
!=
userType
{
upath
=
fmt
.
Sprintf
(
"%s(%s)"
,
typ
.
Name
(),
upath
)
...
...
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