Skip to content

Commit

Permalink
适配cellnet5
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed Apr 22, 2021
1 parent 6ce59c7 commit e1ded6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions gen/ppgo/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,23 @@ func (self *{{.Name}}) Unmarshal(buffer *wire.Buffer, fieldIndex uint64, wt wire
const RegTemplateText = `// Generated by github.com/davyxu/protoplus
package {{.PackageName}}
import (
"github.com/davyxu/cellnet"
import (
"github.com/davyxu/cellnet/codec"
"github.com/davyxu/cellnet/meta"
"reflect"
)
var (
_ cellnet.MessageMeta
_ codec.CodecRecycler
_ cellmeta.Meta
_ cellcodec.CodecRecycler
_ reflect.Kind
)
func init() {
{{range .Structs}}
cellnet.RegisterMessageMeta(&cellnet.MessageMeta{
Codec: codec.MustGetCodec("{{StructCodec .}}"),
cellmeta.Register(&cellmeta.Meta{
Codec: cellcodec.MustGetByName("{{StructCodec .}}"),
Type: reflect.TypeOf((*{{.Name}})(nil)).Elem(),
ID: {{StructMsgID .}},
New: func() interface{} { return &{{.Name}}{} },
Expand Down
12 changes: 6 additions & 6 deletions tests/reg_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@ import (
)

var (
_ cellnet.MessageMeta
_ cellmeta.Meta
_ codec.CodecRecycler
_ reflect.Kind
)

func init() {

cellnet.RegisterMessageMeta(&cellnet.MessageMeta{
cellnet.RegisterMessageMeta(&cellmeta.Meta{
Codec: codec.MustGetCodec("protoplus"),
Type: reflect.TypeOf((*MyTypeMini)(nil)).Elem(),
ID: 0,
New: func() interface{} { return &MyTypeMini{} },
})
cellnet.RegisterMessageMeta(&cellnet.MessageMeta{
cellnet.RegisterMessageMeta(&cellmeta.Meta{
Codec: codec.MustGetCodec("protoplus"),
Type: reflect.TypeOf((*MySubType)(nil)).Elem(),
ID: 0,
New: func() interface{} { return &MySubType{} },
})
cellnet.RegisterMessageMeta(&cellnet.MessageMeta{
cellnet.RegisterMessageMeta(&cellmeta.Meta{
Codec: codec.MustGetCodec("protoplus"),
Type: reflect.TypeOf((*MyType)(nil)).Elem(),
ID: 0,
New: func() interface{} { return &MyType{} },
})
cellnet.RegisterMessageMeta(&cellnet.MessageMeta{
cellnet.RegisterMessageMeta(&cellmeta.Meta{
Codec: codec.MustGetCodec("protoplus"),
Type: reflect.TypeOf((*LoginREQ)(nil)).Elem(),
ID: 17076,
New: func() interface{} { return &LoginREQ{} },
})
cellnet.RegisterMessageMeta(&cellnet.MessageMeta{
cellnet.RegisterMessageMeta(&cellmeta.Meta{
Codec: codec.MustGetCodec("protoplus"),
Type: reflect.TypeOf((*LoginACK)(nil)).Elem(),
ID: 44443,
Expand Down

0 comments on commit e1ded6e

Please sign in to comment.