From 1ff83a2ccb7301c8f675913f1c4f6118ea50b9c7 Mon Sep 17 00:00:00 2001 From: "John (J5) Palmieri" Date: Mon, 16 Aug 2010 21:14:27 -0400 Subject: convert to using PYGLIB_DEFINE_TYPE for module objects https://bugzilla.gnome.org/show_bug.cgi?id=615872 --- gi/pygi-boxed.c | 43 ++++++------------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) (limited to 'gi/pygi-boxed.c') diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index 5edd25ee..2fd446c5 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -45,7 +45,7 @@ _boxed_dealloc (PyGIBoxed *self) } } - ( (PyGObject *) self)->ob_type->tp_free ( (PyObject *) self); + Py_TYPE( (PyGObject *) self)->tp_free ( (PyObject *) self); } void * @@ -133,41 +133,7 @@ _boxed_init (PyObject *self, return 0; } - -PyTypeObject PyGIBoxed_Type = { - PyObject_HEAD_INIT (NULL) - 0, - "gi.Boxed", /* tp_name */ - sizeof (PyGIBoxed), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor) _boxed_dealloc, /* tp_dealloc */ - (printfunc) NULL, /* tp_print */ - (getattrfunc) NULL, /* tp_getattr */ - (setattrfunc) NULL, /* tp_setattr */ - (cmpfunc) NULL, /* tp_compare */ - (reprfunc) NULL, /* tp_repr */ - NULL, /* tp_as_number */ - NULL, /* tp_as_sequence */ - NULL, /* tp_as_mapping */ - (hashfunc) NULL, /* tp_hash */ - (ternaryfunc) NULL, /* tp_call */ - (reprfunc) NULL, /* tp_str */ - (getattrofunc) NULL, /* tp_getattro */ - (setattrofunc) NULL, /* tp_setattro */ - NULL, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - NULL, /* tp_doc */ - (traverseproc) NULL, /* tp_traverse */ - (inquiry) NULL, /* tp_clear */ - (richcmpfunc) NULL, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc) NULL, /* tp_iter */ - (iternextfunc) NULL, /* tp_iternext */ - NULL, /* tp_methods */ - NULL, /* tp_members */ - NULL, /* tp_getset */ - (PyTypeObject *) NULL, /* tp_base */ -}; +PYGLIB_DEFINE_TYPE("gi.Boxed", PyGIBoxed_Type, PyGIBoxed); PyObject * _pygi_boxed_new (PyTypeObject *type, @@ -202,10 +168,13 @@ _pygi_boxed_new (PyTypeObject *type, void _pygi_boxed_register_types (PyObject *m) { - PyGIBoxed_Type.ob_type = &PyType_Type; + Py_TYPE(&PyGIBoxed_Type) = &PyType_Type; PyGIBoxed_Type.tp_base = &PyGBoxed_Type; PyGIBoxed_Type.tp_new = (newfunc) _boxed_new; PyGIBoxed_Type.tp_init = (initproc) _boxed_init; + PyGIBoxed_Type.tp_dealloc = (destructor) _boxed_dealloc; + PyGIBoxed_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE); + if (PyType_Ready (&PyGIBoxed_Type)) return; if (PyModule_AddObject (m, "Boxed", (PyObject *) &PyGIBoxed_Type)) -- cgit v1.2.1