[cable] swig + cable.

Rene Dudfield illumen at yahoo.com
Sun Feb 24 10:38:13 EST 2002


On Sunday 24 February 2002 22:45, David Beazley wrote:
> Rene Dudfield writes:
>  > I want to use gccxml to re write some of the header files so that swig
>  > 1.1 can understand them.
>
> Have you considered the use of SWIG-1.3.11 (which has substantially
> better capabilities than 1.1)?
>

I tried using it, however the code it outputted failed to compile :(  

Couldn't quite figure out what was wrong, so I thought that I'd wait for the 
next stable release.  I think the web page said that version was alpha, and 
changing rapidly.

I wanted to get something working quickly, and thought that getting around 
the problems with swig 1.1 might be easier( as I know 1.1 better) than 
finding out what is wrong with 1.3.  I'd originally looked at using doxygens 
xml output, however the information in it was lacking.

I think I will try and figure out the problems I'm having with swig 1.3.


>  > Specifically these are the problems that I need to fix so far.
>  >
>  > 1) function overloading.
>  > Detect the functions which are overloaded, and add methods which are
>  > based on the type, and number of the arguments.  eg.
>  >  int dosomething(int x);
>  >  int dosomething(float x);
>  > becomes:
>  >  int dosomething_int(int x);
>  >  int dosomething_float(float x);
>
> In SWIG-1.3:
>
>    %rename(dosomething_int)   dosomething(int);
>    %rename(dosomething_float) dosomething(float);
>
> This applies to all occurrences.  However, it can be specialized to
> work across class hierarchies if you need more control.  It can also be
> used on headers without modifying those headers.
>
>  > Then I'll generate wrapper functions for the languages( eg python )
>  > which check the type of the input and call the correct function.
>
> Not sure if SWIG will help with the automatic generation of such
> functions.  However, it might be possible to do something with a
> little work.
>
>  > 2) Pass by reference functions.
>  > Detect functions which use pass by reference and manually add new
>  > functions that use pointers and then dereference them before calling the
>  > pass by reference style function.
>
> SWIG-1.3 already does this.   SWIG-1.1 sort of did it (but the type
> system was somewhat broken and it didn't work in all cases).
>
> In any case, I'd look at 1.3 to see if it solves your problem.   If
> not, it would be interesting to know how gcc-xml could be used as a
> possible front-end to SWIG.   I'm not aware of anyone working on this,
> so you might be the first.  I think it would be interesting to see how
> something like that might work.

I don't really know enough about the swig internals to try this yet.  However 
it seems like a sensible idea( being a more complete parser, with many active 
developers ).  It looks like a class which emulates the Node class could be 
put into the various swig Language classes.  It would read the xml output 
from gccxml.  gccxml uses the preprocessor which includes everything, so 
something may have to be done there( although in the xml output there is info 
about which file each node comes from ).

The other problem I've had is that gcc refuses to read in a header file.  Is 
there anyway to get it to do this?  The way I got around it was to make a 
.cpp file with just a #include "bla.h" in it :)

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




More information about the cable mailing list