summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
diff options
context:
space:
mode:
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba3/Header.pm')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Header.pm27
1 files changed, 24 insertions, 3 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
index 5b7fddc14f..6254abaa2d 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm
@@ -101,10 +101,31 @@ sub ParseUnion($$$)
{
my ($if,$u,$n) = @_;
- pidl "typedef union $if->{NAME}_$n {";
- #FIXME: What about elements that require more then one variable?
+ my $extra = {"switch_value" => 1};
+
+ foreach my $e (@{$u->{ELEMENTS}}) {
+ foreach my $l (@{$e->{LEVELS}}) {
+ if ($l->{TYPE} eq "ARRAY") {
+ if ($l->{IS_CONFORMANT}) {
+ $extra->{"size"} = 1;
+ }
+ if ($l->{IS_VARYING}) {
+ $extra->{"length"} = $extra->{"offset"} = 1;
+ }
+ } elsif ($l->{TYPE} eq "POINTER") {
+ $extra->{"ptr"} = 1;
+ } elsif ($l->{TYPE} eq "SWITCH") {
+ $extra->{"level"} = 1;
+ }
+ }
+ }
+
+ pidl "typedef struct $if->{NAME}_$n\_ctr {";
+ pidl "\tuint32 $_;" foreach (keys %$extra);
+ pidl "\tunion {";
ParseElement($_) foreach (@{$u->{ELEMENTS}});
- pidl "} ".uc($if->{NAME}."_".$n) .";";
+ pidl "\t} u;";
+ pidl "} ".uc("$if->{NAME}_$n\_ctr") .";";
pidl "";
}