maker_go

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MulanPSL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const TDGoConstFileBuiltin = `` /* 389-byte string literal not displayed */
View Source
const TDGoConstValueBuiltin = `{{.ConstName}} = uint32({{.ConstValue}}){{.ConstLineCommentIndent}}`
View Source
const TDGoDefineSTBaseFuncBuiltin = `` /* 164-byte string literal not displayed */
View Source
const TDGoDefineSTMessageFuncBuiltin = `` /* 184-byte string literal not displayed */
View Source
const TDGoDefineSTNewBuiltin = `` /* 233-byte string literal not displayed */
View Source
const TDGoDefineSTStructBuiltin = `` /* 208-byte string literal not displayed */
View Source
const TDGoMessageFileBuiltin = `` /* 1127-byte string literal not displayed */
View Source
const TDGoProtoFileBuiltin = `` /* 561-byte string literal not displayed */
View Source
const TDGoProtoFileImportBuiltin = `` /* 148-byte string literal not displayed */

Variables

View Source
var (
	ArrTemplateDataDefine = []*generator.TemplateDataDefine{
		{Name: "TmplDataGoConstFile", Sample: &TmplDataGoConstFile{}},
		{Name: "TmplDataGoMessageFile", Sample: &TmplDataGoMessageFile{}},
		{Name: "TmplDataGoDefineST", Sample: &TmplDataGoDefineST{}},
		{Name: "TmplDataGoDefineSTField", Sample: &TmplDataGoDefineSTField{}},
		{Name: "TmplDataGoProtoFile", Sample: &TmplDataGoProtoFile{}},
	}
)
View Source
var TDGoConstFile = &generator.TemplateDefine{
	Name:                "TDGoConstFile",
	Filepath:            "go_const_file.tmpl",
	WantTemplateData:    "TmplDataGoConstFile",
	BuiltinTemplateText: TDGoConstFileBuiltin,
}
View Source
var TDGoConstValue = &generator.TemplateDefine{
	Name:                "TDGoConstValue",
	Filepath:            "go_const_value_line.tmpl",
	WantTemplateData:    "TmplDataConstValue",
	BuiltinTemplateText: TDGoConstValueBuiltin,
}
View Source
var TDGoDefineSTBaseFunc = &generator.TemplateDefine{
	Name:                "TDGoDefineSTBaseFunc",
	Filepath:            "go_define_st_base_func.tmpl",
	WantTemplateData:    "TmplDataGoDefineST",
	BuiltinTemplateText: TDGoDefineSTBaseFuncBuiltin,
}
View Source
var TDGoDefineSTMessageFunc = &generator.TemplateDefine{
	Name:                "TDGoDefineSTMessageFunc",
	Filepath:            "go_define_st_message_func.tmpl",
	WantTemplateData:    "TmplDataGoDefineST",
	BuiltinTemplateText: TDGoDefineSTMessageFuncBuiltin,
}
View Source
var TDGoDefineSTNew = &generator.TemplateDefine{
	Name:             "TDGoDefineSTNew",
	Filepath:         "go_define_st_new.tmpl",
	WantTemplateData: "TmplDataGoDefineST",

	BuiltinTemplateText: TDGoDefineSTNewBuiltin,
}
View Source
var TDGoDefineSTStruct = &generator.TemplateDefine{
	Name:             "TDGoDefineSTStruct",
	Filepath:         "go_json_define_st_struct.tmpl",
	WantTemplateData: "TmplDataGoDefineST",

	BuiltinTemplateText: TDGoDefineSTStructBuiltin,
}
View Source
var TDGoMessageFile = &generator.TemplateDefine{
	Name:             "TDGoMessageFile",
	Filepath:         "go_message_file.tmpl",
	WantTemplateData: "TmplDataGoMessageFile",

	BuiltinTemplateText: TDGoMessageFileBuiltin,
}
View Source
var TDGoProtoFile = &generator.TemplateDefine{
	Name:             "TDGoProtoFile",
	Filepath:         "go_proto_file.tmpl",
	WantTemplateData: "TmplDataGoProtoFile",

	BuiltinTemplateText: TDGoProtoFileBuiltin,
}
View Source
var TDGoProtoFileImport = &generator.TemplateDefine{
	Name:             "TDGoProtoFileImport",
	Filepath:         "go_proto_file_import.tmpl",
	WantTemplateData: "TmplDataGoProtoFile",

	BuiltinTemplateText: TDGoProtoFileImportBuiltin,
}

Functions

func BuildProtoFilePath added in v0.3.0

func BuildProtoFilePath(pFile *generator.File, pSet *generator.PrototypeSet) string

