wrapgen

package
v0.0.0-...-3dbd70c Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2014 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CtoCgoType = map[string]string{
	"void*": "unsafe.Pointer",
}
View Source
var CtoGoType = map[string]string{
	"float":  "float32",
	"double": "float64",
	"int":    "int",
	"void*":  "unsafe.Pointer",
	"void":   "",
}

maps C to Go types

View Source
var FilterTokens = map[string]bool{
	"const": true,
	"enum":  true,
}

These tokens are ignored

Functions

func CamelCase

func CamelCase(s string) string

turn some_name_blabla into SomeNameBlabla

func Render

func Render(fname string, templText string, data interface{})

Render template to file

func Tokenize

func Tokenize(fname string) []string

Read header file, split in tokens, ignore words from filter map.

Types

type Arg

type Arg struct {
	CType, Name string
	GoType      string
}

Function argument

type Func

type Func struct {
	CName  string
	CType  string
	Args   []Arg
	GoName string
	GoType string
}

Function prototype

func ParseFuncs

func ParseFuncs(tokens []string) []Func

Parse function prototypes

type TData

type TData struct {
	Funcs []Func
}

Utility type, pass to template rendering

func (*TData) CgoType

func (*TData) CgoType(ctype string) string

Map C type to cgo type. E.g.:

int -> C.int

func (*TData) GoName

func (*TData) GoName(cname string) string

Turn C function name into idiomatic, exported Go name.

func (*TData) GoType

func (*TData) GoType(ctype string) string

Map C type to Go type, using TypeMap lookup. E.g.:

float -> float32

func (*TData) Strip

func (*TData) Strip(s, prefix string) string

Jump to

Keyboard shortcuts

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