protocol

package
v0.3.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 32 Imported by: 6

Documentation

Index

Constants

View Source
const (
	REQ_TYPE_REPLAY = 0
	REQ_TYPE_MAIN   = 1
)
View Source
const (
	TS_CLASSOBJ_HEADER = iota
	TS_CLASSOBJ_DEFINER
	TS_CLASSOBJ_MEMBER_FIELD
	TS_CLASSOBJ_CONSTRUCTOR
	TS_CLASSOBJ_GETTER_SETTER
	TS_CLASSOBJ_FUNCTION
	TS_CLASSOBJ_CLASS_END
)
View Source
const (
	AUTH_STATE_CONNECTED uint8 = 0
	AUTH_STATE_AUTHING   uint8 = 1
	AUTH_STATE_AUTHED    uint8 = 2
)
View Source
const (
	ROUTE_MSG_HEAD_SIZE  int = 25
	BINARY_MSG_HEAD_SIZE int = 8
)
View Source
const (
	// len 2 transId 4
	HEADER_SIZE        = 2 + 4
	MAX_PACKET_SIZE    = 20 * 1024
	DEFAULT_PACKET_LEN = 2048 * 4
	ROUTE_MSG_ADDITION = 2 + 8 + 8
)

Variables

View Source
var (
	ERR_SUCC = CreateError(0, "操作成功")

	//inner error
	ERR_TYPE_NOT_FOUND  = CreateError(-1, "type not found")
	ERR_RPC_TIMEOUT     = CreateError(-2, "rpc timeout")
	ERR_PACKAGE_FORMAT  = CreateError(-3, "wrong packet format")
	ERR_INTERNAL_ERROR  = CreateError(-4, "internal error")
	ERR_ACTOR_NOT_FOUND = CreateError(-101, "actor not found")
	ERR_RPC_FAILED      = CreateError(-102, "rpc failed")

	ERR_JSON_MARSHAL_FAILED = CreateError(-202, "json marshal failed")
	// msg
	ERR_MSG_ROUTE_NOT_FOUND = CreateError(-6001, "msg route local not found avatar")

	// service
	ERR_REGISTER_SERVICE_DUPLICATED   = CreateError(-7001, "service register duplicate")
	ERR_REGISTER_SERVICE_INFO_INVALID = CreateError(-7002, "service info invalid")
	ERR_REGISTER_SERVICE_NOT_FOUND    = CreateError(-7003, "service registered not found")

	ERR_REGISTER_ROUTE_USER_DUPLICATED = CreateError(-7101, "user route register duplicate")

	ERR_ETCD_ERROR       = CreateError(201, "数据错误")
	ERR_DB_ERROR         = CreateError(202, "数据库错误")
	ERR_CONFIG_ERROR     = CreateError(203, "配置错误")
	ERR_ACTOR_ID_INVALID = CreateError(211, "actorId无效")

	ERR_MSG_LEN_INVALID       = CreateError(301, "数据长度无效")
	ERR_MSG_HANDLER_NOT_FOUND = CreateError(302, "处理函数为空")

	ERR_MQ_ERROR               = CreateError(401, "消息队列错误")
	ERR_MQ_NOT_CONNECT         = CreateError(402, "消息队列未开启")
	ERR_MQ_ADD_ACTOR_DUPLICATE = CreateError(403, "消息队列重复添加玩家")
	ERR_MQ_SUBJ_NOT_FIND       = CreateError(404, "消息队列subj未找到")
	ERR_MQ_MARSHAL_ERROR       = CreateError(405, "消息队列序列化错误")
	ERR_MQ_UNMARSHAL_ERROR     = CreateError(406, "消息队列反序列化错误")
	ERR_MQ_REQUEST_ERROR       = CreateError(407, "消息队列请求出错")
	ERR_MQ_NOT_RELPY           = CreateError(408, "消息队列请求回复为空")
	ERR_MQ_SUBJ_PREFIX_ERR     = CreateError(409, "消息队列Key前缀错误")

	ERR_SERVICE_NOT_FOUND = CreateError(410, "服务器未找到")

	//cs error
	ERR_INTERNAL_SERVER        = CreateError(901, "服务器繁忙")
	ERR_TOKEN_EXPIRED          = CreateError(1001, "Token已过期")
	ERR_TOKEN_VALIDATE         = CreateError(1002, "Token无效")
	ERR_ACC_NOT_FIND           = CreateError(1003, "找不到账户")
	ERR_GAME_ACC_NOT_FOUND     = CreateError(1004, "找不到游戏账户")
	ERR_GAME_ACC_EXIST         = CreateError(1011, "游戏账户已存在")
	ERR_GAME_ACC_CREATE_FAILED = CreateError(1012, "创建游戏账户失败")
	ERR_PARAM_NOT_EXIST        = CreateError(1101, "参数不存在")
	ERR_PARAM_TYPE             = CreateError(1102, "参数错误")
	ERR_ACC_AUTH               = CreateError(1103, "账户不存在或者密码错误")
	ERR_PASSWORD_EMPTY         = CreateError(1104, "需要输入密码")
	ERR_AUTH_FAILED            = CreateError(1201, "验证失败")
	ERR_MSG_FORMAT             = CreateError(1202, "数据格式错误")
	ERR_PROTOCOL_NOT_FOUND     = CreateError(1203, "协议未找到")
)
View Source
var COMMENT_REGEXP = regexp.MustCompile(`(.*)((//).*)`)
View Source
var ICOMPONENT_REGEXP = regexp.MustCompile(`Component`)
View Source
var ISERIALIZABLE_REGEXP = regexp.MustCompile(`Serializable`)

Functions

func CreateBinaryLongPacket

func CreateBinaryLongPacket(data []byte, idx int) ([]byte, error)

func CreateJsonLongPacket

func CreateJsonLongPacket(data []byte, idx int) ([]byte, error)

func CreateLongPacket

func CreateLongPacket(protocol TYPE) func(data []byte, idx int) ([]byte, error)

func GetLineRegExps

func GetLineRegExps() map[string]*regexp.Regexp

func GetTransId added in v0.3.6

func GetTransId(data []byte) uint32

func IsProtobuf

func IsProtobuf() bool

func LogActorRouterMsgInfo added in v0.3.34

func LogActorRouterMsgInfo(cmdId BINARY_TAG, transid uint32, fromActorId util.ID, toActorId util.ID, toPid util.ProcessId, isReq bool) log.ZapFields

func LogCmdId added in v0.3.34

func LogCmdId(cmd BINARY_TAG) zap.Field

func LogErrorCode added in v0.3.34

func LogErrorCode(err IError) zap.Field

func LogErrorInfo added in v0.3.34

func LogErrorInfo(err IError) []zap.Field

func LogErrorMessage added in v0.3.34

func LogErrorMessage(err IError) zap.Field

func LogMsgBody added in v0.3.34

func LogMsgBody(serializable ISerializable) zap.Field

func LogMsgDetail added in v0.3.34

func LogMsgDetail(serializable ISerializable) log.ZapFields

func LogMsgId added in v0.3.34

func LogMsgId(serializable ISerializable) zap.Field

func LogMsgInfo added in v0.3.34

func LogMsgInfo(serializable ISerializable) log.ZapFields

func LogMsgName added in v0.3.34

func LogMsgName(serializable ISerializable) zap.Field

func MarshalBinary

func MarshalBinary(s interface{}) ([]byte, error)

func MarshalBinaryMessage

func MarshalBinaryMessage(transId uint32, data interface{}) (ret []byte, err error)

func MarshalBody added in v0.3.9

func MarshalBody(body ISerializable, t TYPE) (bodyData []byte, err error)

func MarshalJsonMessage

func MarshalJsonMessage(transId uint32, data interface{}) (ret []byte, err error)

func MarshalJsonRouteMsg added in v0.2.35

func MarshalJsonRouteMsg(msg *RouteMessage) (ret []byte, err error)

func MarshalMessage

func MarshalMessage(transId uint32, data interface{}, t TYPE) (ret []byte, err error)

func MarshalRouteMsg added in v0.2.35

func MarshalRouteMsg(msg *RouteMessage, t TYPE) (ret []byte, err error)

func MatchGoProtoTag

func MatchGoProtoTag(s string) bool

func PickBinaryLongPacket

func PickBinaryLongPacket(data []byte) (bool, int, []byte)

func PickJsonLongPacket

func PickJsonLongPacket(data []byte) (bool, int, []byte)

func PickLongPacket

func PickLongPacket(protocol TYPE) func(data []byte) (bool, int, []byte)

func SetProtobuf

func SetProtobuf()

func SetTypeRegistry

func SetTypeRegistry(registry *TypeRegistry)

func Split

