示例#1
0
文件: call.go 项目: MogeiWang/py
func CallMethodEx(cfg *Config, self *py.Base, method string, args ...interface{}) (ret *py.Base, err error) {

	args1, err := PackEx(cfg, args...)
	if err != nil {
		err = errors.Info(syscall.EINVAL, "pyutil.Call").Detail(err)
		return
	}
	defer args1.Decref()

	return self.CallMethodObject(method, args1)
}
示例#2
0
文件: call.go 项目: MogeiWang/py
func CallEx(cfg *Config, fn *py.Base, args ...interface{}) (ret *py.Base, err error) {

	args1, err := PackEx(cfg, args...)
	if err != nil {
		err = errors.Info(syscall.EINVAL, "pyutil.Call").Detail(err)
		return
	}
	defer args1.Decref()

	return fn.CallObject(args1)
}
示例#3
0
文件: call.go 项目: MogeiWang/py
func NewEx(cfg *Config, mod *py.Base, clsname string, args ...interface{}) (ret *py.Base, err error) {

	o, err := mod.GetAttrString(clsname)
	if err != nil {
		err = errors.Info(err, "pyutil.New", clsname).Detail(err)
		return
	}
	defer o.Decref()

	ty, ok := py.AsClass(o)
	if !ok {
		err = errors.Info(syscall.EINVAL, "pyutil.New", o.String(), "is not a class")
		return
	}

	return NewInstanceEx(cfg, ty, args...)
}