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

tpot at samba.org tpot at samba.org
Wed Sep 8 12:56:57 GMT 2004


Author: tpot
Date: 2004-09-08 12:56:57 +0000 (Wed, 08 Sep 2004)
New Revision: 2256

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

Log:
Include autogenerated interfaces for lsa and samr pipes.  Typemaps are currently
not working though.

Modified:
   branches/SAMBA_4_0/source/build/pidl/swig.pm
   branches/SAMBA_4_0/source/build/smb_build/makefile.pl
   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-09-08 12:51:46 UTC (rev 2255)
+++ branches/SAMBA_4_0/source/build/pidl/swig.pm	2004-09-08 12:56:57 UTC (rev 2256)
@@ -6,16 +6,81 @@
 package IdlSwig;
 
 use strict;
+use Data::Dumper;
 
+my($res);
+my($name);
+
+sub ParseFunction($)
+{
+    my($fn) = shift;
+
+#    print Dumper($fn);
+
+    # Input typemap
+
+    $res .= "%typemap(in) struct $fn->{NAME} * (struct $fn->{NAME} temp) {\n";
+    $res .= "\tif (!PyDict_Check(\$input)) {\n";
+    $res .= "\t\tPyErr_SetString(PyExc_TypeError, \"dict arg expected\");\n";
+    $res .= "\t\treturn NULL;\n";
+    $res .= "\t}\n\n";
+    $res .= "\tmemset(&temp, 0, sizeof(temp));\n\n";
+    $res .= "\t/* store input params in dict */\n\n";
+    $res .= "\t\$1 = &temp;\n";
+    $res .= "}\n\n";
+
+    # Output typemap
+
+    $res .= "%typemap(argout) struct $fn->{NAME} * {\n";
+    $res .= "\tlong status = PyLong_AsLong(resultobj);\n";
+    $res .= "\tPyObject *dict;\n";
+    $res .= "\n";
+    $res .= "\tif (status != 0) {\n";
+    $res .= "\t\tset_ntstatus_exception(status);\n";
+    $res .= "\t\treturn NULL;\n";
+    $res .= "\t}\n";
+    $res .= "\n";
+    $res .= "\tdict = PyDict_New();\n\n";
+    $res .= "\t/* store output params in dict */\n\n";
+    $res .= "\tresultobj = dict;\n";
+    $res .= "}\n\n";
+
+    # Function definitions
+
+    $res .= "%rename($fn->{NAME}) dcerpc_$fn->{NAME};\n";
+    $res .= "$fn->{RETURN_TYPE} dcerpc_$fn->{NAME}(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct $fn->{NAME} *r);\n\n";
+}
+
+sub ParseInheritedData($)
+{
+    my($data) = shift;
+
+    foreach my $e (@{$data}) {
+	($e->{TYPE} eq "FUNCTION") && ParseFunction($e);
+    }
+}
+
+sub ParseHeader($)
+{
+    my($hdr) = shift;
+
+    $name = $hdr->{NAME};
+    $res .= "#define DCERPC_" . uc($name) . "_UUID \"$hdr->{PROPERTIES}->{uuid}\"\n";
+    $res .= "const int DCERPC_" . uc($name) . "_VERSION = " . $hdr->{PROPERTIES}->{version} . ";\n";
+    $res .= "#define DCERPC_" . uc($name) . "_NAME \"" . $name . "\"\n";
+    $res .= "\n";
+
+    ParseInheritedData($hdr->{INHERITED_DATA});    
+}
+
 sub Parse($)
 {
     my($idl) = shift;
-    my($res) = "";
+    
+    $res = "/* auto-generated by pidl */\n\n";
 
-    $res = "/* header auto-generated by pidl */\n\n";
-
     foreach my $x (@{$idl}) {
-#	($x->{TYPE} eq "INTERFACE") && HeaderInterface($x);
+	($x->{TYPE} eq "INTERFACE") && ParseHeader($x);
     }
 
     return $res;

Modified: branches/SAMBA_4_0/source/build/smb_build/makefile.pl
===================================================================
--- branches/SAMBA_4_0/source/build/smb_build/makefile.pl	2004-09-08 12:51:46 UTC (rev 2255)
+++ branches/SAMBA_4_0/source/build/smb_build/makefile.pl	2004-09-08 12:56:57 UTC (rev 2256)
@@ -776,7 +776,9 @@
 
 PYTHON_DCERPC_LIBS = -lldap
 
-scripting/swig/dcerpc.py: scripting/swig/dcerpc.i scripting/swig/samr.i scripting/swig/samba.i
+SWIG_INCLUDES = librpc/gen_ndr/samr.i librpc/gen_ndr/lsa.i
+
+scripting/swig/dcerpc.py: scripting/swig/dcerpc.i scripting/swig/samba.i \$(SWIG_INCLUDES)
 	swig -python scripting/swig/dcerpc.i
 
 scripting/swig/_dcerpc.so: scripting/swig/dcerpc.py scripting/swig/dcerpc_wrap.o \$(PYTHON_DCERPC_OBJ)

Modified: branches/SAMBA_4_0/source/scripting/swig/dcerpc.i
===================================================================
--- branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2004-09-08 12:51:46 UTC (rev 2255)
+++ branches/SAMBA_4_0/source/scripting/swig/dcerpc.i	2004-09-08 12:56:57 UTC (rev 2256)
@@ -121,4 +121,6 @@
                              const char *domain,
                              const char *username,
                              const char *password);
-%include "samr.i"
+
+%include "librpc/gen_ndr/samr.i"
+%include "librpc/gen_ndr/lsa.i"



More information about the samba-cvs mailing list