summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-05 17:13:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:25 -0500
commit4bbb584ff0dcc172bbaeeff9e8f6dff6d2b94e66 (patch)
tree369076db6e767b0602d935d8f0869e59ce0d5f36 /source4/pidl/lib/Parse
parent5df3b426ee691adaaaa65424aa2cee22dcc10607 (diff)
downloadsamba-4bbb584ff0dcc172bbaeeff9e8f6dff6d2b94e66.tar.gz
samba-4bbb584ff0dcc172bbaeeff9e8f6dff6d2b94e66.tar.bz2
samba-4bbb584ff0dcc172bbaeeff9e8f6dff6d2b94e66.zip
r10734: Generate ptr, size, offset, and length elements in unions just once.
(This used to be commit 12bfa5d01bcb4cb9dad5167e1a3721fd68f06275)
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Header.pm27
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm15
2 files changed, 30 insertions, 12 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
index 6254abaa2d..4579ae2ec0 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
@@ -15,7 +15,10 @@ use vars qw($VERSION);
$VERSION = '0.01';
my $res = "";
-sub pidl($) { my $x = shift; $res .= "$x\n"; }
+my $tabs = "";
+sub indent() { $tabs.="\t"; }
+sub deindent() { $tabs = substr($tabs, 1); }
+sub pidl($) { $res .= $tabs.(shift)."\n"; }
sub fatal($$) { my ($e,$s) = @_; die("$e->{FILE}:$e->{LINE}: $s\n"); }
sub warning($$) { my ($e,$s) = @_; warn("$e->{FILE}:$e->{LINE}: $s\n"); }
@@ -101,7 +104,11 @@ sub ParseUnion($$$)
{
my ($if,$u,$n) = @_;
- my $extra = {"switch_value" => 1};
+ my $extra = {};
+
+ unless (has_property($u, "nodiscriminant")) {
+ $extra->{switch_value} = 1;
+ }
foreach my $e (@{$u->{ELEMENTS}}) {
foreach my $l (@{$e->{LEVELS}}) {
@@ -121,10 +128,17 @@ sub ParseUnion($$$)
}
pidl "typedef struct $if->{NAME}_$n\_ctr {";
- pidl "\tuint32 $_;" foreach (keys %$extra);
- pidl "\tunion {";
- ParseElement($_) foreach (@{$u->{ELEMENTS}});
- pidl "\t} u;";
+ indent;
+ pidl "uint32 $_;" foreach (keys %$extra);
+ pidl "union {";
+ indent;
+ foreach (@{$u->{ELEMENTS}}) {
+ next if ($_->{TYPE} eq "EMPTY");
+ pidl "\t" . DeclShort($_) . ";";
+ }
+ deindent;
+ pidl "} u;";
+ deindent;
pidl "} ".uc("$if->{NAME}_$n\_ctr") .";";
pidl "";
}
@@ -185,6 +199,7 @@ sub Parse($$)
my($ndr,$filename) = @_;
$res = "";
+ $tabs = "";
pidl "/*";
pidl " * Unix SMB/CIFS implementation.";
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
index 49c7cf5e81..d1188e7011 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm
@@ -75,6 +75,7 @@ sub ParseElementLevelArray($$$$$$)
if ($l->{IS_ZERO_TERMINATED}) {
fatal($e, "[string] attribute not supported for Samba3 yet");
+
#FIXME
}
@@ -123,12 +124,6 @@ sub ParseElementLevelSwitch($$$$$$)
{
my ($e,$l,$nl,$env,$varname,$what) = @_;
- if ($what == PRIMITIVES) {
- pidl "if (!prs_uint32(\"level\", ps, depth, &" . ParseExpr("level_$e->{NAME}", $env) . "))";
- pidl "\treturn False;";
- pidl "";
- }
-
ParseElementLevel($e,$nl,$env,$varname,$what);
}
@@ -353,6 +348,14 @@ sub ParseUnion($$$)
pidl "\treturn False;";
pidl "";
+ if (has_property($u, "nodiscriminant")) {
+ pidl "if (!prs_uint32(\"switch_value\", ps, depth, &v->switch_value))";
+ pidl "\treturn False;";
+ pidl "";
+ }
+
+ # Maybe check here that level and v->switch_value are equal?
+
pidl "switch (level) {";
indent;