[svn] commit: r2259 - in /experiments/python-binding/src/lib/dns/python: message_python.cc question_python.cc rdata_python.cc rrset_python.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jun 24 08:38:10 UTC 2010
Author: jelte
Date: Thu Jun 24 08:38:10 2010
New Revision: 2259
Log:
last of the cpp review comments: factoring out common code in creation of statics, added a few explanatory comments
Modified:
experiments/python-binding/src/lib/dns/python/message_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/rrset_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 Thu Jun 24 08:38:10 2010
@@ -144,94 +144,47 @@
}
static PyObject*
-MessageFlag_QR(s_MessageFlag* self UNUSED_PARAM) {
+MessageFlag_createStatic(const MessageFlag& flag) {
s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
if (ret != NULL) {
- ret->messageflag = &MessageFlag::QR();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ ret->messageflag = &flag;
+ }
+ return (ret);
+}
+
+static PyObject*
+MessageFlag_QR(s_MessageFlag* self UNUSED_PARAM) {
+ return MessageFlag_createStatic(MessageFlag::QR());
}
static PyObject*
MessageFlag_AA(s_MessageFlag* self UNUSED_PARAM) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &MessageFlag::AA();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return MessageFlag_createStatic(MessageFlag::AA());
}
static PyObject*
MessageFlag_TC(s_MessageFlag* self UNUSED_PARAM) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &MessageFlag::TC();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return MessageFlag_createStatic(MessageFlag::TC());
}
static PyObject*
MessageFlag_RD(s_MessageFlag* self UNUSED_PARAM) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &MessageFlag::RD();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return MessageFlag_createStatic(MessageFlag::RD());
}
static PyObject*
MessageFlag_RA(s_MessageFlag* self UNUSED_PARAM) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &MessageFlag::RA();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return MessageFlag_createStatic(MessageFlag::RA());
}
static PyObject*
MessageFlag_AD(s_MessageFlag* self UNUSED_PARAM) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &MessageFlag::AD();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return MessageFlag_createStatic(MessageFlag::AD());
}
static PyObject*
MessageFlag_CD(s_MessageFlag* self UNUSED_PARAM) {
- s_MessageFlag* ret = PyObject_New(s_MessageFlag, &messageflag_type);
- if (ret != NULL) {
- ret->messageflag = &MessageFlag::CD();
- if (ret->messageflag == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return MessageFlag_createStatic(MessageFlag::CD());
}
//
@@ -379,211 +332,92 @@
}
static PyObject*
-Opcode_QUERY(s_Opcode* self UNUSED_PARAM) {
+Opcode_createStatic(const Opcode& opcode) {
s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
if (ret != NULL) {
- ret->opcode = &Opcode::QUERY();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ ret->opcode = &opcode;
+ }
+ return (ret);
+}
+
+static PyObject*
+Opcode_QUERY(s_Opcode* self UNUSED_PARAM) {
+ return Opcode_createStatic(Opcode::QUERY());
}
static PyObject*
Opcode_IQUERY(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::IQUERY();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::IQUERY());
}
static PyObject*
Opcode_STATUS(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::STATUS();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::STATUS());
}
static PyObject*
Opcode_RESERVED3(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED3();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED3());
}
static PyObject*
Opcode_NOTIFY(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::NOTIFY();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::NOTIFY());
}
static PyObject*
Opcode_UPDATE(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::UPDATE();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::UPDATE());
}
static PyObject*
Opcode_RESERVED6(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED6();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED6());
}
static PyObject*
Opcode_RESERVED7(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED7();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED7());
}
static PyObject*
Opcode_RESERVED8(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED8();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED8());
}
static PyObject*
Opcode_RESERVED9(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED9();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED9());
}
static PyObject*
Opcode_RESERVED10(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED10();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED10());
}
static PyObject*
Opcode_RESERVED11(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED11();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED11());
}
static PyObject*
Opcode_RESERVED12(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED12();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED12());
}
static PyObject*
Opcode_RESERVED13(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED13();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED13());
}
static PyObject*
Opcode_RESERVED14(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED14();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED14());
}
static PyObject*
Opcode_RESERVED15(s_Opcode* self UNUSED_PARAM) {
- s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
- if (ret != NULL) {
- ret->opcode = &Opcode::RESERVED15();
- if (ret->opcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Opcode_createStatic(Opcode::RESERVED15());
}
static PyObject*
@@ -768,8 +602,8 @@
static void
Rcode_destroy(s_Rcode* self) {
- // We only use the consts from Rcode, so don't
- // delete self->rcode here
+ // Depending on whether we created the rcode or are referring
+ // to a global static one, we do or do not delete self->rcode here
if (!self->static_code) {
delete self->rcode;
}
@@ -796,241 +630,98 @@
}
static PyObject*
-Rcode_NOERROR(s_Rcode* self UNUSED_PARAM) {
+Rcode_createStatic(const Rcode& rcode) {
s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
if (ret != NULL) {
- ret->rcode = &Rcode::NOERROR();
+ ret->rcode = &rcode;
ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ }
+ return (ret);
+}
+
+static PyObject*
+Rcode_NOERROR(s_Rcode* self UNUSED_PARAM) {
+ return Rcode_createStatic(Rcode::NOERROR());
}
static PyObject*
Rcode_FORMERR(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::FORMERR();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::FORMERR());
}
static PyObject*
Rcode_SERVFAIL(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::SERVFAIL();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::SERVFAIL());
}
static PyObject*
Rcode_NXDOMAIN(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::NXDOMAIN();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::NXDOMAIN());
}
static PyObject*
Rcode_NOTIMP(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::NOTIMP();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::NOTIMP());
}
static PyObject*
Rcode_REFUSED(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::REFUSED();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::REFUSED());
}
static PyObject*
Rcode_YXDOMAIN(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::YXDOMAIN();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::YXDOMAIN());
}
static PyObject*
Rcode_YXRRSET(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::YXRRSET();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::YXRRSET());
}
static PyObject*
Rcode_NXRRSET(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::NXRRSET();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::NXRRSET());
}
static PyObject*
Rcode_NOTAUTH(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::NOTAUTH();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::NOTAUTH());
}
static PyObject*
Rcode_NOTZONE(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::NOTZONE();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::NOTZONE());
}
static PyObject*
Rcode_RESERVED11(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::RESERVED11();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::RESERVED11());
}
static PyObject*
Rcode_RESERVED12(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::RESERVED12();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::RESERVED12());
}
static PyObject*
Rcode_RESERVED13(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::RESERVED13();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::RESERVED13());
}
static PyObject*
Rcode_RESERVED14(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::RESERVED14();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::RESERVED14());
}
static PyObject*
Rcode_RESERVED15(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::RESERVED15();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::RESERVED15());
}
static PyObject*
Rcode_BADVERS(s_Rcode* self UNUSED_PARAM) {
- s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
- if (ret != NULL) {
- ret->rcode = &Rcode::BADVERS();
- ret->static_code = true;
- if (ret->rcode == NULL) {
- Py_DECREF(ret);
- return NULL;
- }
- }
- return static_cast<PyObject*>(ret);
+ return Rcode_createStatic(Rcode::BADVERS());
}
static PyObject*
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 Thu Jun 24 08:38:10 2010
@@ -127,9 +127,8 @@
static int
Question_init(s_Question* self, PyObject* args) {
- // The constructor argument can be a string ("IN"), an integer (1),
- // or a sequence of numbers between 0 and 255 (wire code)
-
+ // Try out the various combinations of arguments to call the
+ // correct cpp constructor.
// Note that PyArg_ParseType can set PyError, and we need to clear
// that if we try several like here. Otherwise the *next* python
// call will suddenly appear to throw an exception.
@@ -193,11 +192,6 @@
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)
- {
- Py_DECREF(name);
- return NULL;
- }
}
return static_cast<PyObject*>(name);
@@ -210,11 +204,6 @@
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)
- {
- Py_DECREF(rrtype);
- return NULL;
- }
}
return static_cast<PyObject*>(rrtype);
@@ -227,11 +216,6 @@
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)
- {
- Py_DECREF(rrclass);
- return NULL;
- }
}
return static_cast<PyObject*>(rrclass);
@@ -259,8 +243,9 @@
if (PyArg_ParseTuple(args, "O", &bytes) && PySequence_Check(bytes)) {
PyObject* bytes_o = bytes;
-
- OutputBuffer buffer(255);
+
+ // Max length is Name::MAX_WIRE + rrclass (2) + rrtype (2)
+ OutputBuffer buffer(Name::MAX_WIRE + 4);
self->question->toWire(buffer);
PyObject* n = PyBytes_FromStringAndSize((const char*) buffer.getData(),
buffer.getLength());
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 Thu Jun 24 08:38:10 2010
@@ -40,6 +40,12 @@
//
// The s_* Class simply coverst one instantiation of the object
+
+// Using a shared_ptr here should not really be necessary (PyObject
+// is already reference-counted), however internally on the cpp side,
+// not doing so might result in problems, since we can't copy construct
+// rdata field, adding them to rrsets results in a problem when the
+// rrset is destroyed later
class s_Rdata : public PyObject {
public:
RdataPtr rdata;
@@ -143,9 +149,7 @@
if (PyArg_ParseTuple(args, "O!O!s", &rrtype_type, &rrtype,
&rrclass_type, &rrclass,
- &s, &s
- )) {
- const std::string str(s);
+ &s)) {
self->rdata = createRdata(*rrtype->rrtype, *rrclass->rrclass, s);
return 0;
}
@@ -183,13 +187,13 @@
if (PyArg_ParseTuple(args, "O", &bytes) && PySequence_Check(bytes)) {
PyObject* bytes_o = bytes;
- OutputBuffer buffer(2);
+ OutputBuffer buffer(4);
self->rdata->toWire(buffer);
- PyObject* n = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
- PyObject* result = PySequence_InPlaceConcat(bytes_o, n);
+ PyObject* rd_bytes = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* result = PySequence_InPlaceConcat(bytes_o, rd_bytes);
// We need to release the object we temporarily created here
// to prevent memory leak
- Py_DECREF(n);
+ Py_DECREF(rd_bytes);
return result;
} else if (PyArg_ParseTuple(args, "O!", &messagerenderer_type, (PyObject**) &mr)) {
self->rdata->toWire(*mr->messagerenderer);
@@ -247,7 +251,6 @@
Py_RETURN_FALSE;
}
// end of Rdata
-
// Module Initialization, all statics are initialized here
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 Thu Jun 24 08:38:10 2010
@@ -33,6 +33,12 @@
using namespace isc::dns;
// RRset
+
+// Using a shared_ptr here should not really be necessary (PyObject
+// is already reference-counted), however internally on the cpp side,
+// not doing so might result in problems, since we can't copy construct
+// rrsets, adding them to messages results in a problem when the
+// message is destroyed or cleared later
class s_RRset : public PyObject {
public:
RRsetPtr rrset;
More information about the bind10-changes
mailing list