reduce the aliasing warnings (when compiling with CFLAGS='-O2 -Wstrict-aliasing=2') to the minimum, ie, enums and pointer to functions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8883 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
da1a23a6a2
commit
14b049e8bd
6 changed files with 34 additions and 23 deletions
|
|
@ -12,10 +12,10 @@
|
|||
SWIGINTERN int
|
||||
SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
|
||||
static swig_type_info* desc = 0;
|
||||
FILE *ptr = 0;
|
||||
void *vptr = 0;
|
||||
if (!desc) desc = SWIG_TypeQuery("FILE *");
|
||||
if ((SWIG_ConvertPtr(obj,(void **)(&ptr), desc, 0)) == SWIG_OK) {
|
||||
if (val) *val = ptr;
|
||||
if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
|
||||
if (val) *val = (FILE *)vptr;
|
||||
return SWIG_OK;
|
||||
}
|
||||
if (PyFile_Check(obj)) {
|
||||
|
|
|
|||
|
|
@ -68,3 +68,15 @@ PyString_FromFormat(const char *fmt, ...) {
|
|||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* PyBool_FromLong for old Pythons */
|
||||
#if PY_VERSION_HEX < 0x02030000
|
||||
static
|
||||
PyObject *PyBool_FromLong(long ok)
|
||||
{
|
||||
PyObject *result = ok ? Py_True : Py_False;
|
||||
Py_INCREF(result);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,7 @@
|
|||
SWIGINTERNINLINE PyObject*
|
||||
SWIG_From_dec(bool)(bool value)
|
||||
{
|
||||
PyObject *obj = value ? Py_True : Py_False;
|
||||
Py_INCREF(obj);
|
||||
return obj;
|
||||
return PyBool_FromLong(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,15 +281,17 @@ PySwigClientData_New(PyObject* obj)
|
|||
} else {
|
||||
#if (PY_VERSION_HEX < 0x02020000)
|
||||
data->newraw = 0;
|
||||
data->newargs = obj;
|
||||
Py_INCREF(obj);
|
||||
#else
|
||||
data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, (char *)"__new__");
|
||||
Py_INCREF(data->newraw);
|
||||
data->newargs = PyTuple_New(1);
|
||||
PyTuple_SetItem(data->newargs, 0, obj);
|
||||
Py_INCREF(data->newargs);
|
||||
data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
|
||||
#endif
|
||||
if (data->newraw) {
|
||||
Py_INCREF(data->newraw);
|
||||
data->newargs = PyTuple_New(1);
|
||||
PyTuple_SetItem(data->newargs, 0, obj);
|
||||
} else {
|
||||
data->newargs = obj;
|
||||
}
|
||||
Py_INCREF(data->newargs);
|
||||
}
|
||||
/* the destroy method, aka as the C++ delete method */
|
||||
data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
|
||||
|
|
@ -534,7 +536,7 @@ PySwigObject_own(PyObject *v, PyObject *args)
|
|||
else
|
||||
{
|
||||
PySwigObject *sobj = (PySwigObject *)v;
|
||||
PyObject *obj = sobj->own ? Py_True : Py_False;
|
||||
PyObject *obj = PyBool_FromLong(sobj->own);
|
||||
if (val) {
|
||||
#ifdef METH_NOARGS
|
||||
if (PyObject_IsTrue(val)) {
|
||||
|
|
@ -550,7 +552,6 @@ PySwigObject_own(PyObject *v, PyObject *args)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
Py_INCREF(obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
|
|||
} else {
|
||||
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
|
||||
if (pchar_descriptor) {
|
||||
char* vptr = 0;
|
||||
if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
|
||||
if (cptr) *cptr = vptr;
|
||||
if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
|
||||
void* vptr = 0;
|
||||
if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
|
||||
if (cptr) *cptr = (char *) vptr;
|
||||
if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
|
||||
if (alloc) *alloc = SWIG_OLDOBJ;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
|||
} else {
|
||||
swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
||||
if (pwchar_descriptor) {
|
||||
wchar_t * vptr = 0;
|
||||
if (SWIG_ConvertPtr(obj, (void**)&vptr, pwchar_descriptor, 0) == SWIG_OK) {
|
||||
if (cptr) *cptr = vptr;
|
||||
if (psize) *psize = vptr ? (wcslen(vptr) + 1) : 0;
|
||||
void * vptr = 0;
|
||||
if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
|
||||
if (cptr) *cptr = (wchar_t *)vptr;
|
||||
if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue