tars2go

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EOS = 0

EOS is byte stream terminator

View Source
const VERSION = "1.1.4"

VERSION version of the tars2go tools.

Variables

View Source
var (
	GTarsPath = flag.String("tarsPath", "github.com/jslyzt/tarsgo/tars", "Specify the tars source path.")
)
View Source
var TokenMap = [...]string{
	// contains filtered or unexported fields
}

TokenMap record token value.

Functions

This section is empty.

Types

type ArgInfo

type ArgInfo struct {
	Name       string
	OriginName string //original name
	IsOut      bool
	Type       *VarType
}

ArgInfo record argument information.

type ConstInfo

type ConstInfo struct {
	Type       *VarType
	Name       string
	OriginName string // original name
	Value      string
}

ConstInfo record const information.

type EnumInfo

type EnumInfo struct {
	Module     string
	Name       string
	OriginName string // original name
	Mb         []EnumMember
}

EnumInfo record EnumMember information include name.

type EnumMember

type EnumMember struct {
	Key   string
	Type  int
	Value int32  //type 0
	Name  string //type 1
}

EnumMember record member information.

type FunInfo

type FunInfo struct {
	Name       string // after the uppercase converted name
	OriginName string // original name
	HasRet     bool
	RetType    *VarType
	Args       []ArgInfo
}

FunInfo record function information.

type GenGo

type GenGo struct {
	I        []string // imports with path
	Code     bytes.Buffer
	VC       int // var count. Used to generate unique variable names
	Path     string
	TarsPath string
	Module   string
	Prefix   string
	P        *Parse

	// proto file name(not include .tars)
	ProtoName string
}

GenGo record go code information.

func NewGenGo

func NewGenGo(path string, module string, outdir string) *GenGo

NewGenGo build up a new path

func (*GenGo) Gen

func (gen *GenGo) Gen()

Gen to parse file.

type HashKeyInfo

type HashKeyInfo struct {
	Name   string
	Member []string
}

HashKeyInfo record hashkey information.

type InterfaceInfo

type InterfaceInfo struct {
	Name                string
	OriginName          string // original name
	Fun                 []FunInfo
	DependModule        map[string]bool
	DependModuleWithJce map[string]string
}

InterfaceInfo record interface information.

type LexState

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

LexState record lexical state.

func NewLexState

func NewLexState(source string, buff []byte) *LexState

NewLexState to update LexState struct.

func (*LexState) NextToken

func (ls *LexState) NextToken(bdesc bool) *Token

NextToken return token after lexical analysis.

type Parse

type Parse struct {
	Source string

	Module       string
	OriginModule string
	Include      []string

	Struct    []StructInfo
	Interface []InterfaceInfo
	Enum      []EnumInfo
	Const     []ConstInfo
	HashKey   []HashKeyInfo

	// have parsed include file
	IncParse []*Parse

	// jce include chain
	IncChain []string

	// proto file name(not include .tars)
	ProtoName string

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

Parse record information of parse file.

func ParseFile

func ParseFile(path string, incChain []string) *Parse

ParseFile parse a file,return grammer tree.

type SemInfo

type SemInfo struct {
	I int64
	F float64
	S string
}

SemInfo is struct.

type StructInfo

type StructInfo struct {
	Name                string
	OriginName          string //original name
	Mb                  []StructMember
	DependModule        map[string]bool
	DependModuleWithJce map[string]string
}

StructInfo record struct information.

type StructMember

type StructMember struct {
	Tag       int32
	Require   bool
	Type      *VarType
	Key       string // after the uppercase converted key
	OriginKey string // original key
	Default   string
	DefType   TK
	Desc      string // 描述
}

StructMember member struct.

type StructMemberSorter

type StructMemberSorter []StructMember

StructMemberSorter When serializing, make sure the tags are ordered.

func (StructMemberSorter) Len

func (a StructMemberSorter) Len() int

func (StructMemberSorter) Less

func (a StructMemberSorter) Less(i, j int) bool

func (StructMemberSorter) Swap

func (a StructMemberSorter) Swap(i, j int)

type TK

type TK byte

TK is a byte type.

type Token

type Token struct {
	T    TK
	S    *SemInfo
	Line int
}

Token record token information.

type VarType

type VarType struct {
	Type     TK       // basic type
	Unsigned bool     // whether unsigned
	TypeSt   string   // custom type name, such as an enumerated struct,at this time Type=tkName
	CType    TK       // make sure which type of custom type is,tkEnum, tkStruct
	TypeK    *VarType // vector's member variable,the key of map
	TypeV    *VarType // the value of map
	TypeL    int64    // lenth of array
}

VarType contains variable type(token)

Jump to

Keyboard shortcuts

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