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, ...) error
- func ResetPackages()
- 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 = `` /* 416-byte string literal not displayed */ // 3 = specific package name, 4 = spec pkg path, 5 = doc, 6 = imports PyWrapPreamble = `` /* 631-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 = `` /* 437-byte string literal not displayed */ GoPkgDefs = `` /* 423-byte string literal not displayed */ // 3 = gencmd, 4 = vm, 5 = libext 6 = extraGccArgs MakefileTemplate = `` /* 1212-byte string literal not displayed */ // exe version of template: 3 = gencmd, 4 = vm, 5 = libext MakefileExeTemplate = `` /* 1225-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
Functions ¶
func CmdStrToMakefile ¶ added in v0.3.5
CmdStrToMakefile does what is needed to make the command string suitable for makefiles * removes -output
func GenPyBind ¶ added in v0.3.5
func GenPyBind(mode BuildMode, odir, outname, cmdstr, vm, mainstr, libext, extragccargs string, lang int) error
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.3.5
func ResetPackages()
ResetPackages resets any accumulated packages -- needed when doing tests
Types ¶
type Enum ¶ added in v0.3.5
type Enum struct {
// contains filtered or unexported fields
}
func (*Enum) SortConsts ¶ added in v0.3.5
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.3.5
type Interface struct {
// contains filtered or unexported fields
}
Interface collects information about a go interface.
type Map ¶ added in v0.3.5
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.3.5
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.3.5
func GetPythonConfig ¶ added in v0.3.5
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.3.5
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.3.5
func (s *Struct) FirstEmbed() *symbol
FirstEmbed returns the first field if it is embedded, supporting convention of placing embedded "parent" types first