From 6ec1278d16a34973dae42e51cd089d9411e25467 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 8 Dec 2001 21:43:22 +0000 Subject: Reinvented has_properties() function lost after HD crash. )-: Fixed up handling of pointer to scalar type. (This used to be commit eb3dbe113f9f4e755436caa974394e73a285cb03) --- source4/build/pidl/eparser.pm | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'source4/build') diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm index f0e53961dd..a2ad3c2d0e 100644 --- a/source4/build/pidl/eparser.pm +++ b/source4/build/pidl/eparser.pm @@ -24,6 +24,25 @@ sub is_scalar_type($) return 0; } +sub has_property($$) +{ + my($props) = shift; + my($p) = shift; + + foreach my $d (@{$props}) { + if (ref($d) ne "HASH") { + return 1, if ($d eq $p); + return 1, if ($d eq "in,out" && ($p eq "in" || $p eq "out")); + } else { + foreach my $k (keys %{$d}) { + $res .= "[$k($d->{$k})] "; + } + } + } + + return 0; +} + ##################################################################### # parse a properties list sub ParseProperties($) @@ -63,11 +82,9 @@ sub ParseElement($$) # Arg is a policy handle - foreach my $prop (@{$elt->{PROPERTIES}}) { - if ($prop =~ /context_handle/) { - $res .= "\toffset = prs_policy_hnd(tvb, offset, pinfo, tree);\n"; - return; - } + if (has_property($elt->{PROPERTIES}, "context_handle")) { + $res .= "\toffset = prs_policy_hnd(tvb, offset, pinfo, tree);\n"; + return; } # Parse type @@ -89,9 +106,9 @@ sub ParseElement($$) } else { - # Scalars are not buffers + # Scalars are not buffers, except if they are pointed to - if (!is_scalar_type($elt->{TYPE})) { + if (!is_scalar_type($elt->{TYPE}) || $elt->{POINTERS}) { # If we have a pointer, check it @@ -234,10 +251,8 @@ sub ParseFunctionArg($$) my($arg) = shift; my($io) = shift; # "in" or "out" - if (@{$arg->{PROPERTIES}}[0] =~ /$io/) { - my $is_pol = 0; - - ParseElement($arg, "scalars"); + if (has_property($arg->{PROPERTIES}, $io)) { + ParseElement($arg, "scalars|buffers"); } } -- cgit