From 2b52e6bc268f75876b97f195fb48f5f217d16bf4 Mon Sep 17 00:00:00 2001 From: davyxu Date: Wed, 16 Jun 2021 18:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81import,=20=E7=A7=BB=E9=99=A4s?= =?UTF-8?q?ervice/rpc=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gen/pbscheme/gen_dir.go | 72 ++++++++++++++++++++++++++++++-- model/descriptorset.go | 70 ------------------------------- model/type.go | 1 - parser/context.go | 33 ++++++++++++--- parser/entry.go | 18 +------- parser/enumfield.go | 31 +++++++------- parser/parse_descriptor.go | 34 +++++++-------- parser/parse_descriptorset.go | 11 +++-- parser/parse_import.go | 30 +++++++++++++ parser/parser.go | 2 + parser/service.go | 44 ------------------- parser/structfield.go | 19 +++++---- tests/Make.sh | 14 ++++--- tests/code_test.go | 12 +++--- tests/filelist.proto | 2 + tests/msg.proto | 11 +++++ tests/pb_gen.proto | 2 +- tests/reg_gen.go | 45 +++++++++++--------- tests/{code.proto => type.proto} | 21 ---------- 19 files changed, 227 insertions(+), 245 deletions(-) create mode 100644 parser/parse_import.go delete mode 100644 parser/service.go create mode 100644 tests/filelist.proto create mode 100644 tests/msg.proto rename tests/{code.proto => type.proto} (86%) diff --git a/gen/pbscheme/gen_dir.go b/gen/pbscheme/gen_dir.go index 1efc5d1..31c96f4 100644 --- a/gen/pbscheme/gen_dir.go +++ b/gen/pbscheme/gen_dir.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/davyxu/protoplus/codegen" "github.com/davyxu/protoplus/gen" + "github.com/davyxu/protoplus/model" "io/ioutil" "path/filepath" "strings" @@ -33,20 +34,83 @@ message {{.Name}} { {{range .Fields}} {{end}} ` +type PBDescriptorSet struct { + model.DescriptorSet + + // pb生成文件依赖时, 使用以下字段 + DependentSource []string // 按文件管理的描述符取出时, 这个字段有效. 本文件依赖的其他source的symbiol + SourceName string // 按文件管理的描述符取出时, 这个字段有效. 表示本DescriptorSet的文件名 + dsBySource map[string]*PBDescriptorSet // 按文件名管理的描述符集合 +} + +func (self *PBDescriptorSet) addDependentSource(name string) { + + if self.SourceName == name { + return + } + + for _, n := range self.DependentSource { + if n == name { + return + } + } + + self.DependentSource = append(self.DependentSource, name) +} + +func (self *PBDescriptorSet) DescriptorSetBySource() map[string]*PBDescriptorSet { + if self.dsBySource != nil { + return self.dsBySource + } + + self.dsBySource = map[string]*PBDescriptorSet{} + + for _, obj := range self.Objects { + ds := self.dsBySource[obj.SrcName] + if ds == nil { + ds = &PBDescriptorSet{} + + ds.PackageName = self.PackageName + ds.Codec = self.Codec + ds.SourceName = obj.SrcName + + self.dsBySource[obj.SrcName] = ds + } + + ds.AddObject(obj) + } + + for _, file := range self.dsBySource { + for _, st := range file.Structs() { + + for _, fd := range st.Fields { + + switch fd.Kind { + case model.Kind_Struct, model.Kind_Enum: + refTarget := self.ObjectByName(fd.Type) + if refTarget != nil { + file.addDependentSource(refTarget.SrcName) + } + } + } + } + } + + return self.dsBySource +} + func GenProtoDir(ctx *gen.Context) error { - rootDS := ctx.DescriptorSet + rootDS := &PBDescriptorSet{DescriptorSet: *ctx.DescriptorSet} var sb strings.Builder for srcName, ds := range rootDS.DescriptorSetBySource() { - ctx.DescriptorSet = ds - gen := codegen.NewCodeGen("dirproto"). RegisterTemplateFunc(codegen.UsefulFunc). RegisterTemplateFunc(UsefulFunc). - ParseTemplate(protoDirCodeTemplate, ctx) + ParseTemplate(protoDirCodeTemplate, ds) if gen.Error() != nil { fmt.Println(string(gen.Data())) diff --git a/model/descriptorset.go b/model/descriptorset.go index 349d134..d09d53d 100644 --- a/model/descriptorset.go +++ b/model/descriptorset.go @@ -4,21 +4,6 @@ type DescriptorSet struct { Objects []*Descriptor `json:",omitempty"` PackageName string Codec string - - DependentSource []string // 按文件管理的描述符取出时, 这个字段有效. 本文件依赖的其他source的symbiol - SourceName string // 按文件管理的描述符取出时, 这个字段有效. 表示本DescriptorSet的文件名 - dsBySource map[string]*DescriptorSet // 按文件名管理的描述符集合 -} - -func (self *DescriptorSet) Services() (ret []*Descriptor) { - - for _, o := range self.Objects { - if o.Kind == Kind_Service { - ret = append(ret, o) - } - } - - return } func (self *DescriptorSet) Structs() (ret []*Descriptor) { @@ -68,58 +53,3 @@ func (self *DescriptorSet) ObjectByName(name string) *Descriptor { func (self *DescriptorSet) AddObject(d *Descriptor) { self.Objects = append(self.Objects, d) } - -func (self *DescriptorSet) addDependentSource(name string) { - - if self.SourceName == name { - return - } - - for _, n := range self.DependentSource { - if n == name { - return - } - } - - self.DependentSource = append(self.DependentSource, name) -} - -func (self *DescriptorSet) DescriptorSetBySource() map[string]*DescriptorSet { - if self.dsBySource != nil { - return self.dsBySource - } - - self.dsBySource = map[string]*DescriptorSet{} - - for _, obj := range self.Objects { - ds := self.dsBySource[obj.SrcName] - if ds == nil { - ds = &DescriptorSet{ - PackageName: self.PackageName, - Codec: self.Codec, - SourceName: obj.SrcName, - } - self.dsBySource[obj.SrcName] = ds - } - - ds.AddObject(obj) - } - - for _, file := range self.dsBySource { - for _, st := range file.Structs() { - - for _, fd := range st.Fields { - - switch fd.Kind { - case Kind_Struct, Kind_Enum: - refTarget := self.ObjectByName(fd.Type) - if refTarget != nil { - file.addDependentSource(refTarget.SrcName) - } - } - } - } - } - - return self.dsBySource -} diff --git a/model/type.go b/model/type.go index 0fa2e2b..09ce59a 100644 --- a/model/type.go +++ b/model/type.go @@ -7,7 +7,6 @@ const ( Kind_Primitive = "primitive" Kind_Struct = "struct" Kind_Enum = "enum" - Kind_Service = "service" ) var SchemeType2Type = map[string]string{ diff --git a/parser/context.go b/parser/context.go index 486928b..b0df135 100644 --- a/parser/context.go +++ b/parser/context.go @@ -3,22 +3,33 @@ package parser import ( "github.com/davyxu/golexer" "github.com/davyxu/protoplus/model" + "strings" ) type Context struct { + + // 每个文件对应的属性 SourceName string *protoParser *model.DescriptorSet - *model.Descriptor + // 全局属性 + symbolPos map[interface{}]golexer.TokenPos + + sourceByName map[string]struct{} +} - *model.FieldDescriptor +func (self *Context) AddSource(sourceName string) bool { + lowerName := strings.ToLower(sourceName) + if _, ok := self.sourceByName[lowerName]; ok { + return false + } - *model.ServiceCall + self.sourceByName[lowerName] = struct{}{} - symbolPos map[interface{}]golexer.TokenPos + return true } func (self *Context) QuerySymbolPosString(v interface{}) string { @@ -31,13 +42,23 @@ func (self *Context) QuerySymbolPosString(v interface{}) string { } func (self *Context) AddSymbol(v interface{}, pos golexer.TokenPos) { - self.symbolPos[v] = pos } +func (self *Context) Clone(srcName string) *Context { + + return &Context{ + SourceName: srcName, + symbolPos: self.symbolPos, + sourceByName: self.sourceByName, + DescriptorSet: self.DescriptorSet, + } +} + func newContext() *Context { return &Context{ - symbolPos: make(map[interface{}]golexer.TokenPos), + symbolPos: map[interface{}]golexer.TokenPos{}, + sourceByName: map[string]struct{}{}, } } diff --git a/parser/entry.go b/parser/entry.go index f61da8b..3a9b296 100644 --- a/parser/entry.go +++ b/parser/entry.go @@ -2,7 +2,6 @@ package parser import ( "github.com/davyxu/protoplus/model" - "os" "strings" ) @@ -32,23 +31,10 @@ func ParseFileList(dset *model.DescriptorSet, filelist ...string) error { ctx.DescriptorSet = dset for _, filename := range filelist { - - ctx.SourceName = filename - - if file, err := os.Open(filename); err != nil { + err := parseFile(ctx, filename) + if err != nil { return err - } else { - - if err := rawParse(ctx, file); err != nil { - file.Close() - - return err - } - - file.Close() - } - } return checkAndFix(ctx) diff --git a/parser/enumfield.go b/parser/enumfield.go index 6f7f84c..86db954 100644 --- a/parser/enumfield.go +++ b/parser/enumfield.go @@ -2,18 +2,19 @@ package parser import ( "errors" + "github.com/davyxu/protoplus/model" ) -func parseEnumField(ctx *Context) { +func parseEnumField(ctx *Context, fd *model.FieldDescriptor) { // 注释 nameToken := ctx.RawToken() // 字段名 - ctx.FieldDescriptor.Name = ctx.Expect(Token_Identifier).Value() + fd.Name = ctx.Expect(Token_Identifier).Value() - if ctx.FieldNameExists(ctx.FieldDescriptor.Name) { - panic(errors.New("Duplicate field name: " + ctx.FieldDescriptor.Name)) + if fd.Descriptor.FieldNameExists(fd.Name) { + panic(errors.New("Duplicate field name: " + fd.Name)) } // 有等号 @@ -21,26 +22,26 @@ func parseEnumField(ctx *Context) { ctx.NextToken() // tag - ctx.FieldDescriptor.Tag = ctx.Expect(Token_Numeral).ToInt() + fd.Tag = ctx.Expect(Token_Numeral).ToInt() } else { // 没等号自动生成枚举序号 - if len(ctx.Fields) == 0 { - //fd.AutoTag = 0 - } else { - - // 按前面的序号+1 - //fd.AutoTag = d.MaxTag() + 1 - } + //if len(ctx.Fields) == 0 { + // //fd.AutoTag = 0 + //} else { + // + // // 按前面的序号+1 + // //fd.AutoTag = d.MaxTag() + 1 + //} } - ctx.FieldDescriptor.Comment = ctx.CommentGroupByLine(nameToken.Line()) + fd.Comment = ctx.CommentGroupByLine(nameToken.Line()) // 枚举值类型,始终为int32 - ctx.FieldDescriptor.ParseType("int32") + fd.ParseType("int32") - ctx.AddField(ctx.FieldDescriptor) + fd.Descriptor.AddField(fd) return } diff --git a/parser/parse_descriptor.go b/parser/parse_descriptor.go index b4c5242..24908e5 100644 --- a/parser/parse_descriptor.go +++ b/parser/parse_descriptor.go @@ -5,15 +5,14 @@ import ( "github.com/davyxu/protoplus/model" ) -func parseObject(ctx *Context) { +func parseObject(ctx *Context, d *model.Descriptor) { - dotToken := ctx.RawToken() + keywordToken := ctx.RawToken() ctx.NextToken() // 名字 - ctx.Descriptor.Name = ctx.Expect(Token_Identifier).Value() - ctx.SrcName = ctx.SourceName + d.Name = ctx.Expect(Token_Identifier).Value() // 名字上面的注释 @@ -22,24 +21,19 @@ func parseObject(ctx *Context) { for ctx.TokenID() != Token_CurlyBraceR { - switch ctx.Descriptor.Kind { + var fd model.FieldDescriptor + fd.Descriptor = d + + switch d.Kind { case model.Kind_Struct: - var fd model.FieldDescriptor - ctx.FieldDescriptor = &fd - parseStructField(ctx) + parseStructField(ctx, &fd) case model.Kind_Enum: - var fd model.FieldDescriptor - ctx.FieldDescriptor = &fd - parseEnumField(ctx) - case model.Kind_Service: - var sc model.ServiceCall - ctx.ServiceCall = &sc - parseSvcCallField(ctx) + parseEnumField(ctx, &fd) } // 读取字段后面的[Tag项] if ctx.TokenID() == Token_BracketL { - ctx.FieldDescriptor.TagSet = parseTagSet(ctx) + fd.TagSet = parseTagSet(ctx) } } @@ -48,14 +42,14 @@ func parseObject(ctx *Context) { // } - ctx.Descriptor.Comment = ctx.CommentGroupByLine(dotToken.Line()) + d.Comment = ctx.CommentGroupByLine(keywordToken.Line()) // 名字重复检查 - if ctx.DescriptorSet.ObjectNameExists(ctx.Descriptor.Name) { - panic(errors.New("Duplicate name: " + ctx.Descriptor.Name)) + if ctx.DescriptorSet.ObjectNameExists(d.Name) { + panic(errors.New("Duplicate name: " + d.Name)) } - ctx.AddObject(ctx.Descriptor) + ctx.AddObject(d) } diff --git a/parser/parse_descriptorset.go b/parser/parse_descriptorset.go index a71f606..fab9182 100644 --- a/parser/parse_descriptorset.go +++ b/parser/parse_descriptorset.go @@ -34,7 +34,7 @@ func rawParse(ctx *Context, reader io.Reader) (retErr error) { for ctx.TokenID() != Token_EOF { var d model.Descriptor - ctx.Descriptor = &d + d.SrcName = ctx.SourceName if ctx.TokenID() == Token_BracketL { d.TagSet = parseTagSet(ctx) @@ -43,13 +43,12 @@ func rawParse(ctx *Context, reader io.Reader) (retErr error) { switch ctx.TokenID() { case Token_Struct: d.Kind = model.Kind_Struct - parseObject(ctx) + parseObject(ctx, &d) case Token_Enum: d.Kind = model.Kind_Enum - parseObject(ctx) - case Token_Service: - d.Kind = model.Kind_Service - parseObject(ctx) + parseObject(ctx, &d) + case Token_Import: + parseImport(ctx) default: panic(errors.New("Unknown token: " + ctx.TokenValue())) } diff --git a/parser/parse_import.go b/parser/parse_import.go new file mode 100644 index 0000000..22c2d1f --- /dev/null +++ b/parser/parse_import.go @@ -0,0 +1,30 @@ +package parser + +import "os" + +func parseImport(ctx *Context) error { + + ctx.NextToken() + + fileName := ctx.Expect(Token_String).Value() + + return parseFile(ctx, fileName) +} + +func parseFile(ctx *Context, fileName string) error { + if !ctx.AddSource(fileName) { + return nil + } + + file, err := os.Open(fileName) + + if err != nil { + return err + } + + defer file.Close() + + newCtx := ctx.Clone(fileName) + + return rawParse(newCtx, file) +} diff --git a/parser/parser.go b/parser/parser.go index 0b76a48..f8bcb29 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -33,6 +33,7 @@ const ( Token_Assign // = Token_Service // service Token_RPC // rpc + Token_Import // import ) type protoParser struct { @@ -137,6 +138,7 @@ func newProtoParser(srcName string) *protoParser { l.AddMatcher(golexer.NewKeywordMatcher(Token_Struct, "struct")) l.AddMatcher(golexer.NewKeywordMatcher(Token_Service, "service")) l.AddMatcher(golexer.NewKeywordMatcher(Token_RPC, "rpc")) + l.AddMatcher(golexer.NewKeywordMatcher(Token_Import, "import")) l.AddMatcher(golexer.NewIdentifierMatcher(Token_Identifier)) diff --git a/parser/service.go b/parser/service.go deleted file mode 100644 index f75e489..0000000 --- a/parser/service.go +++ /dev/null @@ -1,44 +0,0 @@ -package parser - -import ( - "errors" -) - -func parseSvcCallField(ctx *Context) { - - // 注释 - nameToken := ctx.RawToken() - - if ctx.TokenID() == Token_RPC { - ctx.NextToken() - ctx.ServiceCall.IsRPC = true - } - - // 字段名 - ctx.ServiceCall.Name = ctx.Expect(Token_Identifier).Value() - - if ctx.CallNameExists(ctx.ServiceCall.Name) { - panic(errors.New("Duplicate svc call name: " + ctx.ServiceCall.Name)) - } - - tp := ctx.TokenPos() - - if ctx.TokenID() == Token_ParenL { - ctx.NextToken() - - ctx.ServiceCall.RequestName = ctx.Expect(Token_Identifier).Value() - ctx.Expect(Token_ParenR) - ctx.ServiceCall.RespondName = ctx.Expect(Token_Identifier).Value() - } else { - ctx.ServiceCall.RequestName = ctx.ServiceCall.Name + "REQ" - ctx.ServiceCall.RespondName = ctx.ServiceCall.Name + "ACK" - } - - ctx.ServiceCall.Comment = ctx.CommentGroupByLine(nameToken.Line()) - - ctx.AddSymbol(ctx.ServiceCall, tp) - - ctx.AddSvcCall(ctx.ServiceCall) - - return -} diff --git a/parser/structfield.go b/parser/structfield.go index 1f2c46e..588c52a 100644 --- a/parser/structfield.go +++ b/parser/structfield.go @@ -2,18 +2,19 @@ package parser import ( "errors" + "github.com/davyxu/protoplus/model" ) -func parseStructField(ctx *Context) { +func parseStructField(ctx *Context, fd *model.FieldDescriptor) { // 注释 nameToken := ctx.RawToken() // 字段名 - ctx.FieldDescriptor.Name = ctx.Expect(Token_Identifier).Value() + fd.Name = ctx.Expect(Token_Identifier).Value() - if ctx.FieldNameExists(ctx.FieldDescriptor.Name) { - panic(errors.New("Duplicate field name: " + ctx.FieldDescriptor.Name)) + if fd.Descriptor.FieldNameExists(fd.Name) { + panic(errors.New("Duplicate field name: " + fd.Name)) } tp := ctx.TokenPos() @@ -22,17 +23,17 @@ func parseStructField(ctx *Context) { if ctx.TokenID() == Token_BracketL { ctx.NextToken() ctx.Expect(Token_BracketR) - ctx.Repeatd = true + fd.Repeatd = true } // 延后在所有解析完后,检查TypeName是否合法,通过symbol还原位置并报错 - ctx.FieldDescriptor.ParseType(ctx.Expect(Token_Identifier).Value()) + fd.ParseType(ctx.Expect(Token_Identifier).Value()) - ctx.FieldDescriptor.Comment = ctx.CommentGroupByLine(nameToken.Line()) + fd.Comment = ctx.CommentGroupByLine(nameToken.Line()) - ctx.AddSymbol(ctx.FieldDescriptor, tp) + ctx.AddSymbol(fd, tp) - ctx.AddField(ctx.FieldDescriptor) + fd.Descriptor.AddField(fd) return } diff --git a/tests/Make.sh b/tests/Make.sh index 44bb5fc..54ae890 100644 --- a/tests/Make.sh +++ b/tests/Make.sh @@ -5,9 +5,11 @@ set -e go build -v -o=${GOPATH}/bin/protoplus github.com/davyxu/protoplus/cmd/protoplus # code.proto为输入文件 -${GOPATH}/bin/protoplus -ppgo_out=code_gen.go -package=tests code.proto -${GOPATH}/bin/protoplus -ppgoreg_out=reg_gen.go -package=tests code.proto -${GOPATH}/bin/protoplus -ppcs_out=../example/csharp/Example/ProtoGen.cs -package=Proto code.proto -${GOPATH}/bin/protoplus -ppcsreg_out=../example/csharp/Example/ProtoGenReg.cs -package=Proto code.proto -${GOPATH}/bin/protoplus -pbscheme_out=pb_gen.proto -package=proto code.proto -${GOPATH}/bin/protoplus -route_out=route.json -package=proto code.proto \ No newline at end of file +ProtoPlusBin=${GOPATH}/bin/protoplus + +${ProtoPlusBin} -ppgo_out=code_gen.go -package=tests filelist.proto +${ProtoPlusBin} -ppgoreg_out=reg_gen.go -package=tests filelist.proto +${ProtoPlusBin} -ppcs_out=../example/csharp/Example/ProtoGen.cs -package=Proto filelist.proto +${ProtoPlusBin} -ppcsreg_out=../example/csharp/Example/ProtoGenReg.cs -package=Proto filelist.proto +${ProtoPlusBin} -pbscheme_out=pb_gen.proto -package=proto filelist.proto +${ProtoPlusBin} -route_out=route.json -package=proto filelist.proto \ No newline at end of file diff --git a/tests/code_test.go b/tests/code_test.go index 73bd77d..b6b073e 100644 --- a/tests/code_test.go +++ b/tests/code_test.go @@ -131,12 +131,12 @@ func TestPtrField(t *testing.T) { } -func TestText(t *testing.T) { - - input := makeMyType() - - verifyText(t, &input) -} +//func TestText(t *testing.T) { +// +// input := makeMyType() +// +// verifyText(t, &input) +//} func TestFloat(t *testing.T) { diff --git a/tests/filelist.proto b/tests/filelist.proto new file mode 100644 index 0000000..2533fb1 --- /dev/null +++ b/tests/filelist.proto @@ -0,0 +1,2 @@ +import "type.proto" +import "msg.proto" \ No newline at end of file diff --git a/tests/msg.proto b/tests/msg.proto new file mode 100644 index 0000000..7654256 --- /dev/null +++ b/tests/msg.proto @@ -0,0 +1,11 @@ + +[AutoMsgID MsgDir: "client -> game"] +struct LoginREQ { + +} + +[AutoMsgID] +struct LoginACK { + +} + diff --git a/tests/pb_gen.proto b/tests/pb_gen.proto index d512b8a..454e333 100644 --- a/tests/pb_gen.proto +++ b/tests/pb_gen.proto @@ -2,7 +2,7 @@ // DO NOT EDIT! syntax = "proto3"; -option go_package= ".;proto"; +option go_package= "./;proto"; package proto; diff --git a/tests/reg_gen.go b/tests/reg_gen.go index efead79..cb15c4a 100644 --- a/tests/reg_gen.go +++ b/tests/reg_gen.go @@ -16,33 +16,38 @@ var ( func init() { cellmeta.Register(&cellmeta.Meta{ - Codec: cellcodec.MustGetByName("protoplus"), - Type: reflect.TypeOf((*MyTypeMini)(nil)).Elem(), - ID: 0, - New: func() interface{} { return &MyTypeMini{} }, + FullName: "tests.MyTypeMini", + ID: 0, + New: func() interface{} { return &MyTypeMini{} }, + Type: reflect.TypeOf((*MyTypeMini)(nil)).Elem(), + Codec: cellcodec.MustGetByName("protoplus"), }) cellmeta.Register(&cellmeta.Meta{ - Codec: cellcodec.MustGetByName("protoplus"), - Type: reflect.TypeOf((*MySubType)(nil)).Elem(), - ID: 0, - New: func() interface{} { return &MySubType{} }, + FullName: "tests.MySubType", + ID: 0, + New: func() interface{} { return &MySubType{} }, + Type: reflect.TypeOf((*MySubType)(nil)).Elem(), + Codec: cellcodec.MustGetByName("protoplus"), }) cellmeta.Register(&cellmeta.Meta{ - Codec: cellcodec.MustGetByName("protoplus"), - Type: reflect.TypeOf((*MyType)(nil)).Elem(), - ID: 0, - New: func() interface{} { return &MyType{} }, + FullName: "tests.MyType", + ID: 0, + New: func() interface{} { return &MyType{} }, + Type: reflect.TypeOf((*MyType)(nil)).Elem(), + Codec: cellcodec.MustGetByName("protoplus"), }) cellmeta.Register(&cellmeta.Meta{ - Codec: cellcodec.MustGetByName("protoplus"), - Type: reflect.TypeOf((*LoginREQ)(nil)).Elem(), - ID: 17076, - New: func() interface{} { return &LoginREQ{} }, + FullName: "tests.LoginREQ", + ID: 17076, + New: func() interface{} { return &LoginREQ{} }, + Type: reflect.TypeOf((*LoginREQ)(nil)).Elem(), + Codec: cellcodec.MustGetByName("protoplus"), }) cellmeta.Register(&cellmeta.Meta{ - Codec: cellcodec.MustGetByName("protoplus"), - Type: reflect.TypeOf((*LoginACK)(nil)).Elem(), - ID: 44443, - New: func() interface{} { return &LoginACK{} }, + FullName: "tests.LoginACK", + ID: 44443, + New: func() interface{} { return &LoginACK{} }, + Type: reflect.TypeOf((*LoginACK)(nil)).Elem(), + Codec: cellcodec.MustGetByName("protoplus"), }) } diff --git a/tests/code.proto b/tests/type.proto similarity index 86% rename from tests/code.proto rename to tests/type.proto index 978a15d..3f0ff54 100644 --- a/tests/code.proto +++ b/tests/type.proto @@ -93,24 +93,3 @@ struct MyType EnumSlice []MyEnum } - -[AutoMsgID MsgDir: "client -> game"] -struct LoginREQ { - -} - -[AutoMsgID] -struct LoginACK { - -} - - - - - -service login -{ - LoginStd(LoginREQ) LoginACK - rpc Login - -} \ No newline at end of file