diff options
author | Tim Potter <tpot@samba.org> | 2004-05-08 23:51:23 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:49 -0500 |
commit | a10936532ee67fbb15d7b1edc9fba68b851f9069 (patch) | |
tree | 49bb393499ad2a83b32978848bf15586cf6971f6 /source4 | |
parent | 35ffc464541366ba1da0a332afae203b68512010 (diff) | |
download | samba-a10936532ee67fbb15d7b1edc9fba68b851f9069.tar.gz samba-a10936532ee67fbb15d7b1edc9fba68b851f9069.tar.bz2 samba-a10936532ee67fbb15d7b1edc9fba68b851f9069.zip |
r589: Fix IDL dump module so --dump and --diff options to pidl.pl work
again. Still a few problems left though.
(This used to be commit e921a5879f8a5a867dce61e684a0010a5dab9472)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/build/pidl/dump.pm | 85 |
1 files changed, 62 insertions, 23 deletions
diff --git a/source4/build/pidl/dump.pm b/source4/build/pidl/dump.pm index ec2002ef10..435866029e 100644 --- a/source4/build/pidl/dump.pm +++ b/source4/build/pidl/dump.pm @@ -3,7 +3,7 @@ # Copyright tridge@samba.org 2000 # released under the GNU GPL -package dump; +package IdlDump; use strict; @@ -14,15 +14,14 @@ my($res); sub DumpProperties($) { my($props) = shift; - foreach my $d (@{$props}) { - if (ref($d) ne "HASH") { - $res .= "[$d] "; - } else { - foreach my $k (keys %{$d}) { - $res .= "[$k($d->{$k})] "; - } + my($res); + + foreach my $d ($props) { + foreach my $k (keys %{$d}) { + $res .= "[$k($d->{$k})] "; } } + return $res; } ##################################################################### @@ -30,8 +29,11 @@ sub DumpProperties($) sub DumpElement($) { my($element) = shift; - (defined $element->{PROPERTIES}) && DumpProperties($element->{PROPERTIES}); - DumpType($element->{TYPE}); + my($res); + + (defined $element->{PROPERTIES}) && + ($res .= DumpProperties($element->{PROPERTIES})); + $res .= DumpType($element->{TYPE}); $res .= " "; if ($element->{POINTERS}) { for (my($i)=0; $i < $element->{POINTERS}; $i++) { @@ -40,6 +42,8 @@ sub DumpElement($) } $res .= "$element->{NAME}"; (defined $element->{ARRAY_LEN}) && ($res .= "[$element->{ARRAY_LEN}]"); + + return $res; } ##################################################################### @@ -47,14 +51,18 @@ sub DumpElement($) sub DumpStruct($) { my($struct) = shift; + my($res); + $res .= "struct {\n"; if (defined $struct->{ELEMENTS}) { foreach my $e (@{$struct->{ELEMENTS}}) { - DumpElement($e); + $res .= DumpElement($e); $res .= ";\n"; } } $res .= "}"; + + return $res; } @@ -63,9 +71,13 @@ sub DumpStruct($) sub DumpUnionElement($) { my($element) = shift; + my($res); + $res .= "[case($element->{CASE})] "; - DumpElement($element->{DATA}); + $res .= DumpElement($element->{DATA}); $res .= ";\n"; + + return $res; } ##################################################################### @@ -73,12 +85,17 @@ sub DumpUnionElement($) sub DumpUnion($) { my($union) = shift; - (defined $union->{PROPERTIES}) && DumpProperties($union->{PROPERTIES}); + my($res); + + (defined $union->{PROPERTIES}) && + ($res .= DumpProperties($union->{PROPERTIES})); $res .= "union {\n"; foreach my $e (@{$union->{DATA}}) { - DumpUnionElement($e); + $res .= DumpUnionElement($e); } $res .= "}"; + + return $res; } ##################################################################### @@ -86,14 +103,18 @@ sub DumpUnion($) sub DumpType($) { my($data) = shift; + my($res); + if (ref($data) eq "HASH") { ($data->{TYPE} eq "STRUCT") && - DumpStruct($data); + ($res .= DumpStruct($data)); ($data->{TYPE} eq "UNION") && - DumpUnion($data); + ($res .= DumpUnion($data)); } else { $res .= "$data"; } + + return $res; } ##################################################################### @@ -101,9 +122,13 @@ sub DumpType($) sub DumpTypedef($) { my($typedef) = shift; + my($res); + $res .= "typedef "; - DumpType($typedef->{DATA}); + $res .= DumpType($typedef->{DATA}); $res .= " $typedef->{NAME};\n\n"; + + return $res; } ##################################################################### @@ -112,13 +137,17 @@ sub DumpFunction($) { my($function) = shift; my($first) = 1; - DumpType($function->{RETURN_TYPE}); + my($res); + + $res .= DumpType($function->{RETURN_TYPE}); $res .= " $function->{NAME}(\n"; for my $d (@{$function->{DATA}}) { $first || ($res .= ",\n"); $first = 0; - DumpElement($d); + $res .= DumpElement($d); } $res .= "\n);\n\n"; + + return $res; } ##################################################################### @@ -128,12 +157,16 @@ sub DumpModuleHeader($) my($header) = shift; my($data) = $header->{DATA}; my($first) = 1; + my($res); + $res .= "[\n"; foreach my $k (keys %{$data}) { $first || ($res .= ",\n"); $first = 0; $res .= "$k($data->{$k})"; } $res .= "\n]\n"; + + return $res; } ##################################################################### @@ -142,14 +175,18 @@ sub DumpInterface($) { my($interface) = shift; my($data) = $interface->{DATA}; + my($res); + $res .= "interface $interface->{NAME}\n{\n"; foreach my $d (@{$data}) { ($d->{TYPE} eq "TYPEDEF") && - DumpTypedef($d); + ($res .= DumpTypedef($d)); ($d->{TYPE} eq "FUNCTION") && - DumpFunction($d); + ($res .= DumpFunction($d)); } $res .= "}\n"; + + return $res; } @@ -158,12 +195,14 @@ sub DumpInterface($) sub Dump($) { my($idl) = shift; + my($res); + $res = "/* Dumped by pidl */\n\n"; foreach my $x (@{$idl}) { ($x->{TYPE} eq "MODULEHEADER") && - DumpModuleHeader($x); + ($res .= DumpModuleHeader($x)); ($x->{TYPE} eq "INTERFACE") && - DumpInterface($x); + ($res .= DumpInterface($x)); } return $res; } |