예제 #1
0
파일: foo.c 프로젝트: jwilk/Pyrex
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
	long size) 
{
	PyObject *py_module = 0;
	PyObject *result = 0;
	
	py_module = __Pyx_ImportModule(module_name);
	if (!py_module)
		goto bad;
	result = PyObject_GetAttrString(py_module, class_name);
	if (!result)
		goto bad;
	if (!PyType_Check(result)) {
		PyErr_Format(PyExc_TypeError, 
			"%s.%s is not a type object",
			module_name, class_name);
		goto bad;
	}
#ifdef __PYX_CHECK_IMPORTED_TYPES
	if (((PyTypeObject *)result)->tp_basicsize != size) {
		PyErr_Format(PyExc_ValueError, 
			"%s.%s does not appear to be the correct type object",
			module_name, class_name);
		goto bad;
	}
#endif
	return (PyTypeObject *)result;
bad:
	Py_XDECREF(result);
	return 0;
}
int import__hermes_common(void) {
  PyObject *module = 0;
  module = __Pyx_ImportModule("_hermes_common");
  if (!module) goto bad;
  if (__Pyx_ImportFunction(module, "c2numpy_int", (void (**)(void))&c2numpy_int, "PyObject *(int *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2numpy_double", (void (**)(void))&c2numpy_double, "PyObject *(double *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "numpy2c_double_inplace", (void (**)(void))&numpy2c_double_inplace, "void (PyObject *, double **, int *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "numpy2c_int_inplace", (void (**)(void))&numpy2c_int_inplace, "void (PyObject *, int **, int *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2py_DenseMatrix", (void (**)(void))&c2py_DenseMatrix, "PyObject *(struct DenseMatrix *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2py_CooMatrix", (void (**)(void))&c2py_CooMatrix, "PyObject *(struct CooMatrix *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2py_CSRMatrix", (void (**)(void))&c2py_CSRMatrix, "PyObject *(struct CSRMatrix *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2py_CSCMatrix", (void (**)(void))&c2py_CSCMatrix, "PyObject *(struct CSCMatrix *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "namespace_create", (void (**)(void))&namespace_create, "PyObject *(void)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "namespace_push", (void (**)(void))&namespace_push, "void (PyObject *, const char*, PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "namespace_print", (void (**)(void))&namespace_print, "void (PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "namespace_pull", (void (**)(void))&namespace_pull, "PyObject *(PyObject *, const char*)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "cmd", (void (**)(void))&cmd, "void (const char*)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "set_verbose_cmd", (void (**)(void))&set_verbose_cmd, "void (int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "insert_object", (void (**)(void))&insert_object, "void (const char*, PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "get_object", (void (**)(void))&get_object, "PyObject *(const char*)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2py_int", (void (**)(void))&c2py_int, "PyObject *(int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "py2c_int", (void (**)(void))&py2c_int, "int (PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "py2c_str", (void (**)(void))&py2c_str, "char *(PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "py2c_double", (void (**)(void))&py2c_double, "double (PyObject *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2numpy_int_inplace", (void (**)(void))&c2numpy_int_inplace, "PyObject *(int *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2numpy_double_inplace", (void (**)(void))&c2numpy_double_inplace, "PyObject *(double *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "c2numpy_double_complex_inplace", (void (**)(void))&c2numpy_double_complex_inplace, "PyObject *(__pyx_t_double_complex *, int)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "numpy2c_double_complex_inplace", (void (**)(void))&numpy2c_double_complex_inplace, "void (PyObject *, __pyx_t_double_complex **, int *)") < 0) goto bad;
  if (__Pyx_ImportFunction(module, "run_cmd", (void (**)(void))&run_cmd, "void (const char*, PyObject *)") < 0) goto bad;
  Py_DECREF(module); module = 0;
  return 0;
  bad:
  Py_XDECREF(module);
  return -1;
}
예제 #3
0
static int __Pyx_RegisterCleanup() {
    /* Don't use Py_AtExit because that has a 32-call limit 
     * and is called after python finalization. 
     */

    PyObject *cleanup_func = 0;
    PyObject *atexit = 0;
    PyObject *reg = 0;
    PyObject *args = 0;
    PyObject *res = 0;
    int ret = -1;
    
    cleanup_func = PyCFunction_New(&cleanup_def, 0);
    args = PyTuple_New(1);
    if (!cleanup_func || !args)
        goto bad;
    PyTuple_SET_ITEM(args, 0, cleanup_func);
    cleanup_func = 0;

    atexit = __Pyx_ImportModule("atexit");
    if (!atexit)
        goto bad;
    reg = PyObject_GetAttrString(atexit, "register");
    if (!reg)
        goto bad;
    res = PyObject_CallObject(reg, args);
    if (!res)
        goto bad;
    ret = 0;
bad:
    Py_XDECREF(cleanup_func);
    Py_XDECREF(atexit);
    Py_XDECREF(reg);
    Py_XDECREF(args);
    Py_XDECREF(res);
    return ret;
}