func Split(data []byte, atEOF bool) (advance int, token []byte, err error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) (err error)

func UnmarshalFromBytes

func UnmarshalFromBytes(data []byte, v interface{}) error

Types

type BINARY_LENGTH

type BINARY_LENGTH uint32

type BINARY_NAME_SIZE

type BINARY_NAME_SIZE int16

type BINARY_TAG

type BINARY_TAG uint16
const (
	//基础类型 0-40
	TAG_End BINARY_TAG = iota
	TAG_Bool
	TAG_Byte
	TAG_Short
	TAG_UShort
	TAG_Int
	TAG_UInt
	TAG_Long
	TAG_ULong
	TAG_Float
	TAG_Double
	TAG_String
	TAG_BoolArray
	TAG_ByteArray
	TAG_ShortArray
	TAG_UShortArray
	TAG_IntArray
	TAG_UIntArray
	TAG_LongArray
	TAG_ULongArray
	TAG_FloatArray
	TAG_DoubleArray
	TAG_List
	TAG_Map
	TAG_Buffer
	TAG_Time
	TAG_Decimal
	TAG_Proto
	TAG_Color
	TAG_Null
	TAG_LongString
	//Ecs
	TAG_EntityRef BINARY_TAG = 32
	//系统预留类型 40-127
	TAG_BinaryMessage BINARY_TAG = 40 //保留基本传输类型
	TAG_Error         BINARY_TAG = 41
	TAG_Compose       BINARY_TAG = 42
	TAG_Ping          BINARY_TAG = 43
	TAG_Pong          BINARY_TAG = 44
	TAG_HandShake     BINARY_TAG = 45
	TAG_RouteMessage  BINARY_TAG = 46
	TAG_OK            BINARY_TAG = 48
)

func GetCmdId

func GetCmdId(data []byte) BINARY_TAG

func GetCmdId16

func GetCmdId16(data []byte) BINARY_TAG

func GetCmdIdFromType

func GetCmdIdFromType(data interface{}) (BINARY_TAG, error)

func GetModelProtoTag

func GetModelProtoTag(s string) BINARY_TAG

func MatchGoSystemTag

func MatchGoSystemTag(s string) (BINARY_TAG, string, string)

func MatchModelProtoTag

func MatchModelProtoTag(s string) BINARY_TAG

func MatchModelSystemTag

func MatchModelSystemTag(s string) (BINARY_TAG, string, string)

func (BINARY_TAG) CsTypeString

func (tag BINARY_TAG) CsTypeString() string

func (BINARY_TAG) GoTypeString

func (tag BINARY_TAG) GoTypeString() string

func (BINARY_TAG) IsArrayLike

func (tag BINARY_TAG) IsArrayLike() bool

func (BINARY_TAG) IsBaseValue

func (tag BINARY_TAG) IsBaseValue() bool

func (BINARY_TAG) IsProto

func (tag BINARY_TAG) IsProto() bool

func (BINARY_TAG) MatchRegExp

func (this BINARY_TAG) MatchRegExp(str string) bool

func (BINARY_TAG) String

func (tag BINARY_TAG) String() string

func (BINARY_TAG) TsTagString

func (tag BINARY_TAG) TsTagString() string

func (BINARY_TAG) TsTypeString

func (tag BINARY_TAG) TsTypeString() string

type BinaryMessage

type BinaryMessage struct {
	ISerializable
	TransId uint32
	Len     uint16
	CmdId   BINARY_TAG
	Body    ISerializable
}

BinaryMessage base protocol

func UnmarshalBinaryMessage

func UnmarshalBinaryMessage(data []byte) (*BinaryMessage, error)

func UnmarshalJsonMessage

func UnmarshalJsonMessage(data []byte) (*BinaryMessage, error)

func UnmarshalMessage

func UnmarshalMessage(data []byte, t TYPE) (*BinaryMessage, error)

func (*BinaryMessage) GetId

func (this *BinaryMessage) GetId() (BINARY_TAG, error)

func (*BinaryMessage) Marshal

func (this *BinaryMessage) Marshal() ([]byte, error)

func (*BinaryMessage) Unmarshal

func (this *BinaryMessage) Unmarshal(from []byte) error

type CommentObject

type CommentObject struct {
	DefaultGeneratorObj
	// contains filtered or unexported fields
}

func NewCommentObject

func NewCommentObject(file GeneratorFile) *CommentObject

func (*CommentObject) CheckLine

func (this *CommentObject) CheckLine(line *LineText) bool

type ComposeData

type ComposeData struct {
	Idx  uint32
	Data []byte
}

func (*ComposeData) GetId

func (this *ComposeData) GetId() (BINARY_TAG, error)

func (*ComposeData) Marshal

func (this *ComposeData) Marshal() ([]byte, error)

func (*ComposeData) Serializable

func (this *ComposeData) Serializable() ISerializable

func (*ComposeData) Unmarshal

func (this *ComposeData) Unmarshal(from []byte) error

type Compression

type Compression byte
const (
	Uncompressed Compression = 0
	GZip         Compression = 1
	ZLib         Compression = 2
)

type ConfFile

type ConfFile struct {
	*DefaultGeneratorFile
	TagName     string
	PackageName string
	Offset      int
	Recursive   bool
}

func NewConfFile

func NewConfFile(generator *Generator) *ConfFile

func (*ConfFile) Parse

func (this *ConfFile) Parse() *promise.Promise[interface{}]

type ConfObject

type ConfObject struct {
	DefaultGeneratorObj
}

func NewConfObject

func NewConfObject(file GeneratorFile) *ConfObject

func (*ConfObject) CheckLine

func (this *ConfObject) CheckLine(line *LineText) bool

type DefaultGeneratorFile

type DefaultGeneratorFile struct {
	GeneratorFile

	FileType   FileType
	FilePath   string
	IsDir      bool
	Generator  *Generator
	DirPath    string
	FileName   string
	LineLength int
	Lines      []*LineText
	Objects    []GeneratorObject
	// contains filtered or unexported fields
}

func NewGeneratorFile

func NewGeneratorFile(generator *Generator) *DefaultGeneratorFile

func (*DefaultGeneratorFile) AddObject

func (this *DefaultGeneratorFile) AddObject(obj GeneratorObject)

func (*DefaultGeneratorFile) CheckFinish

func (this *DefaultGeneratorFile) CheckFinish(offset int) bool

func (*DefaultGeneratorFile) Generate

func (this *DefaultGeneratorFile) Generate(typ FileType) *promise.Promise[interface{}]

func (*DefaultGeneratorFile) GetFile

func (this *DefaultGeneratorFile) GetFile() GeneratorFile

func (*DefaultGeneratorFile) GetFilePath

func (this *DefaultGeneratorFile) GetFilePath() string

func (*DefaultGeneratorFile) GetGoRelativePath

func (this *DefaultGeneratorFile) GetGoRelativePath() string

func (*DefaultGeneratorFile) GetLines

func (this *DefaultGeneratorFile) GetLines() []*LineText

func (*DefaultGeneratorFile) GetLogger added in v0.1.31

func (this *DefaultGeneratorFile) GetLogger() log.ILogger

func (*DefaultGeneratorFile) GetObj

func (this *DefaultGeneratorFile) GetObj(objType ObjectType) []GeneratorObject

func (*DefaultGeneratorFile) GetTsRelativePath

func (this *DefaultGeneratorFile) GetTsRelativePath() string

func (*DefaultGeneratorFile) InsertAfter

func (this *DefaultGeneratorFile) InsertAfter(obj GeneratorObject, after GeneratorObject)

func (*DefaultGeneratorFile) InsertObject

func (this *DefaultGeneratorFile) InsertObject(pos int, obj GeneratorObject)

func (*DefaultGeneratorFile) Load

func (this *DefaultGeneratorFile) Load(path string) *promise.Promise[interface{}]

func (*DefaultGeneratorFile) MarshalToFile

func (this *DefaultGeneratorFile) MarshalToFile(path string) *promise.Promise[interface{}]

func (*DefaultGeneratorFile) Parse

func (this *DefaultGeneratorFile) Parse() *promise.Promise[interface{}]

func (*DefaultGeneratorFile) RemoveAutoGenHeader

func (this *DefaultGeneratorFile) RemoveAutoGenHeader()

func (*DefaultGeneratorFile) RemoveObjByCondition

func (this *DefaultGeneratorFile) RemoveObjByCondition(condition GenerateObjRemoveCondition)

func (*DefaultGeneratorFile) RemoveObjType

func (this *DefaultGeneratorFile) RemoveObjType(objType ObjectType)

func (*DefaultGeneratorFile) SetGenerator

func (this *DefaultGeneratorFile) SetGenerator(generator *Generator)

type DefaultGeneratorObj

