svn commit: samba r15587 - in branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl: . Samba3 Samba4

jelmer at samba.org jelmer at samba.org
Sat May 13 22:03:45 GMT 2006


Author: jelmer
Date: 2006-05-13 22:03:44 +0000 (Sat, 13 May 2006)
New Revision: 15587

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15587

Log:
Generate stubs for the SWIG functions

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm	2006-05-13 21:39:01 UTC (rev 15586)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm	2006-05-13 22:03:44 UTC (rev 15587)
@@ -10,6 +10,7 @@
 use Parse::Pidl::Typelist qw(hasType getType mapType scalar_is_reference);
 use Parse::Pidl::Util qw(has_property ParseExpr is_constant);
 use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
+use Parse::Pidl::Samba4 qw(DeclLong);
 
 use vars qw($VERSION);
 $VERSION = '0.01';
@@ -46,42 +47,6 @@
 	}
 }
 
-sub DeclLong($)
-{
-	my($element) = shift;
-	my $ret = "";
-
-	if (has_property($element, "represent_as")) {
-		$ret.=mapType($element->{PROPERTIES}->{represent_as})." ";
-	} else {
-		if (has_property($element, "charset")) {
-			$ret.="const char";
-		} else {
-			$ret.=mapType($element->{TYPE});
-		}
-
-		$ret.=" ";
-		my $numstar = $element->{ORIGINAL}->{POINTERS};
-		if ($numstar >= 1) {
-			$numstar-- if scalar_is_reference($element->{TYPE});
-		}
-		foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}})
-		{
-			next if is_constant($_) and 
-				not has_property($element, "charset");
-			$numstar++;
-		}
-		$ret.="*" foreach (1..$numstar);
-	}
-	$ret.=$element->{NAME};
-	foreach (@{$element->{ARRAY_LEN}}) {
-		next unless (is_constant($_) and not has_property($element, "charset"));
-		$ret.="[$_]";
-	}
-
-	return $ret;
-}
-
 sub ParseFunction($$)
 {
 	my ($if,$fn) = @_;

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm	2006-05-13 21:39:01 UTC (rev 15586)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4/SWIG.pm	2006-05-13 22:03:44 UTC (rev 15587)
@@ -7,6 +7,8 @@
 package Parse::Pidl::Samba4::SWIG;
 
 use vars qw($VERSION);
+use Parse::Pidl::Samba4 qw(DeclLong);
+use Parse::Pidl::Typelist qw(mapType);
 $VERSION = '0.01';
 
 use strict;
@@ -23,9 +25,9 @@
 sub indent() { $tabs.="\t"; }
 sub deindent() { $tabs = substr($tabs,0,-1); }
 
-sub ParseInterface($)
+sub ParseInterface($$)
 {
-	my $if = shift;
+	my ($basename,$if) = @_;
 
 	pidl "\%{";
 	pidl "struct $if->{NAME} {";
@@ -36,8 +38,6 @@
 	pidl "%}";
 	pidl "";
 
-	# FIXME: Generate ignores for all manual functions
-		
 	pidl "\%extend $if->{NAME} {";
 	indent();
 	pidl "struct $if->{NAME} *$if->{NAME} (const char *binding, struct cli_credentials *cred = NULL, TALLOC_CTX *mem_ctx = NULL, struct event_context *event = NULL)";
@@ -61,8 +61,39 @@
 	pidl "}";
 	pidl "";
 
-	foreach (@{$if->{FUNCTIONS}}) {
-		pidl "/* $_->{NAME} */";
+	foreach my $fn (@{$if->{FUNCTIONS}}) {
+		pidl "/* $fn->{NAME} */";
+		my $args = "";
+		foreach (@{$fn->{ELEMENTS}}) {
+			$args .= DeclLong($_) . ", ";
+		}
+		my $name = $fn->{NAME};
+		$name =~ s/^$if->{NAME}_//g;
+		$name =~ s/^$basename\_//g;
+		$args .= "TALLOC_CTX *mem_ctx = NULL";
+		pidl mapType($fn->{RETURN_TYPE}) . " $name($args)";
+		pidl "{";
+		indent;
+		pidl "struct $fn->{NAME} r;";
+		my $assign = "";
+		if (defined($fn->{RETURN_TYPE})) {
+			pidl mapType($fn->{RETURN_TYPE}) . " ret;";
+			$assign = "ret = ";
+		}
+		pidl "";
+		pidl "/* Fill r structure */";
+		pidl "/* FIXME */";
+		pidl "";
+		pidl $assign."dcerpc_$fn->{NAME}(self->pipe, mem_ctx, &r);";
+		pidl "";
+		pidl "/* Set out arguments */";
+		pidl "/* FIXME */";
+		if (defined($fn->{RETURN_TYPE})) {
+			pidl "return ret;";
+		}
+		deindent;
+		pidl "}";
+		pidl "";
 	}
 
 	deindent();
@@ -70,7 +101,7 @@
 	pidl "";
 
 	foreach (@{$if->{TYPES}}) {
-		pidl "/* $_->{NAME} */";	
+		pidl "/* $_->{NAME} */";
 	}
 	
 	pidl "";
@@ -98,12 +129,11 @@
 	pidl "";
 
 	foreach (@$ndr) {
-		ParseInterface($_) if ($_->{TYPE} eq "INTERFACE");
+		ParseInterface($basename, $_) if ($_->{TYPE} eq "INTERFACE");
 	}
 	#FIXME: Foreach ref pointer, set NONNULL
 	#FIXME: Foreach unique/full pointer, set MAYBENULL
 	#FIXME: Foreach [out] parameter, set OUTPARAM
-	#
 	return $ret;
 }
 

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4.pm	2006-05-13 21:39:01 UTC (rev 15586)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba4.pm	2006-05-13 22:03:44 UTC (rev 15587)
@@ -7,9 +7,10 @@
 
 require Exporter;
 @ISA = qw(Exporter);
- at EXPORT = qw(is_intree choose_header);
+ at EXPORT = qw(is_intree choose_header DeclLong);
 
-use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::Util qw(has_property is_constant);
+use Parse::Pidl::Typelist qw(mapType scalar_is_reference);
 use strict;
 
 use vars qw($VERSION);
@@ -29,4 +30,40 @@
 	return "#include <$out>";
 }
 
+sub DeclLong($)
+{
+	my($element) = shift;
+	my $ret = "";
+
+	if (has_property($element, "represent_as")) {
+		$ret.=mapType($element->{PROPERTIES}->{represent_as})." ";
+	} else {
+		if (has_property($element, "charset")) {
+			$ret.="const char";
+		} else {
+			$ret.=mapType($element->{TYPE});
+		}
+
+		$ret.=" ";
+		my $numstar = $element->{ORIGINAL}->{POINTERS};
+		if ($numstar >= 1) {
+			$numstar-- if scalar_is_reference($element->{TYPE});
+		}
+		foreach (@{$element->{ORIGINAL}->{ARRAY_LEN}})
+		{
+			next if is_constant($_) and 
+				not has_property($element, "charset");
+			$numstar++;
+		}
+		$ret.="*" foreach (1..$numstar);
+	}
+	$ret.=$element->{NAME};
+	foreach (@{$element->{ARRAY_LEN}}) {
+		next unless (is_constant($_) and not has_property($element, "charset"));
+		$ret.="[$_]";
+	}
+
+	return $ret;
+}
+
 1;

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm	2006-05-13 21:39:01 UTC (rev 15586)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm	2006-05-13 22:03:44 UTC (rev 15587)
@@ -194,7 +194,7 @@
 sub mapType($)
 {
 	my $t = shift;
-	die("Undef passed to mapType") unless defined($t);
+	return "void" unless defined($t);
 	my $dt;
 
 	unless ($dt or ($dt = getType($t))) {



More information about the samba-cvs mailing list