Documentation
¶
Index ¶
- Constants
- Variables
- func Finalize()
- func FinalizeEx() int
- func InitGoModuleName(name string, doc string)
- func Initialize()
- func IsInitialized() int
- func NewModuleInitFuncCallBack(moduleName string, fn func() *PyObject) uintptr
- func PyErr_SetString(tp *PyObject, message string)
- func PyImport_AppendInittab(name string, initFunc func() *PyObject) int
- func PyObjectToGo(o *PyObject, to reflect.Type) any
- func PyTypeToGoType(p *PyObject) any
- func RunAnyFile(pathstr string) int
- func RunSimpleFile(pathstr string) int
- func RunSimpleString(command string) int
- func SetProgramName(name string)
- func SetPythonHome(home string)
- type CObj
- type ICObj
- type IPyObject
- type PyBool
- type PyBytes
- type PyClass
- type PyClassGoObj
- type PyDict
- func (p *PyDict) Clear()
- func (p *PyDict) DelItem(key *PyObject) int
- func (p *PyDict) DelItemString(key string) int
- func (p *PyDict) GetItem(key *PyObject) *PyObject
- func (p *PyDict) GetItemString(key string) *PyObject
- func (p *PyDict) Keys() *PyObject
- func (p *PyDict) SetItem(key *PyObject, val *PyObject) int
- func (p *PyDict) SetItemString(key string, val *PyObject) int
- func (p *PyDict) Size() int64
- type PyFrame
- type PyList
- type PyLong
- type PyModule
- func (p *PyModule) AddClass(class *PyClass)
- func (p *PyModule) AddFunction(name string, fn interface{})
- func (p *PyModule) AddIntConstant(name string, value int64) int
- func (p *PyModule) AddObject(name string, value *PyObject) int
- func (p *PyModule) AddObjectRef(name string, value *PyObject) int
- func (p *PyModule) AddStringConstant(name string, value string) int
- func (p *PyModule) GetDict() *PyDict
- func (p *PyModule) GetName() string
- type PyModuleGoObj
- type PyNone
- type PyObject
- func GoToPyObject(o interface{}) *PyObject
- func NewPyBool(b bool) *PyObject
- func NewPyBoolFromLong(l int64) *PyObject
- func PyClassInstanceMethodForward(self *PyObject, args *PyTuple, method interface{}) *PyObject
- func PyErr_NewException(name string, base *PyObject, dict *PyObject) *PyObject
- func PyEval_GetBuiltins() *PyObject
- func PyEval_GetGlobals() *PyObject
- func PyEval_GetLocals() *PyObject
- func PyExc_Exception() *PyObject
- func PyExc_ValueError() *PyObject
- func PyMethodForward(self *PyModule, args *PyTuple, method interface{}) *PyObject
- func PyObjectFromInst(inst uintptr) *PyObject
- func UserException() *PyObject
- func (p *PyObject) AsDouble() float64
- func (p *PyObject) AsInt() int
- func (p *PyObject) AsLong() int
- func (p *PyObject) AsLongLong() int64
- func (p *PyObject) AsObj() *PyObject
- func (p *PyObject) AsUTF8() string
- func (p *PyObject) Call(args *PyObject, kwargs *PyObject) *PyObject
- func (p *PyObject) CallNoArgs() *PyObject
- func (p *PyObject) CallObject(args *PyObject) *PyObject
- func (o *PyObject) DecRef()
- func (p *PyObject) DelAttrString(attr_name string) int
- func (p *PyObject) GetAttr(attr_name string) *PyObject
- func (p *PyObject) GetAttrString(attr_name string) *PyObject
- func (p *PyObject) HashAttrString(attr_name string) int
- func (o *PyObject) IncRef()
- func (p *PyObject) PyObject_Call(args *PyObject, kwargs *PyObject) *PyObject
- func (p *PyObject) RefCount() int
- func (p *PyObject) SetAttrString(attr_name string, v *PyObject) int
- func (p *PyObject) Str() string
- func (p *PyObject) String() string
- func (p *PyObject) Type() *PyType
- type PyTuple
- type PyType
- type PyUnicode
Constants ¶
const ( PYTHON_API_VERSION = 1013 PYTHON_API_STRING = "1013" )
Variables ¶
var PyClassInstanceMethodCallDef *cpy3.PyMethodDef
var PyClassInstanceMethodForwardCallBack = syscall.NewCallback(func(self uintptr, args uintptr) uintptr { pyArgs := PyTupleFromInst(args) arg1 := pyArgs.GetItem(0) tp := arg1.Type() defer tp.DecRef() if tp.Name() == "str" { fmt.Println("static") } else { pyArgsLen := pyArgs.Size() if pyArgsLen < 2 { return Py_RETURN_NONE().instance } ForwardCode := pyArgs.GetItem(1).Str() newArgs := PyTupleFromObj(pyArgs.GetSlice(2, pyArgsLen)) defer newArgs.DecRef() pySelf := pyArgs.GetItem(0) PyClass := PyClassFromObj(pySelf) className := PyClass.GetName() ifn, ok := PyClass.GoObj.CallMap.Load(ForwardCode) if ok == false { PyErr_SetString(UserException(), fmt.Sprintf("%s not find method %s ", className, ForwardCode)) return Py_RETURN_NONE().Instance() } return PyClassInstanceMethodForward(pySelf, newArgs, ifn).instance } return Py_RETURN_NONE().instance })
var PyModuleMethodForwardCallBack = syscall.NewCallback(func(self uintptr, args uintptr) uintptr { pyArgs := PyTupleFromInst(args) pyArgsLen := pyArgs.Size() if pyArgsLen < 1 { return Py_RETURN_NONE().instance } ForwardCode := pyArgs.GetItem(0).Str() pyModule := PyModuleFromInst(self) moduleName := pyModule.GetName() ifn, ok := pyModule.GoObj.CallMap.Load(ForwardCode) if ok == false { PyErr_SetString(UserException(), fmt.Sprintf("%s not find method %s ", moduleName, ForwardCode)) return Py_RETURN_NONE().Instance() } newArgs := PyTupleFromObj(pyArgs.GetSlice(1, pyArgsLen)) defer newArgs.DecRef() return PyMethodForward(pyModule, newArgs, ifn).Instance() })
var PyNil = PyObjectFromInst(0)
var SystemClassMap = sync.Map{}
var SystemModuleMap = sync.Map{}
Functions ¶
func FinalizeEx ¶
func FinalizeEx() int
func InitGoModuleName ¶
func Initialize ¶
func Initialize()
func IsInitialized ¶
func IsInitialized() int
func PyErr_SetString ¶
func PyImport_AppendInittab ¶
func PyTypeToGoType ¶
func RunAnyFile ¶
func RunSimpleFile ¶
func RunSimpleString ¶
func SetProgramName ¶
func SetProgramName(name string)
func SetPythonHome ¶
func SetPythonHome(home string)
Types ¶
type CObj ¶
type CObj struct {
// contains filtered or unexported fields
}
func (*CObj) ClearPointer ¶
func (i *CObj) ClearPointer()
type PyBool ¶
type PyBool struct {
PyObject
}
func PyBoolFromInst ¶
PyBoolFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyBoolFromObj ¶
type PyBytes ¶
type PyBytes struct {
PyObject
}
func PyBytesFromInst ¶
PyBytesFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyBytes_FromString ¶
type PyClass ¶
type PyClass struct { PyObject GoObj *PyClassGoObj }
func CreateClass ¶
func PyClassFromInst ¶
PyClassFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyClassFromObj ¶
func (*PyClass) AddFunction ¶
type PyClassGoObj ¶
type PyDict ¶
type PyDict struct {
PyObject
}
func PyDictFromInst ¶
PyDictFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyDictFromObj ¶
func (*PyDict) DelItemString ¶
func (*PyDict) GetItemString ¶
type PyFrame ¶
type PyFrame struct {
PyObject
}
func PyEval_GetFrame ¶
func PyEval_GetFrame() *PyFrame
func PyFrameFromInst ¶
PyFrameFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
type PyList ¶
type PyList struct {
PyObject
}
func PyListFromInst ¶
PyListFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyListFromObj ¶
type PyLong ¶
type PyLong struct {
PyObject
}
func PyLongFromInst ¶
PyLongFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyLongFromLong ¶
func PyLongFromLongLong ¶
func PyLongFromObj ¶
func PyLong_FromDouble ¶
type PyModule ¶
type PyModule struct { PyObject GoObj *PyModuleGoObj }
var GoModule *PyModule
func CreateModule ¶
func PyImport_Import ¶
func PyModuleFromInst ¶
PyModuleFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyModuleFromObj ¶
func (*PyModule) AddFunction ¶
func (*PyModule) AddStringConstant ¶
type PyModuleGoObj ¶
type PyNone ¶
type PyNone struct {
PyObject
}
func PyNoneFromInst ¶
PyNoneFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func Py_RETURN_NONE ¶
func Py_RETURN_NONE() *PyNone
type PyObject ¶
type PyObject struct {
CObj
}
func GoToPyObject ¶
func GoToPyObject(o interface{}) *PyObject
func NewPyBoolFromLong ¶
func PyErr_NewException ¶
func PyEval_GetBuiltins ¶
func PyEval_GetBuiltins() *PyObject
func PyEval_GetGlobals ¶
func PyEval_GetGlobals() *PyObject
func PyEval_GetLocals ¶
func PyEval_GetLocals() *PyObject
func PyExc_Exception ¶
func PyExc_Exception() *PyObject
func PyExc_ValueError ¶
func PyExc_ValueError() *PyObject
func PyMethodForward ¶
func PyObjectFromInst ¶
PyObjectFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func UserException ¶
func UserException() *PyObject
func (*PyObject) AsLongLong ¶
func (*PyObject) CallNoArgs ¶
func (*PyObject) CallObject ¶
func (*PyObject) DelAttrString ¶
func (*PyObject) GetAttrString ¶
func (*PyObject) HashAttrString ¶
func (*PyObject) PyObject_Call ¶
func (*PyObject) SetAttrString ¶
type PyTuple ¶
type PyTuple struct {
PyObject
}
func NewPyTuple ¶
func PyTupleFromInst ¶
PyTupleFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyTupleFromObj ¶
type PyType ¶
type PyType struct {
PyObject
}
func PyTypeFromInst ¶
PyTypeFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.
func PyTypeFromObj ¶
type PyUnicode ¶
type PyUnicode struct {
PyObject
}
func NewPyUnicode ¶
func PyUnicodeFromInst ¶
PyUnicodeFromInst 新建一个对象来自已经存在的对象实例指针。
Create a new object from an existing object instance pointer.