On 12 Dec 2010 at 14:02, Jacob Davis wrote: > I'm wrapping a C libary with Boost Python and having a really difficult time > with void * typedefs. For example, here's a typedef and the function header > that uses it: > > typedef void * EmoEngineEventHandle; > EmoEngineEventHandle EE_EmoEngineEventCreate(); > [snip] > There are a *lot* of these functions in the library I'm wrapping that use > and return void * typedefs. Is there a way to translate the typedefs to get > all of my function wrappers to pass them properly? Failing that, how do I > modify my wrappers to support the typedefs?
It's actually easier than you might think. Firstly I would suggest you look at the thread regarding the patch I submitted in 2006 adding void * support to BPL which starts at http://mail.python.org/pipermail/cplusplus-sig/2006- February/009836.html. What my original patch did was to declare a trampoline type struct void_ {}; and then cast all void * to void_ *. This gave the BPL runtime type registry enough information to work with. (I might add that as this thread showed, Dave scrubbed my trampoline type implementation for something better. I know not what, but it may be worth your while finding out) Secondly last time I looked GCCXML nowadays dumps out typedefs, so if you feed your C headers to GCCXML you can produce a list of all possible typedef names. It's now trivial to modify a Py++ or whatever bindings generator to spew out a cast to for example a struct EmoEngineEventHandle_ * whenever it sees a EmoEngineEventHandle. And that ought to do it. Shouldn't take you more than thirty or forty hours. And if you integrate all these steps into a build process it can all be automated once you've completed it. Also, Roman may or may not be interested in adding this feature to Py++. Hope this helped, Niall -- Technology & Consulting Services - ned Productions Limited. http://www.nedproductions.biz/. VAT reg: IE 9708311Q. Company no: 472909. _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig