From 94793b80d7fbd6121bb30e36b25e63abe078feee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 25 Dec 2005 17:12:52 +0000 Subject: r12484: Initial work on supporting non-typedeffed types (This used to be commit e7ac6c708dde7afb4c92a8cc4dea7a95b7054e3e) --- source4/pidl/lib/Parse/Pidl/NDR.pm | 69 ++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/NDR.pm') diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index e7b790d1e5..0dd1ab4dd2 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -330,8 +330,9 @@ sub find_largest_alignment($) ##################################################################### # align a type -sub align_type +sub align_type($) { + sub align_type($); my $e = shift; unless (hasType($e)) { @@ -369,9 +370,9 @@ sub ParseElement($) }; } -sub ParseStruct($) +sub ParseStruct($$) { - my $struct = shift; + my ($ndr,$struct) = @_; my @elements = (); my $surrounding = undef; @@ -405,9 +406,9 @@ sub ParseStruct($) }; } -sub ParseUnion($) +sub ParseUnion($$) { - my $e = shift; + my ($ndr,$e) = @_; my @elements = (); my $switch_type = has_property($e, "switch_type"); unless (defined($switch_type)) { $switch_type = "uint32"; } @@ -444,9 +445,9 @@ sub ParseUnion($) }; } -sub ParseEnum($) +sub ParseEnum($$) { - my $e = shift; + my ($ndr,$e) = @_; return { TYPE => "ENUM", @@ -457,9 +458,9 @@ sub ParseEnum($) }; } -sub ParseBitmap($) +sub ParseBitmap($$) { - my $e = shift; + my ($ndr,$e) = @_; return { TYPE => "BITMAP", @@ -470,26 +471,34 @@ sub ParseBitmap($) }; } -sub ParseTypedef($$) +sub ParseType($$) { - my ($ndr,$d) = @_; - my $data; + my ($ndr, $d) = @_; - if ($d->{DATA}->{TYPE} eq "STRUCT" or $d->{DATA}->{TYPE} eq "UNION") { - CheckPointerTypes($d->{DATA}, $ndr->{PROPERTIES}->{pointer_default}); + if ($d->{TYPE} eq "STRUCT" or $d->{TYPE} eq "UNION") { + CheckPointerTypes($d, $ndr->{PROPERTIES}->{pointer_default}); } - if (defined($d->{PROPERTIES}) && !defined($d->{DATA}->{PROPERTIES})) { - $d->{DATA}->{PROPERTIES} = $d->{PROPERTIES}; - } - - $data = { + my $data = { STRUCT => \&ParseStruct, UNION => \&ParseUnion, ENUM => \&ParseEnum, - BITMAP => \&ParseBitmap - }->{$d->{DATA}->{TYPE}}->($d->{DATA}); + BITMAP => \&ParseBitmap, + TYPEDEF => \&ParseTypedef, + }->{$d->{TYPE}}->($ndr, $d); + + return $data; +} + +sub ParseTypedef($$) +{ + my ($ndr,$d) = @_; + if (defined($d->{PROPERTIES}) && !defined($d->{DATA}->{PROPERTIES})) { + $d->{DATA}->{PROPERTIES} = $d->{PROPERTIES}; + } + + my $data = ParseType($ndr, $d->{DATA}); $data->{ALIGN} = align_type($d->{NAME}); return { @@ -563,7 +572,7 @@ sub CheckPointerTypes($$) sub ParseInterface($) { my $idl = shift; - my @typedefs = (); + my @types = (); my @consts = (); my @functions = (); my @endpoints; @@ -582,20 +591,14 @@ sub ParseInterface($) } foreach my $d (@{$idl->{DATA}}) { - if ($d->{TYPE} eq "TYPEDEF") { - push (@typedefs, ParseTypedef($idl, $d)); - } - if ($d->{TYPE} eq "DECLARE") { push (@declares, $d); - } - - if ($d->{TYPE} eq "FUNCTION") { + } elsif ($d->{TYPE} eq "FUNCTION") { push (@functions, ParseFunction($idl, $d, \$opnum)); - } - - if ($d->{TYPE} eq "CONST") { + } elsif ($d->{TYPE} eq "CONST") { push (@consts, ParseConst($idl, $d)); + } else { + push (@types, ParseType($idl, $d)); } } @@ -620,7 +623,7 @@ sub ParseInterface($) PROPERTIES => $idl->{PROPERTIES}, FUNCTIONS => \@functions, CONSTS => \@consts, - TYPEDEFS => \@typedefs, + TYPES => \@types, DECLARES => \@declares, ENDPOINTS => \@endpoints }; -- cgit