classes

package
v0.0.0-...-1746202 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate()

func GoFmt

func GoFmt(filePath string)

func GoImports

func GoImports(filePath string)

func WriteTemplate

func WriteTemplate(templatePath, outputPath string, view View)

Types

type ByEnumName

type ByEnumName []GDEnums

ByEnumName is used for sorting GDAPI objects by name

func (ByEnumName) Len

func (c ByEnumName) Len() int

func (ByEnumName) Less

func (c ByEnumName) Less(i, j int) bool

func (ByEnumName) Swap

func (c ByEnumName) Swap(i, j int)

type ByMethodName

type ByMethodName []GDMethod

ByMethodName is used for sorting GDAPI objects by name

func (ByMethodName) Len

func (c ByMethodName) Len() int

func (ByMethodName) Less

func (c ByMethodName) Less(i, j int) bool

func (ByMethodName) Swap

func (c ByMethodName) Swap(i, j int)

type ByName

type ByName []GDAPI

ByName is used for sorting GDAPI objects by name

func (ByName) Len

func (c ByName) Len() int

func (ByName) Less

func (c ByName) Less(i, j int) bool

func (ByName) Swap

func (c ByName) Swap(i, j int)

type ByPropertyName

type ByPropertyName []GDProperty

ByPropertyName is used for sorting GDAPI objects by name

func (ByPropertyName) Len

func (c ByPropertyName) Len() int

func (ByPropertyName) Less

func (c ByPropertyName) Less(i, j int) bool

func (ByPropertyName) Swap

func (c ByPropertyName) Swap(i, j int)

type BySignalName

type BySignalName []GDSignal

BySignalName is used for sorting GDAPI objects by name

func (BySignalName) Len

func (c BySignalName) Len() int

func (BySignalName) Less

func (c BySignalName) Less(i, j int) bool

func (BySignalName) Swap

func (c BySignalName) Swap(i, j int)

type GDAPI

type GDAPI struct {
	APIType      string           `json:"api_type"`
	BaseClass    string           `json:"base_class"`
	Constants    map[string]int64 `json:"constants"`
	Enums        []GDEnums        `json:"enums"`
	Methods      []GDMethod       `json:"methods"`
	Name         string           `json:"name"`
	Properties   []GDProperty     `json:"properties"`
	Signals      []GDSignal       `json:"signals"`
	Singleton    bool             `json:"singleton"`
	Instanciable bool             `json:"instanciable"`
	IsReference  bool             `json:"is_reference"`
}

GDAPI is a structure for parsed JSON from godot_api.json.

type GDAPIDoc

type GDAPIDoc struct {
	Name        string        `xml:"name,attr"`
	Description string        `xml:"description"`
	Methods     []GDMethodDoc `xml:"methods>method"`
}

GDAPIDoc is a structure for parsed documentation.

type GDArgument

type GDArgument struct {
	DefaultValue    string `json:"default_value"`
	HasDefaultValue bool   `json:"has_default_value"`
	Name            string `json:"name"`
	Type            string `json:"type"`
}

type GDEnums

type GDEnums struct {
	Name   string           `json:"name"`
	Values map[string]int64 `json:"values"`
}

type GDMethod

type GDMethod struct {
	Arguments    []GDArgument `json:"arguments"`
	HasVarargs   bool         `json:"has_varargs"`
	IsConst      bool         `json:"is_const"`
	IsEditor     bool         `json:"is_editor"`
	IsFromScript bool         `json:"is_from_script"`
	IsNoscript   bool         `json:"is_noscript"`
	IsReverse    bool         `json:"is_reverse"`
	IsVirtual    bool         `json:"is_virtual"`
	Name         string       `json:"name"`
	ReturnType   string       `json:"return_type"`
}

type GDMethodDoc

type GDMethodDoc struct {
	Name        string `xml:"name,attr"`
	Description string `xml:"description"`
}

type GDProperty

type GDProperty struct {
	Getter string `json:"getter"`
	Name   string `json:"name"`
	Setter string `json:"setter"`
	Type   string `json:"type"`
}

type GDSignal

type GDSignal struct {
	Arguments []GDArgument `json:"arguments"`
	Name      string       `json:"name"`
}

type View

type View struct {
	API          GDAPI
	APIs         []GDAPI
	Package      string
	PackageMap   map[string]string
	Imports      map[string]map[string]bool
	ClassDocs    map[string]string
	MethodDocs   map[string]map[string]string
	SingletonMap map[string]bool
}

View is a structure that holds the api classes struct, but has additional methods attached to it that we can call inside our template.

func (View) ClassDoc

func (v View) ClassDoc(class string) string

ClassDoc returns the class documentation for the given class.

func (View) GetImports

func (v View) GetImports() []string

func (View) GoArgName

func (v View) GoArgName(argString string) string

GoArgName will check for Go reserved keywords like "type" when used as argument names and convert them, so we don't get compile errors.

func (View) GoClassName

func (v View) GoClassName(classString string) string

GoClassName will convert any _<Name> classes into normal CamelCase names.

func (View) GoEmptyReturnType

func (v View) GoEmptyReturnType(str string) string

func (View) GoMethodName

func (v View) GoMethodName(methodString string) string

GoMethodName will convert the snake_case'd version of the Godot method name into a CamelCase version that is the Go convention.

func (View) GoName

func (v View) GoName(str string) string

func (View) GoNewFromPointerType

func (v View) GoNewFromPointerType(str string) string

func (View) GoValue

func (v View) GoValue(returnString string) string

GoValue will convert the Godot value into a valid Go value.

func (View) HasParentMethod

func (v View) HasParentMethod(base, method string) bool

HasParentMethod checks to see if the given method exists in any of its parents. It will recursively search for any parent with the given method name. This is used to generate interfaces for every Godot class type.

func (View) IsEnum

func (v View) IsEnum(str string) bool

func (View) IsGodotClass

func (v View) IsGodotClass(str string) bool

IsGodotClass will determine if the given string is the name of a Godot class API. This is used to check if a type is another class or a gdnative base type.

func (View) IsValidClass

func (v View) IsValidClass(classString, inheritsString string) bool

IsValidClass will check the class to see if we should generate Go bindings for it.

func (View) MethodDoc

func (v View) MethodDoc(class, method string) string

MethodDoc returns the method documentation for a given class method.

func (View) PackageName

func (v View) PackageName(classString string) string

func (View) ResolvePackage

func (v View) ResolvePackage(curPkg, api string) string

ResolvePackage will look up the api in the package map for the Go package name that we should use.

func (View) SetBaseClassName

func (v View) SetBaseClassName(baseClass string) string

func (View) SetClassName

func (v View) SetClassName(classString string, singleton bool) string

func (View) Trim

func (v View) Trim(str string) string

Trim can be used inside the template to trim starting and ending whitespace.

func (View) UltraTrim

func (v View) UltraTrim(input string) string

UltraTrim will use RegEx to clean all extra whitespace.

Jump to

Keyboard shortcuts

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