svn commit: samba r2235 - in branches/SAMBA_4_0/source/scripting/swig: .

tpot at samba.org tpot at samba.org
Mon Sep 6 11:01:11 GMT 2004


Author: tpot
Date: 2004-09-06 11:01:10 +0000 (Mon, 06 Sep 2004)
New Revision: 2235

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/scripting/swig&rev=2235&nolog=1

Log:
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.

Modified:
   branches/SAMBA_4_0/source/scripting/swig/dcerpc.i


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/swig/dcerpc.i
===================================================================
--- branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2004-09-06 10:29:18 UTC (rev 2234)
+++ branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2004-09-06 11:01:10 UTC (rev 2235)
@@ -41,12 +41,9 @@
 
 void set_ntstatus_exception(int status)
 {
-	PyObject *obj = PyTuple_New(2);
+	PyObject *obj = Py_BuildValue("(i,s)", status, 
+				nt_errstr(NT_STATUS(status)));
 
-	PyTuple_SetItem(obj, 0, PyInt_FromLong(status));
-	PyTuple_SetItem(obj, 1, 
-		PyString_FromString(nt_errstr(NT_STATUS(status))));
-
 	PyErr_SetObject(ntstatus_exception, obj);
 }
 
@@ -86,15 +83,30 @@
 }
 
 %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);
 }
 



More information about the samba-cvs mailing list