summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-03-15 13:13:20 +0100
committerKarolin Seeger <kseeger@samba.org>2012-04-10 20:35:51 +0200
commit4932437be109dee2be2b536392d9e7354962ac6f (patch)
tree1b2db9a571f230986e72c499ba8ea5090f864df1
parent785e1647d41232b1724cd4a4e82b71689f10113e (diff)
downloadsamba-4932437be109dee2be2b536392d9e7354962ac6f.tar.gz
pidl/NDR/Parser: use helper variables for array size and length
metze (cherry picked from commit d84758a5c8ce428ac5a3a8cb2e5b8a0e0662ac27)
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm22
1 files changed, 15 insertions, 7 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 5c4150aeb6e..713900f5c67 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -332,7 +332,8 @@ sub ParseArrayPullGetSize($$$$$$)
check_fully_dereferenced($e, $env));
}
- my $array_size = $size;
+ $self->pidl("size_$e->{NAME}_$l->{LEVEL_INDEX} = $size;");
+ my $array_size = "size_$e->{NAME}_$l->{LEVEL_INDEX}";
return $array_size;
}
@@ -350,7 +351,8 @@ sub ParseArrayPullGetLength($$$$$$;$)
my $array_length = $array_size;
if ($l->{IS_VARYING}) {
my $length = "ndr_get_array_length($ndr, " . get_pointer_to($var_name) .")";
- $array_length = $length;
+ $self->pidl("length_$e->{NAME}_$l->{LEVEL_INDEX} = $length;");
+ $array_length = "length_$e->{NAME}_$l->{LEVEL_INDEX}";
}
return $array_length;
@@ -1538,12 +1540,18 @@ sub DeclarePtrVariables($$)
}
}
-sub DeclareArrayVariables($$)
+sub DeclareArrayVariables($$;$)
{
- my ($self,$e) = @_;
+ my ($self,$e,$pull) = @_;
foreach my $l (@{$e->{LEVELS}}) {
next if ($l->{TYPE} ne "ARRAY");
+ if (defined($pull)) {
+ $self->pidl("uint32_t size_$e->{NAME}_$l->{LEVEL_INDEX} = 0;");
+ if ($l->{IS_VARYING}) {
+ $self->pidl("uint32_t length_$e->{NAME}_$l->{LEVEL_INDEX} = 0;");
+ }
+ }
next if has_fast_array($e,$l);
next if is_charset_array($e,$l);
$self->pidl("uint32_t cntr_$e->{NAME}_$l->{LEVEL_INDEX};");
@@ -1626,7 +1634,7 @@ sub ParseStructPull($$$$)
# declare any internal pointers we need
foreach my $e (@{$struct->{ELEMENTS}}) {
$self->DeclarePtrVariables($e);
- $self->DeclareArrayVariables($e);
+ $self->DeclareArrayVariables($e, "pull");
$self->DeclareMemCtxVariables($e);
}
@@ -1939,7 +1947,7 @@ sub ParseUnionPull($$$$)
next if ($double_cases{"$el->{NAME}"});
$self->DeclareMemCtxVariables($el);
$self->DeclarePtrVariables($el);
- $self->DeclareArrayVariables($el);
+ $self->DeclareArrayVariables($el, "pull");
$double_cases{"$el->{NAME}"} = 1;
}
@@ -2211,7 +2219,7 @@ sub ParseFunctionPull($$)
# declare any internal pointers we need
foreach my $e (@{$fn->{ELEMENTS}}) {
$self->DeclarePtrVariables($e);
- $self->DeclareArrayVariables($e);
+ $self->DeclareArrayVariables($e, "pull");
}
my %double_cases = ();