diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-03-06 17:02:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:10:58 -0500 |
commit | ffae01d432c715961c44e499258ee2a9f7e3d5f1 (patch) | |
tree | 46ba7f1e6fdfca93581c9426c0ab68068b1d1963 /source4/build/pidl/validator.pm | |
parent | 5658167806a6fbe70288a22b0304a3cfd773c44f (diff) | |
download | samba-ffae01d432c715961c44e499258ee2a9f7e3d5f1.tar.gz samba-ffae01d432c715961c44e499258ee2a9f7e3d5f1.tar.bz2 samba-ffae01d432c715961c44e499258ee2a9f7e3d5f1.zip |
r5672: Use switch_type() and the token storage mechanism for unions:
- Makes union handling less special
- Allows unions in arrays, etc
- Compatible with midl
- Pidl will warn about switch_type() and the type of the switch_is() variable being different
(This used to be commit dc6b4ffc82a191631bc16a4b93a4916a39183ec6)
Diffstat (limited to 'source4/build/pidl/validator.pm')
-rw-r--r-- | source4/build/pidl/validator.pm | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm index 1636a155e3..bbef008ee5 100644 --- a/source4/build/pidl/validator.pm +++ b/source4/build/pidl/validator.pm @@ -45,6 +45,25 @@ sub ValidElement($) fatal(el_name($e) . " : pidl does not support full NDR pointers yet\n"); } + # Check whether switches are used correctly. + if (my $switch = util::has_property($e, "switch_is")) { + my $e2 = util::find_sibling($e, $switch); + my $type = typelist::getType($e->{TYPE}); + + if (defined($type) and $type->{DATA}->{TYPE} ne "UNION") { + fatal(el_name($e) . ": switch_is() used on non-union type $e->{TYPE} which is a $type->{DATA}->{TYPE}"); + } + + if (!util::has_property($type, "nodiscriminant") and defined($e2)) { + my $discriminator_type = util::has_property($type, "switch_type"); + $discriminator_type = "uint32" unless defined ($discriminator_type); + + if ($e2->{TYPE} ne $discriminator_type) { + print el_name($e) . ": Warning: switch_is() is of type $e2->{TYPE}, while discriminator type for union $type->{NAME} is $discriminator_type\n"; + } + } + } + if (util::has_property($e, "size_is") and not defined ($e->{ARRAY_LEN})) { fatal(el_name($e) . " : size_is() on non-array element"); } @@ -53,7 +72,6 @@ sub ValidElement($) fatal(el_name($e) . " : length_is() on non-array element"); } - if (!$e->{POINTERS} && ( util::has_property($e, "ptr") or util::has_property($e, "unique") or @@ -84,6 +102,11 @@ sub ValidStruct($) sub ValidUnion($) { my($union) = shift; + + if (util::has_property($union->{PARENT}, "nodiscriminant") and util::has_property($union->{PARENT}, "switch_type")) { + fatal($union->{PARENT}->{NAME} . ": switch_type() on union without discriminant"); + } + foreach my $e (@{$union->{ELEMENTS}}) { $e->{PARENT} = $union; |