[Python-checkins] python/dist/src/Mac/Modules/win _Winmodule.c,1.12,1.13 winsupport.py,1.32,1.33
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
2002年12月03日 15:40:25 -0800
Update of /cvsroot/python/python/dist/src/Mac/Modules/win
In directory sc8-pr-cvs1:/tmp/cvs-serv10318/win
Modified Files:
_Winmodule.c winsupport.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: _Winmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/_Winmodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** _Winmodule.c 29 Nov 2002 23:40:47 -0000 1.12
--- _Winmodule.c 3 Dec 2002 23:40:22 -0000 1.13
***************
*** 78,81 ****
--- 78,82 ----
WindowObject *it;
if (itself == NULL) return PyMac_Error(resNotFound);
+ /* XXXX Or should we use WhichWindow code here? */
it = PyObject_NEW(WindowObject, &Window_Type);
if (it == NULL) return NULL;
***************
*** 2929,2932 ****
--- 2930,2934 ----
#define WinObj_getsetlist NULL
+
static int WinObj_compare(WindowObject *self, WindowObject *other)
{
***************
*** 2947,2950 ****
--- 2949,2970 ----
return (int)self->ob_itself;
}
+ #define WinObj_tp_init 0
+
+ #define WinObj_tp_alloc PyType_GenericAlloc
+
+ static PyObject *WinObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ PyObject *self;
+ WindowPtr itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, WinObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((WindowObject *)self)->ob_itself = itself;
+ return self;
+ }
+
+ #define WinObj_tp_free PyObject_Del
+
PyTypeObject Window_Type = {
***************
*** 2969,2985 ****
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*/
WinObj_methods, /* tp_methods */
! 0, /*outputHook_tp_members*/
WinObj_getsetlist, /*tp_getset*/
! 0, /*outputHook_tp_base*/
};
--- 2989,3013 ----
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*/
WinObj_methods, /* tp_methods */
! 0, /*tp_members*/
WinObj_getsetlist, /*tp_getset*/
! 0, /*tp_base*/
! 0, /*tp_dict*/
! 0, /*tp_descr_get*/
! 0, /*tp_descr_set*/
! 0, /*tp_dictoffset*/
! WinObj_tp_init, /* tp_init */
! WinObj_tp_alloc, /* tp_alloc */
! WinObj_tp_new, /* tp_new */
! WinObj_tp_free, /* tp_free */
};
***************
*** 3829,3834 ****
Window_Type.ob_type = &PyType_Type;
Py_INCREF(&Window_Type);
! if (PyDict_SetItemString(d, "WindowType", (PyObject *)&Window_Type) != 0)
! Py_FatalError("can't initialize WindowType");
}
--- 3857,3864 ----
Window_Type.ob_type = &PyType_Type;
Py_INCREF(&Window_Type);
! PyModule_AddObject(m, "Window", (PyObject *)&Window_Type);
! /* Backward-compatible name */
! Py_INCREF(&Window_Type);
! PyModule_AddObject(m, "WindowType", (PyObject *)&Window_Type);
}
Index: winsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/win/winsupport.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** winsupport.py 29 Nov 2002 23:40:48 -0000 1.32
--- winsupport.py 3 Dec 2002 23:40:22 -0000 1.33
***************
*** 129,135 ****
"""
! class MyObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
def outputStructMembers(self):
GlobalObjectDefinition.outputStructMembers(self)
--- 129,136 ----
"""
! class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("if (itself == NULL) return PyMac_Error(resNotFound);")
+ Output("/* XXXX Or should we use WhichWindow code here? */")
def outputStructMembers(self):
GlobalObjectDefinition.outputStructMembers(self)