[Insight-developers] adding swig command to itk python wrapper

Gaetan Lehmann gaetan.lehmann at jouy.inra.fr
Wed Apr 6 07:18:14 EDT 2005


Hi Bill,

On Mon, 04 Apr 2005 18:40:54 +0200, William A. Hoffman  
<billlist at nycap.rr.com> wrote:

> You may have to remove all the
> wrap_*Tcl.cxx from Wrapping/CSwig/*
> There may be a missing depend on the itk.swg file, but
> that would be the place to make the change.

I can't make cableswig use swig commands. Perhaps can you help me ?


My itk.swg file (using itk 2.0.1) :

/* This is an itk-specific typemap used by CableSwig.  Also see comments
  * and "throws" code in CableSwig.cxx.
  *   -- Charl P. Botha <cpbotha AT ieee.org>
  */

#ifdef SWIGPYTHON

/* ------------------------------------------------------------
  * PyObject *  - Just pass straight through unmodified
  * This is default behaviour for python.swg, but Cable passes
  * a PyObject * through as a "p._object", so we redo the typemap
  * ------------------------------------------------------------ */

%typemap(in)   p._object "$1 = $input;";
%typemap(out)  p._object "$result = $1;";
%rename(__getitem__) itkIndex2::GetElement;
#endif

%include exception.i

/* A "throws" attribute with the "std::exception" type is added  
synthetically
  * to each method node by CableSwig.cxx.  When gcc_xml starts passing  
through
  * correct throws types, this typemap could be optionally extended to
  * account for more different types.  For now this is sufficient though.
  */

%typemap(throws) std::exception {
    SWIG_exception(SWIG_RuntimeError, const_cast<char*>(_e.what()));
}

%include std_string.i




I think that with this line :

%rename(__getitem__) itkIndex2::GetElement;

objects of itkIndex2 class should have a __getitem__ method and no  
GetElement method. But it don't work, and I can't understand why.


Gaetan

>
> -Bill
>
>
> At 10:20 AM 4/4/2005, Gaetan Lehmann wrote:
>
>> Hi,
>>
>> I try to add a swig command to make itk more usable in python, but I  
>> can't
>> find where to add it.
>> Currently, I only tried to add :
>>
>>        %rename(__getitem__) itkIndex2::operator[];
>>
>> to make index accessible with standard python list interface.
>> I tried to add this in itk.swg (where python typemaps are defined), but  
>> it
>> seems that doing some changes in this file don't make make rebuild any
>> file, so I'm not sure that this file is used somewhere.
>> Can somebody tell me where I can add swig commands ?
>>
>> Regards,
>>
>> Gaetan
>>
>> --
>> Gaetan Lehmann <gaetan.lehmann at jouy.inra.fr>
>> Tel: +33 1 34 65 22 34
>> Biologie du Développement et de la Reproduction
>> INRA de Jouy-en-Josas (France)
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>
>



-- 
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)
 


More information about the Insight-developers mailing list