Browse Source

[1245] update makefile and fix createRRsetObject

Jelte Jansen 13 years ago
parent
commit
b12f4e5500
2 changed files with 18 additions and 38 deletions
  1. 2 14
      src/lib/dns/python/Makefile.am
  2. 16 24
      src/lib/dns/python/rrset_python.cc

+ 2 - 14
src/lib/dns/python/Makefile.am

@@ -5,7 +5,7 @@ AM_CPPFLAGS += $(BOOST_INCLUDES)
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 
 lib_LTLIBRARIES = libpydnspp.la
-libpydnspp_la_SOURCES = pydnspp_common.cc pydnspp_towire.h
+libpydnspp_la_SOURCES = pydnspp_common.cc pydnspp_common.h pydnspp_towire.h
 libpydnspp_la_SOURCES += name_python.cc name_python.h
 libpydnspp_la_SOURCES += rrset_python.cc rrset_python.h
 libpydnspp_la_SOURCES += rrclass_python.cc rrclass_python.h
@@ -38,19 +38,7 @@ pydnspp_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
 pydnspp_la_CXXFLAGS = $(AM_CXXFLAGS) $(PYTHON_CXXFLAGS)
 pydnspp_la_LDFLAGS = $(PYTHON_LDFLAGS)
 
-# directly included from source files, so these don't have their own
-# rules
-EXTRA_DIST = pydnspp_common.h
-EXTRA_DIST += edns_python.cc
-EXTRA_DIST += message_python.cc
-EXTRA_DIST += rrclass_python.cc
-EXTRA_DIST += opcode_python.cc
-EXTRA_DIST += rrset_python.cc
-EXTRA_DIST += question_python.cc
-EXTRA_DIST += rrttl_python.cc
-EXTRA_DIST += rdata_python.cc
-EXTRA_DIST += rrtype_python.cc
-EXTRA_DIST += tsigerror_python_inc.cc
+EXTRA_DIST = tsigerror_python_inc.cc
 
 # Python prefers .so, while some OSes (specifically MacOS) use a different
 # suffix for dynamic objects.  -module is necessary to work this around.

+ 16 - 24
src/lib/dns/python/rrset_python.cc

@@ -48,10 +48,6 @@ public:
     isc::dns::RRsetPtr cppobj;
 };
 
-
-// Shortcut type which would be convenient for adding class variables safely.
-typedef CPPPyObjectContainer<s_RRset, RRset> RRsetContainer;
-
 int RRset_init(s_RRset* self, PyObject* args);
 void RRset_destroy(s_RRset* self);
 
@@ -381,34 +377,30 @@ initModulePart_RRset(PyObject* mod) {
 
 PyObject*
 createRRsetObject(const RRset& source) {
-    s_RRset* py_rrset =
-        static_cast<s_RRset*>(rrset_type.tp_alloc(&rrset_type, 0));
-    if (py_rrset == NULL) {
-        isc_throw(PyCPPWrapperException, "Unexpected NULL C++ object, "
-                  "probably due to short memory");
-    }
 
     // RRsets are noncopyable, so as a workaround we recreate a new one
     // and copy over all content
-    try {
-        py_rrset->cppobj = isc::dns::RRsetPtr(
-            new isc::dns::RRset(source.getName(), source.getClass(),
-                                source.getType(), source.getTTL()));
+    RRsetPtr new_rrset = isc::dns::RRsetPtr(
+        new isc::dns::RRset(source.getName(), source.getClass(),
+                            source.getType(), source.getTTL()));
 
-        isc::dns::RdataIteratorPtr rdata_it(source.getRdataIterator());
-        for (rdata_it->first(); !rdata_it->isLast(); rdata_it->next()) {
-            py_rrset->cppobj->addRdata(rdata_it->getCurrent());
-        }
+    isc::dns::RdataIteratorPtr rdata_it(source.getRdataIterator());
+    for (rdata_it->first(); !rdata_it->isLast(); rdata_it->next()) {
+        new_rrset->addRdata(rdata_it->getCurrent());
+    }
 
-        isc::dns::RRsetPtr sigs = source.getRRsig();
-        if (sigs) {
-            py_rrset->cppobj->addRRsig(sigs);
-        }
-        return (py_rrset);
-    } catch (const std::bad_alloc&) {
+    isc::dns::RRsetPtr sigs = source.getRRsig();
+    if (sigs) {
+        new_rrset->addRRsig(sigs);
+    }
+    s_RRset* py_rrset =
+        static_cast<s_RRset*>(rrset_type.tp_alloc(&rrset_type, 0));
+    if (py_rrset == NULL) {
         isc_throw(PyCPPWrapperException, "Unexpected NULL C++ object, "
                   "probably due to short memory");
     }
+    py_rrset->cppobj = new_rrset;
+    return (py_rrset);
 }
 
 bool