func FixTmplDataGoProtoFileOuterImport added in v0.3.0

func FixTmplDataGoProtoFileOuterImport(tdFile *TmplDataGoProtoFile) map[string]bool

func FixTmplDataGoProtoFileTreePackage added in v0.3.0

func FixTmplDataGoProtoFileTreePackage(tdF *TmplDataGoProtoFile, pSet *generator.PrototypeSet)

根据树状模式修正模板参数

func GenCodeForConstFile added in v0.3.0

func GenCodeForConstFile(pSet *generator.PrototypeSet) (string, error)

常量文件代码生成

func GenCodeForIMessage

func GenCodeForIMessage() (string, error)

消息抽象定义代码生成

func GenConstFile added in v0.3.0

func GenConstFile(pSet *generator.PrototypeSet) error

生成常量文件

func GenFileForIMessage

func GenFileForIMessage() error

生成消息抽象定义文件

func GenProtoFileCode added in v0.3.0

func GenProtoFileCode(tdFile *TmplDataGoProtoFile, pSet *generator.PrototypeSet) error

生成协议代码文件

func OutputGoCodeFile added in v0.3.0

func OutputGoCodeFile(filepath string, content string) error

输出一个Go代码文件. 包含gofmt的执行.

Types

type Context added in v0.3.0

type Context struct {
	Dir         string `json:"dir"`         //代码输出根路径
	PackageName string `json:"packageName"` //根的go package

	MessageFilename string `json:"messageFilename"` //公共消息头文件名
	ConstFilename   string `json:"constFilename"`   //公共常量文件名

	OuterImport map[string]string `json:"outerImport"` //外部引用映射

	OuterMessagePackage     string `json:"outerMessagePackage"`     //外部引用message.go文件定义, 适合在工程分层时使用, 需结合OuterMessagePackagePath
	OuterMessagePackagePath string `json:"outerMessagePackagePath"` //外部引用message.go文件的包路径

	//树状模式参数
	//树状模式要求解析器能够提供go模型的包关系
	//树状模式将以源文件集的内部路径关系输出生成的代码文件
	TreePackage       bool   `json:"treePackage"`       //是否使用树状模式
	TreePackagePrefix string `json:"treePackagePrefix"` //输出代码的包路径前缀, 仅在TreePackage为true时有效
	TreeSourcePrefix  string `json:"treeSourcePrefix"`  //源代码的包路径前缀, 仅在TreePackage为true时有效

	Plugins []string `json:"plugins"`
}
var GenCtx *Context

type TmplDataGoConstFile added in v0.3.0

type TmplDataGoConstFile struct {
	*generator.TmplDataConstFile

	GoPackageName string
}

func PrepareTmplDataGoConstFile added in v0.3.0

func PrepareTmplDataGoConstFile(pSet *generator.PrototypeSet) *TmplDataGoConstFile

go语言常量的预计算

type TmplDataGoDefineST added in v0.3.0

type TmplDataGoDefineST struct {
	*generator.TmplDataDefineST

	SuperGoProtoFile *TmplDataGoProtoFile

	GoSTFields []*TmplDataGoDefineSTField

	RootDefineDot string
}

go特征的模板参数: 结构定义

func PrepareTmplDataDefineST added in v0.3.0

func PrepareTmplDataDefineST(df *generator.TmplDataDefineST) *TmplDataGoDefineST

筹备go结构定义的模板参数

type TmplDataGoDefineSTField added in v0.3.0

type TmplDataGoDefineSTField struct {
	*generator.TmplDataDefineSTField

	SuperGoDefineST *TmplDataGoDefineST

	GoFieldTag string
}

go特征的模板参数: 结构字段

type TmplDataGoMessageFile added in v0.3.0

type TmplDataGoMessageFile struct {
	GoPackageName string

	MFOption  map[string]interface{}
	MFPlugins map[string]interface{}
}

func PrepareTmplDataGoMessageFile added in v0.3.0

func PrepareTmplDataGoMessageFile() *TmplDataGoMessageFile

模板参数构造预计算

type TmplDataGoProtoFile added in v0.3.0

type TmplDataGoProtoFile struct {
	*generator.TmplDataProtoFile

	GoPFListDefineST []*TmplDataGoDefineST
}

go特征的模板参数: 协议文件

func PrepareTmplDataProtoFile added in v0.3.0

func PrepareTmplDataProtoFile(pFile *generator.File, pSet *generator.PrototypeSet) *TmplDataGoProtoFile

筹备go协议文件的模板参数

Jump to

Keyboard shortcuts

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