[svn] commit: r2323 - in /experiments/python-binding/src/lib/dns/python: name_python.cc question_python.cc rdata_python.cc rrclass_python.cc rrset_python.cc rrttl_python.cc rrtype_python.cc tests/message_python_test.py tests/rrtype_python_test.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 29 09:53:53 UTC 2010
Author: jelte
Date: Tue Jun 29 09:53:52 2010
New Revision: 2323
Log:
some final comments: use constants from cpp version, updated a few c-style casts, and replaced obj.__str__() calls in tests with str(obj)
Modified:
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
experiments/python-binding/src/lib/dns/python/tests/message_python_test.py
experiments/python-binding/src/lib/dns/python/tests/rrtype_python_test.py
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 Tue Jun 29 09:53:52 2010
@@ -415,7 +415,7 @@
OutputBuffer buffer(Name::MAX_WIRE);
self->name->toWire(buffer);
- PyObject* name_bytes = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* name_bytes = PyBytes_FromStringAndSize(static_cast<const char*>(buffer.getData()), buffer.getLength());
PyObject* result = PySequence_InPlaceConcat(bytes_o, name_bytes);
// We need to release the object we temporarily created here
// to prevent memory leak
@@ -634,17 +634,18 @@
Py_INCREF(&name_type);
// Add the constants to the module
- addClassVariable(name_type, "MAX_WIRE", Py_BuildValue("I", 255U));
- addClassVariable(name_type, "MAX_LABELS", Py_BuildValue("I", 128U));
- addClassVariable(name_type, "MAX_LABELLEN", Py_BuildValue("I", 63U));
- addClassVariable(name_type, "MAX_COMPRESS_POINTER", Py_BuildValue("I", 0x3fffU));
- addClassVariable(name_type, "COMPRESS_POINTER_MARK8", Py_BuildValue("I", 0xc0U));
- addClassVariable(name_type, "COMPRESS_POINTER_MARK16", Py_BuildValue("I", 0xc000U));
+ addClassVariable(name_type, "MAX_WIRE", Py_BuildValue("I", Name::MAX_WIRE));
+ addClassVariable(name_type, "MAX_LABELS", Py_BuildValue("I", Name::MAX_LABELS));
+ addClassVariable(name_type, "MAX_LABELLEN", Py_BuildValue("I", Name::MAX_LABELLEN));
+ addClassVariable(name_type, "MAX_COMPRESS_POINTER", Py_BuildValue("I", Name::MAX_COMPRESS_POINTER));
+ addClassVariable(name_type, "COMPRESS_POINTER_MARK8", Py_BuildValue("I", Name::COMPRESS_POINTER_MARK8));
+ addClassVariable(name_type, "COMPRESS_POINTER_MARK16", Py_BuildValue("I", Name::COMPRESS_POINTER_MARK16));
s_Name* root_name = PyObject_New(s_Name, &name_type);
- root_name->name = new Name(".");
+ // casting const away here should be safe, as it should be impossible
+ // to modify attributes of built-in/extension types.
+ root_name->name = const_cast<Name*>(&Name::ROOT_NAME());
PyObject* po_ROOT_NAME = root_name;
- Py_INCREF(po_ROOT_NAME);
addClassVariable(name_type, "ROOT_NAME", po_ROOT_NAME);
PyModule_AddObject(mod, "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 Tue Jun 29 09:53:52 2010
@@ -247,7 +247,7 @@
// 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(),
+ PyObject* n = PyBytes_FromStringAndSize(static_cast<const char*>(buffer.getData()),
buffer.getLength());
PyObject* result = PySequence_InPlaceConcat(bytes_o, n);
// We need to release the object we temporarily created here
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 Tue Jun 29 09:53:52 2010
@@ -189,7 +189,7 @@
OutputBuffer buffer(4);
self->rdata->toWire(buffer);
- PyObject* rd_bytes = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* rd_bytes = PyBytes_FromStringAndSize(static_cast<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
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 Tue Jun 29 09:53:52 2010
@@ -231,7 +231,7 @@
OutputBuffer buffer(2);
self->rrclass->toWire(buffer);
- PyObject* n = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* n = PyBytes_FromStringAndSize(static_cast<const char*>(buffer.getData()), buffer.getLength());
PyObject* result = PySequence_InPlaceConcat(bytes_o, n);
// We need to release the object we temporarily created here
// to prevent memory leak
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 Tue Jun 29 09:53:52 2010
@@ -309,7 +309,7 @@
OutputBuffer buffer(4096);
self->rrset->toWire(buffer);
- PyObject* n = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* n = PyBytes_FromStringAndSize(static_cast<const char*>(buffer.getData()), buffer.getLength());
PyObject* result = PySequence_InPlaceConcat(bytes_o, n);
// We need to release the object we temporarily created here
// to prevent memory leak
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 Tue Jun 29 09:53:52 2010
@@ -224,7 +224,8 @@
OutputBuffer buffer(4);
self->rrttl->toWire(buffer);
- PyObject* n = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* n = PyBytes_FromStringAndSize(static_cast<const char*>(buffer.getData()),
+ buffer.getLength());
PyObject* result = PySequence_InPlaceConcat(bytes_o, n);
// We need to release the object we temporarily created here
// to prevent memory leak
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 Tue Jun 29 09:53:52 2010
@@ -264,7 +264,7 @@
OutputBuffer buffer(2);
self->rrtype->toWire(buffer);
- PyObject* n = PyBytes_FromStringAndSize((const char*) buffer.getData(), buffer.getLength());
+ PyObject* n = PyBytes_FromStringAndSize(static_cast<const char*>(buffer.getData()), buffer.getLength());
PyObject* result = PySequence_InPlaceConcat(bytes_o, n);
// We need to release the object we temporarily created here
// to prevent memory leak
Modified: experiments/python-binding/src/lib/dns/python/tests/message_python_test.py
==============================================================================
--- experiments/python-binding/src/lib/dns/python/tests/message_python_test.py (original)
+++ experiments/python-binding/src/lib/dns/python/tests/message_python_test.py Tue Jun 29 09:53:52 2010
@@ -141,7 +141,7 @@
def test_to_text(self):
self.assertEqual("NOERROR", Rcode(0).to_text())
- self.assertEqual("NOERROR", Rcode(0).__str__())
+ self.assertEqual("NOERROR", str(Rcode(0)))
self.assertEqual("FORMERR", Rcode(1).to_text())
self.assertEqual("SERVFAIL", Rcode(2).to_text())
self.assertEqual("NXDOMAIN", Rcode(3).to_text())
Modified: experiments/python-binding/src/lib/dns/python/tests/rrtype_python_test.py
==============================================================================
--- experiments/python-binding/src/lib/dns/python/tests/rrtype_python_test.py (original)
+++ experiments/python-binding/src/lib/dns/python/tests/rrtype_python_test.py Tue Jun 29 09:53:52 2010
@@ -64,7 +64,7 @@
def test_to_text(self):
self.assertEqual("A", RRType(1).to_text());
- self.assertEqual("A", RRType(1).__str__());
+ self.assertEqual("A", str(RRType(1)));
self.assertEqual("TYPE65000", RRType(65000).to_text());
def test_to_wire_buffer(self):
More information about the bind10-changes
mailing list