Commit 0845a483 authored by Jelte Jansen's avatar Jelte Jansen

added setTruncated() and setLengthLimit() to messagerenderer wrapper

updated TODO
added some missing INCREFs to message_python


git-svn-id: svn://bind10.isc.org/svn/bind10/experiments/python-binding@1827 e5f2f494-b856-4b98-b285-d166d9295462
parent 61dca75d
......@@ -2,6 +2,8 @@
add statics for RRClass::IN() (RRClass.IN()) etc.
(and replace RRClass("IN") in tests with those)
same for RRType? (xfrout.py.in line 256)
__str__ for name, question, everything with to_text()
All constructors based on buffers need an optional position
......@@ -9,3 +11,5 @@ argument (like question_python has now)
at question.to_wire(bytes) does not seem to work right (only return
value seems correct, while i'd like in-place addition if possible)
creating a render message and not setting opcode/rcode results in a segfault later (nullpointer)
......@@ -1478,8 +1478,10 @@ Message_init(s_Message* self, PyObject* args)
PyErr_Clear();
if (i == Message::PARSE) {
self->message = new Message(Message::PARSE);
Py_INCREF(self);
return 0;
} else if (i == Message::RENDER) {
Py_INCREF(self);
self->message = new Message(Message::RENDER);
return 0;
} else {
......@@ -1723,8 +1725,6 @@ Message_getSection(s_Message* self, PyObject* args)
++rrsi) {
s_RRset *rrset = (s_RRset*)rrset_type.tp_alloc(&rrset_type, 0);
if (rrset != NULL) {
// hmz, copy constructor is private...
//rrset->rrset = new RRset(*rrsi->get());
rrset->rrset = rrsi->get();
if (rrset->rrset == NULL)
{
......@@ -1754,6 +1754,7 @@ Message_addRRset(s_Message* self, PyObject* args)
&PyBool_Type, &sign)) {
return NULL;
}
Py_INCREF(rrset);
RRsetPtr rrset_ptr = RRsetPtr(rrset->rrset);
if (sign == Py_True) {
......
......@@ -39,12 +39,18 @@ static PyObject* MessageRenderer_getData(s_MessageRenderer* self);
static PyObject* MessageRenderer_getLength(s_MessageRenderer* self);
static PyObject* MessageRenderer_isTruncated(s_MessageRenderer* self);
static PyObject* MessageRenderer_getLengthLimit(s_MessageRenderer* self);
// TODO: set/get compressmode
static PyObject* MessageRenderer_setTruncated(s_MessageRenderer* self);
static PyObject* MessageRenderer_setLengthLimit(s_MessageRenderer* self, PyObject* args);
static PyMethodDef MessageRenderer_methods[] = {
{ "get_data", (PyCFunction)MessageRenderer_getData, METH_NOARGS, "Return the data" },
{ "get_length", (PyCFunction)MessageRenderer_getLength, METH_NOARGS, "Return the length of the data" },
{ "is_truncated", (PyCFunction)MessageRenderer_isTruncated, METH_NOARGS, "Returns True if the data is truncated" },
{ "get_length_limit", (PyCFunction)MessageRenderer_getLengthLimit, METH_NOARGS, "Return the length limit of the data" },
{ "set_truncated", (PyCFunction)MessageRenderer_setTruncated, METH_NOARGS, "Set truncated to true" },
{ "set_length_limit", (PyCFunction)MessageRenderer_setLengthLimit, METH_VARARGS, "Set the length limit of the data" },
{ NULL, NULL, 0, NULL }
};
......@@ -145,6 +151,24 @@ MessageRenderer_getLengthLimit(s_MessageRenderer* self)
return Py_BuildValue("I", self->messagerenderer->getLengthLimit());
}
static PyObject*
MessageRenderer_setTruncated(s_MessageRenderer* self)
{
self->messagerenderer->setTruncated();
Py_RETURN_NONE;
}
static PyObject*
MessageRenderer_setLengthLimit(s_MessageRenderer* self, PyObject* args)
{
size_t lengthlimit;
if (!PyArg_ParseTuple(args, "I", &lengthlimit)) {
return NULL;
}
self->messagerenderer->setLengthLimit(lengthlimit);
Py_RETURN_NONE;
}
// end of MessageRenderer
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment