diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2013-05-01 14:12:40 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2013-05-01 14:12:40 +0200 |
commit | 1f700974a2647f5820c2b6f232c1fcae763d37aa (patch) | |
tree | 0cf21de93fa76c428d80e48f42f8c5d96dfdfdd8 | |
parent | 749249574690c227db1931c5319c36c606fbcb84 (diff) | |
download | cython-1f700974a2647f5820c2b6f232c1fcae763d37aa.tar.gz |
move [GS]etVTable utility code to more appropriate ImportExport.c file
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 4 | ||||
-rw-r--r-- | Cython/Utility/ExtensionTypes.c | 49 | ||||
-rw-r--r-- | Cython/Utility/ImportExport.c | 50 |
3 files changed, 52 insertions, 51 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 881668824..e0d5eb16e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -2397,7 +2397,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.error_goto_if_null(type.typeptr_cname, pos)) if type.vtabptr_cname: code.globalstate.use_utility_code( - UtilityCode.load_cached('GetVTable', 'ExtensionTypes.c')) + UtilityCode.load_cached('GetVTable', 'ImportExport.c')) code.putln("%s = (struct %s*)__Pyx_GetVtable(%s->tp_dict); %s" % ( type.vtabptr_cname, type.vtabstruct_cname, @@ -2503,7 +2503,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): type.vtabptr_cname, code.error_goto(entry.pos))) code.globalstate.use_utility_code( - UtilityCode.load_cached('SetVTable', 'ExtensionTypes.c')) + UtilityCode.load_cached('SetVTable', 'ImportExport.c')) if not type.scope.is_internal and not type.scope.directives['internal']: # scope.is_internal is set for types defined by # Cython (such as closures), the 'internal' diff --git a/Cython/Utility/ExtensionTypes.c b/Cython/Utility/ExtensionTypes.c index 0dde7b814..423ed9673 100644 --- a/Cython/Utility/ExtensionTypes.c +++ b/Cython/Utility/ExtensionTypes.c @@ -51,52 +51,3 @@ static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { if (type && type->tp_clear) type->tp_clear(obj); } - - -/////////////// SetVTable.proto /////////////// - -static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ - -/////////////// SetVTable /////////////// - -static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, PYIDENT("__pyx_vtable__"), ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -/////////////// GetVTable.proto /////////////// - -static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ - -/////////////// GetVTable /////////////// - -static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, PYIDENT("__pyx_vtable__")); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} diff --git a/Cython/Utility/ImportExport.c b/Cython/Utility/ImportExport.c index 925eda3cf..c36849b19 100644 --- a/Cython/Utility/ImportExport.c +++ b/Cython/Utility/ImportExport.c @@ -423,3 +423,53 @@ bad: Py_XDECREF(d); return -1; } + + +/////////////// SetVTable.proto /////////////// + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ + +/////////////// SetVTable /////////////// + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, PYIDENT("__pyx_vtable__"), ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + + +/////////////// GetVTable.proto /////////////// + +static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ + +/////////////// GetVTable /////////////// + +static void* __Pyx_GetVtable(PyObject *dict) { + void* ptr; + PyObject *ob = PyObject_GetItem(dict, PYIDENT("__pyx_vtable__")); + if (!ob) + goto bad; +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) + ptr = PyCapsule_GetPointer(ob, 0); +#else + ptr = PyCObject_AsVoidPtr(ob); +#endif + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} |