generators

package
v0.0.0-...-4fe1ee3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ExamplePkg = Package{
		Name:      "main",
		UseSpaces: false,
		Classes: []Class{
			{
				Name: "Fruit",
			},
			{
				Name: "Apple",
				Parent: Parent{
					Name:   "Fruit",
					Access: "public",
				},
				Fields: []Field{
					{
						Access:  "public",
						Type:    "string",
						Name:    "colour",
						Default: `"red"`,
					},
					{
						Access:  "public",
						Type:    "string",
						Static:  true,
						Name:    "sort",
						Default: `"Golden"`,
					},
					{
						Access:  "private",
						Type:    "int",
						Name:    "size",
						Default: "1",
					},
				},
				Methods: []Method{
					{
						Access: "private",
						Name:   "print",
						Parameters: []Parameter{
							{
								Pass:  "&",
								Name:  "colour",
								Type:  "string",
								Const: true,
							},
						},
					},
					{
						Access: "protected",
						Return: "int",
						Static: true,
						Name:   "getSize",
					},
					{
						Access: "public",
						Return: "string",
						Name:   "getColor",
						Const:  true,
					},
				},
			},
			{
				Access: "private",
				Name:   "Seed",
				Fields: []Field{
					{
						Access: "public",
						Type:   "int",
						Name:   "size",
					},
				},
				Methods: []Method{
					{
						Static: true,
						Access: "public",
						Return: "int",
						Name:   "transform",
						Const:  true,
					},
				},
			},
		},
	}
	Generators = map[string]Language{
		"java":   {&JavaGenerator{}, "java", "/* %s */"},
		"go":     {&GoGenerator{}, "go", "/* %s */"},
		"ruby":   {&RubyGenerator{}, "rb", "# %s\n"},
		"cpp":    {&CppGenerator{}, "h", "/* %s */"},
		"python": {&PythonGenerator{}, "py", "# %s\n"},
		"js_es6": {&ES6Generator{}, "js", "/* %s */"},
		"csharp": {&CSharpGenerator{}, "cs", "/* %s */"},
		"xml":    {&XmlGenerator{}, "xml", "<!-- %s -->"},
		"json":   {&JsonGenerator{}, "json", ""},
		"yaml":   {&YamlGenerator{}, "yml", "# %s\n"},
	}
)

Functions

func NormalizeLang

func NormalizeLang(lang string) string

Types

type CSharpGenerator

type CSharpGenerator struct{}

func (CSharpGenerator) Generate

func (gen CSharpGenerator) Generate(pkg Package) map[string]string

The class must be validated before using this function

type Class

type Class struct {
	Name         string        `xml:"name" json:"name" yml:"name"`
	Fields       []Field       `xml:"fields>field" json:"fields" yml:"fields"`
	Methods      []Method      `xml:"methods>method" json:"methods" yml:"methods"`
	Constructors []Constructor `xml:"constructors>constructor" json:"constructors" yml:"constructors"`
	Classes      []Class       `xml:"classes>class" json:"classes" yml:"classes"`
	Parent       Parent        `xml:"parent" json:"parent" yml:"parent"`
	Access       string        `xml:"access" json:"access" yml:"access"`
}

type Constructor

type Constructor struct {
	Explicit   bool        `xml:"explicit" json:"explicit" yml:"explicit"`
	Const      bool        `xml:"const" json:"const" yml:"const"`
	Parameters []Parameter `xml:"parameters>parameter" json:"parameters" yml:"parameters"`
}

type CppGenerator

type CppGenerator struct{}

func (CppGenerator) Generate

func (gen CppGenerator) Generate(pkg Package) map[string]string

type ES6Generator

type ES6Generator struct{}

func (ES6Generator) Generate

func (gen ES6Generator) Generate(pkg Package) map[string]string

type Field

type Field struct {
	Name    string `xml:"name" json:"name" yml:"name"`
	Type    string `xml:"type" json:"type" yml:"type"`
	Const   bool   `xml:"const" json:"const" yml:"const"`
	Pointer bool   `xml:"pointer" json:"pointer" yml:"pointer"`
	Default string `xml:"default" json:"default" yml:"default"`
	Access  string `xml:"access" json:"access" yml:"access"`
	Static  bool   `xml:"static" json:"static" yml:"static"`
}

type Generator

type Generator interface {
	Generate(class Package) map[string]string
	// contains filtered or unexported methods
}

func GetGenerator

func GetGenerator(name string) (Generator, error)

type GoGenerator

type GoGenerator struct{}

func (GoGenerator) Generate

func (gen GoGenerator) Generate(pkg Package) map[string]string

type JavaGenerator

type JavaGenerator struct{}

func (JavaGenerator) Generate

func (gen JavaGenerator) Generate(pkg Package) map[string]string

The class must be validated before using this function

type JsonGenerator

type JsonGenerator struct{}

func (JsonGenerator) Generate

func (gen JsonGenerator) Generate(pkg Package) map[string]string

type Language

type Language struct {
	Generator Generator
	Extension string
	Comment   string
}

type Method

type Method struct {
	Name       string      `xml:"name" json:"name" yml:"name"`
	Return     string      `xml:"return" json:"return" yml:"return"`
	Access     string      `xml:"access" json:"access" yml:"access"`
	Const      bool        `xml:"const" json:"const" yml:"const"`
	Static     bool        `xml:"static" json:"static" yml:"static"`
	Parameters []Parameter `xml:"parameters>parameter" json:"parameters" yml:"parameters"`
}

type Package

type Package struct {
	Name      string   `xml:"name" json:"name" yml:"name"`
	Classes   []Class  `xml:"classes>class" json:"classes" yml:"classes"`
	Functions []Method `xml:"functions>function" json:"functions" yml:"functions"`
	Variables []Field  `xml:"variables>variable" json:"variables" yml:"variables"`
	UseSpaces bool     `xml:"use_spaces" json:"use_spaces" yml:"use_spaces"`
}

type Parameter

type Parameter struct {
	Name    string `xml:"name" json:"name" yml:"name"`
	Type    string `xml:"type" json:"type" yml:"type"`
	Pass    string `xml:"pass" json:"pass" yml:"pass"`
	Const   bool   `xml:"const" json:"const" yml:"const"`
	Default string `xml:"default" json:"default" yml:"default"`
}

type Parent

type Parent struct {
	Name   string `xml:"name" json:"name" yml:"name"`
	Access string `xml:"access" json:"access" yml:"access"`
}

type PythonGenerator

type PythonGenerator struct{}

func (PythonGenerator) Generate

func (gen PythonGenerator) Generate(pkg Package) map[string]string

type RubyGenerator

type RubyGenerator struct{}

func (RubyGenerator) Generate

func (gen RubyGenerator) Generate(pkg Package) map[string]string

type XmlGenerator

type XmlGenerator struct{}

func (XmlGenerator) Generate

func (gen XmlGenerator) Generate(pkg Package) map[string]string

type YamlGenerator

type YamlGenerator struct{}

func (YamlGenerator) Generate

func (gen YamlGenerator) Generate(pkg Package) map[string]string

Jump to

Keyboard shortcuts

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