diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-01-16 17:45:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:43:38 -0500 |
commit | 652f0a7ef8986acc26381c05b16c55c9f8c31e3a (patch) | |
tree | 6983463e395ab6b19d73ae8b7a9ac3987a7bf97e /source4 | |
parent | 85520faa42647c9d7ee7e519d4f2139de82ae4a9 (diff) | |
download | samba-652f0a7ef8986acc26381c05b16c55c9f8c31e3a.tar.gz samba-652f0a7ef8986acc26381c05b16c55c9f8c31e3a.tar.xz samba-652f0a7ef8986acc26381c05b16c55c9f8c31e3a.zip |
r20836: Use real type name, to fix compilation with -WC++-compat
(This used to be commit 10ca65bd78d27c425ae0347930fd2c9a92fe345c)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm index f8ff458275..97cbc8b0ab 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/ServerNDR.pm @@ -8,9 +8,9 @@ package Parse::Pidl::Samba3::ServerNDR; 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($) { $res .= $tabs.(shift)."\n"; } 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 @@ sub ParseFunction($$) 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}"; } |