[Python-checkins] CVS: python/dist/src/Mac/Modules/qd qdsupport.py,1.29,1.30

Jack Jansen jackjansen@users.sourceforge.net
Thu, 17 May 2001 14:57:04 -0700


Update of /cvsroot/python/python/dist/src/Mac/Modules/qd
In directory usw-pr-cvs1:/tmp/cvs-serv8335/Python/Mac/Modules/qd

Modified Files:
	qdsupport.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: qdsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/qdsupport.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** qdsupport.py	2001/02/02 22:41:48	1.29
--- qdsupport.py	2001/05/17 21:57:02	1.30
***************
*** 64,67 ****
--- 64,83 ----
  #include <%s>""" % MACHEADERFILE + """
  
+ #ifdef USE_TOOLBOX_OBJECT_GLUE
+ extern PyObject *_GrafObj_New(GrafPtr);
+ extern int _GrafObj_Convert(PyObject *, GrafPtr *);
+ extern PyObject *_BMObj_New(BitMapPtr);
+ extern int _BMObj_Convert(PyObject *, BitMapPtr *);
+ extern PyObject *_QdRGB_New(RGBColorPtr);
+ extern int _QdRGB_Convert(PyObject *, RGBColorPtr *);
+ 
+ #define GrafObj_New _GrafObj_New
+ #define GrafObj_Convert _GrafObj_Convert
+ #define BMObj_New _BMObj_New
+ #define BMObj_Convert _BMObj_Convert
+ #define QdRGB_New _QdRGB_New
+ #define QdRGB_Convert _QdRGB_Convert
+ #endif
+ 
  #if !ACCESSOR_CALLS_ARE_FUNCTIONS
  #define GetPortBitMapForCopyBits(port) ((const struct BitMap *)&((GrafPort *)(port))->portBits)
***************
*** 202,205 ****
--- 218,230 ----
  """
  
+ initstuff = initstuff + """
+ 	PyMac_INIT_TOOLBOX_OBJECT_NEW(BMObj_New);
+ 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(BMObj_Convert);
+ 	PyMac_INIT_TOOLBOX_OBJECT_NEW(GrafObj_New);
+ 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GrafObj_Convert);
+ 	PyMac_INIT_TOOLBOX_OBJECT_NEW(QdRGB_New);
+ 	PyMac_INIT_TOOLBOX_OBJECT_CONVERT(QdRGB_Convert);
+ """
+ 
  ## not yet...
  ##
***************
*** 220,223 ****
--- 245,258 ----
  		Output("if (itself == NULL) return PyMac_Error(resNotFound);")
  	def outputCheckConvertArg(self):
+ 		Output("#if 1")
+ 		OutLbrace()
+ 		Output("WindowRef win;")
+ 		OutLbrace("if (WinObj_Convert(v, &win) && v)")
+ 		Output("*p_itself = (GrafPtr)GetWindowPort(win);")
+ 		Output("return 1;")
+ 		OutRbrace()
+ 		Output("PyErr_Clear();")
+ 		OutRbrace()
+ 		Output("#else")
  		OutLbrace("if (DlgObj_Check(v))")
  		Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;")
***************
*** 230,233 ****
--- 265,269 ----
  		Output("return 1;")
  		OutRbrace()
+ 		Output("#endif")
  	def outputGetattrHook(self):
  		Output("#if !ACCESSOR_CALLS_ARE_FUNCTIONS")