diff options
Diffstat (limited to 'source4/build')
-rwxr-xr-x | source4/build/pidl/pidl.pl | 3 | ||||
-rw-r--r-- | source4/build/pidl/validator.pm | 101 |
2 files changed, 104 insertions, 0 deletions
diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl index 73d2378612..b4710e5756 100755 --- a/source4/build/pidl/pidl.pl +++ b/source4/build/pidl/pidl.pl @@ -18,6 +18,7 @@ use header; use parser; use eparser; use client; +use validator; use util; my($opt_help) = 0; @@ -111,6 +112,8 @@ if ($opt_parse) { my($idl) = IdlParse($idl_file); defined $idl || die "Failed to parse $idl_file"; util::SaveStructure($pidl_file, $idl) || die "Failed to save $pidl_file"; + + IdlValidator::Validate($idl); } if ($opt_dump) { diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm new file mode 100644 index 0000000000..10863872fe --- /dev/null +++ b/source4/build/pidl/validator.pm @@ -0,0 +1,101 @@ +################################################### +# check that a parsed IDL file is valid +# Copyright tridge@samba.org 2003 +# released under the GNU GPL + +package IdlValidator; + +use strict; +use Data::Dumper; + + +##################################################################### +# signal a fatal validation error +sub fatal($) +{ + my $s = shift; + print "$s\n"; + die "IDL is not valid\n"; +} + +##################################################################### +# parse a struct +sub ValidStruct($) +{ + my($struct) = shift; + + foreach my $e (@{$struct->{ELEMENTS}}) { + + } +} + + +##################################################################### +# parse a union +sub ValidUnion($) +{ + my($union) = shift; + foreach my $e (@{$union->{DATA}}) { + } +} + +##################################################################### +# parse a typedef +sub ValidTypedef($) +{ + my($typedef) = shift; + my $data = $typedef->{DATA}; + + if (ref($data) eq "HASH") { + if ($data->{TYPE} eq "STRUCT") { + ValidStruct($data); + } + + if ($data->{TYPE} eq "UNION") { + ValidUnion($data); + } + } +} + +##################################################################### +# parse a function +sub ValidFunction($) +{ + my($fn) = shift; + + foreach my $e (@{$fn->{DATA}}) { + if (util::has_property($e, "ref") && !$e->{POINTERS}) { + fatal "[ref] variables must be pointers ($fn->{NAME}/$e->{NAME})\n"; + } + } +} + +##################################################################### +# parse the interface definitions +sub ValidInterface($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + + foreach my $d (@{$data}) { + ($d->{TYPE} eq "TYPEDEF") && + ValidTypedef($d); + ($d->{TYPE} eq "FUNCTION") && + ValidFunction($d); + } + +} + +##################################################################### +# parse a parsed IDL into a C header +sub Validate($) +{ + my($idl) = shift; + + foreach my $x (@{$idl}) { + ($x->{TYPE} eq "INTERFACE") && + ValidInterface($x); + } +} + +1; |