diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-05-24 18:46:32 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-05-24 18:46:32 +0200 |
commit | 1cd3a2be3199b7e1a3aa2ef29234255b8c1675ba (patch) | |
tree | 0ee716e3d4ab13e709aef7eb42d36a801a3de059 /source4/pidl | |
parent | 73b789b6d25698dba15c867c71d0cdd8c264f352 (diff) | |
download | samba-1cd3a2be3199b7e1a3aa2ef29234255b8c1675ba.tar.gz samba-1cd3a2be3199b7e1a3aa2ef29234255b8c1675ba.tar.bz2 samba-1cd3a2be3199b7e1a3aa2ef29234255b8c1675ba.zip |
Add __ndr_pack__ method to all DCE/RPC structures.
(This used to be commit 06d272b42f59d0a785697d207e6d7dbbcf355175)
Diffstat (limited to 'source4/pidl')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm index 440b1bff97..ad3cab6ffb 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -225,8 +225,34 @@ sub PythonStruct($$$$$$) $self->pidl("return py_talloc_import(&$name\_Type, ret);"); $self->deindent; $self->pidl("}"); + $self->pidl(""); + + $self->pidl("static PyObject *py_$name\_ndr_pack(PyObject *py_obj)"); + $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("err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), NULL, object, ndr_push_$name);"); + $self->pidl("if (err != NDR_ERR_SUCCESS) {"); + $self->indent; + $self->pidl("PyErr_SetString(PyExc_RuntimeError, \"Unable to ndr pack\");"); + $self->pidl("return NULL;"); + $self->deindent; + $self->pidl("}"); + $self->pidl(""); + $self->pidl("return PyString_FromStringAndSize((char *)blob.data, blob.length);"); + $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("{ NULL, NULL, 0, NULL }"); + $self->deindent; + $self->pidl("};"); + $self->pidl(""); $self->pidl_hdr("PyAPI_DATA(PyTypeObject) $name\_Type;\n"); $self->pidl_hdr("#define $name\_Check(op) PyObject_TypeCheck(op, &$name\_Type)\n"); @@ -243,6 +269,7 @@ sub PythonStruct($$$$$$) $self->pidl(".tp_getset = $getsetters,"); $self->pidl(".tp_repr = py_talloc_default_repr,"); $self->pidl(".tp_doc = $docstring,"); + $self->pidl(".tp_methods = py_$name\_methods,"); $self->pidl(".tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,"); $self->pidl(".tp_new = py_$name\_new,"); $self->deindent; |