[svn] commit: r2239 - in /experiments/python-binding/src/lib/dns/python: message_python.cc messagerenderer_python.cc name_python.cc question_python.cc rdata_python.cc rrclass_python.cc rrset_python.cc rrttl_python.cc rrtype_python.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Jun 23 11:28:49 UTC 2010


Author: jelte
Date: Wed Jun 23 11:28:49 2010
New Revision: 2239

Log:
changed our type-specific structs to classes derived from PyObject, so we can use static_cast instead of interpret_cast

Modified:
    experiments/python-binding/src/lib/dns/python/message_python.cc
    experiments/python-binding/src/lib/dns/python/messagerenderer_python.cc
    experiments/python-binding/src/lib/dns/python/name_python.cc
    experiments/python-binding/src/lib/dns/python/question_python.cc
    experiments/python-binding/src/lib/dns/python/rdata_python.cc
    experiments/python-binding/src/lib/dns/python/rrclass_python.cc
    experiments/python-binding/src/lib/dns/python/rrset_python.cc
    experiments/python-binding/src/lib/dns/python/rrttl_python.cc
    experiments/python-binding/src/lib/dns/python/rrtype_python.cc

Modified: experiments/python-binding/src/lib/dns/python/message_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/message_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/message_python.cc Wed Jun 23 11:28:49 2010
@@ -40,10 +40,10 @@
 //
 // MessageFlag
 //
-typedef struct {
-    PyObject_HEAD
+class s_MessageFlag : public PyObject {
+public:
     const MessageFlag* messageflag;
-} s_MessageFlag;
+};
 
 static int MessageFlag_init(s_MessageFlag* self, PyObject* args);
 static void MessageFlag_destroy(s_MessageFlag* self);
@@ -156,7 +156,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -169,7 +169,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -182,7 +182,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -195,7 +195,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -208,7 +208,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -221,7 +221,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -234,7 +234,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 //
@@ -245,10 +245,10 @@
 //
 // Opcode
 //
-typedef struct {
-    PyObject_HEAD
+class s_Opcode : public PyObject {
+public:
     const Opcode* opcode;
-} s_Opcode;
+};
 
 static int Opcode_init(s_Opcode* self, PyObject* args);
 static void Opcode_destroy(s_Opcode* self);
@@ -394,7 +394,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -407,7 +407,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -420,7 +420,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -433,7 +433,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -446,7 +446,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -459,7 +459,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -472,7 +472,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -485,7 +485,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -498,7 +498,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -511,7 +511,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -524,7 +524,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -537,7 +537,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -550,7 +550,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -563,7 +563,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -576,7 +576,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -589,7 +589,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -599,7 +599,7 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!other ||
-        (reinterpret_cast<PyObject*>(self))->ob_type != (reinterpret_cast<PyObject*>(other))->ob_type
+        (static_cast<PyObject*>(self))->ob_type != (static_cast<PyObject*>(other))->ob_type
        ) {
         Py_RETURN_FALSE;
     }
@@ -650,11 +650,11 @@
 // case Rcode_destroy should not free it (the other option is to
 // allocate new Rcodes for every use of the static ones, but this
 // seems more efficient).
-typedef struct {
-    PyObject_HEAD
+class s_Rcode : public PyObject {
+public:
     const Rcode* rcode;
     bool static_code;
-} s_Rcode;
+};
 
 static int Rcode_init(s_Rcode* self, PyObject* args);
 static void Rcode_destroy(s_Rcode* self);
@@ -817,7 +817,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -831,7 +831,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -845,7 +845,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -859,7 +859,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -873,7 +873,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -887,7 +887,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -901,7 +901,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -915,7 +915,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -929,7 +929,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -943,7 +943,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -957,7 +957,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -971,7 +971,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -985,7 +985,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -999,7 +999,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1013,7 +1013,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1027,7 +1027,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1041,7 +1041,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -1051,7 +1051,7 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!other ||
-        (reinterpret_cast<PyObject*>(self))->ob_type != (reinterpret_cast<PyObject*>(other))->ob_type
+        (static_cast<PyObject*>(self))->ob_type != (static_cast<PyObject*>(other))->ob_type
        ) {
         Py_RETURN_FALSE;
     }
@@ -1098,10 +1098,10 @@
 
 // TODO: iterator?
 
