[Pythonmac-SIG] Breaking the circular dependencies between toolbox modules

Jack Jansen jack@oratrix.nl
Fri, 15 Dec 2000 01:56:37 +0100


Here's a half-baked idea I'd liek some feedback on.

Currently a lot of the toolbox modules depend on each other, mainly to 
create objects and access them. For instance, Dlg depends on Ctl,
because dialog.GetDialogItemAsControl() needs to wrap a MacOS
ControlRef in a Python ControlObj.

These dependencies have now resulted in the majority of the toolbox
modules living in PythonCore, and a few others dynamically linking to
each other. All this is getting messy, and as Steven Majevski's
messages show the headaches are getting bigger once we try to move to
Mach-O, the native MacOSX executable format.

The half-baked idea is as follows: we put placeholders for all the
object-wrapping and unwrapping routines (such as CtlObj_New and
CtlObj_Convert) in a single place (probably PythonCore, or a separate
DLL for Mach-O). These placeholders are referred to through a function 
pointer (i.e. CtlObj_New is #defined as (*CtlObj_New_routineptr)), and 
the only thing they do is import the Ctl module and then call
*CtlObj_New_routineptr again. One of the things the init module of Ctl 
does is store the address of the real wrapper function (_CtlObj_New
seems like a reasonable name) into the CtlObj_New_routineptr variable.

What do you all think? Does this sound feasible?
--
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/ ++++