[Python-checkins] python/dist/src/Mac/Modules/dlg _Dlgmodule.c,1.12,1.13 dlgsupport.py,1.29,1.30

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/dlg
In directory sc8-pr-cvs1:/tmp/cvs-serv10318/dlg

Modified Files:
	_Dlgmodule.c dlgsupport.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: _Dlgmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/dlg/_Dlgmodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** _Dlgmodule.c	29 Nov 2002 23:40:42 -0000	1.12
--- _Dlgmodule.c	3 Dec 2002 23:40:20 -0000	1.13
***************
*** 967,970 ****
--- 967,971 ----
  #define DlgObj_getsetlist NULL
  
+ 
  static int DlgObj_compare(DialogObject *self, DialogObject *other)
  {
***************
*** 980,983 ****
--- 981,1002 ----
  	return (int)self->ob_itself;
  }
+ #define DlgObj_tp_init 0
+ 
+ #define DlgObj_tp_alloc PyType_GenericAlloc
+ 
+ static PyObject *DlgObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ 	PyObject *self;
+ 	DialogPtr itself;
+ 	char *kw[] = {"itself", 0};
+ 
+ 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, DlgObj_Convert, &itself)) return NULL;
+ 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ 	((DialogObject *)self)->ob_itself = itself;
+ 	return self;
+ }
+ 
+ #define DlgObj_tp_free PyObject_Del
+ 
  
  PyTypeObject Dialog_Type = {
***************
*** 1002,1018 ****
  	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*/
  	DlgObj_methods, /* tp_methods */
! 	0, /*outputHook_tp_members*/
  	DlgObj_getsetlist, /*tp_getset*/
! 	0, /*outputHook_tp_base*/
  };
  
--- 1021,1045 ----
  	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*/
  	DlgObj_methods, /* tp_methods */
! 	0, /*tp_members*/
  	DlgObj_getsetlist, /*tp_getset*/
! 	0, /*tp_base*/
! 	0, /*tp_dict*/
! 	0, /*tp_descr_get*/
! 	0, /*tp_descr_set*/
! 	0, /*tp_dictoffset*/
! 	DlgObj_tp_init, /* tp_init */
! 	DlgObj_tp_alloc, /* tp_alloc */
! 	DlgObj_tp_new, /* tp_new */
! 	DlgObj_tp_free, /* tp_free */
  };
  
***************
*** 1590,1595 ****
  	Dialog_Type.ob_type = &PyType_Type;
  	Py_INCREF(&Dialog_Type);
! 	if (PyDict_SetItemString(d, "DialogType", (PyObject *)&Dialog_Type) != 0)
! 		Py_FatalError("can't initialize DialogType");
  }
  
--- 1617,1624 ----
  	Dialog_Type.ob_type = &PyType_Type;
  	Py_INCREF(&Dialog_Type);
! 	PyModule_AddObject(m, "Dialog", (PyObject *)&Dialog_Type);
! 	/* Backward-compatible name */
! 	Py_INCREF(&Dialog_Type);
! 	PyModule_AddObject(m, "DialogType", (PyObject *)&Dialog_Type);
  }
  

Index: dlgsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/dlg/dlgsupport.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** dlgsupport.py	29 Nov 2002 23:40:42 -0000	1.29
--- dlgsupport.py	3 Dec 2002 23:40:20 -0000	1.30
***************
*** 202,206 ****
  
  # Define a class which specializes our object definition
! class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
  	def __init__(self, name, prefix = None, itselftype = None):
  		GlobalObjectDefinition.__init__(self, name, prefix, itselftype)
--- 202,206 ----
  
  # Define a class which specializes our object definition
! class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
  	def __init__(self, name, prefix = None, itselftype = None):
  		GlobalObjectDefinition.__init__(self, name, prefix, itselftype)