예제 #1
0
파일: module.go 프로젝트: MogeiWang/py
func (mod *Module) AddIntConstant(name string, value int) error {
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))

	ret := C.PyModule_AddIntConstant(mod.c(), cname, C.long(value))
	if ret < 0 {
		return exception()
	}

	return nil
}
예제 #2
0
// int PyModule_AddIntConstant(PyObject *module, const char *name, long value)
// Add an integer constant to module as name. This convenience function can be used from the module’s initialization function. Return -1 on error, 0 on success.
//
// New in version 2.0.
func PyModule_AddIntConstant(self *PyObject, name string, value int) error {
	c_name := C.CString(name)
	defer C.free(unsafe.Pointer(c_name))

	return int2err(C.PyModule_AddIntConstant(topy(self), c_name, C.long(value)))
}