From: Stefan Metzmacher Date: Mon, 28 Mar 2005 18:28:16 +0000 (+0000) Subject: r6101: only allow properties we know about, that helps to catch typos! X-Git-Tag: samba-4.0.0alpha6~801^3~11309 X-Git-Url: http://git.samba.org/samba.git/?p=bbaumbach%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=e760bd37b2f3fd135de429e640942ae7aecc7c91 r6101: only allow properties we know about, that helps to catch typos! what does length_of() and id() do? metze (This used to be commit 55963934db51fadb1340c7a2ec275aa24151dd14) --- diff --git a/source4/build/pidl/validator.pm b/source4/build/pidl/validator.pm index d3f3cbe1e72..7bd82f15069 100644 --- a/source4/build/pidl/validator.pm +++ b/source4/build/pidl/validator.pm @@ -35,12 +35,99 @@ sub el_name($) return $e->{NAME}; } +my %property_list = ( + # interface + "helpstring" => {}, + "version" => {}, + "uuid" => {}, + "endpoint" => {}, + "pointer_default" => {}, + "depends" => {}, + "authservice" => {}, + + # dcom + "object" => {}, + "local" => {}, + "iid_is" => {}, + "call_as" => {}, + "iid_is" => {}, + "idempotent" => {}, + + # function + "id" => {},# what is that? --metze + "in" => {}, + "out" => {}, + + # pointer + "ref" => {}, + "ptr" => {}, + "unique" => {}, + "relative" => {}, + + # ndr_size + "gensize" => {}, + "value" => {}, + "flag" => {}, + + # generic + "public" => {}, + "nopush" => {}, + "nopull" => {}, + "noprint" => {}, + + # union + "switch_is" => {}, + "switch_type" => {}, + "nodiscriminant" => {}, + "case" => {}, + "default" => {}, + + # subcontext + "subcontext" => {}, + "subcontext_size" => {}, + "compression" => {}, + + # enum + "enum8bit" => {}, + "enum16bit" => {}, + "v1_enum" => {}, + + # bitmap + "bitmap8bit" => {}, + "bitmap16bit" => {}, + "bitmap32bit" => {}, + "bitmap64bit" => {}, + + # array + "range" => {}, + "size_is" => {}, + "length_is" => {}, + "length_of" => {}, # what is that? --metze +); + +##################################################################### +# check for unknown properties +sub ValidProperties($) +{ + my $e = shift; + + return unless defined $e->{PROPERTIES}; + + foreach my $key (keys %{$e->{PROPERTIES}}) { + if (not defined $property_list{$key}) { + fatal(el_name($e) . ": unknown property '$key'\n"); + } + } +} + ##################################################################### # parse a struct sub ValidElement($) { my $e = shift; - + + ValidProperties($e); + if (util::has_property($e, "ptr")) { fatal(el_name($e) . " : pidl does not support full NDR pointers yet\n"); } @@ -95,6 +182,8 @@ sub ValidStruct($) { my($struct) = shift; + ValidProperties($struct); + foreach my $e (@{$struct->{ELEMENTS}}) { $e->{PARENT} = $struct; ValidElement($e); @@ -107,6 +196,8 @@ sub ValidUnion($) { my($union) = shift; + ValidProperties($union); + 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"); } @@ -140,6 +231,8 @@ sub ValidTypedef($) my($typedef) = shift; my $data = $typedef->{DATA}; + ValidProperties($typedef); + $data->{PARENT} = $typedef; if (ref($data) eq "HASH") { @@ -159,6 +252,8 @@ sub ValidFunction($) { my($fn) = shift; + ValidProperties($fn); + foreach my $e (@{$fn->{ELEMENTS}}) { $e->{PARENT} = $fn; if (util::has_property($e, "ref") && !$e->{POINTERS}) { @@ -175,6 +270,8 @@ sub ValidInterface($) my($interface) = shift; my($data) = $interface->{DATA}; + ValidProperties($interface); + if (util::has_property($interface, "pointer_default") && $interface->{PROPERTIES}->{pointer_default} eq "ptr") { fatal "Full pointers are not supported yet\n";