type DefaultGeneratorObj struct {
	// contains filtered or unexported fields
}

func (*DefaultGeneratorObj) AddLine

func (this *DefaultGeneratorObj) AddLine(line *LineText, lineType LineType) *LineText

func (*DefaultGeneratorObj) CheckLine

func (this *DefaultGeneratorObj) CheckLine(line *LineText) bool

func (*DefaultGeneratorObj) File

func (this *DefaultGeneratorObj) File() GeneratorFile

func (*DefaultGeneratorObj) GenerateToObject

func (this *DefaultGeneratorObj) GenerateToObject(typ ObjectType) GeneratorObject

func (*DefaultGeneratorObj) GetFile

func (this *DefaultGeneratorObj) GetFile() GeneratorFile

func (*DefaultGeneratorObj) GetLines

func (this *DefaultGeneratorObj) GetLines(lineType LineType) []*LineText

func (*DefaultGeneratorObj) GetLogger added in v0.1.31

func (this *DefaultGeneratorObj) GetLogger() log.ILogger

func (*DefaultGeneratorObj) InsertAfter

func (this *DefaultGeneratorObj) InsertAfter(line *LineText, after *LineText) *LineText

func (*DefaultGeneratorObj) InsertLine

func (this *DefaultGeneratorObj) InsertLine(pos int, line *LineText) *LineText

func (*DefaultGeneratorObj) Lines

func (this *DefaultGeneratorObj) Lines() []*LineText

func (*DefaultGeneratorObj) Name

func (this *DefaultGeneratorObj) Name() string

func (*DefaultGeneratorObj) ObjectType

func (this *DefaultGeneratorObj) ObjectType() ObjectType

func (*DefaultGeneratorObj) RemoveLineType

func (this *DefaultGeneratorObj) RemoveLineType(lineType LineType) []*LineText

func (*DefaultGeneratorObj) String

func (this *DefaultGeneratorObj) String() string

func (*DefaultGeneratorObj) TryAddLine

func (this *DefaultGeneratorObj) TryAddLine(line *LineText, lineType LineType) bool

func (*DefaultGeneratorObj) TryAddLineStrict

func (this *DefaultGeneratorObj) TryAddLineStrict(line *LineText, lineType LineType) bool

type EmptyObject

type EmptyObject struct {
	DefaultGeneratorObj
}

func NewEmptyObject

func NewEmptyObject(file GeneratorFile) *EmptyObject

func (*EmptyObject) CheckLine

func (this *EmptyObject) CheckLine(line *LineText) bool

type Enum

type Enum int32

func (Enum) Enum added in v0.1.13

func (this Enum) Enum() Enum

type EnumCollection added in v0.2.2

type EnumCollection[T IEnum] struct {
	Collection []T
}

func NewEnumCollection added in v0.2.2

func NewEnumCollection[T IEnum](colletion []T) EnumCollection[T]

func (EnumCollection[T]) GetEnumByString added in v0.2.2

func (this EnumCollection[T]) GetEnumByString(s string) T

func (EnumCollection[T]) GetEnumByValue added in v0.2.2

func (this EnumCollection[T]) GetEnumByValue(s Enum) T

func (EnumCollection[T]) Has added in v0.2.2

func (this EnumCollection[T]) Has(i int32) bool

type ErrCode

type ErrCode int

func CreateError

func CreateError(code ErrCode, msg string) ErrCode

func (ErrCode) ErrCode

func (this ErrCode) ErrCode() int

func (ErrCode) Error

func (this ErrCode) Error() string

func (ErrCode) Is

func (this ErrCode) Is(err error) bool

func (ErrCode) Message added in v0.3.27

func (this ErrCode) Message() string

func (ErrCode) NewErrMsg

func (this ErrCode) NewErrMsg() *ErrMsg

type ErrMsg

type ErrMsg struct {
	Code    int32
	Message string
}

func NewError

func NewError(code ErrCode) *ErrMsg

func NewErrorMsg

func NewErrorMsg(code int32, message string) *ErrMsg

func (*ErrMsg) ErrCode

func (this *ErrMsg) ErrCode() int

func (*ErrMsg) Error

func (this *ErrMsg) Error() string

func (*ErrMsg) GetId

func (this *ErrMsg) GetId() (BINARY_TAG, error)

func (*ErrMsg) Is added in v0.0.6

func (this *ErrMsg) Is(err error) bool

func (*ErrMsg) Marshal

func (this *ErrMsg) Marshal() ([]byte, error)

func (*ErrMsg) Serializable

func (this *ErrMsg) Serializable() ISerializable

func (*ErrMsg) Unmarshal

func (this *ErrMsg) Unmarshal(from []byte) error

type Fields

type Fields map[string]string

type FileType

type FileType int
const (
	FILE_UNDEFINED FileType = iota
	FILE_CONFIG
	FILE_GO_MODEL
	FILE_GO_IDS
	FILE_TS_MODEL
	FILE_TS_ENUM
	FILE_TS_IDS
	FILE_PROTO
	FILE_PROTO_IDS
	FILE_MODEL
)

func (FileType) String

func (this FileType) String() string

type GenType

type GenType int
const (
	GEN_UNDEFINED GenType = iota
	GEN_GO
	GEN_TS
	GEN_JSON
	GEN_CS
)

type GenerateObjRemoveCondition

type GenerateObjRemoveCondition func(object GeneratorObject) bool

type Generator

