[python] Simpler code for SWIG_AsVal_bool() which fixes a "strict
aliasing" warning from GCC - patch from SF#1724581 by Andrew Baumann. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9938 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
e2d7f303b8
commit
8178898960
2 changed files with 10 additions and 12 deletions
|
|
@ -17,18 +17,11 @@ SWIGINTERNINLINE PyObject*
|
|||
SWIGINTERN int
|
||||
SWIG_AsVal_dec(bool)(PyObject *obj, bool *val)
|
||||
{
|
||||
if (obj == Py_True) {
|
||||
if (val) *val = true;
|
||||
return SWIG_OK;
|
||||
} else if (obj == Py_False) {
|
||||
if (val) *val = false;
|
||||
return SWIG_OK;
|
||||
} else {
|
||||
long v = 0;
|
||||
int res = SWIG_AddCast(SWIG_AsVal(long)(obj, val ? &v : 0));
|
||||
if (SWIG_IsOK(res) && val) *val = v ? true : false;
|
||||
return res;
|
||||
}
|
||||
int r = PyObject_IsTrue(obj);
|
||||
if (r == -1)
|
||||
return SWIG_ERROR;
|
||||
if (val) *val = r ? true : false;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue