[Insight-users] Re: extend classes with cableswig
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Thu Aug 4 04:01:31 EDT 2005
On Wed, 03 Aug 2005 20:06:53 +0200, Brad King <brad.king at kitware.com>
wrote:
> 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.
Ok
So I'll keep my customizations in headers until it can be done in swig :-/
> 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.
>
Do you already know how to modify SWIG ? Is it lot of work to do ?
--
Gaetan Lehmann <gaetan.lehmann at jouy.inra.fr>
Tel: +33 1 34 65 29 66
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
Web: http://voxel.jouy.inra.fr
More information about the Insight-users
mailing list