[Python-checkins] python/dist/src/Mac/Modules/cf _CFmodule.c, 1.24, 1.25 cfsupport.py, 1.24, 1.25

jackjansen at users.sourceforge.net jackjansen at users.sourceforge.net
Thu Jul 15 15:42:14 CEST 2004


Update of /cvsroot/python/python/dist/src/Mac/Modules/cf
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3852

Modified Files:
	_CFmodule.c cfsupport.py 
Log Message:
Make CF module PEP253 based (finally).


Index: _CFmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/_CFmodule.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** _CFmodule.c	20 Nov 2003 13:30:56 -0000	1.24
--- _CFmodule.c	15 Jul 2004 13:42:06 -0000	1.25
***************
*** 160,164 ****
  		self->ob_freeit((CFTypeRef)self->ob_itself);
  	}
! 	PyObject_Free((PyObject *)self);
  }
  
--- 160,164 ----
  		self->ob_freeit((CFTypeRef)self->ob_itself);
  	}
! 	self->ob_type->tp_free((PyObject *)self);
  }
[...1315 lines suppressed...]
  	CFStringRef_Type.ob_type = &PyType_Type;
+ 	CFStringRef_Type.tp_base = &CFTypeRef_Type;
  	if (PyType_Ready(&CFStringRef_Type) < 0) return;
  	Py_INCREF(&CFStringRef_Type);
***************
*** 4415,4418 ****
--- 4944,4948 ----
  	PyModule_AddObject(m, "CFStringRefType", (PyObject *)&CFStringRef_Type);
  	CFMutableStringRef_Type.ob_type = &PyType_Type;
+ 	CFMutableStringRef_Type.tp_base = &CFStringRef_Type;
  	if (PyType_Ready(&CFMutableStringRef_Type) < 0) return;
  	Py_INCREF(&CFMutableStringRef_Type);
***************
*** 4422,4425 ****
--- 4952,4956 ----
  	PyModule_AddObject(m, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type);
  	CFURLRef_Type.ob_type = &PyType_Type;
+ 	CFURLRef_Type.tp_base = &CFTypeRef_Type;
  	if (PyType_Ready(&CFURLRef_Type) < 0) return;
  	Py_INCREF(&CFURLRef_Type);

Index: cfsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cf/cfsupport.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** cfsupport.py	19 Nov 2003 16:13:24 -0000	1.24
--- cfsupport.py	15 Jul 2004 13:42:06 -0000	1.25
***************
*** 251,255 ****
  # Our (opaque) objects
  
! class MyGlobalObjectDefinition(GlobalObjectDefinition):
  	def outputCheckNewArg(self):
  		Output('if (itself == NULL)')
--- 251,255 ----
  # Our (opaque) objects
  
! class MyGlobalObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
  	def outputCheckNewArg(self):
  		Output('if (itself == NULL)')
***************
*** 303,311 ****
  		OutRbrace()
  
  class CFTypeRefObjectDefinition(MyGlobalObjectDefinition):
  	pass
  	
  class CFArrayRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFTypeRefObj_chain"
  	
  	def outputRepr(self):
--- 303,339 ----
  		OutRbrace()
  
+ 	def output_tp_newBody(self):
+ 		Output("PyObject *self;")
+ 		Output
+ 		Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
+ 		Output("((%s *)self)->ob_itself = NULL;", self.objecttype)
+ 		Output("((%s *)self)->ob_freeit = CFRelease;", self.objecttype)
+ 		Output("return self;")
+ 		
+ 	def output_tp_initBody(self):
+ 		Output("%s itself;", self.itselftype)
+ 		Output("char *kw[] = {\"itself\", 0};")
+ 		Output()
+ 		Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, %s_Convert, &itself))",
+ 			self.prefix)
+ 		OutLbrace()
+ 		Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+ 		Output("return 0;")
+ 		OutRbrace()
+ 		if self.prefix != 'CFTypeRefObj':
+ 			Output()
+ 			Output("/* Any CFTypeRef descendent is allowed as initializer too */")
+ 			Output("if (PyArg_ParseTupleAndKeywords(args, kwds, \"O&\", kw, CFTypeRefObj_Convert, &itself))")
+ 			OutLbrace()
+ 			Output("((%s *)self)->ob_itself = itself;", self.objecttype)
+ 			Output("return 0;")
+ 			OutRbrace()
+ 		Output("return -1;")
+ 
  class CFTypeRefObjectDefinition(MyGlobalObjectDefinition):
  	pass
  	
  class CFArrayRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFTypeRef_Type"
  	
  	def outputRepr(self):
***************
*** 319,323 ****
  	
  class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFArrayRefObj_chain"
  	
  	def outputRepr(self):
--- 347,351 ----
  	
  class CFMutableArrayRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFArrayRef_Type"
  	
  	def outputRepr(self):
***************
*** 331,335 ****
  	
  class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFTypeRefObj_chain"
  	
  	def outputRepr(self):
--- 359,363 ----
  	
  class CFDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFTypeRef_Type"
  	
  	def outputRepr(self):
***************
*** 343,347 ****
  	
  class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFDictionaryRefObj_chain"
  	
  	def outputRepr(self):
--- 371,375 ----
  	
  class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFDictionaryRef_Type"
  	
  	def outputRepr(self):
***************
*** 355,359 ****
  	
  class CFDataRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFTypeRefObj_chain"
  	
  	def outputCheckConvertArg(self):
--- 383,387 ----
  	
  class CFDataRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFTypeRef_Type"
  	
  	def outputCheckConvertArg(self):
***************
*** 379,383 ****
  	
  class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFDataRefObj_chain"
  	
  	def outputRepr(self):
--- 407,411 ----
  	
  class CFMutableDataRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFDataRef_Type"
  	
  	def outputRepr(self):
***************
*** 391,395 ****
  
  class CFStringRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFTypeRefObj_chain"
  	
  	def outputCheckConvertArg(self):
--- 419,423 ----
  
  class CFStringRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFTypeRef_Type"
  	
  	def outputCheckConvertArg(self):
***************
*** 424,428 ****
  
  class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition):
! 	basechain = "&CFStringRefObj_chain"
  	
  	def outputCheckConvertArg(self):
--- 452,456 ----
  
  class CFMutableStringRefObjectDefinition(CFStringRefObjectDefinition):
! 	basetype = "CFStringRef_Type"
  	
  	def outputCheckConvertArg(self):
***************
*** 440,444 ****
  
  class CFURLRefObjectDefinition(MyGlobalObjectDefinition):
! 	basechain = "&CFTypeRefObj_chain"
  	
  	def outputRepr(self):
--- 468,472 ----
  
  class CFURLRefObjectDefinition(MyGlobalObjectDefinition):
! 	basetype = "CFTypeRef_Type"
  	
  	def outputRepr(self):



More information about the Python-checkins mailing list