[Insight-users] Re: extend classes with cableswig
Brad King
brad.king at kitware.com
Wed Aug 3 14:06:53 EDT 2005
Gaetan Lehmann wrote:
> swig allow to extend classes with the keyword %extend.
>
> I want to implement methods such as __getitem__, __setitem__ and
> __len__ in Size, Index, Array and FixedArray classes, so those basic
> objects can be accessed with native python interface, and with bound
> checking, which is more python user friendly. Adding __repr__ or
> __str__ method to those classes would also allow user to easily see the
> content of objects of those classes...
> Also, I want to implement __str__ in LighObject class, to return the
> string produced by the Print method, so lots of itk objects can be
> printed with "print anItkObject"
>
> Sadely, with cableswig, it seems %extend have no effect. Do you know why ?
> What can be done to extend classes ? Currently, I'm adding all those
> method directly in .h files...
I think you're stuck for now. The "right" way to do this is to get rid
of CableSwig and extend standard SWIG with a %xml(gccxml) option to
import a gccxml dump. Then all the standard swig stuff will work
properly. I think this approach will be much better than trying to get
all the swig extension syntax into CableSwig.
-Brad
More information about the Insight-users
mailing list