summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/ibcarbon
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-12-03 23:40:22 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-12-03 23:40:22 (GMT)
commit96cebde909bbb8034af576d8f31f465bbad90374 (patch)
tree305f0e665ac5676a19485cf662920a7db5c19eee /Mac/Modules/ibcarbon
parent99899b92b86ee69f0b46b708a465f445059dc793 (diff)
downloadcpython-96cebde909bbb8034af576d8f31f465bbad90374.zip
cpython-96cebde909bbb8034af576d8f31f465bbad90374.tar.gz
cpython-96cebde909bbb8034af576d8f31f465bbad90374.tar.bz2
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).
Diffstat (limited to 'Mac/Modules/ibcarbon')
-rw-r--r--Mac/Modules/ibcarbon/IBCarbonsupport.py4
-rw-r--r--Mac/Modules/ibcarbon/_IBCarbon.c55
2 files changed, 44 insertions, 15 deletions
diff --git a/Mac/Modules/ibcarbon/IBCarbonsupport.py b/Mac/Modules/ibcarbon/IBCarbonsupport.py
index f948c53..25406c7 100644
--- a/Mac/Modules/ibcarbon/IBCarbonsupport.py
+++ b/Mac/Modules/ibcarbon/IBCarbonsupport.py
@@ -31,11 +31,11 @@ initstuff = """
module = MacModule('_IBCarbon', 'IBCarbon', includestuff, finalstuff, initstuff)
-class CFReleaserObject(PEP252Mixin, GlobalObjectDefinition):
+class CFReleaserObject(PEP253Mixin, GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("CFRelease(%s);" % name)
-class CFNibDesc(PEP252Mixin, GlobalObjectDefinition):
+class CFNibDesc(PEP253Mixin, GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("DisposeNibReference(%s);" % name)
diff --git a/Mac/Modules/ibcarbon/_IBCarbon.c b/Mac/Modules/ibcarbon/_IBCarbon.c
index eb9b4c9..02c50fe 100644
--- a/Mac/Modules/ibcarbon/_IBCarbon.c
+++ b/Mac/Modules/ibcarbon/_IBCarbon.c
@@ -142,11 +142,30 @@ static PyMethodDef IBNibRefObj_methods[] = {
#define IBNibRefObj_getsetlist NULL
+
#define IBNibRefObj_compare NULL
#define IBNibRefObj_repr NULL
#define IBNibRefObj_hash NULL
+#define IBNibRefObj_tp_init 0
+
+#define IBNibRefObj_tp_alloc PyType_GenericAlloc
+
+static PyObject *IBNibRefObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ PyObject *self;
+ IBNibRef itself;
+ char *kw[] = {"itself", 0};
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, IBNibRefObj_Convert, &itself)) return NULL;
+ if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;
+ ((IBNibRefObject *)self)->ob_itself = itself;
+ return self;
+}
+
+#define IBNibRefObj_tp_free PyObject_Del
+
PyTypeObject IBNibRef_Type = {
PyObject_HEAD_INIT(NULL)
@@ -169,19 +188,27 @@ PyTypeObject IBNibRef_Type = {
0, /*tp_str*/
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*/
+ 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*/
IBNibRefObj_methods, /* tp_methods */
- 0, /*outputHook_tp_members*/
+ 0, /*tp_members*/
IBNibRefObj_getsetlist, /*tp_getset*/
- 0, /*outputHook_tp_base*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ IBNibRefObj_tp_init, /* tp_init */
+ IBNibRefObj_tp_alloc, /* tp_alloc */
+ IBNibRefObj_tp_new, /* tp_new */
+ IBNibRefObj_tp_free, /* tp_free */
};
/* -------------------- End object type IBNibRef -------------------- */
@@ -230,8 +257,10 @@ void init_IBCarbon(void)
return;
IBNibRef_Type.ob_type = &PyType_Type;
Py_INCREF(&IBNibRef_Type);
- if (PyDict_SetItemString(d, "IBNibRefType", (PyObject *)&IBNibRef_Type) != 0)
- Py_FatalError("can't initialize IBNibRefType");
+ PyModule_AddObject(m, "IBNibRef", (PyObject *)&IBNibRef_Type);
+ /* Backward-compatible name */
+ Py_INCREF(&IBNibRef_Type);
+ PyModule_AddObject(m, "IBNibRefType", (PyObject *)&IBNibRef_Type);
}
/* ====================== End module _IBCarbon ====================== */