Documentation ¶
Index ¶
- Constants
- func ArrayNameFromLength(lengthCName string) string
- func CleanDoxygenComment(name, comment string) string
- func CommonReceiverName(s string) string
- func GenerateFunctionString(af *ASTFunc) string
- func IsInteger(typ *Type) bool
- func LowerFirstCharacter(s string) string
- func ReplaceGoKeywords(s string) string
- func TrimCommonFunctionName(name string, typ Type) string
- func TrimCommonFunctionNamePrefix(name string) string
- func TrimLanguagePrefix(name string) string
- func UpperFirstCharacter(s string) string
- type API
- type ASTFunc
- func (af *ASTFunc) AddAssignment(variable string, e ast.Expr)
- func (af *ASTFunc) AddCArrayFromGoSlice(name string, typ Type)
- func (af *ASTFunc) AddCToGoConversions()
- func (af *ASTFunc) AddCToGoSliceConversion(name string, cname string, lengthOfSlice string)
- func (af *ASTFunc) AddDefer(call *ast.CallExpr)
- func (af *ASTFunc) AddEmptyLine()
- func (af *ASTFunc) AddGoToCSliceConversion(name string, typ Type)
- func (af *ASTFunc) AddReturnItem(item ast.Expr)
- func (af *ASTFunc) AddReturnType(name string, typ Type)
- func (af *ASTFunc) AddStatement(stmt ast.Stmt)
- func (af *ASTFunc) Generate()
- func (af *ASTFunc) GenerateParameters() []ast.Expr
- func (af *ASTFunc) GenerateReceiver()
- func (af *ASTFunc) GenerateReturn(call ast.Expr)
- type Enum
- type EnumItem
- type File
- type Function
- type FunctionParameter
- type Generation
- func (g *Generation) AddBasicMethods(f *Function, fname string, fnamePrefix string, rt Receiver) bool
- func (g *Generation) AddHeaderFiles(headerFiles []*HeaderFile)
- func (g *Generation) AddMethod(f *Function, fname string, fnamePrefix string, rt Receiver) bool
- func (g *Generation) Generate() error
- func (g *Generation) GenerateMethod(receiverName string, m interface{}) string
- func (g *Generation) SetIsPointerComposition(typ *Type)
- type HeaderFile
- type IncludeFiles
- type Lookup
- func (l *Lookup) HasEnum(n string) (*Enum, bool)
- func (l *Lookup) HasStruct(n string) (*Struct, bool)
- func (l *Lookup) IsEnumOrStruct(name string) bool
- func (l *Lookup) LookupNonTypedef(s string) (string, bool)
- func (l *Lookup) RegisterEnum(e *Enum)
- func (l *Lookup) RegisterStruct(s *Struct)
- func (l *Lookup) RemoveStruct(s *Struct)
- type Receiver
- type Struct
- type StructField
- type Type
Constants ¶
const ( GoByte = "byte" GoInt8 = "int8" GoUInt8 = "uint8" GoInt16 = "int16" GoUInt16 = "uint16" GoInt32 = "int32" GoUInt32 = "uint32" GoInt64 = "int64" GoUInt64 = "uint64" GoFloat32 = "float32" GoFloat64 = "float64" GoBool = "bool" GoInterface = "interface" GoPointer = "unsafe.Pointer" )
Defines all available Go types.
const ( CChar = "char" CSChar = "schar" CUChar = "uchar" CShort = "short" CUShort = "ushort" CInt = "int" CUInt = "uint" CLongInt = "long" CULongInt = "ulong" CLongLong = "longlong" CULongLong = "ulonglong" CFloat = "float" CDouble = "double" )
Defines all available C types.
Variables ¶
This section is empty.
Functions ¶
func ArrayNameFromLength ¶
ArrayNameFromLength returns the array name from lengthCName length naming.
func CleanDoxygenComment ¶
CleanDoxygenComment converts Clang Doxygen comment to Go comment.
func CommonReceiverName ¶
CommonReceiverName returns the common function receiver name.
func GenerateFunctionString ¶
GenerateFunctionString generates function string.
func LowerFirstCharacter ¶
LowerFirstCharacter converts first s character to lower.
func ReplaceGoKeywords ¶
ReplaceGoKeywords replaces s to Go keyword.
func TrimCommonFunctionName ¶
TrimCommonFunctionName trims common function-name from name.
func TrimCommonFunctionNamePrefix ¶
TrimCommonFunctionNamePrefix trims common function-name prefix from name.
func TrimLanguagePrefix ¶
TrimLanguagePrefix trims Language prefix from name.
func UpperFirstCharacter ¶
UpperFirstCharacter converts first s character to upper.
Types ¶
type API ¶
type API struct { // PrepareFunctionName returns a prepared function name for further processing. PrepareFunctionName func(g *Generation, f *Function) string // PrepareFunction prepares a function for further processing. PrepareFunction func(f *Function) // FilterFunction determines if a function is generateable. FilterFunction func(f *Function) bool // FilterFunctionParameter determines if a function parameter is generateable. FilterFunctionParameter func(p FunctionParameter) bool // FixFunctionName returns an unempty string if a function needs to receive a specific name. FixFunctionName func(f *Function) string // PrepareStructFields is called before adding struct field getters. PrepareStructFields func(s *Struct) // FilterStructFieldGetter determines if a getter should be generated for a field. FilterStructFieldGetter func(f *StructField) bool // ClangArguments holds the command line arguments for Clang. ClangArguments []string }
API represents a Clang bindings generation.
func (*API) HandleDirectory ¶
func (a *API) HandleDirectory(dir string) ([]*HeaderFile, error)
HandleDirectory handles header files on dir and returns the *HeaderFile slice.
type ASTFunc ¶
ASTFunc represents a AST Func.
func NewASTFunc ¶
NewASTFunc returns the new initialized ASTFunc.
func (*ASTFunc) AddAssignment ¶
AddAssignment adds assignment to af.
func (*ASTFunc) AddCArrayFromGoSlice ¶
AddCArrayFromGoSlice adds C array from Go slice to af.
func (*ASTFunc) AddCToGoConversions ¶
func (af *ASTFunc) AddCToGoConversions()
AddCToGoConversions adds C to Go conversions to af.
func (*ASTFunc) AddCToGoSliceConversion ¶
AddCToGoSliceConversion adds C to Go slice conversion to af.
func (*ASTFunc) AddEmptyLine ¶
func (af *ASTFunc) AddEmptyLine()
AddEmptyLine adds empty line to af.
func (*ASTFunc) AddGoToCSliceConversion ¶
AddGoToCSliceConversion adds Go to C slice conversion to af.
func (*ASTFunc) AddReturnItem ¶
AddReturnItem adds return item to af.
func (*ASTFunc) AddReturnType ¶
AddReturnType adds return type to af.
func (*ASTFunc) AddStatement ¶
AddStatement adds stmt ast.Stmt to af.
func (*ASTFunc) GenerateParameters ¶
GenerateParameters generates function parameters.
func (*ASTFunc) GenerateReceiver ¶
func (af *ASTFunc) GenerateReceiver()
GenerateReceiver generates function receiver.
func (*ASTFunc) GenerateReturn ¶
GenerateReturn generates return statement.
type Enum ¶
type Enum struct { IncludeFiles IncludeFiles Name string CName string CNameIsTypeDef bool Receiver Receiver Comment string UnderlyingType string Items []EnumItem Methods []interface{} }
Enum represents a generation enum.
func HandleEnumCursor ¶
HandleEnumCursor handles enum clang.Cursor and roterns the new *Enum.
func (*Enum) AddEnumSpellingMethod ¶
AddEnumSpellingMethod adds Enum spelling method to e.
func (*Enum) AddEnumStringMethods ¶
AddEnumStringMethods adds Enum String methods to e.
func (*Enum) AddSpellingMethodAlias ¶
AddSpellingMethodAlias adds spelling method alias to e.
func (*Enum) ContainsMethod ¶
ContainsMethod reports whether the contains name to Enum.Methods.
type File ¶
type File struct { Name string IncludeFiles IncludeFiles Functions []interface{} Enums []*Enum Structs []*Struct }
File represents a generation file.
type Function ¶
type Function struct { IncludeFiles IncludeFiles Name string CName string Comment string Parameters []FunctionParameter ReturnType Type Receiver Receiver Member *FunctionParameter }
Function represents a generation function.
func HandleFunctionCursor ¶
HandleFunctionCursor handles function cursor.
func NewFunction ¶
NewFunction returns the initialized *Function.
type FunctionParameter ¶
FunctionParameter represents a generation function parameter.
type Generation ¶
type Generation struct { Lookup // contains filtered or unexported fields }
Generation represents a generation entrypoint.
func NewGeneration ¶
func NewGeneration(a *API) *Generation
NewGeneration returns the new *Generation from a.
func (*Generation) AddBasicMethods ¶
func (g *Generation) AddBasicMethods(f *Function, fname string, fnamePrefix string, rt Receiver) bool
AddBasicMethods adds basic methods.
func (*Generation) AddHeaderFiles ¶
func (g *Generation) AddHeaderFiles(headerFiles []*HeaderFile)
AddHeaderFiles adds headerFiles to g.
func (*Generation) Generate ¶
func (g *Generation) Generate() error
Generate Clang bindings generation.
func (*Generation) GenerateMethod ¶
func (g *Generation) GenerateMethod(receiverName string, m interface{}) string
GenerateMethod method generation.
func (*Generation) SetIsPointerComposition ¶
func (g *Generation) SetIsPointerComposition(typ *Type)
SetIsPointerComposition sets IsPointerComposition if given.
type HeaderFile ¶
type HeaderFile struct { Lookup Filename string Path string Enums []*Enum Functions []*Function Structs []*Struct // contains filtered or unexported fields }
HeaderFile represents a generation headerfile.
func NewHeaderFile ¶
func NewHeaderFile(a *API, name string, dir string) *HeaderFile
NewHeaderFile returns the new initialized HeaderFile.
func (*HeaderFile) FullPath ¶
func (h *HeaderFile) FullPath() string
FullPath returns the full path of h.
func (*HeaderFile) HandleFile ¶
func (h *HeaderFile) HandleFile(cursor clang.Cursor)
HandleFile handles header file.
func (*HeaderFile) Parse ¶
func (h *HeaderFile) Parse(clangArguments []string) error
Parse parses header file with clangArguments.
func (*HeaderFile) PrepareFile ¶
func (h *HeaderFile) PrepareFile() error
PrepareFile prepares header files name.
type IncludeFiles ¶
type IncludeFiles map[string]struct{}
IncludeFiles represents a generation include files.
func NewIncludeFiles ¶
func NewIncludeFiles() IncludeFiles
NewIncludeFiles returns the new include files map.
func (IncludeFiles) AddIncludeFile ¶
func (inf IncludeFiles) AddIncludeFile(includeFile string)
AddIncludeFile adds include file to inf.
type Lookup ¶
type Lookup struct {
// contains filtered or unexported fields
}
Lookup represents a in-memory lookup store.
func (*Lookup) IsEnumOrStruct ¶
IsEnumOrStruct reports whether the name is Enum or Struct.
func (*Lookup) LookupNonTypedef ¶
LookupNonTypedef lookups non typedef from Lookup.
func (*Lookup) RegisterEnum ¶
RegisterEnum registers e *Enum to Lookup.
func (*Lookup) RegisterStruct ¶
RegisterStruct registers s *Struct to Lookup.
func (*Lookup) RemoveStruct ¶
RemoveStruct removes s *Struct from Lookup.
type Receiver ¶
Receiver represents a generation receiver.
TODO(go-clang): refactor https://github.com/go-clang/gen/issues/52
type Struct ¶
type Struct struct { IncludeFiles Name string CName string CNameIsTypeDef bool Receiver Receiver Comment string IsPointerComposition bool Fields []*StructField Methods []interface{} // contains filtered or unexported fields }
Struct represents a generation struct.
func HandleStructCursor ¶
HandleStructCursor handles the struct cursor.
func (*Struct) AddFieldGetters ¶
AddFieldGetters adds field getters to s.
func (*Struct) ContainsMethod ¶
ContainsMethod reports whether the contains name in Struct.
type StructField ¶
StructField field of Struct.
type Type ¶
type Type struct { // CName C Type name CName string // CGoName Cgo Type name CGoName string // GoName Go Type name GoName string // LengthOfSlice length of slice LengthOfSlice string // ArraySize size of array ArraySize int64 // PointerLevel level of pointer PointerLevel int // IsPrimitive whether the this Type is primitive IsPrimitive bool // IsArray whether the this Type is array IsArray bool // IsEnumLiteral whether the this Type is enum literal IsEnumLiteral bool // IsFunctionPointer whether the this Type is function pointer IsFunctionPointer bool // IsReturnArgument whether the this Type is return argument IsReturnArgument bool // IsSlice whether the this Type is slice IsSlice bool // IsPointerComposition whether the this Type is pointer composition IsPointerComposition bool }
Type represents a generation type.