diff options
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba3')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba3/Header.pm | 15 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm | 40 |
2 files changed, 38 insertions, 17 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm index 78bd8fe339..25102e511a 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/Header.pm @@ -31,7 +31,6 @@ sub ParseElement($) return if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "top"); pidl "\tuint32 ptr$l->{POINTER_INDEX}_$e->{NAME};"; } elsif ($l->{TYPE} eq "SWITCH") { - pidl "\tuint32 level_$e->{NAME};"; } elsif ($l->{TYPE} eq "DATA") { pidl "\t" . DeclShort($e) . ";"; } elsif ($l->{TYPE} eq "ARRAY") { @@ -106,30 +105,28 @@ sub ParseUnion($$$) my $extra = {}; - unless (has_property($u, "nodiscriminant")) { - $extra->{switch_value} = 1; - } + $extra->{switch_value} = $u->{SWITCH_TYPE}; foreach my $e (@{$u->{ELEMENTS}}) { foreach my $l (@{$e->{LEVELS}}) { if ($l->{TYPE} eq "ARRAY") { if ($l->{IS_CONFORMANT}) { - $extra->{"size"} = 1; + $extra->{"size"} = "uint32"; } if ($l->{IS_VARYING}) { - $extra->{"length"} = $extra->{"offset"} = 1; + $extra->{"length"} = $extra->{"offset"} = "uint32"; } } elsif ($l->{TYPE} eq "POINTER") { - $extra->{"ptr$l->{POINTER_INDEX}"} = 1; + $extra->{"ptr$l->{POINTER_INDEX}"} = "uint32"; } elsif ($l->{TYPE} eq "SWITCH") { - $extra->{"level"} = 1; + $extra->{"level"} = "uint32"; } } } pidl "typedef struct $if->{NAME}_$n\_ctr {"; indent; - pidl "uint32 $_;" foreach (keys %$extra); + pidl "$extra->{$_} $_;" foreach (keys %$extra); pidl "union $if->{NAME}_$n {"; indent; foreach (@{$u->{ELEMENTS}}) { diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm index eaab50b553..c6cc188391 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm @@ -75,8 +75,18 @@ sub ParseElementLevelData($$$$$$$) # See if we need to add a level argument because we're parsing a union foreach (@{$e->{LEVELS}}) { - push (@args, ParseExpr("level_$e->{NAME}", $env)) - if ($_->{TYPE} eq "SWITCH"); + 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); @@ -263,7 +273,6 @@ sub GenerateEnvElement($$) } elsif ($l->{TYPE} eq "POINTER") { $env->{"ptr$l->{POINTER_INDEX}_$e->{NAME}"} = "v->ptr$l->{POINTER_INDEX}_$e->{NAME}"; } elsif ($l->{TYPE} eq "SWITCH") { - $env->{"level_$e->{NAME}"} = "v->level_$e->{NAME}"; } elsif ($l->{TYPE} eq "ARRAY") { $env->{"length_$e->{NAME}"} = "v->length_$e->{NAME}"; $env->{"size_$e->{NAME}"} = "v->size_$e->{NAME}"; @@ -368,7 +377,6 @@ sub UnionGenerateEnvElement($) } elsif ($l->{TYPE} eq "POINTER") { $env->{"ptr$l->{POINTER_INDEX}_$e->{NAME}"} = "v->ptr$l->{POINTER_INDEX}"; } elsif ($l->{TYPE} eq "SWITCH") { - $env->{"level_$e->{NAME}"} = "v->level"; } elsif ($l->{TYPE} eq "ARRAY") { $env->{"length_$e->{NAME}"} = "v->length"; $env->{"size_$e->{NAME}"} = "v->size"; @@ -394,15 +402,20 @@ sub ParseUnion($$$) indent; DeclareArrayVariables($u->{ELEMENTS}); - unless (has_property($u, "nodiscriminant")) { - pidl "if (!prs_uint32(\"switch_value\", ps, depth, &v->switch_value))"; + 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? - pidl "switch (level) {"; + pidl "switch (v->switch_value) {"; indent; foreach (@{$u->{ELEMENTS}}) { @@ -420,19 +433,30 @@ sub ParseUnion($$$) pidl ""; } + unless ($u->{HAS_DEFAULT}) { + pidl "default:"; + pidl "\treturn False;"; + pidl ""; + } + deindent; pidl "}"; pidl ""; pidl "return True;"; deindent; pidl "}"; + pidl ""; pidl "BOOL $dfn(const char *desc, $sn* v, uint32 level, prs_struct *ps, int depth)"; pidl "{"; indent; DeclareArrayVariables($u->{ELEMENTS}); - pidl "switch (level) {"; + if (defined($u->{SWITCH_TYPE})) { + pidl "switch (v->switch_value) {"; + } else { + pidl "switch (level) {"; + } indent; foreach (@{$u->{ELEMENTS}}) { |