Commit 394239d7 authored by Stefan Behnel's avatar Stefan Behnel

merge

parents 45da07ea fd99a888
...@@ -201,7 +201,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -201,7 +201,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for entry in api_funcs: for entry in api_funcs:
sig = entry.type.signature_string() sig = entry.type.signature_string()
h_code.putln( h_code.putln(
'if (__Pyx_ImportFunction(module, "%s", (void**)&%s, "%s") < 0) goto bad;' % ( 'if (__Pyx_ImportFunction(module, "%s", (void (**)(void))&%s, "%s") < 0) goto bad;' % (
entry.name, entry.name,
entry.cname, entry.cname,
sig)) sig))
...@@ -1800,7 +1800,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1800,7 +1800,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if entry.api or entry.defined_in_pxd: if entry.api or entry.defined_in_pxd:
env.use_utility_code(function_export_utility_code) env.use_utility_code(function_export_utility_code)
signature = entry.type.signature_string() signature = entry.type.signature_string()
code.putln('if (__Pyx_ExportFunction("%s", (void*)%s, "%s") < 0) %s' % ( code.putln('if (__Pyx_ExportFunction("%s", (void (*)(void))%s, "%s") < 0) %s' % (
entry.name, entry.name,
entry.cname, entry.cname,
signature, signature,
...@@ -1832,7 +1832,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1832,7 +1832,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.error_goto(self.pos))) code.error_goto(self.pos)))
for entry in entries: for entry in entries:
code.putln( code.putln(
'if (__Pyx_ImportFunction(%s, "%s", (void**)&%s, "%s") < 0) %s' % ( 'if (__Pyx_ImportFunction(%s, "%s", (void (**)(void))&%s, "%s") < 0) %s' % (
temp, temp,
entry.name, entry.name,
entry.cname, entry.cname,
...@@ -2101,17 +2101,18 @@ bad: ...@@ -2101,17 +2101,18 @@ bad:
function_export_utility_code = UtilityCode( function_export_utility_code = UtilityCode(
proto = """ proto = """
static int __Pyx_ExportFunction(const char *name, void *f, const char *sig); /*proto*/ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /*proto*/
""", """,
impl = r""" impl = r"""
static int __Pyx_ExportFunction(const char *name, void *f, const char *sig) { static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) {
#if PY_VERSION_HEX < 0x02050000 #if PY_VERSION_HEX < 0x02050000
char *api = (char *)"%(API)s"; char *api = (char *)"%(API)s";
#else #else
const char *api = "%(API)s"; const char *api = "%(API)s";
#endif #endif
PyObject *d = 0; PyObject *d = 0;
PyObject *p = 0; PyObject *cobj = 0;
void *p = 0;
d = PyObject_GetAttrString(%(MODULE)s, api); d = PyObject_GetAttrString(%(MODULE)s, api);
if (!d) { if (!d) {
...@@ -2123,16 +2124,17 @@ static int __Pyx_ExportFunction(const char *name, void *f, const char *sig) { ...@@ -2123,16 +2124,17 @@ static int __Pyx_ExportFunction(const char *name, void *f, const char *sig) {
if (PyModule_AddObject(%(MODULE)s, api, d) < 0) if (PyModule_AddObject(%(MODULE)s, api, d) < 0)
goto bad; goto bad;
} }
p = PyCObject_FromVoidPtrAndDesc(f, (void *)sig, 0); p = *(void **)&f;
if (!p) cobj = PyCObject_FromVoidPtrAndDesc(p, (void *)sig, 0);
if (!cobj)
goto bad; goto bad;
if (PyDict_SetItemString(d, name, p) < 0) if (PyDict_SetItemString(d, name, cobj) < 0)
goto bad; goto bad;
Py_DECREF(p); Py_DECREF(cobj);
Py_DECREF(d); Py_DECREF(d);
return 0; return 0;
bad: bad:
Py_XDECREF(p); Py_XDECREF(cobj);
Py_XDECREF(d); Py_XDECREF(d);
return -1; return -1;
} }
...@@ -2143,12 +2145,12 @@ bad: ...@@ -2143,12 +2145,12 @@ bad:
function_import_utility_code = UtilityCode( function_import_utility_code = UtilityCode(
proto = """ proto = """
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f, const char *sig); /*proto*/ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/
""", """,
impl = """ impl = """
#ifndef __PYX_HAVE_RT_ImportFunction #ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction #define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f, const char *sig) { static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
#if PY_VERSION_HEX < 0x02050000 #if PY_VERSION_HEX < 0x02050000
char *api = (char *)"%(API)s"; char *api = (char *)"%(API)s";
#else #else
...@@ -2156,7 +2158,8 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f ...@@ -2156,7 +2158,8 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f
#endif #endif
PyObject *d = 0; PyObject *d = 0;
PyObject *cobj = 0; PyObject *cobj = 0;
char *desc; void *p = 0;
const char *desc = 0;
d = PyObject_GetAttrString(module, api); d = PyObject_GetAttrString(module, api);
if (!d) if (!d)
...@@ -2168,7 +2171,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f ...@@ -2168,7 +2171,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f
PyModule_GetName(module), funcname); PyModule_GetName(module), funcname);
goto bad; goto bad;
} }
desc = (char *)PyCObject_GetDesc(cobj); desc = (const char *)PyCObject_GetDesc(cobj);
if (!desc) if (!desc)
goto bad; goto bad;
if (strcmp(desc, sig) != 0) { if (strcmp(desc, sig) != 0) {
...@@ -2177,7 +2180,8 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f ...@@ -2177,7 +2180,8 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void **f
PyModule_GetName(module), funcname, sig, desc); PyModule_GetName(module), funcname, sig, desc);
goto bad; goto bad;
} }
*f = PyCObject_AsVoidPtr(cobj); p = PyCObject_AsVoidPtr(cobj);
*f = *(void (**)(void))&p;
Py_DECREF(d); Py_DECREF(d);
return 0; return 0;
bad: bad:
......
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