From: JINMEI Tatuya Date: Tue, 20 Dec 2011 22:37:02 +0000 (-0800) Subject: [1484] some trivial (and unrelated for some) cleanups: X-Git-Tag: trac2351_base~299^2~17^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e851b72d4869bd4e7ede881aac0470da39aef3a;p=thirdparty%2Fkea.git [1484] some trivial (and unrelated for some) cleanups: - indentation - constify - eleiminating unnecessary reinterpret_cast --- diff --git a/src/lib/python/isc/datasrc/finder_python.cc b/src/lib/python/isc/datasrc/finder_python.cc index e65e6deb02..19868f5a93 100644 --- a/src/lib/python/isc/datasrc/finder_python.cc +++ b/src/lib/python/isc/datasrc/finder_python.cc @@ -102,9 +102,8 @@ PyObject* ZoneFinder_helper_all(ZoneFinder* finder, PyObject* args) { return (NULL); } PyObject* name; - unsigned int options_int = ZoneFinder::FIND_DEFAULT; - if (PyArg_ParseTuple(args, "O!|I", &name_type, &name, - &options_int)) { + const unsigned int options_int = ZoneFinder::FIND_DEFAULT; + if (PyArg_ParseTuple(args, "O!|I", &name_type, &name, &options_int)) { try { ZoneFinder::FindOptions options = static_cast(options_int); @@ -171,7 +170,7 @@ typedef CPPPyObjectContainer ZoneFinderContainer; // General creation and destruction int -ZoneFinder_init(s_ZoneFinder* self, PyObject* args) { +ZoneFinder_init(PyObject*, PyObject*, PyObject*) { // can't be called directly PyErr_SetString(PyExc_TypeError, "ZoneFinder cannot be constructed directly"); @@ -180,7 +179,8 @@ ZoneFinder_init(s_ZoneFinder* self, PyObject* args) { } void -ZoneFinder_destroy(s_ZoneFinder* const self) { +ZoneFinder_destroy(PyObject* po_self) { + s_ZoneFinder* self = static_cast(po_self); // cppobj is a shared ptr, but to make sure things are not destroyed in // the wrong order, we reset it here. self->cppobj.reset(); @@ -282,7 +282,7 @@ PyTypeObject zonefinder_type = { "datasrc.ZoneFinder", sizeof(s_ZoneFinder), // tp_basicsize 0, // tp_itemsize - reinterpret_cast(ZoneFinder_destroy),// tp_dealloc + ZoneFinder_destroy, // tp_dealloc NULL, // tp_print NULL, // tp_getattr NULL, // tp_setattr @@ -313,7 +313,7 @@ PyTypeObject zonefinder_type = { NULL, // tp_descr_get NULL, // tp_descr_set 0, // tp_dictoffset - reinterpret_cast(ZoneFinder_init),// tp_init + ZoneFinder_init, // tp_init NULL, // tp_alloc PyType_GenericNew, // tp_new NULL, // tp_free diff --git a/src/lib/python/isc/datasrc/updater_python.cc b/src/lib/python/isc/datasrc/updater_python.cc index 00b8940a25..c528a0c16a 100644 --- a/src/lib/python/isc/datasrc/updater_python.cc +++ b/src/lib/python/isc/datasrc/updater_python.cc @@ -75,7 +75,7 @@ typedef CPPPyObjectContainer ZoneUpdaterContainer; // General creation and destruction int -ZoneUpdater_init(s_ZoneUpdater* self, PyObject* args) { +ZoneUpdater_init(PyObject*, PyObject*, PyObject*) { // can't be called directly PyErr_SetString(PyExc_TypeError, "ZoneUpdater cannot be constructed directly"); @@ -84,7 +84,9 @@ ZoneUpdater_init(s_ZoneUpdater* self, PyObject* args) { } void -ZoneUpdater_destroy(s_ZoneUpdater* const self) { +ZoneUpdater_destroy(PyObject* po_self) { + s_ZoneUpdater* const self = static_cast(po_self); + // cppobj is a shared ptr, but to make sure things are not destroyed in // the wrong order, we reset it here. self->cppobj.reset(); @@ -200,22 +202,20 @@ ZoneUpdater_find_all(PyObject* po_self, PyObject* args) { // 3. Argument type // 4. Documentation PyMethodDef ZoneUpdater_methods[] = { - { "add_rrset", reinterpret_cast(ZoneUpdater_addRRset), + { "add_rrset", ZoneUpdater_addRRset, METH_VARARGS, ZoneUpdater_addRRset_doc }, - { "delete_rrset", reinterpret_cast(ZoneUpdater_deleteRRset), + { "delete_rrset", ZoneUpdater_deleteRRset, METH_VARARGS, ZoneUpdater_deleteRRset_doc }, - { "commit", reinterpret_cast(ZoneUpdater_commit), METH_NOARGS, - ZoneUpdater_commit_doc }, + { "commit", ZoneUpdater_commit, METH_NOARGS, ZoneUpdater_commit_doc }, // Instead of a getFinder, we implement the finder functionality directly // This is because ZoneFinder is non-copyable, and we should not create // a ZoneFinder object from a reference only (which is what is returned // by getFinder(). Apart from that - { "get_origin", reinterpret_cast(ZoneUpdater_getOrigin), + { "get_origin", ZoneUpdater_getOrigin, METH_NOARGS, ZoneFinder_getOrigin_doc }, - { "get_class", reinterpret_cast(ZoneUpdater_getClass), + { "get_class", ZoneUpdater_getClass, METH_NOARGS, ZoneFinder_getClass_doc }, - { "find", reinterpret_cast(ZoneUpdater_find), METH_VARARGS, - ZoneFinder_find_doc }, + { "find", ZoneUpdater_find, METH_VARARGS, ZoneFinder_find_doc }, { "find_all", ZoneUpdater_find_all, METH_VARARGS, ZoneFinder_find_all_doc }, { NULL, NULL, 0, NULL } @@ -231,7 +231,7 @@ PyTypeObject zoneupdater_type = { "datasrc.ZoneUpdater", sizeof(s_ZoneUpdater), // tp_basicsize 0, // tp_itemsize - reinterpret_cast(ZoneUpdater_destroy),// tp_dealloc + ZoneUpdater_destroy, // tp_dealloc NULL, // tp_print NULL, // tp_getattr NULL, // tp_setattr @@ -262,7 +262,7 @@ PyTypeObject zoneupdater_type = { NULL, // tp_descr_get NULL, // tp_descr_set 0, // tp_dictoffset - reinterpret_cast(ZoneUpdater_init),// tp_init + ZoneUpdater_init, // tp_init NULL, // tp_alloc PyType_GenericNew, // tp_new NULL, // tp_free