diff options
author | Stefan Metzmacher <metze@samba.org> | 2008-01-31 14:57:35 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-02-01 22:18:54 +0100 |
commit | 9e999a67a7d3ff6172a7bb5db28c2f528d74f87f (patch) | |
tree | e3162199c03f56f02382c8514c289aa238e605d0 /source4/pidl/lib | |
parent | a0c83e990f6dfda809600a0160e383f89bfe2f6c (diff) | |
download | samba-9e999a67a7d3ff6172a7bb5db28c2f528d74f87f.tar.gz samba-9e999a67a7d3ff6172a7bb5db28c2f528d74f87f.tar.bz2 samba-9e999a67a7d3ff6172a7bb5db28c2f528d74f87f.zip |
CHECKED... pidl/Samba4::NDR::Parser: correctly get the name of an array element
When we have "*r->out.ous"
(char ***ous, a pointer to a pointer to an array).
we need to use "(*r->out.ous)[3]" to access the 3rd
element of the array "*r->out.ous[3]" was generated before,
but that's the same as "*(r->out.ous[3])".
metze
(This used to be commit 13afc89a87716063180723f0e9cb4f76daca837e)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/CUtil.pm | 15 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 8 |
2 files changed, 18 insertions, 5 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/CUtil.pm b/source4/pidl/lib/Parse/Pidl/CUtil.pm index bd7b16812c..9deb6ee177 100644 --- a/source4/pidl/lib/Parse/Pidl/CUtil.pm +++ b/source4/pidl/lib/Parse/Pidl/CUtil.pm @@ -6,7 +6,7 @@ package Parse::Pidl::CUtil; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(get_pointer_to get_value_of); +@EXPORT = qw(get_pointer_to get_value_of get_array_element); use vars qw($VERSION); $VERSION = '0.01'; @@ -36,4 +36,17 @@ sub get_value_of($) } } +sub get_array_element($$) +{ + my ($var_name, $idx) = @_; + + if ($var_name =~ /^\*.*$/) { + $var_name = "($var_name)"; + } elsif ($var_name =~ /^\&.*$/) { + $var_name = "($var_name)"; + } + + return "$var_name"."[$idx]"; +} + 1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 281018d4cc..81a8bf88cd 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -14,7 +14,7 @@ require Exporter; use strict; use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid); -use Parse::Pidl::CUtil qw(get_pointer_to get_value_of); +use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::Samba4 qw(is_intree choose_header); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); @@ -584,7 +584,7 @@ sub ParseElementPushLevel my $length = ParseExpr($l->{LENGTH_IS}, $env, $e->{ORIGINAL}); my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); if (($primitives and not $l->{IS_DEFERRED}) or ($deferred and $l->{IS_DEFERRED})) { $self->pidl("for ($counter = 0; $counter < $length; $counter++) {"); @@ -779,7 +779,7 @@ sub ParseElementPrint($$$$) $self->pidl("if (idx_$l->{LEVEL_INDEX}) {"); $self->indent; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); } } elsif ($l->{TYPE} eq "DATA") { $self->ParseDataPrint($e, $l, $var_name); @@ -1048,7 +1048,7 @@ sub ParseElementPullLevel my $counter = "cntr_$e->{NAME}_$l->{LEVEL_INDEX}"; my $array_name = $var_name; - $var_name = $var_name . "[$counter]"; + $var_name = get_array_element($var_name, $counter); $self->ParseMemCtxPullStart($e, $l, $array_name); |