summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse
diff options
context:
space:
mode:
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r--source4/pidl/lib/Parse/Pidl/NDR.pm16
-rw-r--r--source4/pidl/lib/Parse/Pidl/Typelist.pm7
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;
}