summaryrefslogtreecommitdiff
path: root/pidl/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-22 14:46:01 +1000
committerAndrew Tridgell <tridge@samba.org>2010-08-22 14:57:34 +1000
commit5a025c82f566b378a125abf0f9e74fc076d394c0 (patch)
tree545f855a10a2efd8af1d7917ebc8e01f3325d339 /pidl/lib
parent45ac8ffdb4181c31605ccda5035664a8019ffc49 (diff)
downloadsamba-5a025c82f566b378a125abf0f9e74fc076d394c0.tar.gz
samba-5a025c82f566b378a125abf0f9e74fc076d394c0.tar.bz2
samba-5a025c82f566b378a125abf0f9e74fc076d394c0.zip
pidl: added a __ndr_print__() method on python NDR objects
This allows you to print a returned NDR structure using s.__ndr_print__() which gives an easy view of complex structures, such as those from netlogon
Diffstat (limited to 'pidl/lib')
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm13
1 files changed, 13 insertions, 0 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 75aa0a8172..b7d70fafaf 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -288,11 +288,24 @@ sub PythonStruct($$$$$$)
$self->deindent;
$self->pidl("}");
$self->pidl("");
+
+ $self->pidl("static PyObject *py_$name\_ndr_print(PyObject *py_obj)");
+ $self->pidl("{");
+ $self->indent;
+ $self->pidl("$cname *object = ($cname *)py_talloc_get_ptr(py_obj);");
+ $self->pidl("char *retstr;");
+ $self->pidl("retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_$name, \"$name\", object);");
+ $self->pidl("return PyString_FromString(retstr);");
+ $self->deindent;
+ $self->pidl("}");
+ $self->pidl("");
+
$py_methods = "py_$name\_methods";
$self->pidl("static PyMethodDef $py_methods\[] = {");
$self->indent;
$self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_NOARGS, \"S.pack() -> blob\\nNDR pack\" },");
$self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_unpack, METH_VARARGS, \"S.unpack(blob) -> None\\nNDR unpack\" },");
+ $self->pidl("{ \"__ndr_print__\", (PyCFunction)py_$name\_ndr_print, METH_VARARGS, \"S.print(blob) -> None\\nNDR print\" },");
$self->pidl("{ NULL, NULL, 0, NULL }");
$self->deindent;
$self->pidl("};");