[Python] Fix new GCC8 warnings in generated code

Avoid casts between incompatible function types where possible (when
keyword args are in use, it is not possible to avoid such warnings as
they are inherent in the design of Python's C API in that particular
case).  Fixes #1259.
This commit is contained in:
Olly Betts 2018-06-11 15:51:53 +12:00
commit 7f98830110
4 changed files with 36 additions and 21 deletions

View file

@ -347,8 +347,8 @@ SWIG_init(void) {
(char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
};
static SwigPyGetSet thisown_getset_closure = {
(PyCFunction) SwigPyObject_own,
(PyCFunction) SwigPyObject_own
SwigPyObject_own,
SwigPyObject_own
};
static PyGetSetDef thisown_getset_def = {
(char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure

View file

@ -445,6 +445,14 @@ SwigPyObject_repr(SwigPyObject *v)
return repr;
}
/* We need a version taking two PyObject* parameters so it's a valid
* PyCFunction to use in swigobject_methods[]. */
static PyObject *
SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
{
return SwigPyObject_repr((SwigPyObject*)v);
}
SWIGRUNTIME int
SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
{
@ -621,12 +629,12 @@ SwigPyObject_own(PyObject *v, PyObject *args)
static PyMethodDef
swigobject_methods[] = {
{"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"},
{"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"},
{"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"},
{"append", (PyCFunction)SwigPyObject_append, METH_O, "appends another 'this' object"},
{"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"},
{"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, "returns object representation"},
{"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"},
{"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"},
{"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"},
{"append", SwigPyObject_append, METH_O, "appends another 'this' object"},
{"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"},
{"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"},
{0, 0, 0, 0}
};