Documentation ¶
Overview ¶
Package binding provides helpers for building autogenerated cgo bindings.
Index ¶
- func CgoConversionFor(name string, typ cc.Type, types ...map[TypeKey]*template.Template) string
- func CgoConversionForEnum(name string, typ cc.Type, types ...map[string]*template.Template) string
- func DocComments(path string) (docs map[string]map[string][]*ast.Comment, err error)
- func GoTypeFor(typ cc.Type, name string, types ...map[TypeKey]*template.Template) string
- func GoTypeForEnum(typ cc.Type, name string, types ...map[string]*template.Template) string
- func LowerCaseFirst(s string) string
- func UpperCaseFirst(s string) string
- type Declaration
- type Parameter
- type TypeKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CgoConversionFor ¶
CgoConversionFor returns a string representation of the given type using a mapping in types. CgoConversionFor will panic if no type mapping is found after searching the user-provided types mappings and then the following mapping:
{Kind: cc.Void, IsPointer: true}: "unsafe.Pointer(&{{.}}[0])", {Kind: cc.Int}: "C.int({{.}})", {Kind: cc.Float}: "C.float({{.}})", {Kind: cc.Float, IsPointer: true}: "(*C.float)({{.}})", {Kind: cc.Double}: "C.double({{.}})", {Kind: cc.Double, IsPointer: true}: "(*C.double)({{.}})", {Kind: cc.Bool}: "C.bool({{.}})", {Kind: cc.FloatComplex}: "unsafe.Pointer(&{{.}})", {Kind: cc.DoubleComplex}: "unsafe.Pointer(&{{.}})", {Kind: cc.FloatComplex, IsPointer: true}: "unsafe.Pointer(&{{.}}[0])", {Kind: cc.DoubleComplex, IsPointer: true}: "unsafe.Pointer(&{{.}}[0])",
func CgoConversionForEnum ¶
CgoConversionForEnum returns a string representation of the given enum type using a mapping in types. GoTypeForEnum will panic if no type mapping is found after searching the user-provided types mappings or the type is not an enum.
func DocComments ¶
DocComments returns a map of method documentation comments for the package at the given path. The first key of the returned map is the type name and the second is the method name. Non-method function documentation are in docs[""].
func GoTypeFor ¶
GoTypeFor returns a string representation of the given type using a mapping in types. GoTypeFor will panic if no type mapping is found after searching the user-provided types mappings and then the following mapping:
{Kind: cc.Int}: "int", {Kind: cc.Float}: "float32", {Kind: cc.Float, IsPointer: true}: "[]float32", {Kind: cc.Double}: "float64", {Kind: cc.Double, IsPointer: true}: "[]float64", {Kind: cc.Bool}: "bool", {Kind: cc.FloatComplex}: "complex64", {Kind: cc.DoubleComplex}: "complex128",
func GoTypeForEnum ¶
GoTypeForEnum returns a string representation of the given enum type using a mapping in types. GoTypeForEnum will panic if no type mapping is found after searching the user-provided types mappings or the type is not an enum.
func LowerCaseFirst ¶
LowerCaseFirst returns s with the first character lower-cased. LowerCaseFirst assumes s is an ASCII-represented string.
func UpperCaseFirst ¶
UpperCaseFirst returns s with the first character upper-cased. UpperCaseFirst assumes s is an ASCII-represented string.
Types ¶
type Declaration ¶
type Declaration struct { Pos token.Pos Name string Return cc.Type CParameters []cc.Parameter Variadic bool }
Declaration is a description of a C function declaration.
func Declarations ¶
func Declarations(paths ...string) ([]Declaration, error)
Declarations returns the C function declarations in the givel set of file paths.
func (*Declaration) Parameters ¶
func (d *Declaration) Parameters() []Parameter
Parameters returns the declaration's CParameters converted to a []Parameter.
func (*Declaration) Position ¶
func (d *Declaration) Position() token.Position
Position returns the token position of the declaration.