From a7bc3801f94891880a90b2974dfbadc9e9f8c2ee Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Jan 2007 20:52:12 +0000 Subject: r20567: Print proper errors with filename and line numbers in ParseExpr() (This used to be commit f5dc1b47ecf18068a47f8f68016463ef4a55dc03) --- source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 46 ++++++++++++------------ 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'source4/pidl/lib/Parse/Pidl/Samba4/NDR') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index f104ffbad8..debdc8e308 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -257,7 +257,7 @@ sub EnvSubstituteValue($$) foreach my $e (@{$s->{ELEMENTS}}) { next unless (my $v = has_property($e, "value")); - $env->{$e->{NAME}} = ParseExpr($v, $env); + $env->{$e->{NAME}} = ParseExpr($v, $env, $e); } return $env; @@ -309,8 +309,8 @@ sub ParseArrayPushHeader($$$$$) $size = $length = "ndr_string_length($var_name, sizeof(*$var_name))"; } } else { - $size = ParseExpr($l->{SIZE_IS}, $env); - $length = ParseExpr($l->{LENGTH_IS}, $env); + $size = ParseExpr($l->{SIZE_IS}, $env, $e); + $length = ParseExpr($l->{LENGTH_IS}, $env, $e); } if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) { @@ -339,7 +339,7 @@ sub ParseArrayPullHeader($$$$$) } elsif ($l->{IS_ZERO_TERMINATED}) { # Noheader arrays $length = $size = "ndr_get_string_size($ndr, sizeof(*$var_name))"; } else { - $length = $size = ParseExpr($l->{SIZE_IS}, $env); + $length = $size = ParseExpr($l->{SIZE_IS}, $env, $e); } if ((!$l->{IS_SURROUNDING}) and $l->{IS_CONFORMANT}) { @@ -363,7 +363,7 @@ sub ParseArrayPullHeader($$$$$) } if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) { - my $size = ParseExpr($l->{SIZE_IS}, $env); + my $size = ParseExpr($l->{SIZE_IS}, $env, $e); defer "if ($var_name) {"; defer_indent; check_null_pointer_deferred($size); @@ -373,7 +373,7 @@ sub ParseArrayPullHeader($$$$$) } if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) { - my $length = ParseExpr($l->{LENGTH_IS}, $env); + my $length = ParseExpr($l->{LENGTH_IS}, $env, $e); defer "if ($var_name) {"; defer_indent; check_null_pointer_deferred($length); @@ -404,7 +404,7 @@ sub compression_clen($$$) my $compression = $l->{COMPRESSION}; my ($alg, $clen, $dlen) = split(/ /, $compression); - return ParseExpr($clen, $env); + return ParseExpr($clen, $env, $e); } sub compression_dlen($$$) @@ -413,7 +413,7 @@ sub compression_dlen($$$) my $compression = $l->{COMPRESSION}; my ($alg, $clen, $dlen) = split(/ /, $compression); - return ParseExpr($dlen, $env); + return ParseExpr($dlen, $env, $e); } sub ParseCompressionPushStart($$$$) @@ -474,7 +474,7 @@ sub ParseSubcontextPushStart($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env, $e); pidl "{"; indent; @@ -492,7 +492,7 @@ sub ParseSubcontextPushEnd($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env, $e); if (defined $l->{COMPRESSION}) { ParseCompressionPushEnd($e, $l, $subndr, $env); @@ -507,7 +507,7 @@ sub ParseSubcontextPullStart($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env, $e); pidl "{"; indent; @@ -525,7 +525,7 @@ sub ParseSubcontextPullEnd($$$$) { my ($e,$l,$ndr,$env) = @_; my $subndr = "_ndr_$e->{NAME}"; - my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env); + my $subcontext_size = ParseExpr($l->{SUBCONTEXT_SIZE},$env, $e); if (defined $l->{COMPRESSION}) { ParseCompressionPullEnd($e, $l, $subndr, $env); @@ -590,7 +590,7 @@ sub ParseElementPushLevel } } elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and not is_charset_array($e, $l)) { - my $length = ParseExpr($l->{LENGTH_IS}, $env); + my $length = ParseExpr($l->{LENGTH_IS}, $env, $e); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; $var_name = $var_name . "[$counter]"; @@ -641,7 +641,7 @@ sub ParseElementPush($$$$$$) start_flags($e); if (my $value = has_property($e, "value")) { - $var_name = ParseExpr($value, $env); + $var_name = ParseExpr($value, $env, $e); } ParseElementPushLevel($e, $e->{LEVELS}[0], $ndr, $var_name, $env, $primitives, $deferred); @@ -692,7 +692,7 @@ sub ParseElementPrint($$$) $var_name = append_prefix($e, $var_name); if (my $value = has_property($e, "value")) { - $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env) . ":$var_name"; + $var_name = "(ndr->flags & LIBNDR_PRINT_SET_VALUES)?" . ParseExpr($value,$env, $e) . ":$var_name"; } foreach my $l (@{$e->{LEVELS}}) { @@ -714,7 +714,7 @@ sub ParseElementPrint($$$) if ($l->{IS_ZERO_TERMINATED}) { $length = "ndr_string_length($var_name, sizeof(*$var_name))"; } else { - $length = ParseExpr($l->{LENGTH_IS}, $env); + $length = ParseExpr($l->{LENGTH_IS}, $env, $e); } if (is_charset_array($e,$l)) { @@ -744,7 +744,7 @@ sub ParseElementPrint($$$) } pidl "ndr_print_$l->{DATA_TYPE}(ndr, \"$e->{NAME}\", $var_name);"; } elsif ($l->{TYPE} eq "SWITCH") { - my $switch_var = ParseExpr($l->{SWITCH_IS}, $env); + my $switch_var = ParseExpr($l->{SWITCH_IS}, $env, $e); pidl "ndr_print_set_switch_value(ndr, " . get_pointer_to($var_name) . ", $switch_var);"; } } @@ -774,7 +774,7 @@ sub ParseElementPrint($$$) sub ParseSwitchPull($$$$$$) { my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; - my $switch_var = ParseExpr($l->{SWITCH_IS}, $env); + my $switch_var = ParseExpr($l->{SWITCH_IS}, $env, $e); check_null_pointer($switch_var); @@ -787,7 +787,7 @@ sub ParseSwitchPull($$$$$$) sub ParseSwitchPush($$$$$$) { my($e,$l,$ndr,$var_name,$ndr_flags,$env) = @_; - my $switch_var = ParseExpr($l->{SWITCH_IS}, $env); + my $switch_var = ParseExpr($l->{SWITCH_IS}, $env, $e); check_null_pointer($switch_var); $var_name = get_pointer_to($var_name); @@ -986,7 +986,7 @@ sub ParseElementPullLevel } } elsif ($l->{TYPE} eq "ARRAY" and not has_fast_array($e,$l) and not is_charset_array($e, $l)) { - my $length = ParseExpr($l->{LENGTH_IS}, $env); + my $length = ParseExpr($l->{LENGTH_IS}, $env, $e); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; my $array_name = $var_name; @@ -1155,7 +1155,7 @@ sub ParseStructPush($$) $size = "ndr_string_length(r->$e->{NAME}, sizeof(*r->$e->{NAME}))"; } } else { - $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env); + $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e); } pidl "NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, $size));"; @@ -2012,7 +2012,7 @@ sub AllocateArrayLevel($$$$$) { my ($e,$l,$ndr,$env,$size) = @_; - my $var = ParseExpr($e->{NAME}, $env); + my $var = ParseExpr($e->{NAME}, $env, $e); check_null_pointer($size); my $pl = GetPrevLevel($e, $l); @@ -2093,7 +2093,7 @@ sub ParseFunctionPull($) and $e->{LEVELS}[1]->{IS_ZERO_TERMINATED}); if ($e->{LEVELS}[1]->{TYPE} eq "ARRAY") { - my $size = ParseExpr($e->{LEVELS}[1]->{SIZE_IS}, $env); + my $size = ParseExpr($e->{LEVELS}[1]->{SIZE_IS}, $env, $e); check_null_pointer($size); pidl "NDR_PULL_ALLOC_N(ndr, r->out.$e->{NAME}, $size);"; -- cgit