-typedef struct {
-    PyObject_HEAD
+class s_Section : public PyObject {
+public:
     const Section* section;
-} s_Section;
+};
 
 static int Section_init(s_Section* self, PyObject* args);
 static void Section_destroy(s_Section* self);
@@ -1209,7 +1209,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1222,7 +1222,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1235,7 +1235,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1248,7 +1248,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -1258,7 +1258,7 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!other ||
-        (reinterpret_cast<PyObject*>(self))->ob_type != (reinterpret_cast<PyObject*>(other))->ob_type
+        (static_cast<PyObject*>(self))->ob_type != (static_cast<PyObject*>(other))->ob_type
        ) {
         Py_RETURN_FALSE;
     }
@@ -1305,10 +1305,10 @@
 //
 
 // The s_* Class simply coverst one instantiation of the object
-typedef struct {
-    PyObject_HEAD
+class s_Message : public PyObject {
+public:
     Message* message;
-} s_Message;
+};
 
 //
 // We declare the functions here, the definitions are below
@@ -1675,7 +1675,7 @@
 Message_getRcode(s_Message* self) {
     s_Rcode* rcode;
 
-    rcode = reinterpret_cast<s_Rcode*>(rcode_type.tp_alloc(&rcode_type, 0));
+    rcode = static_cast<s_Rcode*>(rcode_type.tp_alloc(&rcode_type, 0));
     if (rcode != NULL) {
         rcode->rcode = new Rcode(self->message->getRcode());
         if (rcode->rcode == NULL)
@@ -1685,7 +1685,7 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(rcode);
+    return static_cast<PyObject*>(rcode);
 }
 
 static PyObject*
@@ -1702,7 +1702,7 @@
 Message_getOpcode(s_Message* self) {
     s_Opcode* opcode;
 
-    opcode = reinterpret_cast<s_Opcode*>(opcode_type.tp_alloc(&opcode_type, 0));
+    opcode = static_cast<s_Opcode*>(opcode_type.tp_alloc(&opcode_type, 0));
     if (opcode != NULL) {
         // Note that we do not new and delete for opcodes.
         // all rcodes point to the statics defined in
@@ -1715,7 +1715,7 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(opcode);
+    return static_cast<PyObject*>(opcode);
 }
 
 static PyObject*
@@ -1745,7 +1745,7 @@
     for (QuestionIterator qi = self->message->beginQuestion();
          qi != self->message->endQuestion();
          ++qi) {
-        s_Question *question = reinterpret_cast<s_Question*>(question_type.tp_alloc(&question_type, 0));
+        s_Question *question = static_cast<s_Question*>(question_type.tp_alloc(&question_type, 0));
         if (question != NULL) {
             question->question = *qi;
             if (question->question == NULL)
@@ -1754,7 +1754,7 @@
                 return NULL;
               }
         }
-        PyList_Append(list, reinterpret_cast<PyObject*>(question));
+        PyList_Append(list, static_cast<PyObject*>(question));
     }
     return list;
 }
@@ -1771,7 +1771,7 @@
          rrsi != self->message->endSection(*section->section);
          ++rrsi) {
 
-        s_RRset *rrset = reinterpret_cast<s_RRset*>(rrset_type.tp_alloc(&rrset_type, 0));
+        s_RRset *rrset = static_cast<s_RRset*>(rrset_type.tp_alloc(&rrset_type, 0));
         if (rrset != NULL) {
             rrset->rrset = *rrsi;
             if (rrset->rrset == NULL)
@@ -1781,7 +1781,7 @@
                 return NULL;
               }
         }
-        PyList_Append(list, reinterpret_cast<PyObject*>(rrset));
+        PyList_Append(list, static_cast<PyObject*>(rrset));
         // PyList_Append increases refcount, so we remove ours since
         // we don't need it anymore
         Py_DECREF(rrset);

Modified: experiments/python-binding/src/lib/dns/python/messagerenderer_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/messagerenderer_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/messagerenderer_python.cc Wed Jun 23 11:28:49 2010
@@ -26,11 +26,11 @@
 // since we don't use *Buffer in the python version (but work with
 // the already existing bytearray type where we use these custom buffers
 // in c++, we need to keep track of one here.
-typedef struct {
-    PyObject_HEAD
+class s_MessageRenderer : public PyObject {
+public:
     OutputBuffer* outputbuffer;
     MessageRenderer* messagerenderer;
-} s_MessageRenderer;
+};
 
 static int MessageRenderer_init(s_MessageRenderer* self);
 static void MessageRenderer_destroy(s_MessageRenderer* self);

Modified: experiments/python-binding/src/lib/dns/python/name_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/name_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/name_python.cc Wed Jun 23 11:28:49 2010
@@ -49,10 +49,10 @@
 using namespace isc::dns;
 
 // NameComparisonResult
-typedef struct {
-    PyObject_HEAD
+class s_NameComparisonResult : public PyObject {
+public:
     isc::dns::NameComparisonResult* ncr;
-} s_NameComparisonResult;
+};
 
 static int NameComparisonResult_init(s_NameComparisonResult* self UNUSED_PARAM, PyObject* args UNUSED_PARAM);
 static void NameComparisonResult_destroy(s_NameComparisonResult* self);
@@ -164,11 +164,11 @@
 
 // Name
 
-typedef struct {
-    PyObject_HEAD
+class s_Name : public PyObject {
+public:
     isc::dns::Name* name;
     size_t position;
-} s_Name;
+};
 
 static int Name_init(s_Name* self, PyObject* args);
 static void Name_destroy(s_Name* self);
@@ -450,7 +450,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -502,7 +502,7 @@
             }
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 #include <iostream>
 
@@ -513,8 +513,8 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!n2 ||
-        (reinterpret_cast<PyObject*>(n1))->ob_type !=
-        (reinterpret_cast<PyObject*>(n2))->ob_type
+        (static_cast<PyObject*>(n1))->ob_type !=
+        (static_cast<PyObject*>(n2))->ob_type
        ) {
         Py_RETURN_FALSE;
     }
@@ -559,7 +559,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -582,14 +582,14 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
 Name_downcase(s_Name* self) {
     self->name->downcase();
     Py_INCREF(self);
-    return reinterpret_cast<PyObject*>(self);
+    return static_cast<PyObject*>(self);
 }
 
 static PyObject*
@@ -642,7 +642,7 @@
 
     s_Name* root_name = PyObject_New(s_Name, &name_type);
     root_name->name = new Name(".");
-    PyObject* po_ROOT_NAME = reinterpret_cast<PyObject*>(root_name);
+    PyObject* po_ROOT_NAME = static_cast<PyObject*>(root_name);
     Py_INCREF(po_ROOT_NAME);
     addClassVariable(name_type, "ROOT_NAME", po_ROOT_NAME);
 

Modified: experiments/python-binding/src/lib/dns/python/question_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/question_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/question_python.cc Wed Jun 23 11:28:49 2010
@@ -22,10 +22,10 @@
 //
 
 // The s_* Class simply coverst one instantiation of the object
-typedef struct {
-    PyObject_HEAD
+class s_Question : public PyObject {
+public:
     QuestionPtr question;
-} s_Question;
+};
 
 //
 // We declare the functions here, the definitions are below
@@ -192,7 +192,7 @@
     s_Name* name;
 
     // is this the best way to do this?
-    name = reinterpret_cast<s_Name*>(name_type.tp_alloc(&name_type, 0));
+    name = static_cast<s_Name*>(name_type.tp_alloc(&name_type, 0));
     if (name != NULL) {
         name->name = new Name(self->question->getName());
         if (name->name == NULL)
@@ -202,14 +202,14 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(name);
+    return static_cast<PyObject*>(name);
 }
 
 static PyObject*
 Question_getType(s_Question* self) {
     s_RRType* rrtype;
 
-    rrtype = reinterpret_cast<s_RRType*>(rrtype_type.tp_alloc(&rrtype_type, 0));
+    rrtype = static_cast<s_RRType*>(rrtype_type.tp_alloc(&rrtype_type, 0));
     if (rrtype != NULL) {
         rrtype->rrtype = new RRType(self->question->getType());
         if (rrtype->rrtype == NULL)
@@ -219,14 +219,14 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrtype);
+    return static_cast<PyObject*>(rrtype);
 }
 
 static PyObject*
 Question_getClass(s_Question* self) {
     s_RRClass* rrclass;
 
-    rrclass = reinterpret_cast<s_RRClass*>(rrclass_type.tp_alloc(&rrclass_type, 0));
+    rrclass = static_cast<s_RRClass*>(rrclass_type.tp_alloc(&rrclass_type, 0));
     if (rrclass != NULL) {
         rrclass->rrclass = new RRClass(self->question->getClass());
         if (rrclass->rrclass == NULL)
@@ -236,7 +236,7 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrclass);
+    return static_cast<PyObject*>(rrclass);
 }
 
 

Modified: experiments/python-binding/src/lib/dns/python/rdata_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rdata_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rdata_python.cc Wed Jun 23 11:28:49 2010
@@ -40,10 +40,10 @@
 //
 
 // The s_* Class simply coverst one instantiation of the object
-typedef struct {
-    PyObject_HEAD
+class s_Rdata : public PyObject {
+public:
     RdataPtr rdata;
-} s_Rdata;
+};
 
 //
 // We declare the functions here, the definitions are below

Modified: experiments/python-binding/src/lib/dns/python/rrclass_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrclass_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrclass_python.cc Wed Jun 23 11:28:49 2010
@@ -38,10 +38,10 @@
 //
 
 // The s_* Class simply covers one instantiation of the object
-typedef struct {
-    PyObject_HEAD
+class s_RRClass : public PyObject {
+public:
     RRClass* rrclass;
-} s_RRClass;
+};
 
 //
 // We declare the functions here, the definitions are below
@@ -263,7 +263,7 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!other ||
-        (reinterpret_cast<PyObject*>(self))->ob_type != (reinterpret_cast<PyObject*>(other))->ob_type
+        (static_cast<PyObject*>(self))->ob_type != (static_cast<PyObject*>(other))->ob_type
        ) {
         Py_RETURN_FALSE;
     }
