svn commit: samba r2409 - in branches/SAMBA_4_0/source/build/pidl: .

tpot at samba.org tpot at samba.org
Sat Sep 18 10:08:43 GMT 2004


Author: tpot
Date: 2004-09-18 10:08:43 +0000 (Sat, 18 Sep 2004)
New Revision: 2409

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

Log:
Convert NULL pointers to Py_None, and vice versa.

This gets samr_QuerySecurity() working again.

Modified:
   branches/SAMBA_4_0/source/build/pidl/swig.pm


Changeset:
Modified: branches/SAMBA_4_0/source/build/pidl/swig.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-09-18 08:41:26 UTC (rev 2408)
+++ branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-09-18 10:08:43 UTC (rev 2409)
@@ -231,8 +231,14 @@
     
     $res .= "struct $s->{NAME} *$s->{NAME}_ptr_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)\n";
     $res .= "{\n";
-    $res .= "\tstruct $s->{NAME} *s = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n";
+    $res .= "\tstruct $s->{NAME} *s;\n\n";
 
+    $res .= "\tif (obj == Py_None) {\n";
+    $res .= "\t\treturn NULL;\n";
+    $res .= "\t}\n\n";
+
+    $res .= "\ts = talloc(mem_ctx, sizeof(struct $s->{NAME}));\n\n";
+
     foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
 	$res .= XFromPython($e, "");
     }
@@ -259,6 +265,11 @@
     
     $res .= "\tPyObject *obj = PyDict_New();\n\n";
 
+    $res .= "\tif (s == NULL) {\n";
+    $res .= "\t\tPy_INCREF(Py_None);\n";
+    $res .= "\t\treturn Py_None;\n";
+    $res .= "\t}\n\n";
+    
     foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
 	$res .= XToPython($e, "");
     }
@@ -282,7 +293,6 @@
 
     $res .= "\tunion $u->{NAME} *u = talloc(mem_ctx, sizeof(union $u->{NAME}));\n";
     $res .= "\tPyObject *dict;\n\n";
-
     
     for my $e (@{$u->{DATA}{DATA}}) {
 	$res .= "\tif ((dict = PyDict_GetItem(obj, PyString_FromString(\"$e->{DATA}{NAME}\")))) {\n";
@@ -305,6 +315,12 @@
 
     $res .= "PyObject *$u->{NAME}_ptr_to_python(TALLOC_CTX *mem_ctx, union $u->{NAME} *u)\n";
     $res .= "{\n";
+
+    $res .= "\tif (u == NULL) {\n";
+    $res .= "\t\tPy_INCREF(Py_None);\n";
+    $res .= "\t\treturn Py_None;\n";
+    $res .= "\t}\n\n";
+
     $res .= "\treturn PyDict_New();\n";
     $res .= "}\n\n";
 



More information about the samba-cvs mailing list