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

jelmer at samba.org jelmer at samba.org
Tue Jan 16 17:45:35 GMT 2007


Author: jelmer
Date: 2007-01-16 17:45:33 +0000 (Tue, 16 Jan 2007)
New Revision: 20836

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

Log:
Use real type name, to fix compilation with -WC++-compat
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm


Changeset:

Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:merge
   - jelmer at samba.org-20060824212938-5923465160f6ab63
jelmer at samba.org-20060830112659-186f132eebc987cc
jelmer at samba.org-20060904121718-63b73248146c14f8
jelmer at samba.org-20060904124721-5e70ab0bd405f748
metze at samba.org-20061010151401-45a5a2ed52cfe172
jelmer at samba.org-20061016130323-400ce51ee51ab30e
jelmer at samba.org-20061016195822-c7783d3ea1a56a53
jelmer at samba.org-20061016230421-75bca2ad62945ede
jelmer at samba.org-20061017145110-8c83a3dd979f6a6a
jelmer at samba.org-20061029173623-eb0459f1d3eb5720
jelmer at samba.org-20070115022006-h5ef1deqflt940b6
jelmer at samba.org-20070116142934-hv99dpwbnq2znh8f
jelmer at samba.org-20070116144126-70rip3bppmvgs3t6
jelmer at samba.org-20070116151516-imvui4r33cj850j9
jelmer at samba.org-20070116154739-3tji4fft7964qgrj

   + jelmer at samba.org-20060824212938-5923465160f6ab63
jelmer at samba.org-20060830112659-186f132eebc987cc
jelmer at samba.org-20060904121718-63b73248146c14f8
jelmer at samba.org-20060904124721-5e70ab0bd405f748
metze at samba.org-20061010151401-45a5a2ed52cfe172
jelmer at samba.org-20061016130323-400ce51ee51ab30e
jelmer at samba.org-20061016195822-c7783d3ea1a56a53
jelmer at samba.org-20061016230421-75bca2ad62945ede
jelmer at samba.org-20061017145110-8c83a3dd979f6a6a
jelmer at samba.org-20061029173623-eb0459f1d3eb5720
jelmer at samba.org-20070115022006-h5ef1deqflt940b6
jelmer at samba.org-20070116142934-hv99dpwbnq2znh8f
jelmer at samba.org-20070116144126-70rip3bppmvgs3t6
jelmer at samba.org-20070116151516-imvui4r33cj850j9
jelmer at samba.org-20070116154739-3tji4fft7964qgrj
jelmer at samba.org-20070116173900-iasa25stcfty6pbr


Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm	2007-01-16 17:39:13 UTC (rev 20835)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm	2007-01-16 17:45:33 UTC (rev 20836)
@@ -8,9 +8,9 @@
 
 use strict;
 use Parse::Pidl qw(warning fatal);
-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::Typelist qw(mapType scalar_is_reference);
+use Parse::Pidl::Util qw(ParseExpr has_property is_constant);
+use Parse::Pidl::NDR qw(GetNextLevel);
 use Parse::Pidl::Samba4 qw(DeclLong);
 
 use vars qw($VERSION);
@@ -25,21 +25,59 @@
 sub pidl_hdr($) { $res_hdr .= (shift)."\n"; }
 sub fn_declare($) { my ($n) = @_; pidl $n; pidl_hdr "$n;"; }
 
+sub DeclLevel($$) 
+{
+	sub DeclLevel($$);
+	my ($e, $l) = @_;
+
+	my $ret = "";
+
+	if (has_property($e, "charset")) {
+		$ret.="const char";
+	} else {
+		$ret.=mapType($e->{TYPE});
+	}
+
+	my $numstar = $e->{ORIGINAL}->{POINTERS};
+	if ($numstar >= 1) {
+		$numstar-- if scalar_is_reference($e->{TYPE});
+	}
+	foreach (@{$e->{ORIGINAL}->{ARRAY_LEN}})
+	{
+		next if is_constant($_) and 
+			not has_property($e, "charset");
+		$numstar++;
+	}
+	$numstar -= $l;
+	die ("Too few pointers") if $numstar < 0;
+	if ($numstar > 0) 
+	{
+		$ret.=" ";
+		$ret.="*" foreach (1..$numstar);
+	}
+
+	return $ret;
+}
+
 sub AllocOutVar($$$$)
 {
 	my ($e, $mem_ctx, $name, $env) = @_;
 
 	my $l = $e->{LEVELS}[0];
+	my $nl = $l;
 
 	if ($l->{TYPE} eq "POINTER") {
-		$l = GetNextLevel($e, $l);
+		$nl = GetNextLevel($e, $l);
 	}
 
 	if ($l->{TYPE} eq "ARRAY") {
 		my $size = ParseExpr($l->{SIZE_IS}, $env, $e);
-		pidl "$name = talloc_zero_size($mem_ctx, sizeof(*$name) * $size);";
+		pidl "$name = talloc_zero_array($mem_ctx, " . DeclLevel($e, 1) . ", $size);";
+	} elsif ($l->{TYPE} eq "POINTER" and $nl->{TYPE} eq "ARRAY") {
+		my $size = ParseExpr($nl->{SIZE_IS}, $env, $e);
+		pidl "$name = talloc_zero_array($mem_ctx, " . DeclLevel($e, 1) . ", $size);";
 	} else {
-		pidl "$name = talloc_zero_size($mem_ctx, sizeof(*$name));";
+		pidl "$name = talloc_zero($mem_ctx, " . DeclLevel($e, 1) . ");";
 	}
 
 	pidl "if ($name == NULL) {";
@@ -101,7 +139,8 @@
 		my @dir = @{$_->{DIRECTION}};
 		if (grep(/in/, @dir) and grep(/out/, @dir)) {
 			pidl "r.out.$_->{NAME} = r.in.$_->{NAME};";
-		} elsif (grep(/out/, @dir)) {
+		} elsif (grep(/out/, @dir) and not 
+				 has_property($_, "represent_as")) {
 			AllocOutVar($_, "mem_ctx", "r.out.$_->{NAME}", \%env);
 		}
 		if (grep(/in/, @dir)) { $ret .= ", r.in.$_->{NAME}"; }



More information about the samba-cvs mailing list