From fda645af50ea82c74d51ef76b37a6b38a826c56c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 16 May 2006 23:49:31 +0000 Subject: r15652: Fix aliases mechanism (fixes #3710) (This used to be commit 3e89ef0875c5c8ccaafa9694d27a8043930127e6) --- source4/pidl/lib/Parse/Pidl/NDR.pm | 6 +++-- source4/pidl/lib/Parse/Pidl/Typelist.pm | 45 ++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 22 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl') diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 3cbf416488..5839b042d3 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -37,7 +37,7 @@ $VERSION = '0.01'; @EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString); use strict; -use Parse::Pidl::Typelist qw(hasType getType); +use Parse::Pidl::Typelist qw(hasType getType expandAlias); use Parse::Pidl::Util qw(has_property property_matches); # Alignment of the built-in scalar types @@ -364,6 +364,8 @@ sub ParseElement($) { my $e = shift; + $e->{TYPE} = expandAlias($e->{TYPE}); + return { NAME => $e->{NAME}, TYPE => $e->{TYPE}, @@ -549,7 +551,7 @@ sub ParseFunction($$$) } if ($d->{RETURN_TYPE} ne "void") { - $rettype = $d->{RETURN_TYPE}; + $rettype = expandAlias($d->{RETURN_TYPE}); } my $async = 0; diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index ff8f18ee48..10a1e8136f 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -7,7 +7,7 @@ package Parse::Pidl::Typelist; require Exporter; @ISA = qw(Exporter); -@EXPORT_OK = qw(hasType getType mapType scalar_is_reference); +@EXPORT_OK = qw(hasType getType mapType scalar_is_reference expandAlias); use vars qw($VERSION); $VERSION = '0.01'; @@ -72,6 +72,29 @@ my %scalars = ( "ipv4address" => "const char *", ); +my %aliases = ( + "error_status_t" => "uint32", + "boolean8" => "uint8", + "boolean32" => "uint32", + "DWORD" => "uint32", + "int" => "int32", + "WORD" => "uint16", + "char" => "uint8", + "long" => "int32", + "short" => "int16", + "HYPER_T" => "hyper", + "HRESULT" => "COMRESULT", +); + +sub expandAlias($) +{ + my $name = shift; + + return $aliases{$name} if defined($aliases{$name}); + + return $name; +} + # map from a IDL type to a C header type sub mapScalarType($) { @@ -148,24 +171,6 @@ sub RegisterScalars() } } -my %aliases = ( - "DWORD" => "uint32", - "int" => "int32", - "WORD" => "uint16", - "char" => "uint8", - "long" => "int32", - "short" => "int16", - "HYPER_T" => "hyper", - "HRESULT" => "COMRESULT", -); - -sub RegisterAliases() -{ - foreach (keys %aliases) { - $typedefs{$_} = $typedefs{$aliases{$_}}; - } -} - sub enum_type_fn($) { my $enum = shift; @@ -196,6 +201,7 @@ sub mapType($) my $t = shift; return "void" unless defined($t); my $dt; + $t = expandAlias($t); unless ($dt or ($dt = getType($t))) { # Best guess @@ -237,6 +243,5 @@ sub LoadIdl($) } RegisterScalars(); -RegisterAliases(); 1; -- cgit