[Python-checkins] python/dist/src/Mac/Modules/ctl _Ctlmodule.c,1.20,1.21 ctlsupport.py,1.51,1.52

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


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

Modified Files:
	_Ctlmodule.c ctlsupport.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: _Ctlmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/_Ctlmodule.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** _Ctlmodule.c	29 Nov 2002 23:40:42 -0000	1.20
--- _Ctlmodule.c	3 Dec 2002 23:40:19 -0000	1.21
***************
*** 4546,4549 ****
--- 4546,4550 ----
  #define CtlObj_getsetlist NULL
  
+ 
  static int CtlObj_compare(ControlObject *self, ControlObject *other)
  {
***************
*** 4571,4574 ****
--- 4572,4593 ----
  	return (long)self->ob_itself;
  }
+ #define CtlObj_tp_init 0
+ 
+ #define CtlObj_tp_alloc PyType_GenericAlloc
+ 
+ static PyObject *CtlObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ 	PyObject *self;
+ 	ControlHandle itself;
+ 	char *kw[] = {"itself", 0};
+ 
+ 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CtlObj_Convert, &itself)) return NULL;
+ 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ 	((ControlObject *)self)->ob_itself = itself;
+ 	return self;
+ }
+ 
+ #define CtlObj_tp_free PyObject_Del
+ 
  
  PyTypeObject Control_Type = {
***************
*** 4593,4609 ****
  	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*/
  	CtlObj_methods, /* tp_methods */
! 	0, /*outputHook_tp_members*/
  	CtlObj_getsetlist, /*tp_getset*/
! 	0, /*outputHook_tp_base*/
  };
  
--- 4612,4636 ----
  	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*/
  	CtlObj_methods, /* tp_methods */
! 	0, /*tp_members*/
  	CtlObj_getsetlist, /*tp_getset*/
! 	0, /*tp_base*/
! 	0, /*tp_dict*/
! 	0, /*tp_descr_get*/
! 	0, /*tp_descr_set*/
! 	0, /*tp_dictoffset*/
! 	CtlObj_tp_init, /* tp_init */
! 	CtlObj_tp_alloc, /* tp_alloc */
! 	CtlObj_tp_new, /* tp_new */
! 	CtlObj_tp_free, /* tp_free */
  };
  
***************
*** 6715,6720 ****
  	Control_Type.ob_type = &PyType_Type;
  	Py_INCREF(&Control_Type);
! 	if (PyDict_SetItemString(d, "ControlType", (PyObject *)&Control_Type) != 0)
! 		Py_FatalError("can't initialize ControlType");
  }
  
--- 6742,6749 ----
  	Control_Type.ob_type = &PyType_Type;
  	Py_INCREF(&Control_Type);
! 	PyModule_AddObject(m, "Control", (PyObject *)&Control_Type);
! 	/* Backward-compatible name */
! 	Py_INCREF(&Control_Type);
! 	PyModule_AddObject(m, "ControlType", (PyObject *)&Control_Type);
  }
  

Index: ctlsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/ctl/ctlsupport.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** ctlsupport.py	29 Nov 2002 23:40:42 -0000	1.51
--- ctlsupport.py	3 Dec 2002 23:40:19 -0000	1.52
***************
*** 491,495 ****
  """
  
! class MyObjectDefinition(PEP252Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
  	def outputStructMembers(self):
  		GlobalObjectDefinition.outputStructMembers(self)
--- 491,495 ----
  """
  
! class MyObjectDefinition(PEP253Mixin, ObjectIdentityMixin, GlobalObjectDefinition):
  	def outputStructMembers(self):
  		GlobalObjectDefinition.outputStructMembers(self)