diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-02-27 23:47:07 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:48:58 -0500 |
commit | d7a7b7fb0c423c461c24e8157ad926d0cee07da1 (patch) | |
tree | cf1a2804ca44edd950fe46d5e4b49ed419b9e086 /source4/pidl/lib | |
parent | 3d61a1bbdda98281d8db46b63aa605c794a6af60 (diff) | |
download | samba-d7a7b7fb0c423c461c24e8157ad926d0cee07da1.tar.gz samba-d7a7b7fb0c423c461c24e8157ad926d0cee07da1.tar.bz2 samba-d7a7b7fb0c423c461c24e8157ad926d0cee07da1.zip |
r21572: More work towards supporting tagged types.
(This used to be commit 4d28396f0928444406334888f4bc345e74a380df)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/NDR.pm | 16 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Typelist.pm | 7 |
2 files changed, 17 insertions, 6 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 7322856cdd..3e45bca1ad 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -35,7 +35,7 @@ use vars qw($VERSION); $VERSION = '0.01'; @ISA = qw(Exporter); @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString); -@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement); +@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type); use strict; use Parse::Pidl qw(warning fatal); @@ -335,7 +335,11 @@ sub find_largest_alignment($) sub align_type($) { sub align_type($); - my $e = shift; + my ($e) = @_; + + if (ref($e) eq "HASH" and $e->{TYPE} eq "SCALAR") { + return $scalar_alignment->{$e->{NAME}}; + } unless (hasType($e)) { # it must be an external type - all we can do is guess @@ -343,16 +347,16 @@ sub align_type($) return 4; } - my $dt = getType($e)->{DATA}; + my $dt = getType($e); - if ($dt->{TYPE} eq "ENUM") { + if ($dt->{TYPE} eq "TYPEDEF") { + return align_type($dt->{DATA}); + } elsif ($dt->{TYPE} eq "ENUM") { return align_type(Parse::Pidl::Typelist::enum_type_fn($dt)); } elsif ($dt->{TYPE} eq "BITMAP") { return align_type(Parse::Pidl::Typelist::bitmap_type_fn($dt)); } elsif (($dt->{TYPE} eq "STRUCT") or ($dt->{TYPE} eq "UNION")) { return find_largest_alignment($dt); - } elsif ($dt->{TYPE} eq "SCALAR") { - return $scalar_alignment->{$dt->{NAME}}; } die("Unknown data type type $dt->{TYPE}"); diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index 55f8390f65..b25ab62e03 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -98,7 +98,9 @@ sub addType($) sub getType($) { my $t = shift; + return ($t) if (ref($t) eq "HASH" and not defined($t->{NAME})); return undef if not hasType($t); + return $types{$t->{NAME}} if (ref($t) eq "HASH"); return $types{$t}; } @@ -113,6 +115,11 @@ sub typeIs($$) sub hasType($) { my $t = shift; + if (ref($t) eq "HASH") { + return 1 if (defined($types{$t->{NAME}}) and + $types{$t->{NAME}}->{TYPE} eq $t->{TYPE}); + return 0; + } return 1 if defined($types{$t}); return 0; } |