From: Jack J. <Jac...@or...> - 2002-03-22 09:33:47
|
On Thursday, March 21, 2002, at 10:11 , Jim Ingham wrote: > Jack, > > I would have tried SWIG for the same purposes. It generates interfaces > for Perl, Python, Tcl/Tk, Guile, Ruby and a bunch of others from C & > C++. I haven't had opportunity to use it, but other people speak very > highly of it. > > Did you have some bad experiences with it, or had you just not heard of > it, or did you mostly want to use a tool written in Python? Bgen predates swig. It was actually written by Guido himself about 8-9 years ago, I think, and I basically inherited it. Swig has the big advantages of being easier to use, and of generating interface modules for other languages than Python. Bgen's main two advantages are that it is more automatic (once it has been setup) and more powerful. More automatic: you can feed it .h files straight from Apple, so the next version of Universal Headers just gets fed through it and often the interface grows with the new functionality automatically. More powerful: it can be told about Python objects wrapping C structs, and you can tell it patterns of C arguments and how to represent them in Python: - RGBColor color - Represent as Python (r, g, b) tuple - const char *foo, int foo_len - Binary input buffer, use a single Python string - WindowRef w - Represent this as a Python PyMac_WindowObject object - WindowRef w as first argument - don't generate this as a function but as a method of the PyMac_WindowObject type. Over the years I've been talking to the swig people about integrating swig and bgen, but all of us always have more urgent things to do, unfortunately:-( -- - Jack Jansen <Jac...@or...> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - |