Commit 54bdaf56 authored by Stefan Behnel's avatar Stefan Behnel

use pre-built Python objects in __Pyx_ExportVoidPtr() utility function

parent de696a4f
......@@ -2267,8 +2267,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env.use_utility_code(UtilityCode.load_cached("VoidPtrExport", "ImportExport.c"))
for entry in entries:
signature = entry.type.declaration_code("")
code.putln('if (__Pyx_ExportVoidPtr("%s", (void *)&%s, "%s") < 0) %s' % (
entry.name, entry.cname, signature,
name = code.intern_identifier(entry.name)
code.putln('if (__Pyx_ExportVoidPtr(%s, (void *)&%s, "%s") < 0) %s' % (
name, entry.cname, signature,
code.error_goto(self.pos)))
def generate_c_function_export_code(self, env, code):
......
......@@ -387,23 +387,23 @@ bad:
/////////////// VoidPtrExport.proto ///////////////
static int __Pyx_ExportVoidPtr(const char *name, void *p, const char *sig); /*proto*/
static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig); /*proto*/
/////////////// VoidPtrExport ///////////////
//@substitute: naming
//@requires: ObjectHandling.c::PyObjectSetAttrStr
static int __Pyx_ExportVoidPtr(const char *name, void *p, const char *sig) {
PyObject *d = 0;
static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) {
PyObject *d;
PyObject *cobj = 0;
d = PyObject_GetAttrString($module_cname, (char *)"$api_name");
d = PyDict_GetItem($moddict_cname, PYIDENT("$api_name"));
Py_XINCREF(d);
if (!d) {
PyErr_Clear();
d = PyDict_New();
if (!d)
goto bad;
Py_INCREF(d);
if (PyModule_AddObject($module_cname, (char *)"$api_name", d) < 0)
if (__Pyx_PyObject_SetAttrStr($module_cname, PYIDENT("$api_name"), d) < 0)
goto bad;
}
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
......@@ -413,7 +413,7 @@ static int __Pyx_ExportVoidPtr(const char *name, void *p, const char *sig) {
#endif
if (!cobj)
goto bad;
if (PyDict_SetItemString(d, name, cobj) < 0)
if (PyDict_SetItem(d, name, cobj) < 0)
goto bad;
Py_DECREF(cobj);
Py_DECREF(d);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment