Browse Source

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

git-svn-id: svn://bind10.isc.org/svn/bind10/experiments/python-binding@2239 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 15 years ago
parent
commit
4353cffbf6

+ 70 - 70
src/lib/dns/python/message_python.cc

@@ -40,10 +40,10 @@ static PyObject* po_DNSMessageBADVERS;
 //
 // 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 @@ MessageFlag_QR(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -169,7 +169,7 @@ MessageFlag_AA(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -182,7 +182,7 @@ MessageFlag_TC(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -195,7 +195,7 @@ MessageFlag_RD(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -208,7 +208,7 @@ MessageFlag_RA(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -221,7 +221,7 @@ MessageFlag_AD(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -234,7 +234,7 @@ MessageFlag_CD(s_MessageFlag* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 //
@@ -245,10 +245,10 @@ MessageFlag_CD(s_MessageFlag* self UNUSED_PARAM) {
 //
 // 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 @@ Opcode_QUERY(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -407,7 +407,7 @@ Opcode_IQUERY(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -420,7 +420,7 @@ Opcode_STATUS(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -433,7 +433,7 @@ Opcode_RESERVED3(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -446,7 +446,7 @@ Opcode_NOTIFY(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -459,7 +459,7 @@ Opcode_UPDATE(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -472,7 +472,7 @@ Opcode_RESERVED6(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -485,7 +485,7 @@ Opcode_RESERVED7(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -498,7 +498,7 @@ Opcode_RESERVED8(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -511,7 +511,7 @@ Opcode_RESERVED9(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -524,7 +524,7 @@ Opcode_RESERVED10(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -537,7 +537,7 @@ Opcode_RESERVED11(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -550,7 +550,7 @@ Opcode_RESERVED12(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -563,7 +563,7 @@ Opcode_RESERVED13(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -576,7 +576,7 @@ Opcode_RESERVED14(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -589,7 +589,7 @@ Opcode_RESERVED15(s_Opcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -599,7 +599,7 @@ Opcode_richcmp(s_Opcode* self, s_Opcode* other, int op) {
     // 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 @@ Opcode_richcmp(s_Opcode* self, s_Opcode* other, int op) {
 // 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 @@ Rcode_NOERROR(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -831,7 +831,7 @@ Rcode_FORMERR(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -845,7 +845,7 @@ Rcode_SERVFAIL(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -859,7 +859,7 @@ Rcode_NXDOMAIN(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -873,7 +873,7 @@ Rcode_NOTIMP(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -887,7 +887,7 @@ Rcode_REFUSED(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -901,7 +901,7 @@ Rcode_YXDOMAIN(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -915,7 +915,7 @@ Rcode_YXRRSET(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -929,7 +929,7 @@ Rcode_NXRRSET(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -943,7 +943,7 @@ Rcode_NOTAUTH(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -957,7 +957,7 @@ Rcode_NOTZONE(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -971,7 +971,7 @@ Rcode_RESERVED11(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -985,7 +985,7 @@ Rcode_RESERVED12(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -999,7 +999,7 @@ Rcode_RESERVED13(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1013,7 +1013,7 @@ Rcode_RESERVED14(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1027,7 +1027,7 @@ Rcode_RESERVED15(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1041,7 +1041,7 @@ Rcode_BADVERS(s_Rcode* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -1051,7 +1051,7 @@ Rcode_richcmp(s_Rcode* self, s_Rcode* other, int op) {
     // 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 @@ Rcode_richcmp(s_Rcode* self, s_Rcode* other, int op) {
 
 // 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 @@ Section_QUESTION(s_Section* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1222,7 +1222,7 @@ Section_ANSWER(s_Section* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1235,7 +1235,7 @@ Section_AUTHORITY(s_Section* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -1248,7 +1248,7 @@ Section_ADDITIONAL(s_Section* self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -1258,7 +1258,7 @@ Section_richcmp(s_Section* self, s_Section* other, int op) {
     // 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 @@ Section_richcmp(s_Section* self, s_Section* other, int op) {
 //
 
 // 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 @@ static PyObject*
 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 @@ Message_getRcode(s_Message* self) {
           }
     }
 
-    return reinterpret_cast<PyObject*>(rcode);
+    return static_cast<PyObject*>(rcode);
 }
 
 static PyObject*
@@ -1702,7 +1702,7 @@ static PyObject*
 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 @@ Message_getOpcode(s_Message* self) {
           }
     }
 
-    return reinterpret_cast<PyObject*>(opcode);
+    return static_cast<PyObject*>(opcode);
 }
 
 static PyObject*
@@ -1745,7 +1745,7 @@ Message_getQuestion(s_Message* self) {
     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 @@ Message_getQuestion(s_Message* self) {
                 return NULL;
               }
         }
-        PyList_Append(list, reinterpret_cast<PyObject*>(question));
+        PyList_Append(list, static_cast<PyObject*>(question));
     }
     return list;
 }
