From 0ea3760cae85226f6fbc59a9ca6b9eb9e2ab577b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 1 Aug 2011 15:17:41 +0200 Subject: pidl:NDR/Parser: allow [string,size_of()] together metze --- pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'pidl') diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 406fc02cec..3d31366abf 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -198,6 +198,12 @@ sub ParseArrayPushHeader($$$$$$) } else { $size = $length = "ndr_string_length($var_name, sizeof(*$var_name))"; } + if (defined($l->{SIZE_IS})) { + $size = ParseExpr($l->{SIZE_IS}, $env, $e); + } + if (defined($l->{LENGTH_IS})) { + $length = ParseExpr($l->{LENGTH_IS}, $env, $e); + } } else { $size = ParseExpr($l->{SIZE_IS}, $env, $e); $length = ParseExpr($l->{LENGTH_IS}, $env, $e); @@ -352,7 +358,7 @@ sub ParseArrayPullHeader($$$$$$) $self->pidl("}"); } - if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) { + if ($l->{IS_CONFORMANT} and (defined($l->{SIZE_IS}) or not $l->{IS_ZERO_TERMINATED})) { $self->defer("if ($var_name) {"); $self->defer_indent; my $size = ParseExprExt($l->{SIZE_IS}, $env, $e->{ORIGINAL}, @@ -364,7 +370,7 @@ sub ParseArrayPullHeader($$$$$$) $self->defer("}"); } - if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) { + 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}, @@ -775,7 +781,7 @@ sub ParseElementPrint($$$$$) $var_name = get_pointer_to($var_name); } - if ($l->{IS_ZERO_TERMINATED}) { + 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}, @@ -1273,6 +1279,9 @@ sub ParseStructPushPrimitives($$$$$) } else { $size = "ndr_string_length($varname->$e->{NAME}, sizeof(*$varname->$e->{NAME}))"; } + if (defined($e->{LEVELS}[0]->{SIZE_IS})) { + $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL}); + } } else { $size = ParseExpr($e->{LEVELS}[0]->{SIZE_IS}, $env, $e->{ORIGINAL}); } -- cgit