Ejemplo n.º 1
0
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
}
Ejemplo n.º 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)))
}