[Python-checkins] python/dist/src/Mac/Modules/cg _CGmodule.c,1.7,1.8 cgsupport.py,1.4,1.5

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Fri, 29 Nov 2002 15:41:14 -0800


Update of /cvsroot/python/python/dist/src/Mac/Modules/cg
In directory sc8-pr-cvs1:/tmp/cvs-serv8673/cg

Modified Files:
	_CGmodule.c cgsupport.py 
Log Message:
Converted the Carbon modules to use PEP252-style objects, with
descriptors in stead of manual getattr hooks to get at attributes
of the objects.

For Qd I have in stead gotten rid of most of the attribute access
in favor of the carbon-style accessor methods (with the exception
of visRgn, to be done later), and of the Carbon.Qd.qd global object,
for which accessor functions are also available.

For List I have fixed the fact that various methods were incorrectly
generated as functions.

CF is untouched: PEP252 doesn't allow "poor-mans-inheritance" with
basechain, so it will have to wait for PEP253 support.


Index: _CGmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** _CGmodule.c	16 Aug 2002 09:09:19 -0000	1.7
--- _CGmodule.c	29 Nov 2002 23:40:42 -0000	1.8
***************
*** 1267,1278 ****
  };
  
! PyMethodChain CGContextRefObj_chain = { CGContextRefObj_methods, NULL };
! 
! static PyObject *CGContextRefObj_getattr(CGContextRefObject *self, char *name)
! {
! 	return Py_FindMethodInChain(&CGContextRefObj_chain, (PyObject *)self, name);
! }
! 
! #define CGContextRefObj_setattr NULL
  
  #define CGContextRefObj_compare NULL
--- 1267,1271 ----
  };
  
! #define CGContextRefObj_getsetlist NULL
  
  #define CGContextRefObj_compare NULL
***************
*** 1291,1296 ****
  	(destructor) CGContextRefObj_dealloc, /*tp_dealloc*/
  	0, /*tp_print*/
! 	(getattrfunc) CGContextRefObj_getattr, /*tp_getattr*/
! 	(setattrfunc) CGContextRefObj_setattr, /*tp_setattr*/
  	(cmpfunc) CGContextRefObj_compare, /*tp_compare*/
  	(reprfunc) CGContextRefObj_repr, /*tp_repr*/
--- 1284,1289 ----
  	(destructor) CGContextRefObj_dealloc, /*tp_dealloc*/
  	0, /*tp_print*/
! 	(getattrfunc)0, /*tp_getattr*/
! 	(setattrfunc)0, /*tp_setattr*/
  	(cmpfunc) CGContextRefObj_compare, /*tp_compare*/
  	(reprfunc) CGContextRefObj_repr, /*tp_repr*/
***************
*** 1299,1302 ****
--- 1292,1312 ----
  	(PyMappingMethods *)0, /* tp_as_mapping */
  	(hashfunc) CGContextRefObj_hash, /*tp_hash*/
+ 	0, /*tp_call*/
+ 	0, /*tp_str*/
+ 	PyObject_GenericGetAttr, /*tp_getattro*/
+ 	PyObject_GenericSetAttr, /*tp_setattro */
+ 	0, /*outputHook_tp_as_buffer*/
+ 	0, /*outputHook_tp_flags*/
+ 	0, /*outputHook_tp_doc*/
+ 	0, /*outputHook_tp_traverse*/
+ 	0, /*outputHook_tp_clear*/
+ 	0, /*outputHook_tp_richcompare*/
+ 	0, /*outputHook_tp_weaklistoffset*/
+ 	0, /*outputHook_tp_iter*/
+ 	0, /*outputHook_tp_iternext*/
+ 	CGContextRefObj_methods, /* tp_methods */
+ 	0, /*outputHook_tp_members*/
+ 	CGContextRefObj_getsetlist, /*tp_getset*/
+ 	0, /*outputHook_tp_base*/
  };
  

Index: cgsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/cgsupport.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** cgsupport.py	4 Mar 2002 10:31:32 -0000	1.4
--- cgsupport.py	29 Nov 2002 23:40:42 -0000	1.5
***************
*** 251,255 ****
  
  
! class MyObjectDefinition(GlobalObjectDefinition):
  	def outputStructMembers(self):
  		ObjectDefinition.outputStructMembers(self)
--- 251,255 ----
  
  
! class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
  	def outputStructMembers(self):
  		ObjectDefinition.outputStructMembers(self)