From: Lisandro D. <da...@gm...> - 2007-08-16 21:53:30
|
Long time ago SWIG changed the way of getting 'this' from objetcs. Originally, it used PyObject_GetAttr, but next it changed to look for 'this' in object's __dict__. Since that change, as I need to use PyObject_GetAttr, I add to my interface files a hack shown below. There is any posibility to get this change go in SIWG. or perhaps better to be included in SWIG python library as a '.i' file I can include in my wrappers to get this behavior? %runtime %{ SWIGINTERNINLINE PyObject* _My_SWIG_GetThis(PyObject* obj) { if (!obj) return NULL; obj =3D PyObject_GetAttr(obj, SWIG_This()); if (!obj) PyErr_Clear(); return obj; } SWIGINTERNINLINE int _My_SWIG_ConvertPtr(PyObject *obj, void **ptr, =09=09 swig_type_info *ty, int flags) { int res =3D SWIG_ConvertPtr(obj, ptr, ty, flags); if (!SWIG_IsOK(res)) { PyObject* _this =3D _My_SWIG_GetThis(obj); res =3D SWIG_ConvertPtr(_this, ptr, ty, flags); Py_XDECREF(_this); } return res; } #undef SWIG_ConvertPtr #define SWIG_ConvertPtr(obj, pptr, type, flags) \ _My_SWIG_ConvertPtr(obj, pptr, type, flags) %} --=20 Lisandro Dalc=EDn --------------- Centro Internacional de M=E9todos Computacionales en Ingenier=EDa (CIMEC) Instituto de Desarrollo Tecnol=F3gico para la Industria Qu=EDmica (INTEC) Consejo Nacional de Investigaciones Cient=EDficas y T=E9cnicas (CONICET) PTLC - G=FCemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 |