1 ###################################################
2 # check that a parsed IDL file is valid
3 # Copyright tridge@samba.org 2003
4 # released under the GNU GPL
10 #####################################################################
11 # signal a fatal validation error
16 die "IDL is not valid\n";
23 if ($e->{PARENT
} && $e->{PARENT
}->{NAME
}) {
24 return "$e->{PARENT}->{NAME}.$e->{NAME}";
27 if ($e->{PARENT
} && $e->{PARENT
}->{PARENT
}->{NAME
}) {
28 return "$e->{PARENT}->{PARENT}->{NAME}.$e->{NAME}";
32 return "$e->{PARENT}->{NAME}.$e->{NAME}";
37 #####################################################################
42 if ($e->{POINTERS
} && $e->{POINTERS
} > 1) {
43 fatal
(el_name
($e) . " : pidl cannot handle multiple pointer levels. Use a sub-structure containing a pointer instead\n");
46 if ($e->{POINTERS
} && $e->{ARRAY_LEN
}) {
47 fatal
(el_name
($e) . " : pidl cannot handle pointers to arrays. Use a substructure instead\n");
51 #####################################################################
57 foreach my $e (@
{$struct->{ELEMENTS
}}) {
58 $e->{PARENT
} = $struct;
64 #####################################################################
69 foreach my $e (@
{$union->{DATA
}}) {
70 $e->{PARENT
} = $union;
75 #####################################################################
80 my $data = $typedef->{DATA
};
82 $data->{PARENT
} = $typedef;
84 if (ref($data) eq "HASH") {
85 if ($data->{TYPE
} eq "STRUCT") {
89 if ($data->{TYPE
} eq "UNION") {
95 #####################################################################
101 foreach my $e (@
{$fn->{DATA
}}) {
103 if (util
::has_property
($e, "ref") && !$e->{POINTERS
}) {
104 fatal
"[ref] variables must be pointers ($fn->{NAME}/$e->{NAME})\n";
110 #####################################################################
111 # parse the interface definitions
112 sub ValidInterface
($)
114 my($interface) = shift;
115 my($data) = $interface->{DATA
};
117 if (util
::has_property
($interface, "object")) {
118 if(util
::has_property
($interface, "version") &&
119 $interface->{PROPERTIES
}->{version
} != 0) {
120 fatal
"Object interfaces must have version 0.0 ($interface->{NAME})\n";
123 if(!defined($interface->{BASE
}) &&
124 not ($interface->{NAME
} eq "IUnknown")) {
125 fatal
"Object interfaces must all derive from IUnknown ($interface->{NAME})\n";
129 foreach my $d (@
{$data}) {
130 ($d->{TYPE
} eq "TYPEDEF") &&
132 ($d->{TYPE
} eq "FUNCTION") &&
138 #####################################################################
139 # parse a parsed IDL into a C header
144 foreach my $x (@
{$idl}) {
145 ($x->{TYPE
} eq "INTERFACE") &&