types

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: 13 Imported by: 0

Documentation

Overview

Package types is responsible for parsing the Godot headers for type definitions and generating Go wrappers around that structure.

Package types is a package that parses the GDNative headers for type definitions to create wrapper structures for Go.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate()

Generate will generate Go wrappers for all Godot base types

func GoFmt

func GoFmt(filePath string)

func GoImports

func GoImports(filePath string)

func WriteTemplate

func WriteTemplate(templatePath, outputPath string, view View)

Types

type Method

type Method struct {
	Name       string
	ReturnType string
	Arguments  [][]string
}

type TypeDef

type TypeDef struct {
	Base       string    // Base will let us know if this is a struct, int, etc.
	Comment    string    // Contains the comment on the line of the struct
	GoName     string    // The Go type name in camelCase
	HeaderName string    // The header file this type shows up in
	IsPointer  bool      // Usually for properties; defines if it is a pointer type
	Name       string    // The C type name in snake_case
	Properties []TypeDef // Optional C struct fields
	SimpleType bool      // Whether or not the definition is just one line long (e.g. bool, int, etc.)
}

TypeDef is a structure for holding C type definitions. This is used so we can generate a Go wrapper for all Godot base types.

func Parse

func Parse(excludeHeaders, excludeStructs []string) []TypeDef

Parse will parse the GDNative headers. Takes a list of headers/structs to ignore. Definitions in the given headers and definitions with the given name will not be added to the returned list of type definitions. We'll need to manually create these structures.

type View

type View struct {
	Headers           []string
	TypeDefinitions   []TypeDef
	MethodDefinitions []Method
	IgnoreMethods     []string
}

View is a structure that holds the api struct, so it can be used inside our temaplte.

func (View) Debug

func (v View) Debug(itm string) string

Debug will allow you to log inside the running template.

func (View) HasPointerReturn

func (v View) HasPointerReturn(str string) bool

func (View) HasReturn

func (v View) HasReturn(str string) bool

func (View) IsBasicType

func (v View) IsBasicType(str string) bool

func (View) IsDoublePointer

func (v View) IsDoublePointer(str string) bool

func (View) IsGodotBaseType

func (v View) IsGodotBaseType(typeDef TypeDef) bool

IsGodotBaseType will check to see if the given simple type definition is defining a built-in C type or a Godot type.

func (View) IsValidProperty

func (v View) IsValidProperty(prop TypeDef) bool

IsValidProperty will determine if we should be generating the given property in our Go structure.

func (View) IsVoidPointerType

func (v View) IsVoidPointerType(str string) bool

func (View) IsWcharT

func (v View) IsWcharT(str string) bool

func (View) MethodIsConstructor

func (v View) MethodIsConstructor(method Method) bool

func (View) MethodsList

func (v View) MethodsList(typeDef TypeDef) []Method

MethodsList returns all of the methods that match this typedef.

func (View) NotSelfArg

func (v View) NotSelfArg(str string) bool

func (View) OutputCArg

func (v View) OutputCArg(arg []string) string

OutputCArg will determine if we need to reference, dereference, etc. an argument before passing it to a C function.

func (View) StripPointer

func (v View) StripPointer(str string) string

func (View) ToGoArgName

func (v View) ToGoArgName(str string) string

func (View) ToGoArgType

func (v View) ToGoArgType(str string, parseArray bool) string

func (View) ToGoBaseType

func (v View) ToGoBaseType(base string) string

ToGoBaseType will convert a base type name to the correct Go base type.

func (View) ToGoMethodName

func (v View) ToGoMethodName(typeDef TypeDef, method Method) string

func (View) ToGoName

func (v View) ToGoName(str string) string

func (View) ToGoReturnType

func (v View) ToGoReturnType(str string) string

Jump to

Keyboard shortcuts

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