1 ###################################################
2 # C parser generator for IDL structures
3 # Copyright tridge@samba.org 2000
4 # released under the GNU GPL
12 #####################################################################
13 # dump a properties list
17 foreach my $d (@{$props}) {
18 if (ref($d) ne "HASH") {
21 foreach my $k (keys %{$d}) {
22 $res .= "[$k($d->{$k})] ";
28 #####################################################################
29 # dump a structure element
33 (defined $element->{PROPERTIES}) && DumpProperties($element->{PROPERTIES});
34 DumpType($element->{TYPE});
36 if ($element->{POINTERS}) {
37 for (my($i)=0; $i < $element->{POINTERS}; $i++) {
41 $res .= "$element->{NAME}";
42 (defined $element->{ARRAY_LEN}) && ($res .= "[$element->{ARRAY_LEN}]");
45 #####################################################################
51 if (defined $struct->{ELEMENTS}) {
52 foreach my $e (@{$struct->{ELEMENTS}}) {
61 #####################################################################
62 # dump a union element
63 sub DumpUnionElement($)
66 $res .= "[case($element->{CASE})] ";
67 DumpElement($element->{DATA});
71 #####################################################################
76 (defined $union->{PROPERTIES}) && DumpProperties($union->{PROPERTIES});
78 foreach my $e (@{$union->{DATA}}) {
84 #####################################################################
89 if (ref($data) eq "HASH") {
90 ($data->{TYPE} eq "STRUCT") &&
92 ($data->{TYPE} eq "UNION") &&
99 #####################################################################
103 my($typedef) = shift;
105 DumpType($typedef->{DATA});
106 $res .= " $typedef->{NAME};\n\n";
109 #####################################################################
113 my($function) = shift;
114 $res .= "/* ignoring function $function->{NAME} */\n";
117 #####################################################################
118 # dump the interface definitions
121 my($interface) = shift;
122 my($data) = $interface->{DATA};
123 foreach my $d (@{$data}) {
124 ($d->{TYPE} eq "TYPEDEF") &&
126 ($d->{TYPE} eq "FUNCTION") &&
132 #####################################################################
133 # dump a parsed IDL structure back into an IDL file
137 $res = "/* parser auto-generated by pidl */\n\n";
138 foreach my $x (@{$idl}) {
139 ($x->{TYPE} eq "INTERFACE") &&