summaryrefslogtreecommitdiff
path: root/source4/scripting/swig/dcerpc.i
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-09-06 11:01:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:33 -0500
commit0a3a76fe969fc56a033af1745374b90fd4aff6c7 (patch)
tree680088a858b9ad57813393fb083fa4bfdc196297 /source4/scripting/swig/dcerpc.i
parentaeaec31533ca74e4f2e9ff03fe9554ad7e006962 (diff)
downloadsamba-0a3a76fe969fc56a033af1745374b90fd4aff6c7.tar.gz
samba-0a3a76fe969fc56a033af1745374b90fd4aff6c7.tar.bz2
samba-0a3a76fe969fc56a033af1745374b90fd4aff6c7.zip
r2235: When creating exception data, use Py_BuildValue instead of doing it
all by hand. Use $symname to name TALLOC_CTX's created in wrapper function. Also, make sure to free context afterwards. Set the DCERPC_NDR_REF_ALLOC flag in the dcerpc_pipe struct to save use lots of initialisation. (This used to be commit 5fead63618b5ee76cadc4719d933ea9cee7538b5)
Diffstat (limited to 'source4/scripting/swig/dcerpc.i')
-rw-r--r--source4/scripting/swig/dcerpc.i24
1 files changed, 18 insertions, 6 deletions
diff --git a/source4/scripting/swig/dcerpc.i b/source4/scripting/swig/dcerpc.i
index c843ec3c36..afa968a640 100644
--- a/source4/scripting/swig/dcerpc.i
+++ b/source4/scripting/swig/dcerpc.i
@@ -41,11 +41,8 @@ PyObject *ntstatus_exception;
void set_ntstatus_exception(int status)
{
- PyObject *obj = PyTuple_New(2);
-
- PyTuple_SetItem(obj, 0, PyInt_FromLong(status));
- PyTuple_SetItem(obj, 1,
- PyString_FromString(nt_errstr(NT_STATUS(status))));
+ PyObject *obj = Py_BuildValue("(i,s)", status,
+ nt_errstr(NT_STATUS(status)));
PyErr_SetObject(ntstatus_exception, obj);
}
@@ -86,15 +83,30 @@ uint32 get_uint32_property(PyObject *dict, char *key)
}
%typemap(in, numinputs=0) TALLOC_CTX * {
- $1 = talloc_init("foo");
+ $1 = talloc_init("$symname");
+}
+
+%typemap(freearg) TALLOC_CTX * {
+ talloc_free($1);
}
%typemap(argout) struct dcerpc_pipe ** {
long status = PyLong_AsLong(resultobj);
+
+ /* Throw exception if result was not OK */
+
if (status != 0) {
set_ntstatus_exception(status);
return NULL;
}
+
+ /* Set REF_ALLOC flag so we don't have to do too much extra
+ mucking around with ref variables in ndr unmarshalling. */
+
+ (*$1)->flags |= DCERPC_NDR_REF_ALLOC;
+
+ /* Return swig handle on dcerpc_pipe */
+
resultobj = SWIG_NewPointerObj(*$1, SWIGTYPE_p_dcerpc_pipe, 0);
}