diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-10-05 14:52:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:39:25 -0500 |
commit | 5df3b426ee691adaaaa65424aa2cee22dcc10607 (patch) | |
tree | 880508a1ec2edf0d3650577e180990bf2c9fbdca /source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm | |
parent | 7838e13e917041fa3786eaa442765ab88b9f0039 (diff) | |
download | samba-5df3b426ee691adaaaa65424aa2cee22dcc10607.tar.gz samba-5df3b426ee691adaaaa65424aa2cee22dcc10607.tar.bz2 samba-5df3b426ee691adaaaa65424aa2cee22dcc10607.zip |
r10732: Generate _ctr structures for unions
(This used to be commit bd8fcb05003ad75f521783ad9603c923eacafc1a)
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm index 702835c378..49c7cf5e81 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/Parser.pm @@ -73,6 +73,11 @@ sub ParseElementLevelArray($$$$$$) { my ($e,$l,$nl,$env,$varname,$what) = @_; + if ($l->{IS_ZERO_TERMINATED}) { + fatal($e, "[string] attribute not supported for Samba3 yet"); + #FIXME + } + my $len = ParseExpr($l->{LENGTH_IS}, $env); my $size = ParseExpr($l->{SIZE_IS}, $env); @@ -308,12 +313,34 @@ sub ParseStruct($$$) pidl ""; } +sub UnionGenerateEnvElement($) +{ + my $e = shift; + my $env = {}; + + foreach my $l (@{$e->{LEVELS}}) { + if ($l->{TYPE} eq "DATA") { + $env->{$e->{NAME}} = "v->u.$e->{NAME}"; + } elsif ($l->{TYPE} eq "POINTER") { + $env->{"ptr_$e->{NAME}"} = "v->ptr"; + } 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"; + $env->{"offset_$e->{NAME}"} = "v->offset"; + } + } + + return $env; +} + sub ParseUnion($$$) { my ($if,$u,$n) = @_; my $fn = "$if->{NAME}_io_$n"; - my $sn = uc("$if->{NAME}_$n"); + my $sn = uc("$if->{NAME}_$n\_ctr"); my $pfn = "$fn\_p"; my $dfn = "$fn\_d"; @@ -334,8 +361,7 @@ sub ParseUnion($$$) indent; if ($_->{TYPE} ne "EMPTY") { pidl "depth++;"; - my $env = {}; - GenerateEnvElement($_, $env); + my $env = UnionGenerateEnvElement($_); ParseElement($_, $env, PRIMITIVES); ParseElement($_, $env, DEFERRED); pidl "depth--;"; @@ -368,8 +394,7 @@ sub ParseUnion($$$) indent; if ($_->{TYPE} ne "EMPTY") { pidl "depth++;"; - my $env = {}; - GenerateEnvElement($_, $env); + my $env = UnionGenerateEnvElement($_); ParseElement($_, $env, DEFERRED); pidl "depth--;"; } |