diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-05-24 18:55:46 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-05-24 18:55:46 +0200 |
commit | 14c4028f261cbbdba03cc8b3f0ec6e32a390c79e (patch) | |
tree | 47d2d48aa25426fa12569d3f7a3b00fc6b099052 /source4/pidl/lib | |
parent | 1cd3a2be3199b7e1a3aa2ef29234255b8c1675ba (diff) | |
download | samba-14c4028f261cbbdba03cc8b3f0ec6e32a390c79e.tar.gz samba-14c4028f261cbbdba03cc8b3f0ec6e32a390c79e.tar.bz2 samba-14c4028f261cbbdba03cc8b3f0ec6e32a390c79e.zip |
Support __ndr_unpack__ on DCE/RPC structures in Python.
(This used to be commit 3b2bd4d849946aaff2b0adfbacdc15284670b916)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm index ad3cab6ffb..56d54d3d36 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -244,11 +244,33 @@ sub PythonStruct($$$$$$) $self->pidl("return PyString_FromStringAndSize((char *)blob.data, blob.length);"); $self->deindent; $self->pidl("}"); + $self->pidl(""); + $self->pidl("static PyObject *py_$name\_ndr_unpack(PyObject *py_obj, PyObject *args)"); + $self->pidl("{"); + $self->indent; + $self->pidl("$cname *object = py_talloc_get_ptr(py_obj);"); + $self->pidl("DATA_BLOB blob;"); + $self->pidl("enum ndr_err_code err;"); + $self->pidl("if (!PyArg_ParseTuple(args, \"s#\", &blob.data, &blob.length))"); + $self->pidl("\treturn NULL;"); + $self->pidl(""); + $self->pidl("err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, ndr_pull_$name);"); + $self->pidl("if (err != NDR_ERR_SUCCESS) {"); + $self->indent; + $self->pidl("PyErr_SetString(PyExc_RuntimeError, \"Unable to ndr unpack\");"); + $self->pidl("return NULL;"); + $self->deindent; + $self->pidl("}"); + $self->pidl(""); + $self->pidl("return Py_None;"); + $self->deindent; + $self->pidl("}"); $self->pidl(""); $self->pidl("static PyMethodDef py_$name\_methods[] = {"); $self->indent; - $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_O|METH_NOARGS, \"NDR pack\" },"); + $self->pidl("{ \"__ndr_pack__\", (PyCFunction)py_$name\_ndr_pack, METH_O|METH_NOARGS, \"S.pack() -> blob\\nNDR pack\" },"); + $self->pidl("{ \"__ndr_unpack__\", (PyCFunction)py_$name\_ndr_pack, METH_O|METH_VARARGS, \"S.unpack(blob) -> None\\nNDR unpack\" },"); $self->pidl("{ NULL, NULL, 0, NULL }"); $self->deindent; $self->pidl("};"); |