From c3008e086b1a87c5f4add2a7d1474c2f9a34bfd2 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze@samba.org>
Date: Thu, 31 Jan 2008 14:57:35 +0100
Subject: 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 of pointers).
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])" which would mean
the array would apply to a different level.

This patch prepares support for:

[out,ref,size_is(,num)] [string,charset(UTF16)] uint16 ***names;

It means a [ref] pointer to a [unique] pointer to an array
of [unique] pointers which point to an UTF16 string.

metze
(This used to be commit ec0ee2aa5f4bef32f09a426d91c28c985f843038)
---
 source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 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 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);
 
-- 
cgit