[Pythonmac-SIG] SWIG and making extension modules

Jack Jansen jack@oratrix.nl
Fri, 10 Dec 1999 14:28:57 +0100


> I have successfully used SWIG to wrap the Processor Manager 
> functions. At this time I have really only tested the 
> GetProcessInformation and the MacGetCurrentProcess functions. I set 
> this up to see how hard it would be to use SWIG for this purpose. 
> Mainly I wanted to be able to get the process name, Signature, and 
> active time.
> 
> It turns out that it is not as easy to use as I would like. However, 
> it does give you a lot of flexibility. The main problems revolve 
> around trying to use the special objects that Jack provides for 
> things like FSspec pointers and OSTypes... I want to clean it up a 
> little and add some documentation and then hope to make it available.

This is one of the reasons I've always stayed away from SWIG. SWIG is nice, 
but it has two drawbacks that are (to me, at least) showstoppers:
- Any arguments other than the standard int/string/float/etc are difficult. 
Bgen has no trouble with this: as long as you can explain it the C code needed 
to wrap/unwrap argument types it'll do it for you.
- SWIG exports a C-library more-or-less as-is, which means you often have to 
wrap it into an OO module in Python. Again, bgen is superior here: you can 
explain it if the first (or last, or whatever) argument is of type X the C 
function should be exported to Python as a method of the X type.

--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm