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/SWIG@8883 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
220a0ad055
commit
a2c99f619d
6 changed files with 34 additions and 23 deletions
|
|
@ -12,10 +12,10 @@
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
|
SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
|
||||||
static swig_type_info* desc = 0;
|
static swig_type_info* desc = 0;
|
||||||
FILE *ptr = 0;
|
void *vptr = 0;
|
||||||
if (!desc) desc = SWIG_TypeQuery("FILE *");
|
if (!desc) desc = SWIG_TypeQuery("FILE *");
|
||||||
if ((SWIG_ConvertPtr(obj,(void **)(&ptr), desc, 0)) == SWIG_OK) {
|
if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
|
||||||
if (val) *val = ptr;
|
if (val) *val = (FILE *)vptr;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
if (PyFile_Check(obj)) {
|
if (PyFile_Check(obj)) {
|
||||||
|
|
|
||||||
|
|
@ -68,3 +68,15 @@ PyString_FromFormat(const char *fmt, ...) {
|
||||||
# endif
|
# endif
|
||||||
#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*
|
SWIGINTERNINLINE PyObject*
|
||||||
SWIG_From_dec(bool)(bool value)
|
SWIG_From_dec(bool)(bool value)
|
||||||
{
|
{
|
||||||
PyObject *obj = value ? Py_True : Py_False;
|
return PyBool_FromLong(value ? 1 : 0);
|
||||||
Py_INCREF(obj);
|
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -281,15 +281,17 @@ PySwigClientData_New(PyObject* obj)
|
||||||
} else {
|
} else {
|
||||||
#if (PY_VERSION_HEX < 0x02020000)
|
#if (PY_VERSION_HEX < 0x02020000)
|
||||||
data->newraw = 0;
|
data->newraw = 0;
|
||||||
data->newargs = obj;
|
|
||||||
Py_INCREF(obj);
|
|
||||||
#else
|
#else
|
||||||
data->newraw = PyObject_GetAttrString((PyObject*)&PyBaseObject_Type, (char *)"__new__");
|
data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
|
||||||
Py_INCREF(data->newraw);
|
|
||||||
data->newargs = PyTuple_New(1);
|
|
||||||
PyTuple_SetItem(data->newargs, 0, obj);
|
|
||||||
Py_INCREF(data->newargs);
|
|
||||||
#endif
|
#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 */
|
/* the destroy method, aka as the C++ delete method */
|
||||||
data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
|
data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
|
||||||
|
|
@ -534,7 +536,7 @@ PySwigObject_own(PyObject *v, PyObject *args)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PySwigObject *sobj = (PySwigObject *)v;
|
PySwigObject *sobj = (PySwigObject *)v;
|
||||||
PyObject *obj = sobj->own ? Py_True : Py_False;
|
PyObject *obj = PyBool_FromLong(sobj->own);
|
||||||
if (val) {
|
if (val) {
|
||||||
#ifdef METH_NOARGS
|
#ifdef METH_NOARGS
|
||||||
if (PyObject_IsTrue(val)) {
|
if (PyObject_IsTrue(val)) {
|
||||||
|
|
@ -550,7 +552,6 @@ PySwigObject_own(PyObject *v, PyObject *args)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Py_INCREF(obj);
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
|
||||||
} else {
|
} else {
|
||||||
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
|
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
|
||||||
if (pchar_descriptor) {
|
if (pchar_descriptor) {
|
||||||
char* vptr = 0;
|
void* vptr = 0;
|
||||||
if (SWIG_ConvertPtr(obj, (void**)&vptr, pchar_descriptor, 0) == SWIG_OK) {
|
if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
|
||||||
if (cptr) *cptr = vptr;
|
if (cptr) *cptr = (char *) vptr;
|
||||||
if (psize) *psize = vptr ? (strlen(vptr) + 1) : 0;
|
if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0;
|
||||||
if (alloc) *alloc = SWIG_OLDOBJ;
|
if (alloc) *alloc = SWIG_OLDOBJ;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,10 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
|
||||||
} else {
|
} else {
|
||||||
swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
|
||||||
if (pwchar_descriptor) {
|
if (pwchar_descriptor) {
|
||||||
wchar_t * vptr = 0;
|
void * vptr = 0;
|
||||||
if (SWIG_ConvertPtr(obj, (void**)&vptr, pwchar_descriptor, 0) == SWIG_OK) {
|
if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
|
||||||
if (cptr) *cptr = vptr;
|
if (cptr) *cptr = (wchar_t *)vptr;
|
||||||
if (psize) *psize = vptr ? (wcslen(vptr) + 1) : 0;
|
if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue