diff options
Diffstat (limited to 'source4/pidl/lib/Parse/Pidl')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/NDR.pm | 16 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Typelist.pm | 18 |
2 files changed, 22 insertions, 12 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 3e45bca1ad..934aba3a02 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 align_type); +@EXPORT_OK = qw(GetElementLevelTable ParseElement ValidElement align_type mapToScalar); use strict; use Parse::Pidl qw(warning fatal); @@ -880,17 +880,19 @@ sub ValidProperties($$) sub mapToScalar($) { + sub mapToScalar($); my $t = shift; + return $t->{NAME} if (ref($t) eq "HASH" and $t->{TYPE} eq "SCALAR"); my $ti = getType($t); if (not defined ($ti)) { return undef; - } elsif ($ti->{DATA}->{TYPE} eq "ENUM") { - return Parse::Pidl::Typelist::enum_type_fn($ti->{DATA}); - } elsif ($ti->{DATA}->{TYPE} eq "BITMAP") { - return Parse::Pidl::Typelist::enum_type_fn($ti->{DATA}); - } elsif ($ti->{DATA}->{TYPE} eq "SCALAR") { - return $t; + } elsif ($ti->{TYPE} eq "TYPEDEF") { + return mapToScalar($ti->{DATA}); + } elsif ($ti->{TYPE} eq "ENUM") { + return Parse::Pidl::Typelist::enum_type_fn($ti); + } elsif ($ti->{TYPE} eq "BITMAP") { + return Parse::Pidl::Typelist::bitmap_type_fn($ti); } return undef; diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index b25ab62e03..72c4b18d0b 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -107,8 +107,13 @@ sub getType($) sub typeIs($$) { my ($t,$tt) = @_; - - return 1 if (hasType($t) and getType($t)->{DATA}->{TYPE} eq $tt); + + if (ref($t) eq "HASH") { + return 1 if ($t->{TYPE} eq $tt); + return 0; + } + return 1 if (hasType($t) and getType($t)->{TYPE} eq "TYPEDEF" and + getType($t)->{DATA}->{TYPE} eq $tt); return 0; } @@ -116,6 +121,7 @@ sub hasType($) { my $t = shift; if (ref($t) eq "HASH") { + return 1 if (not defined($t->{NAME})); return 1 if (defined($types{$t->{NAME}}) and $types{$t->{NAME}}->{TYPE} eq $t->{TYPE}); return 0; @@ -128,10 +134,12 @@ sub is_scalar($) { my $type = shift; - return 0 unless(hasType($type)); + return 1 if (ref($type) eq "HASH" and $type->{TYPE} eq "SCALAR"); - if (my $dt = getType($type)->{DATA}->{TYPE}) { - return 1 if ($dt eq "SCALAR" or $dt eq "ENUM" or $dt eq "BITMAP"); + if (my $dt = getType($type)) { + return is_scalar($dt->{DATA}) if ($dt->{TYPE} eq "TYPEDEF"); + return 1 if ($dt->{TYPE} eq "SCALAR" or $dt->{TYPE} eq "ENUM" or + $dt->{TYPE} eq "BITMAP"); } return 0; |