[Pythonmac-SIG] dynload_next

Jack Jansen Jack.Jansen@oratrix.nl
Sun, 27 Jan 2002 21:24:28 +0100


On Sunday, January 27, 2002, at 07:26  PM, Steven Majewski wrote:
> BTW: Did you acatually test that dynload_next  with VTK ? I would think
> that what you describe is similar to the case for the Carbon 
> libs, which
> do appear to work. (At least I don't get any errors on loading them --
> I'm trying to merge the resources so I can test them more completely.)
>
> Maybe Jack can comment on how the Carbon modules are cross linked now ?

I used my python-dev membership to smuggle a set of glue 
routines into the core:-)

This glue code can be found in Python/mactoolboxglue.c. The CPP 
magic is in mactoolboxglue.h. The main thing I needed was that 
the modules need each others' _New() and _Convert() routines 
(the routines you pass to PyArg_Parse "O&" format). Whereas in 
MacPython 2.0 the various modules used to be linked against each 
other in devious ways (and it all worked because the shared 
libraries lived in a single folder so the Code Fragment Manager 
would load dependent modules as needed) the new setup is that 
each module's init routine registers its _New and _Convert 
routines with mactoolboxglue.c. If you use an _New or _Convert 
from another module you're actually calling a routine in 
mactoolboxglue. If the routine you want to call is already 
registered it's a quick indirection through a function pointer. 
If it isn't registered yet we import the module in which the 
routine we need is defined (which should then register the 
routine in its init routine).

A fallback solution I had in mind (in case my mod to the core 
wasn't accepted) which might work for VTK was to put this glue 
code in a separate shared library, and then link all my modules 
against it. For my problem this wouldn't have been a 100% 
solution (there's a bit of other stuff in mactoolboxglue.c as 
well), but for the problem of getting access at each others 
routine pointers it would be.
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- 
Emma Goldman -