[Python-checkins] python/dist/src/Mac/Modules/alias _Aliasmodule.c,1.2,1.3 aliassupport.py,1.2,1.3

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


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

Modified Files:
	_Aliasmodule.c aliassupport.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: _Aliasmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/alias/_Aliasmodule.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** _Aliasmodule.c	29 Nov 2002 23:40:41 -0000	1.2
--- _Aliasmodule.c	3 Dec 2002 23:40:18 -0000	1.3
***************
*** 98,101 ****
--- 98,102 ----
  #define AliasObj_getsetlist NULL
  
+ 
  #define AliasObj_compare NULL
  
***************
*** 103,106 ****
--- 104,125 ----
  
  #define AliasObj_hash NULL
+ #define AliasObj_tp_init 0
+ 
+ #define AliasObj_tp_alloc PyType_GenericAlloc
+ 
+ static PyObject *AliasObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ 	PyObject *self;
+ 	AliasHandle itself;
+ 	char *kw[] = {"itself", 0};
+ 
+ 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, AliasObj_Convert, &itself)) return NULL;
+ 	if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ 	((AliasObject *)self)->ob_itself = itself;
+ 	return self;
+ }
+ 
+ #define AliasObj_tp_free PyObject_Del
+ 
  
  PyTypeObject Alias_Type = {
***************
*** 125,141 ****
  	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*/
  	AliasObj_methods, /* tp_methods */
! 	0, /*outputHook_tp_members*/
  	AliasObj_getsetlist, /*tp_getset*/
! 	0, /*outputHook_tp_base*/
  };
  
--- 144,168 ----
  	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*/
  	AliasObj_methods, /* tp_methods */
! 	0, /*tp_members*/
  	AliasObj_getsetlist, /*tp_getset*/
! 	0, /*tp_base*/
! 	0, /*tp_dict*/
! 	0, /*tp_descr_get*/
! 	0, /*tp_descr_set*/
! 	0, /*tp_dictoffset*/
! 	AliasObj_tp_init, /* tp_init */
! 	AliasObj_tp_alloc, /* tp_alloc */
! 	AliasObj_tp_new, /* tp_new */
! 	AliasObj_tp_free, /* tp_free */
  };
  
***************
*** 666,671 ****
  	Alias_Type.ob_type = &PyType_Type;
  	Py_INCREF(&Alias_Type);
! 	if (PyDict_SetItemString(d, "AliasType", (PyObject *)&Alias_Type) != 0)
! 		Py_FatalError("can't initialize AliasType");
  }
  
--- 693,700 ----
  	Alias_Type.ob_type = &PyType_Type;
  	Py_INCREF(&Alias_Type);
! 	PyModule_AddObject(m, "Alias", (PyObject *)&Alias_Type);
! 	/* Backward-compatible name */
! 	Py_INCREF(&Alias_Type);
! 	PyModule_AddObject(m, "AliasType", (PyObject *)&Alias_Type);
  }
  

Index: aliassupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/alias/aliassupport.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** aliassupport.py	29 Nov 2002 23:40:41 -0000	1.2
--- aliassupport.py	3 Dec 2002 23:40:18 -0000	1.3
***************
*** 73,77 ****
  module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
  
! class AliasDefinition(PEP252Mixin, GlobalObjectDefinition):
  
  	def outputCheckNewArg(self):
--- 73,78 ----
  module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
  
! class AliasDefinition(PEP253Mixin, GlobalObjectDefinition):
! 	# XXXX Should inherit from resource?
  
  	def outputCheckNewArg(self):