Browse Source

[1484] some trivial (and unrelated for some) cleanups:
- indentation
- constify
- eleiminating unnecessary reinterpret_cast

JINMEI Tatuya 13 years ago
parent
commit
3e851b72d4

+ 7 - 7
src/lib/python/isc/datasrc/finder_python.cc

@@ -102,9 +102,8 @@ PyObject* ZoneFinder_helper_all(ZoneFinder* finder, PyObject* args) {
         return (NULL);
         return (NULL);
     }
     }
     PyObject* name;
     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 {
         try {
             ZoneFinder::FindOptions options =
             ZoneFinder::FindOptions options =
                 static_cast<ZoneFinder::FindOptions>(options_int);
                 static_cast<ZoneFinder::FindOptions>(options_int);
@@ -171,7 +170,7 @@ typedef CPPPyObjectContainer<s_ZoneFinder, ZoneFinder> ZoneFinderContainer;
 
 
 // General creation and destruction
 // General creation and destruction
 int
 int
-ZoneFinder_init(s_ZoneFinder* self, PyObject* args) {
+ZoneFinder_init(PyObject*, PyObject*, PyObject*) {
     // can't be called directly
     // can't be called directly
     PyErr_SetString(PyExc_TypeError,
     PyErr_SetString(PyExc_TypeError,
                     "ZoneFinder cannot be constructed directly");
                     "ZoneFinder cannot be constructed directly");
@@ -180,7 +179,8 @@ ZoneFinder_init(s_ZoneFinder* self, PyObject* args) {
 }
 }
 
 
 void
 void
-ZoneFinder_destroy(s_ZoneFinder* const self) {
+ZoneFinder_destroy(PyObject* po_self) {
+    s_ZoneFinder* self = static_cast<s_ZoneFinder*>(po_self);
     // cppobj is a shared ptr, but to make sure things are not destroyed in
     // cppobj is a shared ptr, but to make sure things are not destroyed in
     // the wrong order, we reset it here.
     // the wrong order, we reset it here.
     self->cppobj.reset();
     self->cppobj.reset();
@@ -282,7 +282,7 @@ PyTypeObject zonefinder_type = {
     "datasrc.ZoneFinder",
     "datasrc.ZoneFinder",
     sizeof(s_ZoneFinder),               // tp_basicsize
     sizeof(s_ZoneFinder),               // tp_basicsize
     0,                                  // tp_itemsize
     0,                                  // tp_itemsize
-    reinterpret_cast<destructor>(ZoneFinder_destroy),// tp_dealloc
+    ZoneFinder_destroy,                 // tp_dealloc
     NULL,                               // tp_print
     NULL,                               // tp_print
     NULL,                               // tp_getattr
     NULL,                               // tp_getattr
     NULL,                               // tp_setattr
     NULL,                               // tp_setattr
@@ -313,7 +313,7 @@ PyTypeObject zonefinder_type = {
     NULL,                               // tp_descr_get
     NULL,                               // tp_descr_get
     NULL,                               // tp_descr_set
     NULL,                               // tp_descr_set
     0,                                  // tp_dictoffset
     0,                                  // tp_dictoffset
-    reinterpret_cast<initproc>(ZoneFinder_init),// tp_init
+    ZoneFinder_init,                    // tp_init
     NULL,                               // tp_alloc
     NULL,                               // tp_alloc
     PyType_GenericNew,                  // tp_new
     PyType_GenericNew,                  // tp_new
     NULL,                               // tp_free
     NULL,                               // tp_free

+ 12 - 12
src/lib/python/isc/datasrc/updater_python.cc

@@ -75,7 +75,7 @@ typedef CPPPyObjectContainer<s_ZoneUpdater, ZoneUpdater> ZoneUpdaterContainer;
 
 
 // General creation and destruction
 // General creation and destruction
 int
 int
-ZoneUpdater_init(s_ZoneUpdater* self, PyObject* args) {
+ZoneUpdater_init(PyObject*, PyObject*, PyObject*) {
     // can't be called directly
     // can't be called directly
     PyErr_SetString(PyExc_TypeError,
     PyErr_SetString(PyExc_TypeError,
                     "ZoneUpdater cannot be constructed directly");
                     "ZoneUpdater cannot be constructed directly");
@@ -84,7 +84,9 @@ ZoneUpdater_init(s_ZoneUpdater* self, PyObject* args) {
 }
 }
 
 
 void
 void
-ZoneUpdater_destroy(s_ZoneUpdater* const self) {
+ZoneUpdater_destroy(PyObject* po_self) {
+    s_ZoneUpdater* const self = static_cast<s_ZoneUpdater*>(po_self);
+
     // cppobj is a shared ptr, but to make sure things are not destroyed in
     // cppobj is a shared ptr, but to make sure things are not destroyed in
     // the wrong order, we reset it here.
     // the wrong order, we reset it here.
     self->cppobj.reset();
     self->cppobj.reset();
@@ -200,22 +202,20 @@ ZoneUpdater_find_all(PyObject* po_self, PyObject* args) {
 // 3. Argument type
 // 3. Argument type
 // 4. Documentation
 // 4. Documentation
 PyMethodDef ZoneUpdater_methods[] = {
 PyMethodDef ZoneUpdater_methods[] = {
-    { "add_rrset", reinterpret_cast<PyCFunction>(ZoneUpdater_addRRset),
+    { "add_rrset", ZoneUpdater_addRRset,
       METH_VARARGS, ZoneUpdater_addRRset_doc },
       METH_VARARGS, ZoneUpdater_addRRset_doc },
-    { "delete_rrset", reinterpret_cast<PyCFunction>(ZoneUpdater_deleteRRset),
+    { "delete_rrset", ZoneUpdater_deleteRRset,
       METH_VARARGS, ZoneUpdater_deleteRRset_doc },
       METH_VARARGS, ZoneUpdater_deleteRRset_doc },
-    { "commit", reinterpret_cast<PyCFunction>(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
     // Instead of a getFinder, we implement the finder functionality directly
     // This is because ZoneFinder is non-copyable, and we should not create
     // This is because ZoneFinder is non-copyable, and we should not create
     // a ZoneFinder object from a reference only (which is what is returned
     // a ZoneFinder object from a reference only (which is what is returned
     // by getFinder(). Apart from that
     // by getFinder(). Apart from that
-    { "get_origin", reinterpret_cast<PyCFunction>(ZoneUpdater_getOrigin),
+    { "get_origin", ZoneUpdater_getOrigin,
       METH_NOARGS, ZoneFinder_getOrigin_doc },
       METH_NOARGS, ZoneFinder_getOrigin_doc },
-    { "get_class", reinterpret_cast<PyCFunction>(ZoneUpdater_getClass),
+    { "get_class", ZoneUpdater_getClass,
       METH_NOARGS, ZoneFinder_getClass_doc },
       METH_NOARGS, ZoneFinder_getClass_doc },
-    { "find", reinterpret_cast<PyCFunction>(ZoneUpdater_find), METH_VARARGS,
-      ZoneFinder_find_doc },
+    { "find", ZoneUpdater_find, METH_VARARGS, ZoneFinder_find_doc },
     { "find_all", ZoneUpdater_find_all, METH_VARARGS,
     { "find_all", ZoneUpdater_find_all, METH_VARARGS,
       ZoneFinder_find_all_doc },
       ZoneFinder_find_all_doc },
     { NULL, NULL, 0, NULL }
     { NULL, NULL, 0, NULL }
@@ -231,7 +231,7 @@ PyTypeObject zoneupdater_type = {
     "datasrc.ZoneUpdater",
     "datasrc.ZoneUpdater",
     sizeof(s_ZoneUpdater),              // tp_basicsize
     sizeof(s_ZoneUpdater),              // tp_basicsize
     0,                                  // tp_itemsize
     0,                                  // tp_itemsize
-    reinterpret_cast<destructor>(ZoneUpdater_destroy),// tp_dealloc
+    ZoneUpdater_destroy,                // tp_dealloc
     NULL,                               // tp_print
     NULL,                               // tp_print
     NULL,                               // tp_getattr
     NULL,                               // tp_getattr
     NULL,                               // tp_setattr
     NULL,                               // tp_setattr
@@ -262,7 +262,7 @@ PyTypeObject zoneupdater_type = {
     NULL,                               // tp_descr_get
     NULL,                               // tp_descr_get
     NULL,                               // tp_descr_set
     NULL,                               // tp_descr_set
     0,                                  // tp_dictoffset
     0,                                  // tp_dictoffset
-    reinterpret_cast<initproc>(ZoneUpdater_init),// tp_init
+    ZoneUpdater_init,                   // tp_init
     NULL,                               // tp_alloc
     NULL,                               // tp_alloc
     PyType_GenericNew,                  // tp_new
     PyType_GenericNew,                  // tp_new
     NULL,                               // tp_free
     NULL,                               // tp_free