generator

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: MulanPSL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArrGenerator = []Generator{}
View Source
var ArrParser = []Parser{}
View Source
var TemplateFileMap = map[string]string{}

Functions

func ForeachPluginGenerators added in v0.2.0

func ForeachPluginGenerators(list []string, f func(p *PluginGenerator)) error

func ParseTemplate added in v0.2.0

func ParseTemplate(h *TemplateHeader) error

func RegPluginGenerator added in v0.2.0

func RegPluginGenerator(pg *PluginGenerator)

func RegTemplate added in v0.2.0

func RegTemplate(h *TemplateHeader)

Types

type ConstValue

type ConstValue struct {
	Name    string `json:"name,omitempty"`
	Value   uint32 `json:"value,omitempty"`
	Comment string `json:"comment,omitempty"`
}

type DefineField

type DefineField struct {
	BuiltinType       reflect.Kind `json:"builtin_type,omitempty"`
	CustomType        string       `json:"custom_type,omitempty"` //DefineST.Name
	CustomTypePackage string       `json:"custom_type_package,omitempty"`

	IsArray bool `json:"is_array,omitempty"`

	IsMap  bool         `json:"is_map,omitempty"`
	MapKey reflect.Kind `json:"map_key,omitempty"`

	Doc     []string          `json:"doc,omitempty"`
	Comment string            `json:"comment,omitempty"`
	Option  map[string]string `json:"tag,omitempty"`
}

type DefineST

type DefineST struct {
	Name   string                  `json:"name,omitempty"`
	Fields map[string]*DefineField `json:"fields,omitempty"`

	Doc    []string        `json:"doc,omitempty"`
	Option *DefineSTOption `json:"option,omitempty"`
}

type DefineSTOption

type DefineSTOption struct {
	Custom map[string]string `json:"custom,omitempty"`
}

type File

type File struct {
	Name string `json:"name,omitempty"`

	DefineST []*DefineST            `json:"define_st,omitempty"`
	ProtoID  map[uint32]*ConstValue `json:"proto_id,omitempty"`
	ErrCode  map[uint32]*ConstValue `json:"err_code,omitempty"`

	Doc    []string           `json:"doc,omitempty"`
	Option *MessageFileOption `json:"option,omitempty"`
}

type Generator

type Generator interface {
	Lang() string
	Proto() string

	NewConfig() GeneratorConfig
	Generate(GeneratorConfig, *PrototypeSet) error
}

type GeneratorConfig

type GeneratorConfig interface{}

type Message

type Message struct {
	//必须有一个相同名称的DefineST
	Name        string `json:"name,omitempty"`
	ProtoIDName string `json:"proto_id_name,omitempty"`

	Option *MessageOption `json:"option,omitempty"`
}

type MessageFileOption

type MessageFileOption struct {
	PackageName string            `json:"package_name,omitempty"`
	Imports     map[string]string `json:"imports,omitempty"`
	Custom      map[string]string `json:"custom,omitempty"`
}

type MessageOption

type MessageOption struct {
	Custom map[string]string `json:"custom,omitempty"`
}

type Parser

type Parser interface {
	Name() string
	NewConfig() ParserConfig
	Parse(ParserConfig) (*PrototypeSet, error)
}

type ParserConfig

type ParserConfig interface{}

type PluginFuncAppendConstValue added in v0.2.0

type PluginFuncAppendConstValue func(tmplData interface{}, pSet *PrototypeSet)

type PluginFuncAppendDefineField added in v0.2.0

type PluginFuncAppendDefineField func(tmplData interface{}, pSet *PrototypeSet, cursor *DefineField)

type PluginFuncAppendDefineST added in v0.2.0

type PluginFuncAppendDefineST func(tmplData interface{}, pSet *PrototypeSet, cursor *DefineST)

type PluginFuncAppendFile added in v0.2.0

type PluginFuncAppendFile func(tmplData interface{}, pSet *PrototypeSet, cursor *File)

type PluginFuncAppendMessage added in v0.2.0

type PluginFuncAppendMessage func(tmplData interface{}, pSet *PrototypeSet, cursor *Message)

type PluginGenerator added in v0.2.0

type PluginGenerator struct {
	Name string

	AppendFile        PluginFuncAppendFile
	AppendMessage     PluginFuncAppendMessage
	AppendDefineST    PluginFuncAppendDefineST
	AppendDefineField PluginFuncAppendDefineField
	AppendConstValue  PluginFuncAppendConstValue
}

func GetPluginGenerator added in v0.2.0

func GetPluginGenerator(name string) *PluginGenerator

type PrototypeSet

type PrototypeSet struct {
	RootDir  string                 `json:"root_dir,omitempty"`
	File     map[string]*File       `json:"file,omitempty"`
	Message  map[string]*Message    `json:"message,omitempty"`
	DefineST map[string]*DefineST   `json:"define_st,omitempty"`
	ProtoID  map[uint32]*ConstValue `json:"proto_id,omitempty"`
	ErrCode  map[uint32]*ConstValue `json:"err_code,omitempty"`
}

type TemplateHeader added in v0.2.0

type TemplateHeader struct {
	Name     string
	Filepath string

	BuiltinTemplateText string

	Template *template.Template

	ActualFilepath     string
	ActualTemplateText string
}

func ArrTemplate added in v0.2.0

func ArrTemplate() []*TemplateHeader

func GetTemplate added in v0.2.0

func GetTemplate(name string) *TemplateHeader

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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