summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-08 20:19:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:34 -0500
commit36517c801cb7116df635dea8a129730c5bc014ea (patch)
tree1421a83ddee63d071f1b649dfb30b59ff212fbf5
parentfa0fbb46b8268ebaec4f8f2c7b18e3ceebb58b53 (diff)
downloadsamba-36517c801cb7116df635dea8a129730c5bc014ea.tar.gz
samba-36517c801cb7116df635dea8a129730c5bc014ea.tar.bz2
samba-36517c801cb7116df635dea8a129730c5bc014ea.zip
r10842: Fix some issues with [out] unions that have a discriminator that is only
[in] (This used to be commit 3a4086d6142fa73b3adb2d66b1bfc9cd2585f31d)
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Client.pm3
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Header.pm10
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm52
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Types.pm48
4 files changed, 37 insertions, 76 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Client.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Client.pm
index ee1ab09324..ceeb81c3d7 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Client.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Client.pm
@@ -84,11 +84,12 @@ sub ParseFunction($$)
pidl "/* Return variables */";
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/out/, @{$e->{DIRECTION}}));
-
+
if ($e->{LEVELS}[0]->{TYPE} ne "POINTER") {
warning($e->{ORIGINAL}, "First element not a pointer for [out] argument");
next;
}
+
CopyLevel($e, $e->{LEVELS}[1], $e->{NAME}, "r.$e->{NAME}");
}
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
index 25102e511a..d14bac2df7 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
@@ -103,9 +103,13 @@ sub ParseUnion($$$)
{
my ($if,$u,$n) = @_;
- my $extra = {};
-
- $extra->{switch_value} = $u->{SWITCH_TYPE};
+ my $extra = {
+ switch_value => $u->{SWITCH_TYPE}
+ };
+
+ if (not defined($extra->{switch_value})) {
+ $extra->{switch_value} = "uint32";
+ }
foreach my $e (@{$u->{ELEMENTS}}) {
foreach my $l (@{$e->{LEVELS}}) {
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
index c6cc188391..b87951adee 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
@@ -71,25 +71,7 @@ sub ParseElementLevelData($$$$$$$)
{
my ($e,$l,$nl,$env,$varname,$what,$align) = @_;
- my @args = ($e,$l,$varname,$what,$align);
-
- # See if we need to add a level argument because we're parsing a union
- foreach (@{$e->{LEVELS}}) {
- next unless ($_->{TYPE} eq "SWITCH");
- my $t = getType($l->{DATA_TYPE});
-
- # Set 0 here because one of the variables referenced in SWITCH_IS
- # might be an in variable while this one is [out]
- if (grep(/in/, @{$e->{DIRECTION}}) or
- not defined($t) or
- has_property($t->{DATA}, "nodiscriminant")) {
- push (@args, ParseExpr($_->{SWITCH_IS}, $env));
- } else {
- push (@args, -1);
- }
- }
-
- my $c = DissectType(@args);
+ my $c = DissectType($e,$l,$varname,$what,$align);
return if not $c;
if (defined($e->{ALIGN})) {
@@ -261,6 +243,7 @@ sub InitLevel($$$$)
pidl InitType($e, $l, ParseExpr($e->{NAME}, $env), $varname);
} elsif ($l->{TYPE} eq "SWITCH") {
InitLevel($e, GetNextLevel($e,$l), $varname, $env);
+ pidl ParseExpr($e->{NAME}, $env) . ".switch_value = " . ParseExpr($l->{SWITCH_IS}, $env) . ";";
}
}
@@ -397,20 +380,15 @@ sub ParseUnion($$$)
my $pfn = "$fn\_p";
my $dfn = "$fn\_d";
- pidl "BOOL $pfn(const char *desc, $sn* v, uint32 level, prs_struct *ps, int depth)";
+ pidl "BOOL $pfn(const char *desc, $sn* v, prs_struct *ps, int depth)";
pidl "{";
indent;
DeclareArrayVariables($u->{ELEMENTS});
if (defined ($u->{SWITCH_TYPE})) {
- pidl "if (MARSHALLING(ps)) ";
- pidl "\tv->switch_value = level;";
- pidl "";
pidl "if (!prs_$u->{SWITCH_TYPE}(\"switch_value\", ps, depth, &v->switch_value))";
pidl "\treturn False;";
pidl "";
- } else {
- pidl "v->switch_value = level;";
}
# Maybe check here that level and v->switch_value are equal?
@@ -447,7 +425,7 @@ sub ParseUnion($$$)
pidl "}";
pidl "";
- pidl "BOOL $dfn(const char *desc, $sn* v, uint32 level, prs_struct *ps, int depth)";
+ pidl "BOOL $dfn(const char *desc, $sn* v, prs_struct *ps, int depth)";
pidl "{";
indent;
DeclareArrayVariables($u->{ELEMENTS});
@@ -483,16 +461,14 @@ sub ParseUnion($$$)
}
-sub CreateFnDirection($$$$)
+sub CreateFnDirection($$$$$)
{
- my ($fn,$ifn, $s,$es) = @_;
+ my ($fn,$ifn,$s,$all,$es) = @_;
my $args = "";
- foreach (@$es) {
- $args .= ", " . DeclLong($_);
- }
+ foreach (@$all) { $args .= ", " . DeclLong($_); }
- my $env = { "this" => "v" };
+ my $env = { };
GenerateEnvElement($_, $env) foreach (@$es);
pidl "BOOL $ifn($s *v$args)";
@@ -539,6 +515,7 @@ sub ParseFunction($$)
my @in = ();
my @out = ();
+ my @all = @{$fn->{ELEMENTS}};
foreach (@{$fn->{ELEMENTS}}) {
push (@in, $_) if (grep(/in/, @{$_->{DIRECTION}}));
@@ -546,7 +523,7 @@ sub ParseFunction($$)
}
if (defined($fn->{RETURN_TYPE})) {
- push (@out, {
+ my $status = {
NAME => "status",
TYPE => $fn->{RETURN_TYPE},
LEVELS => [
@@ -555,17 +532,20 @@ sub ParseFunction($$)
DATA_TYPE => $fn->{RETURN_TYPE}
}
]
- } );
+ };
+
+ push (@out, $status);
+ push (@all, $status);
}
CreateFnDirection("$if->{NAME}_io_q_$fn->{NAME}",
"init_$if->{NAME}_q_$fn->{NAME}",
uc("$if->{NAME}_q_$fn->{NAME}"),
- \@in);
+ \@in, \@in);
CreateFnDirection("$if->{NAME}_io_r_$fn->{NAME}",
"init_$if->{NAME}_r_$fn->{NAME}",
uc("$if->{NAME}_r_$fn->{NAME}"),
- \@out);
+ \@all, \@out);
}
sub ParseInterface($)
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
index 8cb09343ac..135b02f1e3 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
@@ -205,12 +205,6 @@ sub AddType($$)
$known_types->{$t} = $d;
}
-sub GetType($)
-{
- my $e = shift;
-
-}
-
# Return type without special stuff, as used in
# declarations for internal structs
sub DeclShort($)
@@ -305,14 +299,9 @@ sub InitType($$$$)
}
}
-sub DissectType
+sub DissectType($$$$$)
{
- my @args = @_;
- my $e = shift @_;
- my $l = shift @_;
- my $varname = shift @_;
- my $what = shift @_;
- my $align = shift @_;
+ my ($e,$l,$varname,$what,$align) = @_;
my $t = $known_types->{$l->{DATA_TYPE}};
@@ -332,7 +321,7 @@ sub DissectType
# DISSECT can be a function
if (ref($dissect) eq "CODE") {
- return $dissect->(@args);
+ return $dissect->($e,$l,$varname,$what,$align);
} else {
return $dissect;
}
@@ -356,31 +345,18 @@ sub LoadTypes($)
my $dissect_p;
if ($td->{DATA}->{TYPE} eq "UNION") {
$decl.="_CTR";
- $dissect_p = sub {
- my ($e,$l,$n,$w,$a,$s) = @_;
-
- return "$if->{NAME}_io_$td->{NAME}_p(\"$e->{NAME}\", &$n, $s, ps, depth)";
- };
+ }
- $dissect_d = sub {
- my ($e,$l,$n,$w,$a,$s) = @_;
+ $dissect_p = sub {
+ my ($e,$l,$n,$w,$a) = @_;
- return "$if->{NAME}_io_$td->{NAME}_d(\"$e->{NAME}\", &$n, $s, ps, depth)";
- };
-
- } else {
- $dissect_p = sub {
- my ($e,$l,$n,$w,$a) = @_;
-
- return "$if->{NAME}_io_$td->{NAME}_p(\"$e->{NAME}\", &$n, ps, depth)";
- };
- $dissect_d = sub {
- my ($e,$l,$n,$w,$a) = @_;
-
- return "$if->{NAME}_io_$td->{NAME}_d(\"$e->{NAME}\", &$n, ps, depth)";
- };
+ return "$if->{NAME}_io_$td->{NAME}_p(\"$e->{NAME}\", &$n, ps, depth)";
+ };
+ $dissect_d = sub {
+ my ($e,$l,$n,$w,$a) = @_;
- }
+ return "$if->{NAME}_io_$td->{NAME}_d(\"$e->{NAME}\", &$n, ps, depth)";
+ };
AddType($td->{NAME}, {
DECL => $decl,