[Python-checkins] CVS: python/dist/src/Mac/Modules/win winsupport.py,1.22,1.23
Jack Jansen
jackjansen@users.sourceforge.net
Thu, 17 May 2001 14:58:36 -0700
Update of /cvsroot/python/python/dist/src/Mac/Modules/win
In directory usw-pr-cvs1:/tmp/cvs-serv8669/Python/Mac/Modules/win
Modified Files:
winsupport.py
Log Message:
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.
Index: winsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/winsupport.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** winsupport.py 2001/04/25 22:09:29 1.22
--- winsupport.py 2001/05/17 21:58:34 1.23
***************
*** 57,60 ****
--- 57,70 ----
#include <%s>""" % MACHEADERFILE + """
+ #ifdef USE_TOOLBOX_OBJECT_GLUE
+ extern PyObject *_WinObj_New(WindowRef);
+ extern PyObject *_WinObj_WhichWindow(WindowRef);
+ extern int _WinObj_Convert(PyObject *, WindowRef *);
+
+ #define WinObj_New _WinObj_New
+ #define WinObj_WhichWindow _WinObj_WhichWindow
+ #define WinObj_Convert _WinObj_Convert
+ #endif
+
#if !ACCESSOR_CALLS_ARE_FUNCTIONS
/* Carbon calls that we emulate in classic mode */
***************
*** 104,107 ****
--- 114,123 ----
"""
+ initstuff = initstuff + """
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(WinObj_New);
+ PyMac_INIT_TOOLBOX_OBJECT_NEW(WinObj_WhichWindow);
+ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(WinObj_Convert);
+ """
+
class MyObjectDefinition(GlobalObjectDefinition):
def outputCheckNewArg(self):
***************
*** 119,126 ****
--- 135,153 ----
OutRbrace()
def outputCheckConvertArg(self):
+ Output("#if 1")
+ OutLbrace()
+ Output("DialogRef dlg;")
+ OutLbrace("if (DlgObj_Convert(v, &dlg) && dlg)")
+ Output("*p_itself = GetDialogWindow(dlg);")
+ Output("return 1;")
+ OutRbrace()
+ Output("PyErr_Clear();")
+ OutRbrace()
+ Output("#else")
OutLbrace("if (DlgObj_Check(v))")
Output("*p_itself = DlgObj_ConvertToWindow(v);")
Output("return 1;")
OutRbrace()
+ Output("#endif")
Out("""
if (v == Py_None) { *p_itself = NULL; return 1; }