From: Joseph Sutton Date: Thu, 9 Nov 2023 01:08:19 +0000 (+1300) Subject: pidl: Remove trailing whitespace X-Git-Tag: talloc-2.4.2~658 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddb98e7d611f7c3160af4ea54bb6cf6bdf1ad0a3;p=thirdparty%2Fsamba.git pidl: Remove trailing whitespace Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm index 48fc2cb20c8..1f95cdfd739 100644 --- a/pidl/lib/Parse/Pidl/NDR.pm +++ b/pidl/lib/Parse/Pidl/NDR.pm @@ -198,7 +198,7 @@ sub GetElementLevelTable($$$) $length = $size; } - if ($e == $e->{PARENT}->{ELEMENTS}[-1] + if ($e == $e->{PARENT}->{ELEMENTS}[-1] and $e->{PARENT}->{TYPE} ne "FUNCTION") { $is_surrounding = 1; } @@ -257,7 +257,7 @@ sub GetElementLevelTable($$$) $pt = $pointer_default; } - push (@$order, { + push (@$order, { TYPE => "POINTER", POINTER_TYPE => $pt, POINTER_INDEX => $pointer_idx, @@ -265,13 +265,13 @@ sub GetElementLevelTable($$$) LEVEL => $level }); - warning($e, "top-level \[out\] pointer `$e->{NAME}' is not a \[ref\] pointer") + warning($e, "top-level \[out\] pointer `$e->{NAME}' is not a \[ref\] pointer") if ($i == 1 and $pt ne "ref" and - $e->{PARENT}->{TYPE} eq "FUNCTION" and + $e->{PARENT}->{TYPE} eq "FUNCTION" and not has_property($e, "in")); $pointer_idx++; - + # everything that follows will be deferred $is_deferred = 1 if ($level ne "TOP"); @@ -288,9 +288,9 @@ sub GetElementLevelTable($$$) $array_length = $array_size; $is_varying =0; } - } - - if (scalar(@size_is) == 0 and has_property($e, "string") and + } + + if (scalar(@size_is) == 0 and has_property($e, "string") and $i == $e->{POINTERS}) { $is_string = 1; $is_varying = $is_conformant = has_property($e, "noheader")?0:1; @@ -312,7 +312,7 @@ sub GetElementLevelTable($$$) }); $is_deferred = 0; - } + } } if ($is_pipe) { @@ -331,10 +331,10 @@ sub GetElementLevelTable($$$) if (defined(has_property($e, "subcontext"))) { my $hdr_size = has_property($e, "subcontext"); my $subsize = has_property($e, "subcontext_size"); - if (not defined($subsize)) { - $subsize = -1; + if (not defined($subsize)) { + $subsize = -1; } - + push (@$order, { TYPE => "SUBCONTEXT", HEADER_SIZE => $hdr_size, @@ -346,7 +346,7 @@ sub GetElementLevelTable($$$) if (my $switch = has_property($e, "switch_is")) { push (@$order, { - TYPE => "SWITCH", + TYPE => "SWITCH", SWITCH_IS => $switch, IS_DEFERRED => $is_deferred }); @@ -395,7 +395,7 @@ sub GetTypedefLevelTable($$$$) } ##################################################################### -# see if a type contains any deferred data +# see if a type contains any deferred data sub can_contain_deferred { sub can_contain_deferred; @@ -438,7 +438,7 @@ sub pointer_type($) my $e = shift; return undef unless $e->{POINTERS}; - + return "ref" if (has_property($e, "ref")); return "full" if (has_property($e, "ptr")); return "sptr" if (has_property($e, "sptr")); @@ -464,7 +464,7 @@ sub find_largest_alignment # the NDR layer translates this into # an alignment of 4 for NDR and 8 for NDR64 $a = 5; - } elsif (has_property($e, "subcontext")) { + } elsif (has_property($e, "subcontext")) { $a = 1; } elsif (has_property($e, "transmit_as")) { $a = align_type($e->{PROPERTIES}->{transmit_as}, @@ -497,7 +497,7 @@ sub align_type return 0 if ($e eq "EMPTY"); unless (hasType($e)) { - # it must be an external type - all we can do is guess + # it must be an external type - all we can do is guess # warning($e, "assuming alignment of unknown type '$e' is 4"); return 4; } @@ -592,10 +592,10 @@ sub ParseStruct($$$) CheckPointerTypes($struct, $pointer_default); - foreach my $x (@{$struct->{ELEMENTS}}) + foreach my $x (@{$struct->{ELEMENTS}}) { my $e = ParseElement($x, $pointer_default, $ms_union); - if ($x != $struct->{ELEMENTS}[-1] and + if ($x != $struct->{ELEMENTS}[-1] and $e->{LEVELS}[0]->{IS_SURROUNDING}) { fatal($x, "conformant member not at end of struct"); } @@ -617,7 +617,7 @@ sub ParseStruct($$$) if ($struct->{NAME}) { $align = align_type($struct->{NAME}); } - + return { TYPE => "STRUCT", NAME => $struct->{NAME}, @@ -654,7 +654,7 @@ sub ParseUnion($$) CheckPointerTypes($e, $pointer_default); - foreach my $x (@{$e->{ELEMENTS}}) + foreach my $x (@{$e->{ELEMENTS}}) { my $t; if ($x->{TYPE} eq "EMPTY") { @@ -846,7 +846,7 @@ sub ParseFunction($$$$) if ($d->{RETURN_TYPE} ne "void") { $rettype = expandAlias($d->{RETURN_TYPE}); } - + return { NAME => $d->{NAME}, TYPE => "FUNCTION", @@ -938,7 +938,7 @@ sub ParseInterface($) $version = "0.0"; - if(defined $idl->{PROPERTIES}->{version}) { + if(defined $idl->{PROPERTIES}->{version}) { my @if_version = split(/\./, $idl->{PROPERTIES}->{version}); if ($if_version[0] == $idl->{PROPERTIES}->{version}) { $version = $idl->{PROPERTIES}->{version}; @@ -954,7 +954,7 @@ sub ParseInterface($) @endpoints = split /,/, $idl->{PROPERTIES}->{endpoint}; } - return { + return { NAME => $idl->{NAME}, UUID => lc(has_property($idl, "uuid") // ''), VERSION => $version, @@ -978,7 +978,7 @@ sub Parse($) return undef unless (defined($idl)); Parse::Pidl::NDR::Validate($idl); - + my @ndr = (); foreach (@{$idl}) { @@ -1050,10 +1050,10 @@ sub ContainsDeferred($$) while ($l = GetNextLevel($e,$l)) { - return 1 if ($l->{IS_DEFERRED}); + return 1 if ($l->{IS_DEFERRED}); return 1 if ($l->{CONTAINS_DEFERRED}); - } - + } + return 0; } @@ -1306,7 +1306,7 @@ sub ValidElement($) has_property($e, "relative") or has_property($e, "relative_short") or has_property($e, "ref"))) { - fatal($e, el_name($e) . " : pointer properties on non-pointer element\n"); + fatal($e, el_name($e) . " : pointer properties on non-pointer element\n"); } } @@ -1352,7 +1352,7 @@ sub ValidUnion($) ValidProperties($union,"UNION"); - if (has_property($union->{PARENT}, "nodiscriminant") and + if (has_property($union->{PARENT}, "nodiscriminant") and has_property($union->{PARENT}, "switch_type")) { fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type(" . $union->{PARENT}->{PROPERTIES}->{switch_type} . ") on union without discriminant"); } @@ -1362,12 +1362,12 @@ sub ValidUnion($) foreach my $e (@{$union->{ELEMENTS}}) { $e->{PARENT} = $union; - if (defined($e->{PROPERTIES}->{default}) and + if (defined($e->{PROPERTIES}->{default}) and defined($e->{PROPERTIES}->{case})) { fatal($e, "Union member $e->{NAME} can not have both default and case properties!"); } - - unless (defined ($e->{PROPERTIES}->{default}) or + + unless (defined ($e->{PROPERTIES}->{default}) or defined ($e->{PROPERTIES}->{case})) { fatal($e, "Union member $e->{NAME} must have default or case property"); } @@ -1440,7 +1440,7 @@ sub ValidType($) { my ($t) = @_; - { + { TYPEDEF => \&ValidTypedef, STRUCT => \&ValidStruct, UNION => \&ValidUnion, @@ -1464,29 +1464,29 @@ sub ValidInterface($) ValidProperties($interface,"INTERFACE"); if (has_property($interface, "pointer_default")) { - if (not grep (/$interface->{PROPERTIES}->{pointer_default}/, + if (not grep (/$interface->{PROPERTIES}->{pointer_default}/, ("ref", "unique", "ptr"))) { fatal($interface, "Unknown default pointer type `$interface->{PROPERTIES}->{pointer_default}'"); } } if (has_property($interface, "object")) { - if (has_property($interface, "version") && + if (has_property($interface, "version") && $interface->{PROPERTIES}->{version} != 0) { fatal($interface, "Object interfaces must have version 0.0 ($interface->{NAME})"); } - if (!defined($interface->{BASE}) && + if (!defined($interface->{BASE}) && not ($interface->{NAME} eq "IUnknown")) { fatal($interface, "Object interfaces must all derive from IUnknown ($interface->{NAME})"); } } - + foreach my $d (@{$data}) { ($d->{TYPE} eq "FUNCTION") && ValidFunction($d); - ($d->{TYPE} eq "TYPEDEF" or + ($d->{TYPE} eq "TYPEDEF" or $d->{TYPE} eq "STRUCT" or - $d->{TYPE} eq "UNION" or + $d->{TYPE} eq "UNION" or $d->{TYPE} eq "ENUM" or $d->{TYPE} eq "BITMAP" or $d->{TYPE} eq "PIPE") && ValidType($d); @@ -1501,7 +1501,7 @@ sub Validate($) my($idl) = shift; foreach my $x (@{$idl}) { - ($x->{TYPE} eq "INTERFACE") && + ($x->{TYPE} eq "INTERFACE") && ValidInterface($x); ($x->{TYPE} eq "IMPORTLIB") && fatal($x, "importlib() not supported"); diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm index 65720111a0e..a0b002f6724 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -494,7 +494,7 @@ sub EnvSubstituteValue($$) # Substitute the value() values in the env foreach my $e (@{$s->{ELEMENTS}}) { next unless (defined(my $v = has_property($e, "value"))); - + $env->{$e->{NAME}} = ParseExpr($v, $env, $e); } diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index d08497ee3ce..799b467bc28 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -57,7 +57,7 @@ sub append_prefix($$) $pointers++; } elsif ($l->{TYPE} eq "ARRAY") { $arrays++; - if (($pointers == 0) and + if (($pointers == 0) and (not $l->{IS_FIXED}) and (not $l->{IS_INLINE})) { return get_value_of($var_name); @@ -68,7 +68,7 @@ sub append_prefix($$) } } } - + return $var_name; } @@ -102,8 +102,8 @@ sub is_public_struct } #################################### -# defer() is like pidl(), but adds to -# a deferred buffer which is then added to the +# defer() is like pidl(), but adds to +# a deferred buffer which is then added to the # output buffer at the end of the structure/union/function # This is needed to cope with code that must be pushed back # to the end of a block of elements @@ -235,7 +235,7 @@ sub check_fully_dereferenced($$) last; } } - + return($origvar) unless (defined($var)); my $e; foreach (@{$element->{PARENT}->{ELEMENTS}}) { @@ -258,7 +258,7 @@ sub check_fully_dereferenced($$) warning($element->{ORIGINAL}, "Got pointer for `$e->{NAME}', expected fully dereferenced variable") if ($nump > length($ptr)); return ($origvar); } -} +} sub check_null_pointer($$$$) { @@ -279,7 +279,7 @@ sub check_null_pointer($$$$) last; } } - + if (defined($var)) { my $e; # lookup ptr in $e @@ -295,7 +295,7 @@ sub check_null_pointer($$$$) # See if pointer at pointer level $level # needs to be checked. foreach my $l (@{$e->{LEVELS}}) { - if ($l->{TYPE} eq "POINTER" and + if ($l->{TYPE} eq "POINTER" and $l->{POINTER_INDEX} == length($ptr)) { # No need to check ref pointers $check = ($l->{POINTER_TYPE} ne "ref"); @@ -310,7 +310,7 @@ sub check_null_pointer($$$$) warning($element, "unknown dereferenced expression `$expandedvar'"); $check = 1; } - + $print_fn->("if ($ptr$expandedvar == NULL) $return") if $check; } } @@ -465,7 +465,7 @@ sub ParseArrayPullHeader($$$$$$) if ($l->{IS_VARYING} and (defined($l->{LENGTH_IS}) or not $l->{IS_ZERO_TERMINATED})) { $self->defer("if ($var_name) {"); $self->defer_indent; - my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, + my $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->defer(shift); }, "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for length_is()\");"), check_fully_dereferenced($e, $env)); @@ -645,7 +645,7 @@ sub ParseElementPushLevel } elsif ($l->{TYPE} eq "POINTER") { $self->ParsePtrPush($e, $l, $ndr, $var_name); } elsif ($l->{TYPE} eq "ARRAY") { - my $length = $self->ParseArrayPushHeader($e, $l, $ndr, $var_name, $env); + my $length = $self->ParseArrayPushHeader($e, $l, $ndr, $var_name, $env); my $nl = GetNextLevel($e, $l); @@ -660,7 +660,7 @@ sub ParseElementPushLevel } elsif (has_fast_array($e,$l)) { $self->pidl("NDR_CHECK(ndr_push_array_$nl->{DATA_TYPE}($ndr, $ndr_flags, $var_name, $length));"); return; - } + } } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPush($e, $l, $ndr, $var_name, $primitives, $deferred); } elsif ($l->{TYPE} eq "TYPEDEF") { @@ -906,13 +906,13 @@ sub ParseElementPrint($$$$$) my $length; if ($l->{IS_CONFORMANT} or $l->{IS_VARYING}) { - $var_name = get_pointer_to($var_name); + $var_name = get_pointer_to($var_name); } - + if ($l->{IS_ZERO_TERMINATED} and not defined($l->{LENGTH_IS})) { $length = "ndr_string_length($var_name, sizeof(*$var_name))"; } else { - $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, + $length = ParseExprExt($l->{LENGTH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return;"), check_fully_dereferenced($e, $env)); } @@ -936,10 +936,10 @@ sub ParseElementPrint($$$$$) } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPrint($e, $l, $ndr, $var_name); } elsif ($l->{TYPE} eq "SWITCH") { - my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, + my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return;"), check_fully_dereferenced($e, $env)); $self->pidl("ndr_print_set_switch_value($ndr, " . get_pointer_to($var_name) . ", $switch_var);"); - } + } } foreach my $l (reverse @{$e->{LEVELS}}) { @@ -976,7 +976,7 @@ sub ParseElementPrint($$$$$) sub ParseSwitchPull($$$$$$) { my($self,$e,$l,$ndr,$var_name,$env) = @_; - my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, + my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return ndr_pull_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"), check_fully_dereferenced($e, $env)); @@ -990,7 +990,7 @@ sub ParseSwitchPull($$$$$$) sub ParseSwitchPush($$$$$$) { my($self,$e,$l,$ndr,$var_name,$env) = @_; - my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, + my $switch_var = ParseExprExt($l->{SWITCH_IS}, $env, $e->{ORIGINAL}, check_null_pointer($e, $env, sub { $self->pidl(shift); }, "return ndr_push_error($ndr, NDR_ERR_INVALID_POINTER, \"NULL Pointer for switch_is()\");"), check_fully_dereferenced($e, $env)); @@ -1084,14 +1084,14 @@ sub CalcNdrFlags($$$) my $scalars = 0; my $buffers = 0; - # Add NDR_SCALARS if this one is deferred + # Add NDR_SCALARS if this one is deferred # and deferreds may be pushed $scalars = 1 if ($l->{IS_DEFERRED} and $deferred); - # Add NDR_SCALARS if this one is not deferred and + # Add NDR_SCALARS if this one is not deferred and # primitives may be pushed $scalars = 1 if (!$l->{IS_DEFERRED} and $primitives); - + # Add NDR_BUFFERS if this one contains deferred stuff # and deferreds may be pushed $buffers = 1 if ($l->{CONTAINS_DEFERRED} and $deferred); @@ -1255,7 +1255,7 @@ sub ParseElementPullLevel $self->deindent; $self->pidl("}"); } - } elsif ($l->{TYPE} eq "ARRAY" and + } elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and not is_charset_array($e, $l)) { my $length = $array_length; my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; @@ -1357,21 +1357,21 @@ sub ParsePtrPull($$$$$) my $nl = GetNextLevel($e, $l); my $next_is_array = ($nl->{TYPE} eq "ARRAY"); - my $next_is_string = (($nl->{TYPE} eq "DATA") and + my $next_is_string = (($nl->{TYPE} eq "DATA") and ($nl->{DATA_TYPE} eq "string")); if ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP") { if (!$next_is_array and !$next_is_string) { $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); - $self->pidl("\tNDR_PULL_ALLOC($ndr, $var_name);"); + $self->pidl("\tNDR_PULL_ALLOC($ndr, $var_name);"); $self->pidl("}"); } return; } elsif ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "EMBEDDED") { $self->pidl("NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));"); - } elsif (($l->{POINTER_TYPE} eq "unique") or + } elsif (($l->{POINTER_TYPE} eq "unique") or ($l->{POINTER_TYPE} eq "relative") or ($l->{POINTER_TYPE} eq "full")) { $self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));"); @@ -1393,10 +1393,10 @@ sub ParsePtrPull($$$$$) # allocation, as we forced it to NULL just above, and # we may not know the declared type anyway. } else { - # Don't do this for arrays, they're allocated at the actual level + # Don't do this for arrays, they're allocated at the actual level # of the array - unless ($next_is_array or $next_is_string) { - $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);"); + unless ($next_is_array or $next_is_string) { + $self->pidl("NDR_PULL_ALLOC($ndr, $var_name);"); } else { # FIXME: Yes, this is nasty. # We allocate an array twice @@ -1448,10 +1448,10 @@ sub ParseStructPushPrimitives($$$$$) if (defined($struct->{SURROUNDING_ELEMENT})) { my $e = $struct->{SURROUNDING_ELEMENT}; - if (defined($e->{LEVELS}[0]) and + if (defined($e->{LEVELS}[0]) and $e->{LEVELS}[0]->{TYPE} eq "ARRAY") { my $size; - + if ($e->{LEVELS}[0]->{IS_ZERO_TERMINATED}) { if (has_property($e, "charset")) { $size = "ndr_charset_length($varname->$e->{NAME}, CH_$e->{PROPERTIES}->{charset})"; @@ -1500,7 +1500,7 @@ sub ParseStructPushDeferred($$$$) sub ParseStructPush($$$$) { my ($self, $struct, $ndr, $varname) = @_; - + return unless defined($struct->{ELEMENTS}); my $env = GenerateStructEnv($struct, $varname); @@ -1580,7 +1580,7 @@ sub ParseEnumPrint($$$$$) $self->deindent; $self->pidl("}"); - + $self->pidl("ndr_print_enum($ndr, name, \"$enum->{TYPE}\", val, $varname);"); $self->end_flags($enum, $ndr); @@ -1589,7 +1589,7 @@ sub ParseEnumPrint($$$$$) sub DeclEnum($$$$) { my ($e,$t,$name,$varname) = @_; - return "enum $name " . + return "enum $name " . ($t eq "pull"?"*":"") . $varname; } @@ -1672,7 +1672,7 @@ sub ParseBitmapPrint($$$$$) sub DeclBitmap($$$$) { my ($e,$t,$name,$varname) = @_; - return mapTypeName(Parse::Pidl::Typelist::bitmap_type_fn($e)) . + return mapTypeName(Parse::Pidl::Typelist::bitmap_type_fn($e)) . ($t eq "pull"?" *":" ") . $varname; } @@ -1701,7 +1701,7 @@ sub ParseStructPrint($$$$$) $self->start_flags($struct, $ndr); $self->pidl("$ndr->depth++;"); - + $self->ParseElementPrint($_, $ndr, $env->{$_->{NAME}}, $env) foreach (@{$struct->{ELEMENTS}}); $self->pidl("$ndr->depth--;"); @@ -1719,7 +1719,7 @@ sub DeclarePtrVariables($$) foreach my $l (@{$e->{LEVELS}}) { my $size = 32; - if ($l->{TYPE} eq "POINTER" and + if ($l->{TYPE} eq "POINTER" and not ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP")) { if ($l->{POINTER_TYPE} eq "relative_short") { $size = 16; @@ -2108,7 +2108,7 @@ sub ParseUnionPullPrimitives($$$$$) } $self->pidl("NDR_CHECK(ndr_pull_$switch_type($ndr, NDR_SCALARS, &_level));"); - $self->pidl("if (_level != level) {"); + $self->pidl("if (_level != level) {"); $self->pidl("\treturn ndr_pull_error($ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %$fmt for $varname at \%s\", ($data_type)_level, __location__);"); $self->pidl("}"); } @@ -2127,7 +2127,7 @@ sub ParseUnionPullPrimitives($$$$$) foreach my $el (@{$e->{ELEMENTS}}) { if ($el->{CASE} eq "default") { $have_default = 1; - } + } $self->pidl("$el->{CASE}: {"); if ($el->{TYPE} ne "EMPTY") { @@ -2162,7 +2162,7 @@ sub ParseUnionPullDeferred($$$$) foreach my $el (@{$e->{ELEMENTS}}) { if ($el->{CASE} eq "default") { $have_default = 1; - } + } $self->pidl("$el->{CASE}:"); if ($el->{TYPE} ne "EMPTY") { @@ -2265,7 +2265,7 @@ $typefamily{UNION} = { SIZE_FN_ARGS => \&ArgsUnionNdrSize, SIZE_FN_BODY => \&ParseUnionNdrSize, }; - + ##################################################################### # parse a typedef - push side sub ParseTypedefPush($$$$) @@ -2313,7 +2313,7 @@ sub ParseTypedefNdrSize($$$$) sub DeclTypedef($$$$) { my ($e, $t, $name, $varname) = @_; - + return $typefamily{$e->{DATA}->{TYPE}}->{DECL}->($e->{DATA}, $t, $name, $varname); } @@ -2467,7 +2467,7 @@ sub ParseFunctionPrint($$) $self->pidl("$ndr->depth--;"); $self->deindent; $self->pidl("}"); - + $self->pidl("if (flags & NDR_OUT) {"); $self->indent; $self->pidl("ndr_print_struct($ndr, \"out\", \"$fn->{NAME}\");"); @@ -2485,7 +2485,7 @@ sub ParseFunctionPrint($$) $self->pidl("$ndr->depth--;"); $self->deindent; $self->pidl("}"); - + $self->pidl("$ndr->depth--;"); $self->deindent; $self->pidl("}"); @@ -2495,7 +2495,7 @@ sub ParseFunctionPrint($$) ##################################################################### # parse a function sub ParseFunctionPush($$) -{ +{ my($self, $fn) = @_; my $ndr = "ndr"; @@ -2506,7 +2506,7 @@ sub ParseFunctionPush($$) $self->pidl("{"); $self->indent; - foreach my $e (@{$fn->{ELEMENTS}}) { + foreach my $e (@{$fn->{ELEMENTS}}) { $self->DeclareArrayVariables($e); } @@ -2555,7 +2555,7 @@ sub ParseFunctionPush($$) if ($fn->{RETURN_TYPE}) { $self->pidl("NDR_CHECK(ndr_push_$fn->{RETURN_TYPE}($ndr, NDR_SCALARS, r->out.result));"); } - + $self->deindent; $self->pidl("}"); $self->pidl("return NDR_ERR_SUCCESS;"); @@ -2569,8 +2569,8 @@ sub AllocateArrayLevel($$$$$$) my ($self,$e,$l,$ndr,$var,$size) = @_; my $pl = GetPrevLevel($e, $l); - if (defined($pl) and - $pl->{TYPE} eq "POINTER" and + if (defined($pl) and + $pl->{TYPE} eq "POINTER" and $pl->{POINTER_TYPE} eq "ref" and not $l->{IS_ZERO_TERMINATED}) { $self->pidl("if ($ndr->flags & LIBNDR_FLAG_REF_ALLOC) {"); @@ -2589,7 +2589,7 @@ sub AllocateArrayLevel($$$$$$) ##################################################################### # parse a function sub ParseFunctionPull($$) -{ +{ my($self,$fn) = @_; my $ndr = "ndr"; @@ -2600,7 +2600,7 @@ sub ParseFunctionPull($$) $self->indent; # declare any internal pointers we need - foreach my $e (@{$fn->{ELEMENTS}}) { + foreach my $e (@{$fn->{ELEMENTS}}) { $self->DeclarePtrVariables($e); $self->DeclareArrayVariables($e, "pull"); } @@ -2641,12 +2641,12 @@ sub ParseFunctionPull($$) foreach my $e (@{$fn->{ELEMENTS}}) { next unless (grep(/out/, @{$e->{DIRECTION}})); - next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and + next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and $e->{LEVELS}[0]->{POINTER_TYPE} eq "ref"); - next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and + next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and ($e->{LEVELS}[1]->{DATA_TYPE} eq "string")); next if ($e->{LEVELS}[1]->{TYPE} eq "PIPE"); - next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY") + next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY") and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED}); if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") { @@ -2669,7 +2669,7 @@ sub ParseFunctionPull($$) } } else { $self->pidl("NDR_PULL_ALLOC($ndr, r->out.$e->{NAME});"); - + if (grep(/in/, @{$e->{DIRECTION}})) { $self->pidl("*r->out.$e->{NAME} = *r->in.$e->{NAME};"); } else { @@ -2681,7 +2681,7 @@ sub ParseFunctionPull($$) $self->add_deferred(); $self->deindent; $self->pidl("}"); - + $self->pidl("if (flags & NDR_OUT) {"); $self->indent; @@ -2909,7 +2909,7 @@ sub FunctionTable($$) $self->pidl("\t$ep, "); } my $endpoint_count = $#{$interface->{ENDPOINTS}}+1; - + $self->pidl("};"); $self->pidl(""); @@ -2972,7 +2972,7 @@ sub HeaderInclude ##################################################################### # generate prototypes and defines for the interface definitions -# FIXME: these prototypes are for the DCE/RPC client functions, not the +# FIXME: these prototypes are for the DCE/RPC client functions, not the # NDR parser and so do not belong here, technically speaking sub HeaderInterface($$$) { @@ -2994,7 +2994,7 @@ sub HeaderInterface($$$) if (defined $interface->{PROPERTIES}->{uuid}) { my $name = uc $interface->{NAME}; - $self->pidl_hdr("#define NDR_$name\_UUID " . + $self->pidl_hdr("#define NDR_$name\_UUID " . Parse::Pidl::Util::make_str(lc($interface->{UUID}))); $self->pidl_hdr("#define NDR_$name\_VERSION $interface->{VERSION}"); @@ -3019,12 +3019,12 @@ sub HeaderInterface($$$) next if has_property($_, "noopnum"); next if grep(/^$_->{NAME}$/,@{$interface->{INHERITED_FUNCTIONS}}); my $u_name = uc $_->{NAME}; - + my $val = sprintf("0x%02x", $count); if (defined($interface->{BASE})) { $val .= " + NDR_" . uc $interface->{BASE} . "_CALL_COUNT"; } - + $self->pidl_hdr("#define NDR_$u_name ($val)"); $self->pidl_hdr(""); @@ -3192,8 +3192,8 @@ sub ParseInterface($$$) ($needed->{TypeFunctionName("ndr_print", $d)}) && $self->ParseTypePrintFunction($d, "r"); # Make sure we don't generate a function twice... - $needed->{TypeFunctionName("ndr_push", $d)} = - $needed->{TypeFunctionName("ndr_pull", $d)} = + $needed->{TypeFunctionName("ndr_push", $d)} = + $needed->{TypeFunctionName("ndr_pull", $d)} = $needed->{TypeFunctionName("ndr_print", $d)} = 0; ($needed->{"ndr_size_$d->{NAME}"}) && $self->ParseTypeNdrSize($d); @@ -3277,7 +3277,7 @@ sub NeededElement($$$) return if ($e->{TYPE} eq "EMPTY"); - return if (ref($e->{TYPE}) eq "HASH" and + return if (ref($e->{TYPE}) eq "HASH" and not defined($e->{TYPE}->{NAME})); my ($t, $rt); @@ -3341,7 +3341,7 @@ sub NeededType($$$) return unless defined($t->{ELEMENTS}); for my $e (@{$t->{ELEMENTS}}) { $e->{PARENT} = $t; - if (has_property($e, "compression")) { + if (has_property($e, "compression")) { $needed->{"compression"} = 1; } NeededElement($e, $req, $needed); @@ -3359,7 +3359,7 @@ sub NeededInterface($$) foreach (reverse @{$interface->{TYPES}}) { if (has_property($_, "public")) { - $needed->{TypeFunctionName("ndr_pull", $_)} = $needed->{TypeFunctionName("ndr_push", $_)} = + $needed->{TypeFunctionName("ndr_pull", $_)} = $needed->{TypeFunctionName("ndr_push", $_)} = $needed->{TypeFunctionName("ndr_print", $_)} = 1; } @@ -3376,7 +3376,7 @@ sub TypeFunctionName($$) { my ($prefix, $t) = @_; - return "$prefix\_$t->{NAME}" if (ref($t) eq "HASH" and + return "$prefix\_$t->{NAME}" if (ref($t) eq "HASH" and $t->{TYPE} eq "TYPEDEF"); return "$prefix\_$t->{TYPE}_$t->{NAME}" if (ref($t) eq "HASH"); return "$prefix\_$t"; diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm index b86312ed54f..f3cb6021847 100644 --- a/pidl/lib/Parse/Pidl/Typelist.pm +++ b/pidl/lib/Parse/Pidl/Typelist.pm @@ -174,7 +174,7 @@ sub hasType($) my $t = shift; if (ref($t) eq "HASH") { return 1 if (not defined($t->{NAME})); - return 1 if (defined($types{$t->{NAME}}) and + return 1 if (defined($types{$t->{NAME}}) and $types{$t->{NAME}}->{TYPE} eq $t->{TYPE}); return 0; } @@ -200,13 +200,13 @@ sub is_scalar($) sub is_scalar($); my $type = shift; - return 1 if (ref($type) eq "HASH" and - ($type->{TYPE} eq "SCALAR" or $type->{TYPE} eq "ENUM" or + return 1 if (ref($type) eq "HASH" and + ($type->{TYPE} eq "SCALAR" or $type->{TYPE} eq "ENUM" or $type->{TYPE} eq "BITMAP")); if (my $dt = getType($type)) { return is_scalar($dt->{DATA}) if ($dt->{TYPE} eq "TYPEDEF"); - return 1 if ($dt->{TYPE} eq "SCALAR" or $dt->{TYPE} eq "ENUM" or + return 1 if ($dt->{TYPE} eq "SCALAR" or $dt->{TYPE} eq "ENUM" or $dt->{TYPE} eq "BITMAP"); }