From e231e24d89dfe3faaf0f791dc5e0df5fa9c21590 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Jan 2008 06:23:13 +0100 Subject: pidl/python: Deal with arrays that are not pointers. (This used to be commit 7516af7c7262240df3b804dda962194a811d4e96) --- source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/pidl') diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm index e0751d0c72..1483083e22 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -673,8 +673,14 @@ sub ConvertObjectFromPythonLevel($$$$$$$$) } elsif ($l->{TYPE} eq "ARRAY") { if (is_charset_array($e, $l)) { $self->pidl("PY_CHECK_TYPE(PyUnicode, $py_var, $fail);"); + # FIXME: Use Unix charset setting rather than utf-8 $self->pidl(get_pointer_to($var_name) . " = PyString_AsString(PyUnicode_AsEncodedString($py_var, \"utf-8\", \"ignore\"));"); } else { + my $pl = GetPrevLevel($e, $l); + if ($pl && $pl->{TYPE} eq "POINTER") { + $var_name = get_pointer_to($var_name); + } + my $counter = "$e->{NAME}_cntr_$l->{LEVEL_INDEX}"; $self->pidl("PY_CHECK_TYPE(PyList, $py_var, $fail);"); $self->pidl("{"); @@ -816,8 +822,14 @@ sub ConvertObjectToPythonLevel($$$$$) } elsif ($l->{TYPE} eq "ARRAY") { if (is_charset_array($e, $l)) { $var_name = get_pointer_to($var_name); + # FIXME: Use Unix charset setting rather than utf-8 $self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");"); } else { + my $pl = GetPrevLevel($e, $l); + if ($pl && $pl->{TYPE} eq "POINTER") { + $var_name = get_pointer_to($var_name); + } + die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS})); my $length = $l->{SIZE_IS}; if (defined($l->{LENGTH_IS})) { -- cgit