[Python-checkins] python/dist/src/Mac/Modules/cm _Cmmodule.c,1.11,1.12 cmsupport.py,1.7,1.8
jackjansen@users.sourceforge.net
jackjansen@users.sourceforge.net
Tue, 03 Dec 2002 15:40:51 -0800
Update of /cvsroot/python/python/dist/src/Mac/Modules/cm
In directory sc8-pr-cvs1:/tmp/cvs-serv10318/cm
Modified Files:
_Cmmodule.c cmsupport.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: _Cmmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/_Cmmodule.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** _Cmmodule.c 29 Nov 2002 23:40:42 -0000 1.11
--- _Cmmodule.c 3 Dec 2002 23:40:19 -0000 1.12
***************
*** 308,311 ****
--- 308,312 ----
#define CmpInstObj_getsetlist NULL
+
#define CmpInstObj_compare NULL
***************
*** 313,316 ****
--- 314,335 ----
#define CmpInstObj_hash NULL
+ #define CmpInstObj_tp_init 0
+
+ #define CmpInstObj_tp_alloc PyType_GenericAlloc
+
+ static PyObject *CmpInstObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ PyObject *self;
+ ComponentInstance itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CmpInstObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((ComponentInstanceObject *)self)->ob_itself = itself;
+ return self;
+ }
+
+ #define CmpInstObj_tp_free PyObject_Del
+
PyTypeObject ComponentInstance_Type = {
***************
*** 335,351 ****
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*/
CmpInstObj_methods, /* tp_methods */
! 0, /*outputHook_tp_members*/
CmpInstObj_getsetlist, /*tp_getset*/
! 0, /*outputHook_tp_base*/
};
--- 354,378 ----
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*/
CmpInstObj_methods, /* tp_methods */
! 0, /*tp_members*/
CmpInstObj_getsetlist, /*tp_getset*/
! 0, /*tp_base*/
! 0, /*tp_dict*/
! 0, /*tp_descr_get*/
! 0, /*tp_descr_set*/
! 0, /*tp_dictoffset*/
! CmpInstObj_tp_init, /* tp_init */
! CmpInstObj_tp_alloc, /* tp_alloc */
! CmpInstObj_tp_new, /* tp_new */
! CmpInstObj_tp_free, /* tp_free */
};
***************
*** 714,717 ****
--- 741,745 ----
#define CmpObj_getsetlist NULL
+
#define CmpObj_compare NULL
***************
*** 719,722 ****
--- 747,768 ----
#define CmpObj_hash NULL
+ #define CmpObj_tp_init 0
+
+ #define CmpObj_tp_alloc PyType_GenericAlloc
+
+ static PyObject *CmpObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+ {
+ PyObject *self;
+ Component itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, CmpObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((ComponentObject *)self)->ob_itself = itself;
+ return self;
+ }
+
+ #define CmpObj_tp_free PyObject_Del
+
PyTypeObject Component_Type = {
***************
*** 741,757 ****
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*/
CmpObj_methods, /* tp_methods */
! 0, /*outputHook_tp_members*/
CmpObj_getsetlist, /*tp_getset*/
! 0, /*outputHook_tp_base*/
};
--- 787,811 ----
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*/
CmpObj_methods, /* tp_methods */
! 0, /*tp_members*/
CmpObj_getsetlist, /*tp_getset*/
! 0, /*tp_base*/
! 0, /*tp_dict*/
! 0, /*tp_descr_get*/
! 0, /*tp_descr_set*/
! 0, /*tp_dictoffset*/
! CmpObj_tp_init, /* tp_init */
! CmpObj_tp_alloc, /* tp_alloc */
! CmpObj_tp_new, /* tp_new */
! CmpObj_tp_free, /* tp_free */
};
***************
*** 931,940 ****
ComponentInstance_Type.ob_type = &PyType_Type;
Py_INCREF(&ComponentInstance_Type);
! if (PyDict_SetItemString(d, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type) != 0)
! Py_FatalError("can't initialize ComponentInstanceType");
Component_Type.ob_type = &PyType_Type;
Py_INCREF(&Component_Type);
! if (PyDict_SetItemString(d, "ComponentType", (PyObject *)&Component_Type) != 0)
! Py_FatalError("can't initialize ComponentType");
}
--- 985,998 ----
ComponentInstance_Type.ob_type = &PyType_Type;
Py_INCREF(&ComponentInstance_Type);
! PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type);
! /* Backward-compatible name */
! Py_INCREF(&ComponentInstance_Type);
! PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type);
Component_Type.ob_type = &PyType_Type;
Py_INCREF(&Component_Type);
! PyModule_AddObject(m, "Component", (PyObject *)&Component_Type);
! /* Backward-compatible name */
! Py_INCREF(&Component_Type);
! PyModule_AddObject(m, "ComponentType", (PyObject *)&Component_Type);
}
Index: cmsupport.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Mac/Modules/cm/cmsupport.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** cmsupport.py 29 Nov 2002 23:40:42 -0000 1.7
--- cmsupport.py 3 Dec 2002 23:40:19 -0000 1.8
***************
*** 80,84 ****
ComponentResourceHandle = OpaqueByValueType("ComponentResourceHandle", "ResObj")
! class MyCIObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
--- 80,84 ----
ComponentResourceHandle = OpaqueByValueType("ComponentResourceHandle", "ResObj")
! class MyCIObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
***************
*** 87,91 ****
}""")
! class MyCObjectDefinition(PEP252Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {
--- 87,91 ----
}""")
! class MyCObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
def outputCheckNewArg(self):
Output("""if (itself == NULL) {