1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00

r20836: Use real type name, to fix compilation with -WC++-compat

(This used to be commit 10ca65bd78d27c425ae0347930fd2c9a92fe345c)
This commit is contained in:
Jelmer Vernooij 2007-01-16 17:45:33 +00:00 committed by Gerald (Jerry) Carter
parent 85520faa42
commit 652f0a7ef8

View File

@ -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}"; }