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

jackjansen@users.sourceforge.net jackjansen@users.sourceforge.net
Tue, 03 Dec 2002 15:40:51 -0800


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

Modified Files:
	_CGmodule.c cgsupport.py 
Log Message:
Added PEP253 support to most Carbon modules. This isn't complete yet:
some of the more compilcated cases (CF, Res) haven't been done yet. Also,
various types should inherit from each other (anything with an as_Resource
method should be a Resource subtype, the CF types should become one family).


Index: _CGmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cg/_CGmodule.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** _CGmodule.c	29 Nov 2002 23:40:42 -0000	1.8
--- _CGmodule.c	3 Dec 2002 23:40:19 -0000	1.9
***************
*** 1269,1272 ****
--- 1269,1273 ----
  #define CGContextRefObj_getsetlist NULL
  
+ 
  #define CGContextRefObj_compare NULL
  
***************
*** 1274,1277 ****
--- 1275,1296 ----
  
  #define CGContextRefObj_hash NULL
+ #define CGContextRefObj_tp_init 0
+ 
+ #define CGContextRefObj_tp_alloc PyType_GenericAlloc
+ 
+ static PyObject *CGContextRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ 	PyObject *self;
+ 	CGContextRef itself;
+ 	char *kw[] = {"itself", 0};
+ 
+ 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CGContextRefObj_Convert, &itself)) return NULL;
+ 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ 	((CGContextRefObject *)self)->ob_itself = itself;
+ 	return self;
+ }
+ 
+ #define CGContextRefObj_tp_free PyObject_Del
+ 
  
  PyTypeObject CGContextRef_Type = {
***************
*** 1296,1312 ****
  	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*/
  };
  
--- 1315,1339 ----
  	PyObject_GenericGetAttr, /*tp_getattro*/
  	PyObject_GenericSetAttr, /*tp_setattro */
! 	0, /*tp_as_buffer*/
! 	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
! 	0, /*tp_doc*/
! 	0, /*tp_traverse*/
! 	0, /*tp_clear*/
! 	0, /*tp_richcompare*/
! 	0, /*tp_weaklistoffset*/
! 	0, /*tp_iter*/
! 	0, /*tp_iternext*/
  	CGContextRefObj_methods, /* tp_methods */
! 	0, /*tp_members*/
  	CGContextRefObj_getsetlist, /*tp_getset*/
! 	0, /*tp_base*/
! 	0, /*tp_dict*/
! 	0, /*tp_descr_get*/
! 	0, /*tp_descr_set*/
! 	0, /*tp_dictoffset*/
! 	CGContextRefObj_tp_init, /* tp_init */
! 	CGContextRefObj_tp_alloc, /* tp_alloc */
! 	CGContextRefObj_tp_new, /* tp_new */
! 	CGContextRefObj_tp_free, /* tp_free */
  };
  
***************
*** 1374,1379 ****
  	CGContextRef_Type.ob_type = &PyType_Type;
  	Py_INCREF(&CGContextRef_Type);
! 	if (PyDict_SetItemString(d, "CGContextRefType", (PyObject *)&CGContextRef_Type) != 0)
! 		Py_FatalError("can't initialize CGContextRefType");
  }
  
--- 1401,1408 ----
  	CGContextRef_Type.ob_type = &PyType_Type;
  	Py_INCREF(&CGContextRef_Type);
! 	PyModule_AddObject(m, "CGContextRef", (PyObject *)&CGContextRef_Type);
! 	/* Backward-compatible name */
! 	Py_INCREF(&CGContextRef_Type);
! 	PyModule_AddObject(m, "CGContextRefType", (PyObject *)&CGContextRef_Type);
  }
  

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