[Python-bugs-list] Re: SWIG's embed.i and Python 1.5.2 on WinNT (PR#25)
Guido van Rossum
guido@CNRI.Reston.VA.US
Wed, 14 Jul 1999 13:03:38 -0400
> SWIG automatically generates scripting language bindings
> for C libraries.
I knew that :-)
> It provides a feature to build a standalone
> interpreter that contains the wrapper module and all the
> standard builtin modules of Python. For that purpose the
> SWIG-generated module source provides its own `main',
> "grabs" Python's inittab[] structure, adds the wrapper
> module, sets PyImport_Inittab to the patched inittab and
> calls Py_Main(). The generated source looks like this
> (with some omissions):
>
> #define _PyImport_Inittab swig_inittab
> /* Grab Python's inittab[] structure */
>
> #include <config.c> /* This is Pythons's config.c! */
>
> #undef _PyImport_Inittab
>
> /* Now define our own version of it.
> Hopefully someone does not have more than 1000
> built-in modules */
>
> struct _inittab _SwigImport_Inittab[1000];
>
> [...]
>
> int
> main(int argc, char **argv) {
> swig_add_builtin(); /* add wrapper module */
> PyImport_Inittab = _SwigImport_Inittab;
> return Py_Main(argc,argv);
> }
I'm not sure I understand what this has to do with your original
request. Do you still think it requires a patch to Python?
Also Python has a better way to manipulate the inittab than to play
dirty preprocessor tricks. There's a whole API to deal with it:
PyImport_ExtendInittab(), PyImport_AppendInittab().
> If you allow, I'd like to forward your questions to Dave Beazley
> (beazley@cs.uchicago.edu), the author of SWIG.
Sure, go agead.
> P.S. Sorry for the duplicate PR#26. I was braindead and
> pressed "Reload".
No problem -- it has happened to each of us. We conclude that the
Jitterbug interface has a problem, but we can't easily fix it so we'll
live with it.
--Guido van Rossum (home page: http://www.python.org/~guido/)