Commit 171422b2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e6779822
...@@ -55,8 +55,11 @@ can do a good job the work is delegated to it. ...@@ -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 package main
...@@ -113,6 +116,9 @@ func typeName(typ types.Type) string { ...@@ -113,6 +116,9 @@ func typeName(typ types.Type) string {
return types.TypeString(typ, qf) return types.TypeString(typ, qf)
} }
// type of neo.customCodec
var neo_customCodec *types.Interface
// bytes.Buffer + bell & whistles // bytes.Buffer + bell & whistles
type Buffer struct { type Buffer struct {
bytes.Buffer bytes.Buffer
...@@ -238,7 +244,18 @@ func main() { ...@@ -238,7 +244,18 @@ func main() {
// go through proto.go and AST'ify & typecheck it // go through proto.go and AST'ify & typecheck it
zodbPkg = loadPkg("lab.nexedi.com/kirr/neo/go/zodb", "../zodb/zodb.go") 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 // prologue
f := fileMap["proto.go"] f := fileMap["proto.go"]
...@@ -1101,7 +1118,7 @@ func (d *decoder) genCustom(path string) { ...@@ -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 // 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) // we can point to source location for where it happened)
func codegenType(path string, typ types.Type, obj types.Object, codegen CodeGenerator) { func codegenType(path string, typ types.Type, obj types.Object, codegen CodeGenerator) {
if types.Implements(typ, neoCustomXXX) { if types.Implements(typ, neo_customCodec) {
codegen.genCustom(path) codegen.genCustom(path)
return return
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment