diff options
Diffstat (limited to 'Mac/Modules/mlte')
-rw-r--r-- | Mac/Modules/mlte/_Mltemodule.c | 110 | ||||
-rw-r--r-- | Mac/Modules/mlte/mltesupport.py | 4 |
2 files changed, 86 insertions, 28 deletions
diff --git a/Mac/Modules/mlte/_Mltemodule.c b/Mac/Modules/mlte/_Mltemodule.c index 84b6130..83bbbf8 100644 --- a/Mac/Modules/mlte/_Mltemodule.c +++ b/Mac/Modules/mlte/_Mltemodule.c @@ -1297,11 +1297,30 @@ static PyMethodDef TXNObj_methods[] = { #define TXNObj_getsetlist NULL + #define TXNObj_compare NULL #define TXNObj_repr NULL #define TXNObj_hash NULL +#define TXNObj_tp_init 0 + +#define TXNObj_tp_alloc PyType_GenericAlloc + +static PyObject *TXNObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + TXNObject itself; + char *kw[] = {"itself", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TXNObj_Convert, &itself)) return NULL; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TXNObjectObject *)self)->ob_itself = itself; + return self; +} + +#define TXNObj_tp_free PyObject_Del + PyTypeObject TXNObject_Type = { PyObject_HEAD_INIT(NULL) @@ -1324,19 +1343,27 @@ PyTypeObject TXNObject_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*/ TXNObj_methods, /* tp_methods */ - 0, /*outputHook_tp_members*/ + 0, /*tp_members*/ TXNObj_getsetlist, /*tp_getset*/ - 0, /*outputHook_tp_base*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + TXNObj_tp_init, /* tp_init */ + TXNObj_tp_alloc, /* tp_alloc */ + TXNObj_tp_new, /* tp_new */ + TXNObj_tp_free, /* tp_free */ }; /* ------------------- End object type TXNObject -------------------- */ @@ -1423,11 +1450,30 @@ static PyMethodDef TXNFontMenuObj_methods[] = { #define TXNFontMenuObj_getsetlist NULL + #define TXNFontMenuObj_compare NULL #define TXNFontMenuObj_repr NULL #define TXNFontMenuObj_hash NULL +#define TXNFontMenuObj_tp_init 0 + +#define TXNFontMenuObj_tp_alloc PyType_GenericAlloc + +static PyObject *TXNFontMenuObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + TXNFontMenuObject itself; + char *kw[] = {"itself", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, TXNFontMenuObj_Convert, &itself)) return NULL; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((TXNFontMenuObjectObject *)self)->ob_itself = itself; + return self; +} + +#define TXNFontMenuObj_tp_free PyObject_Del + PyTypeObject TXNFontMenuObject_Type = { PyObject_HEAD_INIT(NULL) @@ -1450,19 +1496,27 @@ PyTypeObject TXNFontMenuObject_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*/ TXNFontMenuObj_methods, /* tp_methods */ - 0, /*outputHook_tp_members*/ + 0, /*tp_members*/ TXNFontMenuObj_getsetlist, /*tp_getset*/ - 0, /*outputHook_tp_base*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + TXNFontMenuObj_tp_init, /* tp_init */ + TXNFontMenuObj_tp_alloc, /* tp_alloc */ + TXNFontMenuObj_tp_new, /* tp_new */ + TXNFontMenuObj_tp_free, /* tp_free */ }; /* --------------- End object type TXNFontMenuObject ---------------- */ @@ -1676,12 +1730,16 @@ void init_Mlte(void) return; TXNObject_Type.ob_type = &PyType_Type; Py_INCREF(&TXNObject_Type); - if (PyDict_SetItemString(d, "TXNObjectType", (PyObject *)&TXNObject_Type) != 0) - Py_FatalError("can't initialize TXNObjectType"); + PyModule_AddObject(m, "TXNObject", (PyObject *)&TXNObject_Type); + /* Backward-compatible name */ + Py_INCREF(&TXNObject_Type); + PyModule_AddObject(m, "TXNObjectType", (PyObject *)&TXNObject_Type); TXNFontMenuObject_Type.ob_type = &PyType_Type; Py_INCREF(&TXNFontMenuObject_Type); - if (PyDict_SetItemString(d, "TXNFontMenuObjectType", (PyObject *)&TXNFontMenuObject_Type) != 0) - Py_FatalError("can't initialize TXNFontMenuObjectType"); + PyModule_AddObject(m, "TXNFontMenuObject", (PyObject *)&TXNFontMenuObject_Type); + /* Backward-compatible name */ + Py_INCREF(&TXNFontMenuObject_Type); + PyModule_AddObject(m, "TXNFontMenuObjectType", (PyObject *)&TXNFontMenuObject_Type); } /* ======================== End module _Mlte ======================== */ diff --git a/Mac/Modules/mlte/mltesupport.py b/Mac/Modules/mlte/mltesupport.py index e9df43f..fe34fc7 100644 --- a/Mac/Modules/mlte/mltesupport.py +++ b/Mac/Modules/mlte/mltesupport.py @@ -136,11 +136,11 @@ execfile("mltetypetest.py") # Our (opaque) objects -class TXNObjDefinition(PEP252Mixin, GlobalObjectDefinition): +class TXNObjDefinition(PEP253Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") -class TXNFontMenuObjDefinition(PEP252Mixin, GlobalObjectDefinition): +class TXNFontMenuObjDefinition(PEP253Mixin, GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") |