[Insight-users] Re: CableSwig and %rename or %extend

Brad King brad.king at kitware.com
Mon Feb 6 11:17:34 EST 2006


Zachary Pincus wrote:
> In trying to spruce up the ITK wrappers, Gaetan and I have repeatedly  
> run into the need to the swig directives like %rename and %extend to  
> (respectively) rename things like 'operator++' to valid names in the  
> target language and to add language-specific methods like '__str__'  to 
> classes.
> 
> Despite the fact that the SWIG version from which CableSwig derives  
> supports these directives, it appears that CableSwig silently ignores  
> them. Is there any way to get CableSwig to work properly with these  
> directives? Failing that, could anyone tell me whether it would be  easy 
> to modify CableSwig to support this?

The right way to do this is to add a %xml(gccxml) directive to SWIG 
itself that would allow specification of a gccxml output file to load 
and insert in the SWIG parse tree.  Then the ITK wrapper config files 
could just be the standard SWIG .i files with all the directives 
supported.  One could also contribute the gccxml => swig parser back to 
SWIG itself and then we could just get rid of CableSwig altogether. 
This is a non-trivial undertaking, though, which is why it has not been 
done.

The short way to do this is to add a way to put SWIG directives into the 
.cxx input files processed by GCC-XML that are currently the config 
files.  I think there is a little precedent for this in the "renames" 
namespace but I'm not sure.

-Brad


More information about the Insight-users mailing list