Commit 2c1cb10d authored by Kirill Smelkov's avatar Kirill Smelkov

go/neo/proto: protogen: Prepare to generate code for struct heads

It is noop for 'N' encoding, but will be non-empty for MessagePack.
parent 6e705e4e
...@@ -472,6 +472,9 @@ type CodeGenerator interface { ...@@ -472,6 +472,9 @@ type CodeGenerator interface {
genArray1(path string, typ *types.Array) genArray1(path string, typ *types.Array)
genSlice1(path string, typ types.Type) genSlice1(path string, typ types.Type)
// generate code to process header of struct
genStructHead(path string, typ *types.Struct, userType types.Type)
// mem.Buf // mem.Buf
genBuf(path string) genBuf(path string)
...@@ -1236,6 +1239,14 @@ func (d *decoderN) genCustomN(path string) { ...@@ -1236,6 +1239,14 @@ func (d *decoderN) genCustomN(path string) {
d.overflowCheck() d.overflowCheck()
} }
// ---- struct head ----
// N: nothing
func (s *sizerN) genStructHead(path string, typ *types.Struct, userType types.Type) {}
func (e *encoderN) genStructHead(path string, typ *types.Struct, userType types.Type) {}
func (d *decoderN) genStructHead(path string, typ *types.Struct, userType types.Type) {}
// top-level driver for emitting size/encode/decode code for a type // top-level driver for emitting size/encode/decode code for a type
// //
// 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
...@@ -1270,6 +1281,7 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodeGene ...@@ -1270,6 +1281,7 @@ func codegenType(path string, typ types.Type, obj types.Object, codegen CodeGene
codegen.genBasic(path, u, typ) codegen.genBasic(path, u, typ)
case *types.Struct: case *types.Struct:
codegen.genStructHead(path, u, typ)
for i := 0; i < u.NumFields(); i++ { for i := 0; i < u.NumFields(); i++ {
v := u.Field(i) v := u.Field(i)
codegenType(path+"."+v.Name(), v.Type(), v, codegen) codegenType(path+"."+v.Name(), v.Type(), v, codegen)
......
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