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

tpot at samba.org tpot at samba.org
Mon Sep 13 11:55:37 GMT 2004


Author: tpot
Date: 2004-09-13 11:55:36 +0000 (Mon, 13 Sep 2004)
New Revision: 2322

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

Log:
More renames of autogenerated functions so they all have approximately
the same signature.

Start to handle structures with no pointers.

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-13 10:36:59 UTC (rev 2321)
+++ branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-09-13 11:55:36 UTC (rev 2322)
@@ -71,8 +71,15 @@
 	    $result .= DebugElement($e);
 	}
     } else {
-	# Non-scalar type
-	$result .= DebugElement($e);
+	if ($e->{POINTERS} == 0) {
+	    # Non-scalar type, no pointer
+	    $result .= DebugElement($e);
+	} elsif ($e->{POINTERS} == 1) {
+	    $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python(mem_ctx, $obj);\n";
+	} else {
+	    # Non-scalar type, multiple pointers
+	    $result .= DebugElement($e);
+	}
     }
 
     return $result;
@@ -111,8 +118,15 @@
 	    $result .= DebugElement($e);
 	}
     } else {
-	# Non-scalar type
-	$result .= DebugElement($e);
+	if ($e->{POINTERS} == 0) {
+	    # Non-scalar type, no pointer
+	    $result .= DebugElement($e);
+	} elsif ($e->{POINTERS} == 1) {
+	    $result .= "\ts->$prefix$e->{NAME} = $e->{TYPE}_from_python(mem_ctx, $obj);\n";
+	} else {
+	    # Non-scalar type, multiple pointers
+	    $result .= DebugElement($e);
+	}
     }
 
     return $result;
@@ -126,28 +140,32 @@
 
     $res .= "/* Convert Python dict to struct $fn->{NAME}.in */\n\n";
 
-    $res .= "int $fn->{NAME}_from_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s, PyObject *obj)\n";
+    $res .= "struct $fn->{NAME} *$fn->{NAME}_from_python(TALLOC_CTX *mem_ctx, PyObject *obj)\n";
     $res .= "{\n";
 
+    $res .= "\tstruct $fn->{NAME} *s = talloc(mem_ctx, sizeof(struct $fn->{NAME}));\n\n";
+
     foreach my $e (@{$fn->{DATA}}) {
 	$res .= XFromPython($e, "in.") if util::has_property($e, "in")
     }
 
     $res .= "\n";
-    $res .= "\treturn True;\n";
+    $res .= "\treturn s;\n";
     $res .= "}\n\n";
 
     $res .= "/* Convert struct $fn->{NAME}.out to Python dict */\n\n";
 
-    $res .= "int $fn->{NAME}_to_python(TALLOC_CTX *mem_ctx, PyObject *obj, struct $fn->{NAME} *s)\n";
+    $res .= "PyObject *$fn->{NAME}_to_python(TALLOC_CTX *mem_ctx, struct $fn->{NAME} *s)\n";
     $res .= "{\n";
 
+    $res .= "\tPyObject *obj = PyDict_New();\n\n";
+
     foreach my $e (@{$fn->{DATA}}) {
 	$res .= XToPython($e, "out.") if util::has_property($e, "out")
     }
 
     $res .= "\n";
-    $res .= "\treturn True;\n";
+    $res .= "\treturn obj;\n";
     $res .= "}\n\n";
 
     $res .= "%}\n\n";
@@ -192,28 +210,31 @@
     $res .= "%{\n\n";
     $res .= "/* Convert Python dict to struct $s->{NAME} */\n\n";
     
-    $res .= "int python_to_$s->{NAME}(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s, PyObject *obj)\n";
+    $res .= "struct $s->{NAME} *$s->{NAME}_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";
 
     foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
 	$res .= XFromPython($e, "");
     }
 
     $res .= "\n";
-    $res .= "\treturn TRUE;\n";
+    $res .= "\treturn s;\n";
     $res .= "}\n\n";
 
     $res .= "/* Convert struct $s->{NAME} to Python dict */\n\n";
 
-    $res .= "int $s->{NAME}_to_python(TALLOC_CTX *mem_ctx, PyObject *obj, struct $s->{NAME} *s)\n";
+    $res .= "PyObject *$s->{NAME}_to_python(TALLOC_CTX *mem_ctx, struct $s->{NAME} *s)\n";
     $res .= "{\n";
+    
+    $res .= "\tPyObject *obj = PyDict_New();\n\n";
 
     foreach my $e (@{$s->{DATA}{ELEMENTS}}) {
 	$res .= XToPython($e, "");
     }
 
     $res .= "\n";
-    $res .= "\treturn TRUE;\n";
+    $res .= "\treturn obj;\n";
     $res .= "}\n";
 
     $res .= "\n%}\n\n";    



More information about the samba-cvs mailing list