@@ -307,7 +307,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* RRClass_CH(s_RRClass *self UNUSED_PARAM) {
@@ -319,7 +319,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* RRClass_HS(s_RRClass *self UNUSED_PARAM) {
@@ -331,7 +331,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* RRClass_NONE(s_RRClass *self UNUSED_PARAM) {
@@ -343,7 +343,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* RRClass_ANY(s_RRClass *self UNUSED_PARAM) {
@@ -355,7 +355,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 // end of RRClass
 

Modified: experiments/python-binding/src/lib/dns/python/rrset_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrset_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrset_python.cc Wed Jun 23 11:28:49 2010
@@ -49,10 +49,10 @@
 using namespace isc::dns;
 
 // RRset
-typedef struct {
-    PyObject_HEAD
+class s_RRset : public PyObject {
+public:
     RRsetPtr rrset;
-} s_RRset;
+};
 
 static int RRset_init(s_RRset* self, PyObject* args);
 static void RRset_destroy(s_RRset* self);
@@ -208,7 +208,7 @@
     s_Name* name;
 
     // is this the best way to do this?
-    name = reinterpret_cast<s_Name*>(name_type.tp_alloc(&name_type, 0));
+    name = static_cast<s_Name*>(name_type.tp_alloc(&name_type, 0));
     if (name != NULL) {
         name->name = new Name(self->rrset->getName());
         if (name->name == NULL)
@@ -218,14 +218,14 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(name);
+    return static_cast<PyObject*>(name);
 }
 
 static PyObject*
 RRset_getClass(s_RRset* self) {
     s_RRClass* rrclass;
 
-    rrclass = reinterpret_cast<s_RRClass*>(rrclass_type.tp_alloc(&rrclass_type, 0));
+    rrclass = static_cast<s_RRClass*>(rrclass_type.tp_alloc(&rrclass_type, 0));
     if (rrclass != NULL) {
         rrclass->rrclass = new RRClass(self->rrset->getClass());
         if (rrclass->rrclass == NULL)
@@ -235,14 +235,14 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrclass);
+    return static_cast<PyObject*>(rrclass);
 }
 
 static PyObject*
 RRset_getType(s_RRset* self) {
     s_RRType* rrtype;
 
-    rrtype = reinterpret_cast<s_RRType*>(rrtype_type.tp_alloc(&rrtype_type, 0));
+    rrtype = static_cast<s_RRType*>(rrtype_type.tp_alloc(&rrtype_type, 0));
     if (rrtype != NULL) {
         rrtype->rrtype = new RRType(self->rrset->getType());
         if (rrtype->rrtype == NULL)
@@ -252,14 +252,14 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrtype);
+    return static_cast<PyObject*>(rrtype);
 }
 
 static PyObject*
 RRset_getTTL(s_RRset* self) {
     s_RRTTL* rrttl;
 
-    rrttl = reinterpret_cast<s_RRTTL*>(rrttl_type.tp_alloc(&rrttl_type, 0));
+    rrttl = static_cast<s_RRTTL*>(rrttl_type.tp_alloc(&rrttl_type, 0));
     if (rrttl != NULL) {
         rrttl->rrttl = new RRTTL(self->rrset->getTTL());
         if (rrttl->rrttl == NULL)
@@ -269,7 +269,7 @@
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrttl);
+    return static_cast<PyObject*>(rrttl);
 }
 
 static PyObject*
@@ -368,14 +368,14 @@
     RdataIteratorPtr it = self->rrset->getRdataIterator();
 
     for (it->first(); !it->isLast(); it->next()) {
-        s_Rdata *rds = reinterpret_cast<s_Rdata*>(rdata_type.tp_alloc(&rdata_type, 0));
+        s_Rdata *rds = static_cast<s_Rdata*>(rdata_type.tp_alloc(&rdata_type, 0));
         if (rds != NULL) {
             // hmz them iterators/shared_ptrs and private constructors
             // make this a bit weird, so we create a new one with
             // the data available
             const Rdata *rd = &it->getCurrent();
             rds->rdata = createRdata(self->rrset->getType(), self->rrset->getClass(), *rd);
-            PyList_Append(list, reinterpret_cast<PyObject*>(rds));
+            PyList_Append(list, static_cast<PyObject*>(rds));
         } else {
             return NULL;
         }

Modified: experiments/python-binding/src/lib/dns/python/rrttl_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrttl_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrttl_python.cc Wed Jun 23 11:28:49 2010
@@ -38,10 +38,10 @@
 //
 
 // The s_* Class simply covers one instantiation of the object
-typedef struct {
-    PyObject_HEAD
+class s_RRTTL : public PyObject {
+public:
     RRTTL* rrttl;
-} s_RRTTL;
+};
 
 //
 // We declare the functions here, the definitions are below
@@ -256,8 +256,8 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!other ||
-        (reinterpret_cast<PyObject*>(self))->ob_type !=
-        (reinterpret_cast<PyObject*>(other))->ob_type
+        (static_cast<PyObject*>(self))->ob_type !=
+        (static_cast<PyObject*>(other))->ob_type
        ) {
         Py_RETURN_FALSE;
     }

Modified: experiments/python-binding/src/lib/dns/python/rrtype_python.cc
==============================================================================
--- experiments/python-binding/src/lib/dns/python/rrtype_python.cc (original)
+++ experiments/python-binding/src/lib/dns/python/rrtype_python.cc Wed Jun 23 11:28:49 2010
@@ -38,10 +38,10 @@
 //
 
 // The s_* Class simply covers one instantiation of the object
-typedef struct {
-    PyObject_HEAD
+class s_RRType : public PyObject {
+public:
     const RRType* rrtype;
-} s_RRType;
+};
 
 //
 // We declare the functions here, the definitions are below
@@ -321,8 +321,8 @@
     // Check for null and if the types match. If different type,
     // simply return False
     if (!other ||
-        (reinterpret_cast<PyObject*>(self))->ob_type !=
-        (reinterpret_cast<PyObject*>(other))->ob_type
+        (static_cast<PyObject*>(self))->ob_type !=
+        (static_cast<PyObject*>(other))->ob_type
        ) {
         Py_RETURN_FALSE;
     }
@@ -367,7 +367,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -380,7 +380,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -393,7 +393,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -406,7 +406,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -419,7 +419,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -432,7 +432,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -445,7 +445,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -458,7 +458,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -471,7 +471,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -484,7 +484,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -497,7 +497,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -510,7 +510,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -523,7 +523,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -536,7 +536,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -549,7 +549,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -562,7 +562,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -575,7 +575,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -588,7 +588,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -601,7 +601,7 @@
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 




More information about the bind10-changes mailing list