svn commit: samba r2966 - in branches/SAMBA_4_0/source: build/pidl scripting/swig

tpot at samba.org tpot at samba.org
Thu Oct 14 07:33:09 GMT 2004


Author: tpot
Date: 2004-10-14 07:33:09 +0000 (Thu, 14 Oct 2004)
New Revision: 2966

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

Log:
Handle conversion of DATA_BLOB fields from Python in a slightly nicer
manner.  I'm hoping to get rid of DATA_BLOB's but for the moment they
make it easy to get some spoolss action happening quickly.

Modified:
   branches/SAMBA_4_0/source/build/pidl/swig.pm
   branches/SAMBA_4_0/source/scripting/swig/dcerpc.i


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/swig.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-10-14 07:25:47 UTC (rev 2965)
+++ branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-10-14 07:33:09 UTC (rev 2966)
@@ -96,6 +96,11 @@
 	return $result;
     }
 
+    if ($e->{TYPE} eq "DATA_BLOB") {
+	$result .= "\tDATA_BLOB_ptr_from_python(mem_ctx, &s->$prefix$e->{NAME}, $obj, \"$e->{NAME}\");\n";
+	return $result;
+    }
+
     # Generate conversion for element
     
     if (util::is_scalar_type($e->{TYPE})) {

Modified: branches/SAMBA_4_0/source/scripting/swig/dcerpc.i
===================================================================
--- branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2004-10-14 07:25:47 UTC (rev 2965)
+++ branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2004-10-14 07:33:09 UTC (rev 2966)
@@ -254,28 +254,28 @@
 #define dom_sid2_ptr_to_python dom_sid_ptr_to_python
 #define dom_sid2_ptr_from_python dom_sid_ptr_from_python
 
-DATA_BLOB DATA_BLOB_from_python(PyObject *obj, char *name)
+void DATA_BLOB_ptr_from_python(TALLOC_CTX *mem_ctx, DATA_BLOB **s, 
+			       PyObject *obj, char *name)
 {
-	DATA_BLOB ret;
-
-	/* Because we treat DATA_BLOB as a scalar type (why?) there 
-	   doesn't seem to be a way to pass back when an error has
-	   occured. */
-
 	if (obj == NULL) {
 		PyErr_Format(PyExc_ValueError, "Expecting key %s", name);
 		return;
 	}
 
+	if (obj == Py_None) {
+		*s = NULL;
+		return;
+	}
+
 	if (!PyString_Check(obj)) {
 		PyErr_Format(PyExc_TypeError, "Expecting string value for key '%s'", name);
 		return;
 	}
 
-	ret.length = PyString_Size(obj);
-	ret.data = PyString_AsString(obj);
+	*s = talloc(mem_ctx, sizeof(DATA_BLOB));
 
-	return ret;
+	(*s)->length = PyString_Size(obj);
+	(*s)->data = PyString_AsString(obj);
 }
 
 PyObject *DATA_BLOB_to_python(DATA_BLOB obj)



More information about the samba-cvs mailing list