From: Daniel R. <dr...@gm...> - 2011-04-09 16:02:33
|
Two suggestions for automating things. Both involving creating an internal swig based module from the raw C interface. 1) Assuming the function names for Foo start with foo_, traverse the internal python module (in python) to find all the functions that should be added to a given class and use that list to have a python script write out a proper swig wrapper. To do this, you can do dir on the private module to get the list of all functions and search the list for ones with the right name. 2) implement the proxy class directly manually that implements __getattr__ that maps arbitrary function calls to appropriate C function calls when available. That is, if __getattr__ is called with argument "functionname", it looks to see if there is a function foo_functionname and, if so, returns that with the first argument bound. On Apr 8, 2011, at 4:40 PM, Malte Forkel wrote: > Am 09.04.2011 01:20, schrieb Ben Webb: >> >> I have no idea - if I did, I would have told you. ;) If you didn't mind >> writing a simple C++ wrapper for your code, you could have SWIG wrap >> that (in which case it would take care of the methods). But that would >> introduce a C++ dependency to your project, which you might not want. > > I was afraid you'd say that. ;) > > I really would not want to use C++. > > I guess if I can't get SWIG to do it, I'll write my own Python wrapper > as you suggested. I just don't like to do things manually that I think > could be automated. Given the number of functions in the libray, it will > take a while to write all those proxys. Plus it'll be boring and error > prone. Plus the wrapper code has to be adapted every time there is a > change in the library. Plus... > > Isn't there any SWIG developer out there whom I could convince to add > some automatism to SWIG to do this? ;) > > Malte > > > > ------------------------------------------------------------------------------ > Xperia(TM) PLAY > It's a major breakthrough. An authentic gaming > smartphone on the nation's most reliable network. > And it wants your games. > http://p.sf.net/sfu/verizon-sfdev > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user |