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
171422b2
Commit
171422b2
authored
Sep 04, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e6779822
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
go/neo/protogen.go
go/neo/protogen.go
+20
-3
No files found.
go/neo/protogen.go
View file @
171422b2
...
...
@@ -55,8 +55,11 @@ can do a good job the work is delegated to it.
--------
XXX also types registry tables are generated - document
Also along the way types registry table is generated for
msgCode -> message type
lookup needed in packet receive codepath.
*/
package
main
...
...
@@ -113,6 +116,9 @@ func typeName(typ types.Type) string {
return
types
.
TypeString
(
typ
,
qf
)
}
// type of neo.customCodec
var
neo_customCodec
*
types
.
Interface
// bytes.Buffer + bell & whistles
type
Buffer
struct
{
bytes
.
Buffer
...
...
@@ -238,7 +244,18 @@ func main() {
// go through proto.go and AST'ify & typecheck it
zodbPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/zodb"
,
"../zodb/zodb.go"
)
neoPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/neo"
,
"proto.go"
)
neoPkg
=
loadPkg
(
"lab.nexedi.com/kirr/neo/go/neo"
,
"proto.go"
,
"packed.go"
)
// extract neo.customCodec
cc
:=
neoPkg
.
Scope
()
.
Lookup
(
"customCodec"
)
if
cc
==
nil
{
log
.
Fatal
(
"cannot find `customCodec`"
)
}
var
ok
bool
neo_customCodec
,
ok
=
cc
.
Type
()
.
Underlying
()
.
(
*
types
.
Interface
)
if
!
ok
{
log
.
Fatal
(
"customCodec is not interface (got %v)"
,
cc
.
Type
())
}
// prologue
f
:=
fileMap
[
"proto.go"
]
...
...
@@ -1101,7 +1118,7 @@ func (d *decoder) genCustom(path string) {
// obj is object that uses this type in source program (so in case of an error
// we can point to source location for where it happened)
func
codegenType
(
path
string
,
typ
types
.
Type
,
obj
types
.
Object
,
codegen
CodeGenerator
)
{
if
types
.
Implements
(
typ
,
neo
CustomXXX
)
{
if
types
.
Implements
(
typ
,
neo
_customCodec
)
{
codegen
.
genCustom
(
path
)
return
}
...
...
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