Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorLine(errIn error, genData string) error
- func GenerateByTmpl(dstFile io.Writer, params any, name, tmpl string) *arerror.ErrGeneratorPhases
- func GenerateFixtureTmpl(dstFile io.Writer, params PkgData) *arerror.ErrGeneratorPhases
- func GenerateOctopus(params PkgData) (map[string]bytes.Buffer, *arerror.ErrGeneratorPhases)
- type GenerateFile
- type MetaData
- type OctopusFormatParam
- func (p OctopusFormatParam) DefaultValue() string
- func (p OctopusFormatParam) Len(l uint32) uint
- func (p OctopusFormatParam) MaxValue() string
- func (p OctopusFormatParam) MinValue() string
- func (p OctopusFormatParam) MutatorTypeConv() string
- func (p OctopusFormatParam) PackConvFunc(fieldname string) string
- func (p OctopusFormatParam) PackFunc() string
- func (p OctopusFormatParam) ToString() []string
- func (p OctopusFormatParam) UnpackFunc() string
- func (p OctopusFormatParam) UnpackType() string
- type OctopusMutatorParam
- type PkgData
Constants ¶
View Source
const TemplateName = `ARPkgTemplate`
Variables ¶
View Source
var MetaTmpl string
View Source
var OctopusFixtureRepositoryTmpl string
View Source
var OctopusFormatMapper = map[octopus.Format]OctopusFormatParam{ octopus.Bool: {Name: "Uint8", UnpackConvFunc: "octopus.UintToBool", /* contains filtered or unexported fields */}, octopus.Uint8: {Name: "Uint8", /* contains filtered or unexported fields */}, octopus.Uint16: {Name: "Uint16", /* contains filtered or unexported fields */}, octopus.Uint32: {Name: "Uint32", /* contains filtered or unexported fields */}, octopus.Uint64: {Name: "Uint64", /* contains filtered or unexported fields */}, octopus.Uint: {Name: "Uint32", UnpackConvFunc: "uint", /* contains filtered or unexported fields */}, octopus.Int8: {Name: "Uint8", UnpackConvFunc: "int8", /* contains filtered or unexported fields */}, octopus.Int16: {Name: "Uint16", UnpackConvFunc: "int16", /* contains filtered or unexported fields */}, octopus.Int32: {Name: "Uint32", UnpackConvFunc: "int32", /* contains filtered or unexported fields */}, octopus.Int64: {Name: "Uint64", UnpackConvFunc: "int64", /* contains filtered or unexported fields */}, octopus.Int: {Name: "Uint32", UnpackConvFunc: "int", /* contains filtered or unexported fields */}, octopus.Float32: {Name: "Uint32", UnpackConvFunc: "math.Float32frombits", /* contains filtered or unexported fields */}, octopus.Float64: {Name: "Uint64", UnpackConvFunc: "math.Float64frombits", /* contains filtered or unexported fields */}, octopus.String: {Name: "String", /* contains filtered or unexported fields */}}
View Source
var OctopusMockRepositoryTmpl string
View Source
var OctopusMutatorMapper = map[ds.FieldMutator]OctopusMutatorParam{ ds.IncMutator: {Name: "Inc", AvailableType: octopus.NumericFormat}, ds.DecMutator: {Name: "Dec", AvailableType: octopus.NumericFormat}, ds.AndMutator: {Name: "And", AvailableType: octopus.UnsignedFormat}, ds.OrMutator: {Name: "Or", AvailableType: octopus.UnsignedFormat}, ds.XorMutator: {Name: "Xor", AvailableType: octopus.UnsignedFormat}, ds.ClearBitMutator: {Name: "ClearBit", AvailableType: octopus.UnsignedFormat}, ds.SetBitMutator: {Name: "SetBit", AvailableType: octopus.UnsignedFormat}, }
View Source
var OctopusRootRepositoryTmpl string
View Source
var OctopusTemplateFuncs = template.FuncMap{ "packerParam": func(format octopus.Format) OctopusFormatParam { ret, ex := OctopusFormatMapper[format] if !ex { log.Fatalf("packer for type `%s` not found", format) } return ret }, "mutatorParam": func(mut ds.FieldMutator, format octopus.Format) OctopusMutatorParam { ret, ex := OctopusMutatorMapper[mut] if !ex { log.Fatalf("mutator packer for type `%s` not found", format) } for _, availFormat := range ret.AvailableType { if availFormat == format { return ret } } log.Fatalf("Mutator `%s` not available for type `%s`", mut, format) return OctopusMutatorParam{} }, "addImport": func(flds []ds.FieldDeclaration) (imports []string) { var needMath, needStrconv bool for _, fld := range flds { if fld.Format == octopus.Float32 || fld.Format == octopus.Float64 { needMath = true } if len(fld.Mutators) > 0 && fld.Format != "uint32" && fld.Format != "uint64" && fld.Format != "uint" { needMath = true } if fld.PrimaryKey && fld.Format != "string" { needStrconv = true } } if needMath { imports = append(imports, "math") } if needStrconv { imports = append(imports, "strconv") } return }, "trimPrefix": strings.TrimPrefix, "hasPrefix": strings.HasPrefix, }
View Source
var ToLower = cases.Title(language.English)
Functions ¶
func GenerateByTmpl ¶
func GenerateFixtureTmpl ¶
func GenerateFixtureTmpl(dstFile io.Writer, params PkgData) *arerror.ErrGeneratorPhases
func GenerateOctopus ¶
Types ¶
type GenerateFile ¶
func Generate ¶
func Generate(appInfo string, cl ds.RecordPackage, linkObject map[string]ds.RecordPackage) (ret []GenerateFile, err error)
func GenerateFixture ¶
func GenerateFixture(appInfo string, cl ds.RecordPackage, pkg string) ([]GenerateFile, error)
func GenerateMeta ¶
func GenerateMeta(params MetaData) ([]GenerateFile, *arerror.ErrGeneratorFile)
type MetaData ¶
type MetaData struct { Namespaces []*ds.RecordPackage AppInfo string }
type OctopusFormatParam ¶
type OctopusFormatParam struct { Name string Default []byte UnpackConvFunc string // contains filtered or unexported fields }
func (OctopusFormatParam) DefaultValue ¶
func (p OctopusFormatParam) DefaultValue() string
func (OctopusFormatParam) Len ¶
func (p OctopusFormatParam) Len(l uint32) uint
func (OctopusFormatParam) MaxValue ¶
func (p OctopusFormatParam) MaxValue() string
func (OctopusFormatParam) MinValue ¶
func (p OctopusFormatParam) MinValue() string
func (OctopusFormatParam) MutatorTypeConv ¶
func (p OctopusFormatParam) MutatorTypeConv() string
func (OctopusFormatParam) PackConvFunc ¶
func (p OctopusFormatParam) PackConvFunc(fieldname string) string
func (OctopusFormatParam) PackFunc ¶
func (p OctopusFormatParam) PackFunc() string
func (OctopusFormatParam) ToString ¶
func (p OctopusFormatParam) ToString() []string
func (OctopusFormatParam) UnpackFunc ¶
func (p OctopusFormatParam) UnpackFunc() string
func (OctopusFormatParam) UnpackType ¶
func (p OctopusFormatParam) UnpackType() string
type OctopusMutatorParam ¶
type PkgData ¶
type PkgData struct { ARPkg string ARPkgTitle string FieldList []ds.FieldDeclaration FieldMap map[string]int FieldObject map[string]ds.FieldObject LinkedObject map[string]ds.RecordPackage Server ds.ServerDeclaration Container ds.NamespaceDeclaration Indexes []ds.IndexDeclaration Serializers map[string]ds.SerializerDeclaration Imports []ds.ImportDeclaration Triggers map[string]ds.TriggerDeclaration Flags map[string]ds.FlagDeclaration AppInfo string }
func NewPkgData ¶
func NewPkgData(appInfo string, cl ds.RecordPackage) PkgData
Click to show internal directories.
Click to hide internal directories.