1 ###################################################
2 # create C header files for an IDL structure
3 # Copyright tridge@samba.org 2000
4 # released under the GNU GPL
14 for (my($i)=0; $i < $tab_depth; $i++) {
19 #####################################################################
20 # dump a properties list
27 foreach my $d (@{$props}) {
28 if (ref($d) ne "HASH") {
29 $res .= "/* [$d] */ ";
31 foreach my $k (keys %{$d}) {
32 $res .= "/* [$k($d->{$k})] */ ";
38 #####################################################################
39 # dump a structure element
44 if (util::has_property($element, "struct_len")) {
45 # a struct_len is an internal artifact - it is put on the
46 # wire but not exposed via the api, which means it does
47 # not appear in the header file
52 (defined $element->{PROPERTIES}) && DumpProperties($element->{PROPERTIES});
54 DumpType($element->{TYPE}, "");
56 if ($element->{POINTERS}) {
57 my($n) = $element->{POINTERS};
58 for (my($i)=$n; $i > 0; $i--) {
62 $res .= "$element->{NAME}";
63 (defined $element->{ARRAY_LEN}) && ($res .= "[$element->{ARRAY_LEN}]");
67 #####################################################################
73 $res .= "struct $name {\n";
75 if (defined $struct->{ELEMENTS}) {
76 foreach my $e (@{$struct->{ELEMENTS}}) {
85 #####################################################################
86 # dump a union element
87 sub DumpUnionElement($)
90 $res .= "/* [case($element->{CASE})] */ ";
91 DumpElement($element->{DATA});
94 #####################################################################
100 (defined $union->{PROPERTIES}) && DumpProperties($union->{PROPERTIES});
101 $res .= "union $name {\n";
102 foreach my $e (@{$union->{DATA}}) {
103 DumpUnionElement($e);
108 #####################################################################
114 if (ref($data) eq "HASH") {
115 ($data->{TYPE} eq "STRUCT") &&
116 DumpStruct($data, $name);
117 ($data->{TYPE} eq "UNION") &&
118 DumpUnion($data, $name);
121 if ($data =~ "unistr") {
122 $res .= "const char";
123 } elsif (util::is_scalar_type($data)) {
126 $res .= "struct $data";
130 #####################################################################
134 my($typedef) = shift;
135 DumpType($typedef->{DATA}, $typedef->{NAME});
139 #####################################################################
141 sub DumpFunctionInOut($$)
145 foreach my $e (@{$fn->{DATA}}) {
146 if (util::has_property($e, $prop)) {
153 #####################################################################
158 $res .= "struct $fn->{NAME} {\n";
161 $res .= "struct {\n";
163 DumpFunctionInOut($fn, "in");
168 $res .= "struct {\n";
170 DumpFunctionInOut($fn, "out");
171 if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") {
173 $res .= "$fn->{RETURN_TYPE} result;\n";
177 $res .= "} out;\n\n";
182 #####################################################################
183 # dump the interface definitions
186 my($interface) = shift;
187 my($data) = $interface->{DATA};
188 foreach my $d (@{$data}) {
189 ($d->{TYPE} eq "TYPEDEF") &&
191 ($d->{TYPE} eq "FUNCTION") &&
197 foreach my $d (@{$data}) {
198 if ($d->{TYPE} eq "FUNCTION") {
199 $u_name = uc $d->{NAME};
200 $res .= "#define DCERPC_$u_name $count\n";
207 #####################################################################
208 # dump a parsed IDL structure back into an IDL file
214 $res = "/* header auto-generated by pidl */\n\n";
215 foreach my $x (@{$idl}) {
216 ($x->{TYPE} eq "INTERFACE") &&