@@ -1771,7 +1771,7 @@ Message_getSection(s_Message* self, PyObject* args) {
          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 @@ Message_getSection(s_Message* self, PyObject* args) {
                 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);

+ 3 - 3
src/lib/dns/python/messagerenderer_python.cc

@@ -26,11 +26,11 @@ using namespace isc::dns;
 // 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);

+ 14 - 14
src/lib/dns/python/name_python.cc

@@ -49,10 +49,10 @@ static PyObject* po_NameRelation;
 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 @@ NameComparisonResult_getRelation(s_NameComparisonResult* self) {
 
 // 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 @@ Name_compare(s_Name* self, PyObject* args) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject* 
@@ -502,7 +502,7 @@ Name_split(s_Name* self, PyObject* args) {
             }
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 #include <iostream>
 
@@ -513,8 +513,8 @@ Name_richcmp(s_Name* n1, s_Name* n2, int op) {
     // 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 @@ Name_reverse(s_Name* self) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -582,14 +582,14 @@ Name_concatenate(s_Name* self, PyObject* args) {
             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 @@ initModulePart_Name(PyObject* mod) {
 
     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);
 

+ 9 - 9
src/lib/dns/python/question_python.cc

@@ -22,10 +22,10 @@ using namespace isc::dns;
 //
 
 // 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 @@ Question_getName(s_Question* self) {
     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 @@ Question_getName(s_Question* self) {
           }
     }
 
-    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 @@ Question_getType(s_Question* self) {
           }
     }
 
-    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 @@ Question_getClass(s_Question* self) {
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrclass);
+    return static_cast<PyObject*>(rrclass);
 }
 
 

+ 3 - 3
src/lib/dns/python/rdata_python.cc

@@ -40,10 +40,10 @@ static PyObject* po_CharStringTooLong;
 //
 
 // 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

+ 9 - 9
src/lib/dns/python/rrclass_python.cc

@@ -38,10 +38,10 @@ static PyObject* po_IncompleteRRClass;
 //
 
 // 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 @@ RRClass_richcmp(s_RRClass* self, s_RRClass* other, int op) {
     // 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 @@ static PyObject* RRClass_IN(s_RRClass *self UNUSED_PARAM) {
             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 @@ static PyObject* RRClass_CH(s_RRClass *self UNUSED_PARAM) {
             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 @@ static PyObject* RRClass_HS(s_RRClass *self UNUSED_PARAM) {
             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 @@ static PyObject* RRClass_NONE(s_RRClass *self UNUSED_PARAM) {
             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 @@ static PyObject* RRClass_ANY(s_RRClass *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 // end of RRClass
 

+ 13 - 13
src/lib/dns/python/rrset_python.cc

@@ -49,10 +49,10 @@ static PyObject* po_EmptyRRset;
 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 @@ RRset_getName(s_RRset* self) {
     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 @@ RRset_getName(s_RRset* self) {
           }
     }
 
-    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 @@ RRset_getClass(s_RRset* self) {
           }
     }
 
-    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 @@ RRset_getType(s_RRset* self) {
           }
     }
 
-    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 @@ RRset_getTTL(s_RRset* self) {
           }
     }
 
-    return reinterpret_cast<PyObject*>(rrttl);
+    return static_cast<PyObject*>(rrttl);
 }
 
 static PyObject*
@@ -368,14 +368,14 @@ RRset_getRdata(s_RRset* self) {
     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;
         }

+ 5 - 5
src/lib/dns/python/rrttl_python.cc

@@ -38,10 +38,10 @@ static PyObject* po_IncompleteRRTTL;
 //
 
 // 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 @@ RRTTL_richcmp(s_RRTTL* self, s_RRTTL* other, int op) {
     // 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;
     }

+ 24 - 24
src/lib/dns/python/rrtype_python.cc

@@ -38,10 +38,10 @@ static PyObject* po_IncompleteRRType;
 //
 
 // 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 @@ RRType_richcmp(s_RRType* self, s_RRType* other, int op) {
     // 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 @@ RRType_NSEC3PARAM(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -380,7 +380,7 @@ RRType_DNAME(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -393,7 +393,7 @@ RRType_PTR(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -406,7 +406,7 @@ RRType_MX(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -419,7 +419,7 @@ RRType_DNSKEY(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -432,7 +432,7 @@ RRType_TXT(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -445,7 +445,7 @@ RRType_RRSIG(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -458,7 +458,7 @@ RRType_NSEC(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -471,7 +471,7 @@ RRType_AAAA(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -484,7 +484,7 @@ RRType_DS(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -497,7 +497,7 @@ RRType_OPT(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -510,7 +510,7 @@ RRType_A(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -523,7 +523,7 @@ RRType_NS(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -536,7 +536,7 @@ RRType_CNAME(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -549,7 +549,7 @@ RRType_SOA(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -562,7 +562,7 @@ RRType_NSEC3(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -575,7 +575,7 @@ RRType_IXFR(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -588,7 +588,7 @@ RRType_AXFR(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }
 
 static PyObject*
@@ -601,7 +601,7 @@ RRType_ANY(s_RRType *self UNUSED_PARAM) {
             return NULL;
         }
     }
-    return reinterpret_cast<PyObject*>(ret);
+    return static_cast<PyObject*>(ret);
 }