Documentation ¶
Overview ¶
Package bind provides tools to generate bindings to use Go from Python.
Index ¶
- Constants
- Variables
- func CmdStrToMakefile(cmdstr string) string
- func GenPyBind(mode BuildMode, libext, extragccargs string, lang int, cfg *BindCfg) error
- func ResetPackages()
- type BindCfg
- type BuildMode
- type Const
- type Enum
- type ErrorList
- type Func
- type Interface
- type Map
- type Object
- type Package
- type Protocol
- type PyConfig
- type Signature
- type Slice
- type Struct
- type Type
- type Var
Constants ¶
const ( // GoHandle is the type to use for the Handle map key, go-side GoHandle = "int64" // CGoHandle is Handle for cgo files CGoHandle = "C.longlong" // PyHandle is within python PyHandle = "int64_t" )
const ( ModeGen BuildMode = "gen" ModeBuild = "build" ModeExe = "exe" ModePkg = "pkg" )
const ( PyBuildPreamble = `` /* 1792-byte string literal not displayed */ // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports PyWrapPreamble = `` /* 725-byte string literal not displayed */ // exe version of preamble -- doesn't need complex code to load _ module // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports PyWrapExePreamble = `` /* 514-byte string literal not displayed */ GoPkgDefs = `` /* 524-byte string literal not displayed */ // 3 = gencmd, 4 = vm, 5 = libext 6 = extraGccArgs, 7 = CFLAGS, 8 = LDLFAGS, // 9 = windows special declspec hack MakefileTemplate = `` /* 1154-byte string literal not displayed */ // exe version of template: 3 = gencmd, 4 = vm, 5 = libext MakefileExeTemplate = `` /* 1160-byte string literal not displayed */ )
3 = libcfg, 4 = GoHandle, 5 = CGoHandle, 6 = all imports, 7 = mainstr, 8 = exe pre C, 9 = exe pre go
Variables ¶
var NoMake = false
NoMake turns off generation of Makefiles
var NoWarn = false
NoWarn turns off warnings -- this must be a global as it is relevant during initial package parsing before e.g., thePyGen is present.
var Packages []*Package
Packages accumulates all the packages processed
var WindowsOS = false
set this to true if OS is windows
Functions ¶
func CmdStrToMakefile ¶ added in v0.4.1
CmdStrToMakefile does what is needed to make the command string suitable for makefiles * removes -output
func GenPyBind ¶ added in v0.4.1
GenPyBind generates a .go file, build.py file to enable pybindgen to create python bindings, and wrapper .py file(s) that are loaded as the interface to the package with shadow python-side classes mode = gen, build, pkg, exe
func ResetPackages ¶ added in v0.4.1
func ResetPackages()
ResetPackages resets any accumulated packages -- needed when doing tests
Types ¶
type BindCfg ¶ added in v0.4.1
type BindCfg struct { // output directory for bindings OutputDir string // name of output package (otherwise name of first package is used) Name string // code string to run in the go main() function in the cgo library Main string // the full command args as a string, without path to exe Cmd string // path to python interpreter VM string // package prefix used when generating python import statements PkgPrefix string // rename Go exported symbols to python PEP snake_case RenameCase bool }
BindCfg is a configuration used during binding generation
type Enum ¶ added in v0.4.1
type Enum struct {
// contains filtered or unexported fields
}
func (*Enum) SortConsts ¶ added in v0.4.1
func (e *Enum) SortConsts()
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func collects information about a go func/method.
type Interface ¶ added in v0.4.1
type Interface struct {
// contains filtered or unexported fields
}
Interface collects information about a go interface.
type Map ¶ added in v0.4.1
type Map struct {
// contains filtered or unexported fields
}
Map collects information about a go map.
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package ties types.Package and ast.Package together. Package also collects information about specific types (structs, ifaces, etc)
func NewPackage ¶
NewPackage creates a new Package, tying types.Package and ast.Package together.
func (*Package) AddPyImport ¶ added in v0.4.1
add given path to python imports -- these packages were referenced
func (*Package) ImportPath ¶
ImportPath returns the package import path.
type Protocol ¶
type Protocol int
Protocol encodes the various protocols a python type may implement
type PyConfig ¶ added in v0.4.1
func GetPythonConfig ¶ added in v0.4.1
GetPythonConfig returns the needed python configuration for the given python VM (python, python2, python3, pypy, etc...)
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
A Signature represents a (non-builtin) function or method type.
type Slice ¶ added in v0.4.1
type Slice struct {
// contains filtered or unexported fields
}
Slice collects information about a go slice.
type Struct ¶
type Struct struct {
// contains filtered or unexported fields
}
Struct collects information about a go struct.
func (*Struct) FirstEmbed ¶ added in v0.4.1
func (s *Struct) FirstEmbed() *symbol
FirstEmbed returns the first field if it is embedded, supporting convention of placing embedded "parent" types first