logo       

Re: How to emove prefix from classes?: msg#00191

programming.swig

Subject: Re: How to emove prefix from classes?

Raghavendra Chandrashekara wrote:
Hi Everybody!

I have a lot of classes which start with a certain prefix. For example,

ftkClass1
ftkClass2
...

Is there a way of renaming the classes in the wrapper library (I am using Python) so that they become:

ftk.Class1
ftk.Class2
...

I think Robin Dunn has done this for wxPython and I would like to do something similar.

I have done it, but it wasn't easy. I first thought of modifying %rename to be able to take a regex or something and doing global renames that way, but I never found a way to implement that without major surgery on SWIG.

So instead I run SWIG twice on each .i file. The first time it is to generate the XML of the parse tree. Then I run some Python code on the XML and generate a file full of %rename directives, one for each top level name that needs to have the wx removed. Finally, I run SWIG again, this time including the file with the %rename's. It's mostly all in wxPython's setup.py and config.py if you're interested in looking closer.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise