diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-22 12:25:20 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-22 12:25:20 +0000 |
commit | 277322b9d4b9d009782f1a47baf09ee4033c8328 (patch) | |
tree | 934b8b7b8921f4c691be02324f2931a3c0a1b0df /source4/build/pidl/validator.pm | |
parent | be77d9c60d17e0ef2ed0b51ea0814c42a41a40a3 (diff) | |
download | samba-277322b9d4b9d009782f1a47baf09ee4033c8328.tar.gz samba-277322b9d4b9d009782f1a47baf09ee4033c8328.tar.bz2 samba-277322b9d4b9d009782f1a47baf09ee4033c8328.zip |
added the beginnings of an IDL validator, to give clearer errors when
IDL is not valid
(This used to be commit c1b708708e262350d697829d444d0fb6a981a80f)
Diffstat (limited to 'source4/build/pidl/validator.pm')
-rw-r--r-- | source4/build/pidl/validator.pm | 101 |
1 files changed, 101 insertions, 0 deletions
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; |