diff options
Diffstat (limited to 'Mac/Modules/qdoffs/_Qdoffsmodule.c')
-rw-r--r-- | Mac/Modules/qdoffs/_Qdoffsmodule.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/Mac/Modules/qdoffs/_Qdoffsmodule.c b/Mac/Modules/qdoffs/_Qdoffsmodule.c index 9804b71..3f5dd04 100644 --- a/Mac/Modules/qdoffs/_Qdoffsmodule.c +++ b/Mac/Modules/qdoffs/_Qdoffsmodule.c @@ -133,11 +133,30 @@ static PyMethodDef GWorldObj_methods[] = { #define GWorldObj_getsetlist NULL + #define GWorldObj_compare NULL #define GWorldObj_repr NULL #define GWorldObj_hash NULL +#define GWorldObj_tp_init 0 + +#define GWorldObj_tp_alloc PyType_GenericAlloc + +static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyObject *self; + GWorldPtr itself; + char *kw[] = {"itself", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kw, GWorldObj_Convert, &itself)) return NULL; + if ((self = type->tp_alloc(type, 0)) == NULL) return NULL; + ((GWorldObject *)self)->ob_itself = itself; + return self; +} + +#define GWorldObj_tp_free PyObject_Del + PyTypeObject GWorld_Type = { PyObject_HEAD_INIT(NULL) @@ -160,19 +179,27 @@ PyTypeObject GWorld_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*/ GWorldObj_methods, /* tp_methods */ - 0, /*outputHook_tp_members*/ + 0, /*tp_members*/ GWorldObj_getsetlist, /*tp_getset*/ - 0, /*outputHook_tp_base*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + GWorldObj_tp_init, /* tp_init */ + GWorldObj_tp_alloc, /* tp_alloc */ + GWorldObj_tp_new, /* tp_new */ + GWorldObj_tp_free, /* tp_free */ }; /* --------------------- End object type GWorld --------------------- */ @@ -684,8 +711,10 @@ void init_Qdoffs(void) return; GWorld_Type.ob_type = &PyType_Type; Py_INCREF(&GWorld_Type); - if (PyDict_SetItemString(d, "GWorldType", (PyObject *)&GWorld_Type) != 0) - Py_FatalError("can't initialize GWorldType"); + PyModule_AddObject(m, "GWorld", (PyObject *)&GWorld_Type); + /* Backward-compatible name */ + Py_INCREF(&GWorld_Type); + PyModule_AddObject(m, "GWorldType", (PyObject *)&GWorld_Type); } /* ======================= End module _Qdoffs ======================= */ |