type Generator struct {
	CsCamelCase         bool
	Models              map[string]GeneratorFile
	GoModels            map[string]GeneratorFile
	Protos              map[string]GeneratorFile
	GoIds               *GoIdsFile
	ProtoIds            *ProtoIdsFile
	Conf                *ConfFile
	GoStructObjects     []*GoStructObject
	GoEnumObjects       []*GoEnumObject
	ProtoMsgObjects     []*ProtoMsgObject
	ModelClassObjects   []*ModelClassObject
	ModelEnumObjects    []*ModelEnumObject
	ModelIdsObjects     map[uint16]*ModelId
	ModelErrorObjects   map[int]*ModelError
	ModelPackages       map[string]*ModelPackageObject
	TsGenerateFilePaths []string
	CsImpl              bool
	TsModels            []*TsModelFile
	TsIds               *TsIdsFile
	TsEnums             *TsEnumFile
	TsClassObjects      []*TsClassObject
	TsEnumObjects       []*TsEnumObject

	Individual bool
	GoPath     string
	TsPath     string
	ProtoPath  string
	ModelPaths []string
	CsPath     string

	Proto2GoCmdLinExec func(pack, protoPath, GoPath string) error
	Proto2TsCmdLinExec func(pack, protoPath, GoPath string) error
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator() *Generator

func (*Generator) Clear

func (this *Generator) Clear()

func (*Generator) GenerateModel2Cs

func (this *Generator) GenerateModel2Cs() error

func (*Generator) GenerateModel2Go

func (this *Generator) GenerateModel2Go() error

func (*Generator) GenerateModel2Ts

func (this *Generator) GenerateModel2Ts() error

func (*Generator) GetEnumByName added in v0.1.25

func (this *Generator) GetEnumByName(s string) *ModelEnumObject

func (*Generator) GetErrorName added in v0.0.6

func (this *Generator) GetErrorName(id int) string

func (*Generator) GetLogger added in v0.1.31

func (this *Generator) GetLogger() log.ILogger

func (*Generator) GetModelByName added in v0.1.25

func (this *Generator) GetModelByName(s string) *ModelClassObject

func (*Generator) IsEnum added in v0.0.6

func (this *Generator) IsEnum(s string) bool

func (*Generator) IsErrorName added in v0.0.6

func (this *Generator) IsErrorName(s string) bool

func (*Generator) LoadAndParseTsFile

func (this *Generator) LoadAndParseTsFile(modelsPath string) (*TsModelFile, error)

func (*Generator) LoadCsFolder

func (this *Generator) LoadCsFolder(p string) *promise.Promise[interface{}]

func (*Generator) LoadGo2TsModels

func (this *Generator) LoadGo2TsModels(p string) error

func (*Generator) LoadModelFolder

func (this *Generator) LoadModelFolder(p ...string) *promise.Promise[interface{}]

func (*Generator) LoadModels

func (this *Generator) LoadModels(p []string) error

func (*Generator) LoadTsFolder added in v0.1.26

func (this *Generator) LoadTsFolder(p string) *promise.Promise[interface{}]

func (*Generator) LoadTsIds added in v0.1.31

func (this *Generator) LoadTsIds(p string) error

func (*Generator) ProcessModelPackages added in v0.3.14

func (this *Generator) ProcessModelPackages() error

func (*Generator) SetLogger added in v0.1.31

func (this *Generator) SetLogger(logger log.ILogger)

func (*Generator) SetOption

func (this *Generator) SetOption(opt GeneratorOption)

func (*Generator) SetProto2GoCmdLine

func (this *Generator) SetProto2GoCmdLine(f func(pack, protoPath, GoPath string) error)

func (*Generator) SetProto2TsCmdLine

func (this *Generator) SetProto2TsCmdLine(f func(pack, protoPath, TsPath string) error)

type GeneratorFile

type GeneratorFile interface {
	GetLogger() log.ILogger
	Parse() *promise.Promise[interface{}]
	Load(string) *promise.Promise[interface{}]
	GetFilePath() string
	GetTsRelativePath() string
	GetGoRelativePath() string
	SetGenerator(generator *Generator)
	GetLines() []*LineText
	GetFile() GeneratorFile
	AddObject(obj GeneratorObject)
	InsertObject(pos int, obj GeneratorObject)
}

type GeneratorObject

type GeneratorObject interface {
	Name() string
	File() GeneratorFile
	ObjectType() ObjectType
	GenerateToObject(typ ObjectType) GeneratorObject
	Lines() []*LineText
	GetLines(lineType LineType) []*LineText
	CheckLine(line *LineText) bool
	AddLine(line *LineText, lineType LineType) *LineText
	TryAddLine(line *LineText, lineType LineType) bool
	RemoveLineType(lineType LineType) []*LineText
	InsertLine(pos int, line *LineText) *LineText
	InsertAfter(line *LineText, after *LineText) *LineText
	String() string
}

type GeneratorOption

type GeneratorOption struct {
	SourcePath string
	DestPath   string
}

type GoAssignedId

type GoAssignedId struct {
	Tag     string
	Struct  string
	Package string
	Value   int
	Line    int
}

type GoDefineObject

type GoDefineObject struct {
	DefaultGeneratorObj
}

func NewGoDefineObject

func NewGoDefineObject(file GeneratorFile) *GoDefineObject

func (*GoDefineObject) CheckLine

func (this *GoDefineObject) CheckLine(line *LineText) bool

type GoEnumObject

type GoEnumObject struct {
	DefaultGeneratorObj
	// contains filtered or unexported fields
}

func NewGoEnumObject

func NewGoEnumObject(file GeneratorFile) *GoEnumObject

func (*GoEnumObject) CheckLine

func (this *GoEnumObject) CheckLine(line *LineText) bool

func (*GoEnumObject) Type

func (this *GoEnumObject) Type() string

type GoFuncObject

type GoFuncObject struct {
	DefaultGeneratorObj
}

func NewGoFuncObject

func NewGoFuncObject(file GeneratorFile) *GoFuncObject

func (*GoFuncObject) CheckLine

func (this *GoFuncObject) CheckLine(line *LineText) bool

type GoIdObject

type GoIdObject struct {
	DefaultGeneratorObj
}

func NewGoIdObject

func NewGoIdObject(file GeneratorFile) *GoIdObject

func (*GoIdObject) CheckLine

func (this *GoIdObject) CheckLine(line *LineText) bool

type GoIdRegObject

type GoIdRegObject struct {
	DefaultGeneratorObj
}

func NewGoIdRegObject

func NewGoIdRegObject(file GeneratorFile) *GoIdRegObject

func (*GoIdRegObject) CheckLine

func (this *GoIdRegObject) CheckLine(line *LineText) bool

type GoIdsFile

type GoIdsFile struct {
	*DefaultGeneratorFile
	TagName       string
	Offset        int
	AssignedIds   []*GoAssignedId
	AssignedTypes []*GoAssignedId
	MinId         int
	MaxId         int
}

func NewGoIdsFile

func NewGoIdsFile(generator *Generator) *GoIdsFile

func (*GoIdsFile) Generate

func (this *GoIdsFile) Generate() *promise.Promise[interface{}]

func (*GoIdsFile) Parse

func (this *GoIdsFile) Parse() *promise.Promise[interface{}]

func (*GoIdsFile) ProcessIds

func (this *GoIdsFile) ProcessIds()

type GoImportObject

type GoImportObject struct {
	DefaultGeneratorObj
}

func NewGoImportObject

func NewGoImportObject(file GeneratorFile) *GoImportObject

func (*GoImportObject) CheckLine

func (this *GoImportObject) CheckLine(line *LineText) bool

type GoInterfaceObject

type GoInterfaceObject struct {
	DefaultGeneratorObj
	// contains filtered or unexported fields
}

func NewGoInterfaceObject

func NewGoInterfaceObject(file GeneratorFile) *GoInterfaceObject

func (*GoInterfaceObject) CheckLine

func (this *GoInterfaceObject) CheckLine(line *LineText) bool

type GoModelFile

type GoModelFile struct {
	*DefaultGeneratorFile
}

func NewGoModelFile

func NewGoModelFile(generator *Generator) *GoModelFile

func (*GoModelFile) Generate

func (this *GoModelFile) Generate() *promise.Promise[interface{}]

func (*GoModelFile) Parse

func (this *GoModelFile) Parse() *promise.Promise[interface{}]

func (*GoModelFile) ProcessEnum

func (this *GoModelFile) ProcessEnum() []*GoEnumObject

func (*GoModelFile) ProcessStruct

func (this *GoModelFile) ProcessStruct() []*GoStructObject

type GoPackageObject

type GoPackageObject struct {
	DefaultGeneratorObj
	// contains filtered or unexported fields
}

func NewGoPackageObject

func NewGoPackageObject(file GeneratorFile) *GoPackageObject

func (*GoPackageObject) CheckLine

func (this *GoPackageObject) CheckLine(line *LineText) bool

type GoStructFields

type GoStructFields struct {
	Name    string
	Type    string
	Package string
	Index   int
}

type GoStructFuncObject

type GoStructFuncObject struct {
	DefaultGeneratorObj
}

func NewGoStructFuncObject

func NewGoStructFuncObject(file GeneratorFile) *GoStructFuncObject

func (*GoStructFuncObject) CheckLine

func (this *GoStructFuncObject) CheckLine(line *LineText) bool

type GoStructObject

type GoStructObject struct {
	DefaultGeneratorObj
	TagId BINARY_TAG

	Fields        []*GoStructFields
	Package       string
	StructName    string
	ISerializable bool
	IComponent    bool
	// contains filtered or unexported fields
}

func NewGoStructObject

func NewGoStructObject(file GeneratorFile) *GoStructObject

func (*GoStructObject) CheckLine

func (this *GoStructObject) CheckLine(line *LineText) bool

func (*GoStructObject) IsModel

func (this *GoStructObject) IsModel() bool

func (*GoStructObject) SetPackage

func (this *GoStructObject) SetPackage(pack string)

type GoVarObject

type GoVarObject struct {
	DefaultGeneratorObj
}

func NewGoVarObject

func NewGoVarObject(file GeneratorFile) *GoVarObject

func (*GoVarObject) CheckLine

func (this *GoVarObject) CheckLine(line *LineText) bool

type HandShake

type HandShake struct {
	Data []byte
}

func (*HandShake) GetId

func (this *HandShake) GetId() (BINARY_TAG, error)

func (*HandShake) Marshal

func (this *HandShake) Marshal() ([]byte, error)

func (*HandShake) Serializable

func (this *HandShake) Serializable() ISerializable

func (*HandShake) Unmarshal

func (this *HandShake) Unmarshal(from []byte) error

type IEnum added in v0.1.13

type IEnum interface {
	ToString() string
	Enum() Enum
}

type IEnumCollection added in v0.1.24

type IEnumCollection []IEnum

func GetAllLineRegExpEnums added in v0.1.25

func GetAllLineRegExpEnums() IEnumCollection

func (IEnumCollection) GetEnumByString added in v0.1.24

func (this IEnumCollection) GetEnumByString(s string) IEnum

func (IEnumCollection) GetEnumByValue added in v0.1.24

func (this IEnumCollection) GetEnumByValue(s Enum) IEnum

func (IEnumCollection) Has added in v0.2.1

func (this IEnumCollection) Has(i int32) bool

type IError

type IError interface {
	Error() string
	ErrCode() int
	Is(e error) bool
}

type ISerializable

type ISerializable interface {
	GetId() (BINARY_TAG, error)
	Serializable() ISerializable
}

func UnmarshJsonBody added in v0.3.28

func UnmarshJsonBody(cmdId BINARY_TAG, body []byte) (ISerializable, error)

func UnmarshalBody added in v0.3.28

func UnmarshalBody(cmdId BINARY_TAG, body []byte, t TYPE) (ISerializable, error)

type LineText

type LineText struct {
	Obj         GeneratorObject
	LineNum     int
	Text        string
	LineType    LineType
	PackageName string
	StructName  string
	Name        string
	TagName     string
	Value       int
	Type        string
	Comment     string
}

func (*LineText) GetName

func (this *LineText) GetName() string

func (*LineText) GetPkgName

func (this *LineText) GetPkgName() string

func (*LineText) GetStructName

func (this *LineText) GetStructName() string

func (*LineText) GetTagName

func (this *LineText) GetTagName() string

func (*LineText) GetTypeName

func (this *LineText) GetTypeName() string

func (*LineText) GetValue

func (this *LineText) GetValue() int

func (*LineText) IsBufferTag added in v0.1.33

func (this *LineText) IsBufferTag() bool

func (*LineText) IsLongStringTag

func (this *LineText) IsLongStringTag() bool

func (*LineText) ObjName

func (this *LineText) ObjName() string

func (*LineText) Parse

func (this *LineText) Parse() string

type LineType

type LineType int
const (
	LINE_UNDEFINED LineType = iota
	LINE_COMMENT
	LINE_COMMENT_START
	LINE_COMMENT_END
	LINE_ANY
	LINE_EMPTY
	LINE_GO_PACKAGE
	LINE_GO_IMPORT_HEADER
	LINE_GO_IMPORT_BODY
	LINE_GO_IMPORT_SINGLELINE
	LINE_GO_INTERFACE_HEADER
	LINE_GO_PUBLIC_STRUCT_HEADER
	LINE_GO_PRIVATE_STRUCT_HEADER
	LINE_GO_STRUCT_FIELD_INHERIT
	LINE_GO_STRUCT_FIELD_PUBLIC
	LINE_GO_STRUCT_FIELD_PRIVATE
	LINE_GO_FUNC_HEADER
	LINE_GO_INIT_FUNC_HEADER
	LINE_GO_STRUCT_FUNC_HEADER
	LINE_GO_DEFINER
	LINE_GO_ENUM_DEFINER
	LINE_GO_CONST
	LINE_GO_VARIABLE
	LINE_GO_TAG_DEFINER
	LINE_GO_TAG_REGISTRY
	LINE_GO_CONST_CLOSURE_START
	LINE_GO_VAR_CLOSURE_START
	LINE_GO_ENUM_VARIABLE_IOTA
	LINE_GO_ENUM_VARIABLE
	LINE_GO_ENUM_AUTO

	LINE_CONF_TAG
	LINE_CONF_PACKAGE
	LINE_CONF_OFFSET
	LINE_CONF_RECUR
	LINE_BRACKET_END
	LINE_CLOSURE_END

	LINE_TS_IMPORT_SINGLELINE
	LINE_TS_IMPORT_CLOSURE_START
	LINE_TS_IMPORT_CLOSURE_END
	LINE_TS_IMPORT_OBJ
	LINE_TS_ENUM_CLOSURE_START
	LINE_TS_ENUM_OBJ
	LINE_TS_CLASS_DECORATOR_COCOS
	LINE_TS_CLASS_DECORATOR
	LINE_TS_CLASS_HEADER
	LINE_TS_CLASS_CONSTRUCTOR_HEADER
	LINE_TS_CLASS_FIELD
	LINE_TS_CLASS_FIELD_PUBLIC
	LINE_TS_CLASS_FIELD_PRIVATE
	LINE_TS_CLASS_FIELD_PROTECTED
	LINE_TS_CLASS_GETTER_HEADER
	LINE_TS_CLASS_SETTER_HEADER
	LINE_TS_CLASS_FUNC_HEADER
	LINE_TS_CLASS_FUNC_END

	LINE_TS_FUNC_HEADER

	LINE_TS_VAR_SINGLELINE
	LINE_TS_VAR_CLOSURE_START
	LINE_TS_VAR_ARRAY_START
	LINE_TS_ARRAY_END

	LINE_TS_DEFINE_SINGLELINE
	LINE_TS_DEFINE_START
	LINE_TS_DEFINE_OBJ
	LINE_TS_DEFINE_END

	LINE_TS_ERRORS_HEADER
	LINE_TS_ERRORS_FIELD

	LINE_TS_INIT_FUNC_HEADER
	LINE_TS_INIT_FUNC_COCOS
	LINE_TS_INIT_FUNC_END
	LINE_TS_ID_REG
	LINE_TS_PROTO_ID_REG

	LINE_MODEL_PACKAGE
	LINE_MODEL_GOPACKAGE
	LINE_MODEL_CSPACKAGE
	LINE_MODEL_TSPACKAGE
	LINE_MODEL_IMPORTS
	LINE_MODEL_ERRORS_HEADER
	LINE_MODEL_ERROR
	LINE_MODEL_IDS_HEADER
	LINE_MODEL_ID
	LINE_MODEL_CLASS_HEADER
	LINE_MODEL_CLASS_FIELD
	LINE_MODEL_ENUM_HEADER
	LINE_MODEL_ENUM_FIELD

	LINE_PROTO_PACKAGE
	LINE_PROTO_HEADER
	LINE_PROTO_FIELD
	LINE_PROTO_ENUM_HEADER
	LINE_PROTO_ENUM_FIELD
	LINE_PROTO_ENUM_ALIAS
	LINE_PROTO_SYNTAX
	LINE_PROTO_ID
)

func (LineType) Parse

func (this LineType) Parse(origin string, args map[string]string) string

func (LineType) RegExp

func (this LineType) RegExp() *regexp.Regexp

func (LineType) RegMatch

func (this LineType) RegMatch(str string) bool

func (LineType) RegReplaceName

func (this LineType) RegReplaceName(str string) string

func (LineType) RegReplacePkg

func (this LineType) RegReplacePkg(str string) string

func (LineType) RegReplaceStructName

func (this LineType) RegReplaceStructName(str string) string

func (LineType) RegReplaceTagName

func (this LineType) RegReplaceTagName(str string) string

func (LineType) RegReplaceType

func (this LineType) RegReplaceType(str string) string

func (LineType) RegReplaceValue

func (this LineType) RegReplaceValue(str string) string

func (LineType) String

func (this LineType) String() string

type ModelClassFields

type ModelClassFields struct {
	Name    string
	Type    string
	Index   int
	Comment string
}

func (*ModelClassFields) CsString

func (this *ModelClassFields) CsString(g *Generator) string

func (*ModelClassFields) Deps added in v0.1.25

func (this *ModelClassFields) Deps(g *Generator) []string

TODO:dep

func (*ModelClassFields) GoString

func (this *ModelClassFields) GoString(g *Generator) string

func (*ModelClassFields) ParamAssignString

func (this *ModelClassFields) ParamAssignString(g *Generator) string

func (*ModelClassFields) ParamString

func (this *ModelClassFields) ParamString(g *Generator) string

func (*ModelClassFields) TsDefineTags added in v0.1.26

func (this *ModelClassFields) TsDefineTags(g *Generator, tsClass *TsClassObject) string

func (*ModelClassFields) TsPublicString added in v0.1.26

func (this *ModelClassFields) TsPublicString(g *Generator) string

func (*ModelClassFields) TsPublicType added in v0.1.26

func (this *ModelClassFields) TsPublicType(g *Generator) string

type ModelClassObject

type ModelClassObject struct {
	DefaultGeneratorObj
	TagId BINARY_TAG

	Fields    []*ModelClassFields
	Component bool
	Package   string
	CsPackage string
	GoPackage string
	TsPackage string
	ClassName string
	Comment   string
	Depends   []string
	// contains filtered or unexported fields
}

func NewModelClassObject

func NewModelClassObject(file GeneratorFile) *ModelClassObject

func (*ModelClassObject) CheckLine

func (this *ModelClassObject) CheckLine(line *LineText) bool

func (*ModelClassObject) CsImplString added in v0.3.27

func (this *ModelClassObject) CsImplString(g *Generator) string

func (*ModelClassObject) CsString

func (this *ModelClassObject) CsString(g *Generator) string

func (*ModelClassObject) Deps added in v0.1.25

func (this *ModelClassObject) Deps(g *Generator) []string

func (*ModelClassObject) GetPackageName added in v0.3.14

func (this *ModelClassObject) GetPackageName() string

func (*ModelClassObject) GoImplString

func (this *ModelClassObject) GoImplString(g *Generator) string

func (*ModelClassObject) GoString

func (this *ModelClassObject) GoString(g *Generator) string

func (*ModelClassObject) HashString added in v0.3.14

func (this *ModelClassObject) HashString() string

func (*ModelClassObject) SetPackage

func (this *ModelClassObject) SetPackage(pack string)

func (*ModelClassObject) SortString added in v0.3.14

func (this *ModelClassObject) SortString() string

func (*ModelClassObject) ToTsClassHeader added in v0.1.26

func (this *ModelClassObject) ToTsClassHeader(g *Generator, object *TsClassObject) string

func (*ModelClassObject) TsDefineEnd added in v0.1.26

func (this *ModelClassObject) TsDefineEnd(g *Generator) string

func (*ModelClassObject) TsDefineLines added in v0.1.26

func (this *ModelClassObject) TsDefineLines(g *Generator, tsClass *TsClassObject) []string

func (*ModelClassObject) TsDefineSingleLine added in v0.1.26

func (this *ModelClassObject) TsDefineSingleLine(g *Generator) string

func (*ModelClassObject) TsDefineStart added in v0.1.26

func (this *ModelClassObject) TsDefineStart(g *Generator) string

type ModelEnumObject

type ModelEnumObject struct {
	DefaultGeneratorObj

	Package   string
	CsPackage string
	GoPackage string
	TsPackage string
	EnumName  string
	Comment   string
	// contains filtered or unexported fields
}

func NewModelEnumObject

func NewModelEnumObject(file GeneratorFile) *ModelEnumObject

func (*ModelEnumObject) CheckLine

func (this *ModelEnumObject) CheckLine(line *LineText) bool

func (*ModelEnumObject) CsString

func (this *ModelEnumObject) CsString(g *Generator) string

func (*ModelEnumObject) GetPackageName added in v0.3.14

func (this *ModelEnumObject) GetPackageName() string

func (*ModelEnumObject) GoString

func (this *ModelEnumObject) GoString(g *Generator) string

func (*ModelEnumObject) HashString added in v0.3.14

func (this *ModelEnumObject) HashString() string

func (*ModelEnumObject) SetPackage

func (this *ModelEnumObject) SetPackage(pack string)

func (*ModelEnumObject) SortString added in v0.3.14

func (this *ModelEnumObject) SortString() string

func (*ModelEnumObject) TsString added in v0.1.26

func (this *ModelEnumObject) TsString(g *Generator) string

type ModelError added in v0.0.6

type ModelError struct {
	ErrorName   string
	ErrorId     int
	ErrorText   string
	PackageName string
}

func (*ModelError) CsString added in v0.0.6

func (this *ModelError) CsString(g *Generator) string

func (*ModelError) GetPackageName added in v0.3.14

func (this *ModelError) GetPackageName() string

func (*ModelError) GoString added in v0.0.6

func (this *ModelError) GoString(g *Generator) string

func (*ModelError) HashString added in v0.3.14

func (this *ModelError) HashString() string

func (*ModelError) SortString added in v0.3.14

func (this *ModelError) SortString() string

func (*ModelError) TsString added in v0.1.33

func (this *ModelError) TsString(g *Generator) string

type ModelErrorsObject added in v0.0.6

type ModelErrorsObject struct {
	DefaultGeneratorObj
	PackageName   string
	GoPackageName string
	CsPackageName string
	TsPackageName string
	Errors        map[int]*ModelError
}

func NewModelErrorsObject added in v0.0.6

func NewModelErrorsObject(file GeneratorFile) *ModelErrorsObject

func (*ModelErrorsObject) CheckLine added in v0.0.6

func (this *ModelErrorsObject) CheckLine(line *LineText) bool

type ModelFile

type ModelFile struct {
	*DefaultGeneratorFile
	Package   string
	GoPackage string
	CsPackage string
	TsPackage string
}

func NewModelFile

func NewModelFile(generator *Generator) *ModelFile

func (*ModelFile) Generate

func (this *ModelFile) Generate() *promise.Promise[interface{}]

func (*ModelFile) Parse

func (this *ModelFile) Parse() *promise.Promise[interface{}]

func (*ModelFile) ProcessEnums

func (this *ModelFile) ProcessEnums() []*ModelEnumObject

func (*ModelFile) ProcessErrors added in v0.0.6

func (this *ModelFile) ProcessErrors() []*ModelError

func (*ModelFile) ProcessIds

func (this *ModelFile) ProcessIds() []*ModelId

func (*ModelFile) ProcessImports added in v0.1.25

func (this *ModelFile) ProcessImports() []string

func (*ModelFile) ProcessModels

func (this *ModelFile) ProcessModels() []*ModelClassObject

func (*ModelFile) ProcessPackages

func (this *ModelFile) ProcessPackages() *ModelPackageObject

type ModelId

type ModelId struct {
	Name         string
	Id           int
	Type         string
	Resp         string
	Comment      string
	PackageName  string
	ClassObj     *ModelClassObject
	RespClassObj *ModelClassObject
}

func (*ModelId) Deps added in v0.1.25

func (this *ModelId) Deps(g *Generator) []string

func (*ModelId) GetCsIdRegisterString

func (this *ModelId) GetCsIdRegisterString(g *Generator) string

func (*ModelId) GetCsMessageRegisterString

func (this *ModelId) GetCsMessageRegisterString(g *Generator) string

func (*ModelId) GetCsProtocolFuncString

func (this *ModelId) GetCsProtocolFuncString(g *Generator) string

func (*ModelId) GetGoIdAssignString

func (this *ModelId) GetGoIdAssignString(g *Generator) string

func (*ModelId) GetGoIdRegisterString

func (this *ModelId) GetGoIdRegisterString(g *Generator) string

func (*ModelId) GetGoProtocolFuncString

func (this *ModelId) GetGoProtocolFuncString(g *Generator) string

func (*ModelId) GetPackageName added in v0.3.14

func (this *ModelId) GetPackageName() string

func (*ModelId) HashString added in v0.3.14

func (this *ModelId) HashString() string

func (*ModelId) SortString added in v0.3.14

func (this *ModelId) SortString() string

type ModelIdsObject

type ModelIdsObject struct {
	DefaultGeneratorObj

	PackageName string
	Ids         map[int]*ModelId
	// contains filtered or unexported fields
}

func NewModelIdsObject

func NewModelIdsObject(file GeneratorFile) *ModelIdsObject

func (*ModelIdsObject) CheckLine

func (this *ModelIdsObject) CheckLine(line *LineText) bool

func (*ModelIdsObject) Deps added in v0.1.25

func (this *ModelIdsObject) Deps(g *Generator) []string

type ModelImportObject

type ModelImportObject struct {
	DefaultGeneratorObj
	// contains filtered or unexported fields
}

func NewModelImportObject

func NewModelImportObject(file GeneratorFile) *ModelImportObject

func (*ModelImportObject) CheckLine

func (this *ModelImportObject) CheckLine(line *LineText) bool

type ModelPackageObject

type ModelPackageObject struct {
	DefaultGeneratorObj
	PackageName   string
	GoPackageName string
	CsPackageName string
	TsPackageName string
	Imports       map[string]*ModelPackageObject
	Ids           map[BINARY_TAG]*ModelId
	Errors        map[int]*ModelError
}

func NewModelPackageObject

func NewModelPackageObject(file GeneratorFile) *ModelPackageObject

func (*ModelPackageObject) CheckLine

func (this *ModelPackageObject) CheckLine(line *LineText) bool

func (*ModelPackageObject) CsErrorString added in v0.0.6

func (this *ModelPackageObject) CsErrorString(g *Generator) string

func (*ModelPackageObject) CsString

func (this *ModelPackageObject) CsString(g *Generator) string

func (*ModelPackageObject) GetCsFuncString

func (this *ModelPackageObject) GetCsFuncString(g *Generator) string

func (*ModelPackageObject) GetCsIdRegString

func (this *ModelPackageObject) GetCsIdRegString(g *Generator) string

func (*ModelPackageObject) GetCsMessageRegString

func (this *ModelPackageObject) GetCsMessageRegString(g *Generator) string

func (*ModelPackageObject) GetCsPackageName

func (this *ModelPackageObject) GetCsPackageName() string

func (*ModelPackageObject) GetGoFuncString

func (this *ModelPackageObject) GetGoFuncString(g *Generator) string

func (*ModelPackageObject) GetGoIdAssignString

func (this *ModelPackageObject) GetGoIdAssignString(g *Generator) string

func (*ModelPackageObject) GetGoIdRegString

func (this *ModelPackageObject) GetGoIdRegString(g *Generator) string

func (*ModelPackageObject) GetGoPackageName

func (this *ModelPackageObject) GetGoPackageName() string

func (*ModelPackageObject) GoErrorString added in v0.0.6

func (this *ModelPackageObject) GoErrorString(g *Generator) string

func (*ModelPackageObject) GoString

func (this *ModelPackageObject) GoString(g *Generator) string

TODO

func (*ModelPackageObject) HashString added in v0.3.14

func (this *ModelPackageObject) HashString() string

func (*ModelPackageObject) TsErrorString added in v0.1.33

func (this *ModelPackageObject) TsErrorString(g *Generator) string

func (*ModelPackageObject) TsString added in v0.1.26

func (this *ModelPackageObject) TsString(g *Generator) string

type OK added in v0.3.36

type OK struct {
	Msg string
}

func NewOK added in v0.3.36

func NewOK() *OK

func (*OK) GetId added in v0.3.36

func (this *OK) GetId() (BINARY_TAG, error)

func (*OK) Marshal added in v0.3.36

func (this *OK) Marshal() ([]byte, error)

func (*OK) Serializable added in v0.3.36

func (this *OK) Serializable() ISerializable

func (*OK) Unmarshal added in v0.3.36

func (this *OK) Unmarshal(from []byte) error

type ObjectId

type ObjectId struct {
	// contains filtered or unexported fields
}

A globally unique identifier for Objects.

func NewObjectId

func NewObjectId() ObjectId

News generates new ObjectID with a unique value.

func Parse

func Parse(input string) (o ObjectId, err error)

Parses a string and creates a new ObjectId.

func (ObjectId) Increment

func (o ObjectId) Increment() int32

func (ObjectId) Machine

func (o ObjectId) Machine() int32

func (ObjectId) Pid

func (o ObjectId) Pid() int32

func (ObjectId) String

func (o ObjectId) String() string

String returns the ObjectID id as a 24 byte hex string representation.

func (ObjectId) Timestamp

func (o ObjectId) Timestamp() int64

type ObjectType

type ObjectType int
const (
	OBJ_UNDEFINED ObjectType = iota
	OBJ_GO_PACKAGE
	OBJ_GO_IMPORTS
	OBJ_GO_INTERFACE
	OBJ_GO_STRUCT
	OBJ_GO_STRUCT_FUNC
	OBJ_GO_FUNC
	OBJ_GO_VAR
	OBJ_GO_ENUM
	OBJ_GO_ID
	OBJ_GO_ID_REG
	OBJ_GO_DEFINE
	OBJ_CONF

	OBJ_EMPTY
	OBJ_COMMENT

	OBJ_TS_CLASS
	OBJ_TS_IMPORTS
	OBJ_TS_VAR
	OBJ_TS_FUNC
	OBJ_TS_ENUM
	OBJ_TS_IDS
	OBJ_TS_ERRORS

	OBJ_MODEL_PACKAGE
	OBJ_MODEL_IMPORTS
	OBJ_MODEL_IDS
	OBJ_MODEL_ERRORS
	OBJ_MODEL_CLASS
	OBJ_MODEL_ENUM

	OBJ_PROTO_PACKAGE
	OBJ_PROTO_SYNTAX
	OBJ_PROTO_MSG
	OBJ_PROTO_IDS
	OBJ_PROTO_ENUM

	OBJ_PROTO_TS_INTERFACE
)

func (ObjectType) Create

func (this ObjectType) Create(file GeneratorFile) GeneratorObject

func (ObjectType) String

func (this ObjectType) String() string

type Ping

type Ping struct {
	Time time.Time
}

func (*Ping) GetId

func (this *Ping) GetId() (BINARY_TAG, error)

func (*Ping) Marshal

func (this *Ping) Marshal() ([]byte, error)

func (*Ping) Serializable

func (this *Ping) Serializable() ISerializable

func (*Ping) Unmarshal

func (this *Ping) Unmarshal(from []byte) error

type Pong

type Pong struct {
	Time time.Time
}

func (*Pong) GetId

func (this *Pong) GetId() (BINARY_TAG, error)

func (*Pong) Marshal

func (this *Pong) Marshal() ([]byte, error)

func (*Pong) Serializable

func (this *Pong) Serializable() ISerializable

func (*Pong) Unmarshal

func (this *Pong) Unmarshal(from []byte) error

type ProtoEnumObject

type ProtoEnumObject struct {
	DefaultGeneratorObj
	Alias  bool
	Fields []*ProtoField
}

func NewProtoEnumObject

func NewProtoEnumObject(file GeneratorFile) *ProtoEnumObject

func (*ProtoEnumObject) CheckField

func (this *ProtoEnumObject) CheckField(line *LineText)

func (*ProtoEnumObject) CheckLine

func (this *ProtoEnumObject) CheckLine(line *LineText) bool

type ProtoField

type ProtoField struct {
	Repeated bool
	Map      bool
	Proto    bool
	Enum     bool
	KeyType  string
	Type     string
	Id       int
}

type ProtoFile

type ProtoFile struct {
	*DefaultGeneratorFile
}

func NewProtoFile

func NewProtoFile(generator *Generator) *ProtoFile

func (*ProtoFile) Generate

func (this *ProtoFile) Generate() *promise.Promise[interface{}]

func (*ProtoFile) Parse

func (this *ProtoFile) Parse() *promise.Promise[interface{}]

func (*ProtoFile) ProcessProtos

func (this *ProtoFile) ProcessProtos() []*ProtoMsgObject

type ProtoIdsFile

type ProtoIdsFile struct {
	*DefaultGeneratorFile
	Ids map[int]string
}

func NewProtoIdsFile

func NewProtoIdsFile(generator *Generator) *ProtoIdsFile

func (*ProtoIdsFile) AddId

func (this *ProtoIdsFile) AddId(s string, id int)

func (*ProtoIdsFile) Generate

func (this *ProtoIdsFile) Generate() *promise.Promise[interface{}]

func (*ProtoIdsFile) Parse

func (this *ProtoIdsFile) Parse() *promise.Promise[interface{}]

type ProtoIdsObj

type ProtoIdsObj struct {
	DefaultGeneratorObj
	ProtoName string
	Id        int
}

func NewProtoIdsObj

func NewProtoIdsObj(file GeneratorFile) *ProtoIdsObj

func (*ProtoIdsObj) Check

func (this *ProtoIdsObj) Check(line *LineText)

func (*ProtoIdsObj) CheckLine

func (this *ProtoIdsObj) CheckLine(line *LineText) bool

type ProtoMsgObject

type ProtoMsgObject struct {
	DefaultGeneratorObj
	ProtoName string
	ProtoId   int
	Fields    []*ProtoField
}

func NewProtoMsgObject

func NewProtoMsgObject(file GeneratorFile) *ProtoMsgObject

func (*ProtoMsgObject) CheckField

func (this *ProtoMsgObject) CheckField(line *LineText)

func (*ProtoMsgObject) CheckLine

func (this *ProtoMsgObject) CheckLine(line *LineText) bool

type ProtoPackageObj

type ProtoPackageObj struct {
	DefaultGeneratorObj
}

func NewProtoPackageObj

func NewProtoPackageObj(file GeneratorFile) *ProtoPackageObj

func (*ProtoPackageObj) CheckLine

func (this *ProtoPackageObj) CheckLine(line *LineText) bool

type ProtoSyntaxObj

type ProtoSyntaxObj struct {
	DefaultGeneratorObj
}

func NewProtoSyntaxObj

func NewProtoSyntaxObj(file GeneratorFile) *ProtoSyntaxObj

func (*ProtoSyntaxObj) CheckLine

func (this *ProtoSyntaxObj) CheckLine(line *LineText) bool

type REGEXP_LINE_ENUM added in v0.1.25

type REGEXP_LINE_ENUM Enum

func (REGEXP_LINE_ENUM) Enum added in v0.1.25

func (this REGEXP_LINE_ENUM) Enum() Enum

func (REGEXP_LINE_ENUM) ToString added in v0.1.25

func (this REGEXP_LINE_ENUM) ToString() string

type RouteDataMsg added in v0.3.6

type RouteDataMsg struct {
	Protocol  TYPE
	Len       uint16
	Cmd       BINARY_TAG
	TransId   uint32
	ReqType   uint8
	FromActor util.ID
	FromPid   util.ProcessId
	ToActor   util.ID
	ToPid     util.ProcessId
	BodyData  []byte
}

func NewRouteDataMsg added in v0.3.6

func NewRouteDataMsg(fromActorId util.ID, toActorId util.ID, transId uint32, cmd BINARY_TAG, reqType uint8, body []byte, protocolType TYPE) *RouteDataMsg

func UnmarshalRouteDataMsg added in v0.3.6

func UnmarshalRouteDataMsg(data []byte, protocolType TYPE, fromPid util.ProcessId) (*RouteDataMsg, error)

func (*RouteDataMsg) LogInfo added in v0.3.34

func (msg *RouteDataMsg) LogInfo() log.ZapFields

func (*RouteDataMsg) MarshalData added in v0.3.6

func (msg *RouteDataMsg) MarshalData() ([]byte, error)

func (*RouteDataMsg) UnmarshalData added in v0.3.9

func (msg *RouteDataMsg) UnmarshalData() (ISerializable, error)

type RouteHead added in v0.3.9

type RouteHead struct {
	Len       uint16
	Cmd       uint16
	TransId   uint32
	ToActor   uint64
	FromActor uint64
}

type RouteMessage

type RouteMessage struct {
	TransId   uint32
	Len       uint16
	Req       bool
	ReqType   uint8
	CmdId     BINARY_TAG
	InnerId   BINARY_TAG
	FromActor util.ID
	FromPid   util.ProcessId // TODO  add route
	ToActor   util.ID
	ToPid     util.ProcessId
	Body      ISerializable
}

RouteMessage rpc message across server

func NewRouteMessage

func NewRouteMessage(fromActor util.ID, toActor util.ID, transId uint32, msg ISerializable, isReq bool) *RouteMessage

func NewRouteMsg added in v0.3.6

func NewRouteMsg(fromActor util.ID, toActor util.ID, transId uint32, msg ISerializable, reqType uint8) *RouteMessage

new ctor

func UnmarshalJsonRouteMsg added in v0.2.35

func UnmarshalJsonRouteMsg(data []byte) (*RouteMessage, error)

func UnmarshalRouteMsg added in v0.2.35

func UnmarshalRouteMsg(data []byte, t TYPE) (*RouteMessage, error)

func (*RouteMessage) BinaryMessage

func (this *RouteMessage) BinaryMessage() *BinaryMessage

func (*RouteMessage) GetId

func (this *RouteMessage) GetId() (BINARY_TAG, error)

func (*RouteMessage) LogInfo added in v0.3.34

func (this *RouteMessage) LogInfo() log.ZapFields

func (*RouteMessage) Marshal

func (this *RouteMessage) Marshal() ([]byte, error)

func (*RouteMessage) Serializable

func (this *RouteMessage) Serializable() ISerializable

func (*RouteMessage) Unmarshal

func (this *RouteMessage) Unmarshal(from []byte) error

type RouteRecv added in v0.3.6

type RouteRecv struct {
	Protocol TYPE
	// FromActor util.ID
	FromPid util.ProcessId
	Head    *RouteHead
	Data    []byte
}

func NewRouteRecv added in v0.3.9

func NewRouteRecv(data []byte, protocolType TYPE, fromPid util.ProcessId) *RouteRecv

func (*RouteRecv) GetCmd added in v0.3.6

func (recv *RouteRecv) GetCmd() uint16

func (*RouteRecv) GetReq added in v0.3.6

func (recv *RouteRecv) GetReq() bool

func (*RouteRecv) GetTransId added in v0.3.6

func (recv *RouteRecv) GetTransId() uint32

func (*RouteRecv) UnmarshalHead added in v0.3.9

func (recv *RouteRecv) UnmarshalHead()

type TYPE

type TYPE int
const (
	BINARY TYPE = 0
	JSON   TYPE = 1
)

func String2Type

func String2Type(s string) TYPE

func (TYPE) String

func (this TYPE) String() string

type TsClassMember

type TsClassMember struct {
	IsGetter bool
	IsSetter bool
	IsPublic bool
	Name     string
	Type     string
	Line     *LineText
}

type TsClassObject

type TsClassObject struct {
	DefaultGeneratorObj
	Package           string
	ClassName         string
	IsComponent       bool
	IsRenderComponent bool
	IsSerializable    bool

	LongStringTag map[string]bool
	BufferTag     map[string]bool
	// contains filtered or unexported fields
}

func NewTsClassObject

func NewTsClassObject(file GeneratorFile) *TsClassObject

func (*TsClassObject) CheckBuffer added in v0.1.33

func (this *TsClassObject) CheckBuffer(mName string) bool

func (*TsClassObject) CheckLine

func (this *TsClassObject) CheckLine(line *LineText) bool

func (*TsClassObject) CheckLongString

func (this *TsClassObject) CheckLongString(mName string) bool

func (*TsClassObject) GetClassMember

func (this *TsClassObject) GetClassMember(s string) *TsClassMember

func (*TsClassObject) GetClassName

func (this *TsClassObject) GetClassName() string

func (*TsClassObject) IsModel

func (this *TsClassObject) IsModel() bool

func (*TsClassObject) Name

func (this *TsClassObject) Name() string

type TsEnumFile

type TsEnumFile struct {
	*DefaultGeneratorFile
}

func NewTsEnumFile

func NewTsEnumFile(generator *Generator) *TsEnumFile

func (*TsEnumFile) Generate

func (this *TsEnumFile) Generate() *promise.Promise[interface{}]

func (*TsEnumFile) Parse

func (this *TsEnumFile) Parse() *promise.Promise[interface{}]

type TsEnumObject

type TsEnumObject struct {
	DefaultGeneratorObj
}

func NewTsEnumObject

func NewTsEnumObject(file GeneratorFile) *TsEnumObject

func (*TsEnumObject) CheckLine

func (this *TsEnumObject) CheckLine(line *LineText) bool

type TsErrorsObject added in v0.1.33

type TsErrorsObject struct {
	DefaultGeneratorObj
}

func NewTsErrorsObject added in v0.1.33

func NewTsErrorsObject(file GeneratorFile) *TsErrorsObject

func (*TsErrorsObject) CheckLine added in v0.1.33

func (this *TsErrorsObject) CheckLine(line *LineText) bool

type TsFuncObject

type TsFuncObject struct {
	DefaultGeneratorObj
}

func NewTsFuncObject

func NewTsFuncObject(file GeneratorFile) *TsFuncObject

func (*TsFuncObject) CheckLine

func (this *TsFuncObject) CheckLine(line *LineText) bool

type TsIdsFile

type TsIdsFile struct {
	*DefaultGeneratorFile
}

func NewTsIdsFile

func NewTsIdsFile(generator *Generator) *TsIdsFile

func (*TsIdsFile) Generate

func (this *TsIdsFile) Generate() *promise.Promise[interface{}]

func (*TsIdsFile) Parse

func (this *TsIdsFile) Parse() *promise.Promise[interface{}]

type TsIdsObject

type TsIdsObject struct {
	DefaultGeneratorObj
}

func NewTsIdsObject

func NewTsIdsObject(file GeneratorFile) *TsIdsObject

func (*TsIdsObject) CheckLine

func (this *TsIdsObject) CheckLine(line *LineText) bool

type TsImportObject

type TsImportObject struct {
	DefaultGeneratorObj
}

func NewTsImportObject

func NewTsImportObject(file GeneratorFile) *TsImportObject

func (*TsImportObject) CheckLine

func (this *TsImportObject) CheckLine(line *LineText) bool

type TsModelFile

type TsModelFile struct {
	*DefaultGeneratorFile
	Package   string
	ClassName string
}

func NewTsModelFile

func NewTsModelFile(generator *Generator) *TsModelFile

func (*TsModelFile) Generate

func (this *TsModelFile) Generate() *promise.Promise[interface{}]

func (*TsModelFile) Parse

func (this *TsModelFile) Parse() *promise.Promise[interface{}]

func (*TsModelFile) ProcessClasses

func (this *TsModelFile) ProcessClasses() []*TsClassObject

type TsVarObject

type TsVarObject struct {
	DefaultGeneratorObj
}

func NewTsVarObject

func NewTsVarObject(file GeneratorFile) *TsVarObject

func (*TsVarObject) CheckLine

func (this *TsVarObject) CheckLine(line *LineText) bool

type TypeRegistry

type TypeRegistry struct {
	// contains filtered or unexported fields
}

func GetTypeRegistry

func GetTypeRegistry() *TypeRegistry

单例,进程唯一

func (*TypeRegistry) GetInterfaceByTag

func (this *TypeRegistry) GetInterfaceByTag(t BINARY_TAG) (ISerializable, error)

func (*TypeRegistry) GetNameByType

func (this *TypeRegistry) GetNameByType(t reflect.Type) string

func (*TypeRegistry) GetTagByName

func (this *TypeRegistry) GetTagByName(s string) BINARY_TAG

func (*TypeRegistry) GetTagByType

func (this *TypeRegistry) GetTagByType(p reflect.Type) (BINARY_TAG, error)

func (*TypeRegistry) GetTagName

func (this *TypeRegistry) GetTagName(t BINARY_TAG) string

func (*TypeRegistry) GetTypeByTag

func (this *TypeRegistry) GetTypeByTag(t BINARY_TAG) (reflect.Type, error)

func (*TypeRegistry) RegistrySystemTag

func (this *TypeRegistry) RegistrySystemTag(t BINARY_TAG, s string)

func (*TypeRegistry) RegistryTemplateTag

func (this *TypeRegistry) RegistryTemplateTag(t BINARY_TAG, s string)

func (*TypeRegistry) RegistryType

func (this *TypeRegistry) RegistryType(t BINARY_TAG, p reflect.Type)

Directories

Path Synopsis
encoding
number_json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL