Author: jelmer Date: 2006-05-16 23:49:31 +0000 (Tue, 16 May 2006) New Revision: 15652
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15652 Log: Fix aliases mechanism (fixes #3710) Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm Changeset: Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm =================================================================== --- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm 2006-05-16 22:25:13 UTC (rev 15651) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm 2006-05-16 23:49:31 UTC (rev 15652) @@ -37,7 +37,7 @@ @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 @@ { my $e = shift; + $e->{TYPE} = expandAlias($e->{TYPE}); + return { NAME => $e->{NAME}, TYPE => $e->{TYPE}, @@ -549,7 +551,7 @@ } if ($d->{RETURN_TYPE} ne "void") { - $rettype = $d->{RETURN_TYPE}; + $rettype = expandAlias($d->{RETURN_TYPE}); } my $async = 0; Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm =================================================================== --- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm 2006-05-16 22:25:13 UTC (rev 15651) +++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Typelist.pm 2006-05-16 23:49:31 UTC (rev 15652) @@ -7,7 +7,7 @@ require Exporter; @ISA = qw(Exporter); [EMAIL PROTECTED] = qw(hasType getType mapType scalar_is_reference); [EMAIL PROTECTED] = qw(hasType getType mapType scalar_is_reference expandAlias); use vars qw($VERSION); $VERSION = '0.01'; @@ -72,6 +72,29 @@ "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 @@ } } -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 @@ 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 @@ } RegisterScalars(); -RegisterAliases(); 1;
