[cable] pointer & reference swapped in python wrapping

Brad King brad.king at kitware.com
Thu Feb 12 17:13:29 EST 2004


Kaben Nanlohy wrote:
> Hello;
> 
> I am working with code using pointers to functions returning references,
> something like :
> 
>   typedef cFu &(*tPtrRefFun)();
> 
> and a class method taking such a pointer as an argument :
> 
>   void cHello::setPtrRefFun(tPtrRefFun fun);
> 
> CSwig generates a slightly mixed-up wrapping for this function :
> 
>   static PyObject *_wrap_cHello_setPtrRefFun(PyObject *self, PyObject *args) {
>     (void)self; (void)args;
>     PyObject *resultobj;
>     cHello *arg1 = (cHello *) 0 ;
>     cFu *(*arg2)() = (cFu *(*)()) 0 ;
>     
>     .
>     .
>     
>     (arg1)->setPtrRefFun(*arg2);
> 
> ... the last line tries to pass a referenced pointer (*arg2) instead of
> a pointer to setPtrRefFun(); and instead of having type tPtrRefFun, arg2
> is a pointer to a function returning a pointer. I've been tweaking the
> wrapping by hand to make it compile. I'm not using the callbacks from
> python just yet, and would be happy if I could prevent the wrapping.

CableSwig just adds an alternative parsing framework to help SWIG 
understand extremely complex templated code.  The code generation for 
the wrappers themselves is unchanged.  Have you tried to duplicate this 
problem on native SWIG?  The current CableSwig is based on a SWIG 
version that is almost a year old.  This bug may have been fixed 
upstream.  We are currently in the process of upgrading to a more recent 
SWIG inside CableSwig, but may not be done for a week or two.

-Brad




More information about the cable mailing list