First step in porting MacPython modules to OSX/unix: break all references between modules except for the obj_New() and obj_Convert() routines, the PyArg_Parse and Py_BuildValue helpers.
And these can now be vectored through glue routines (by defining USE_TOOLBOX_OBJECT_GLUE) which will do the necessary imports, whereupon the module's init routine will tell the glue routine about the real conversion routine address and everything is fine again.
diff --git a/Mac/Modules/ae/aesupport.py b/Mac/Modules/ae/aesupport.py
index 86f2094..094a309 100644
--- a/Mac/Modules/ae/aesupport.py
+++ b/Mac/Modules/ae/aesupport.py
@@ -85,6 +85,14 @@
#include <AppleEvents.h>
#include <AEObjects.h>
+#ifdef USE_TOOLBOX_OBJECT_GLUE
+extern PyObject *_AEDesc_New(AEDesc *);
+extern int _AEDesc_Convert(PyObject *, AEDesc *);
+
+#define AEDesc_New _AEDesc_New
+#define AEDesc_Convert _AEDesc_Convert
+#endif
+
static pascal OSErr GenericEventHandler(); /* Forward */
AEEventHandlerUPP upp_GenericEventHandler;
@@ -138,6 +146,8 @@
initstuff = initstuff + """
upp_AEIdleProc = NewAEIdleProc(AEIdleProc);
upp_GenericEventHandler = NewAEEventHandlerProc(GenericEventHandler);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(AEDesc_New);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(AEDesc_Convert);
"""
module = MacModule('AE', 'AE', includestuff, finalstuff, initstuff)