[Python-checkins] python/dist/src/Mac/Modules/qd _Qdmodule.c,1.12,1.13 qdsupport.py,1.40,1.41
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
2002年12月03日 15:40:23 -0800
Update of /cvsroot/python/python/dist/src/Mac/Modules/qd
In directory sc8-pr-cvs1:/tmp/cvs-serv10318/qd
Modified Files:
_Qdmodule.c qdsupport.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: _Qdmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/_Qdmodule.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** _Qdmodule.c 29 Nov 2002 23:40:44 -0000 1.12
--- _Qdmodule.c 3 Dec 2002 23:40:21 -0000 1.13
***************
*** 1116,1119 ****
--- 1116,1137 ----
#define GrafObj_hash NULL
+ #define GrafObj_tp_init 0
+
+ #define GrafObj_tp_alloc PyType_GenericAlloc
+
+ static PyObject *GrafObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ PyObject *self;
+ GrafPtr itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, GrafObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((GrafPortObject *)self)->ob_itself = itself;
+ return self;
+ }
+
+ #define GrafObj_tp_free PyObject_Del
+
PyTypeObject GrafPort_Type = {
***************
*** 1138,1154 ****
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*/
GrafObj_methods, /* tp_methods */
! 0, /*outputHook_tp_members*/
GrafObj_getsetlist, /*tp_getset*/
! 0, /*outputHook_tp_base*/
};
--- 1156,1180 ----
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*/
GrafObj_methods, /* tp_methods */
! 0, /*tp_members*/
GrafObj_getsetlist, /*tp_getset*/
! 0, /*tp_base*/
! 0, /*tp_dict*/
! 0, /*tp_descr_get*/
! 0, /*tp_descr_set*/
! 0, /*tp_dictoffset*/
! GrafObj_tp_init, /* tp_init */
! GrafObj_tp_alloc, /* tp_alloc */
! GrafObj_tp_new, /* tp_new */
! GrafObj_tp_free, /* tp_free */
};
***************
*** 1288,1291 ****
--- 1314,1335 ----
#define BMObj_hash NULL
+ #define BMObj_tp_init 0
+
+ #define BMObj_tp_alloc PyType_GenericAlloc
+
+ static PyObject *BMObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ PyObject *self;
+ BitMapPtr itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, BMObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((BitMapObject *)self)->ob_itself = itself;
+ return self;
+ }
+
+ #define BMObj_tp_free PyObject_Del
+
PyTypeObject BitMap_Type = {
***************
*** 1310,1326 ****
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*/
BMObj_methods, /* tp_methods */
! 0, /*outputHook_tp_members*/
BMObj_getsetlist, /*tp_getset*/
! 0, /*outputHook_tp_base*/
};
--- 1354,1378 ----
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*/
BMObj_methods, /* tp_methods */
! 0, /*tp_members*/
BMObj_getsetlist, /*tp_getset*/
! 0, /*tp_base*/
! 0, /*tp_dict*/
! 0, /*tp_descr_get*/
! 0, /*tp_descr_set*/
! 0, /*tp_dictoffset*/
! BMObj_tp_init, /* tp_init */
! BMObj_tp_alloc, /* tp_alloc */
! BMObj_tp_new, /* tp_new */
! BMObj_tp_free, /* tp_free */
};
***************
*** 6873,6882 ****
GrafPort_Type.ob_type = &PyType_Type;
Py_INCREF(&GrafPort_Type);
! if (PyDict_SetItemString(d, "GrafPortType", (PyObject *)&GrafPort_Type) != 0)
! Py_FatalError("can't initialize GrafPortType");
BitMap_Type.ob_type = &PyType_Type;
Py_INCREF(&BitMap_Type);
! if (PyDict_SetItemString(d, "BitMapType", (PyObject *)&BitMap_Type) != 0)
! Py_FatalError("can't initialize BitMapType");
}
--- 6925,6938 ----
GrafPort_Type.ob_type = &PyType_Type;
Py_INCREF(&GrafPort_Type);
! PyModule_AddObject(m, "GrafPort", (PyObject *)&GrafPort_Type);
! /* Backward-compatible name */
! Py_INCREF(&GrafPort_Type);
! PyModule_AddObject(m, "GrafPortType", (PyObject *)&GrafPort_Type);
BitMap_Type.ob_type = &PyType_Type;
Py_INCREF(&BitMap_Type);
! PyModule_AddObject(m, "BitMap", (PyObject *)&BitMap_Type);
! /* Backward-compatible name */
! Py_INCREF(&BitMap_Type);
! PyModule_AddObject(m, "BitMapType", (PyObject *)&BitMap_Type);
}
Index: qdsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/qd/qdsupport.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** qdsupport.py 29 Nov 2002 23:40:46 -0000 1.40
--- qdsupport.py 3 Dec 2002 23:40:21 -0000 1.41
***************
*** 237,241 ****
## Output("KillPoly(%s);", itselfname)
! class MyGRObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [
('visRgn',
--- 237,241 ----
## Output("KillPoly(%s);", itselfname)
! class MyGRObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
getsetlist = [
('visRgn',
***************
*** 278,282 ****
Output("#endif")
! class MyBMObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
getsetlist = [
(
--- 278,282 ----
Output("#endif")
! class MyBMObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
getsetlist = [
(