python: Fix handling of pointer-less strings in function arguments.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 19:09:18 +0000 (20:09 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 14 Jan 2008 19:09:18 +0000 (20:09 +0100)
source/pidl/lib/Parse/Pidl/Samba4/Python.pm

index 31b06d16b899d6b50ac9a395f52bfe5ede26af9c..2475925377269c95a7a8c7c72372bf212eb72adf 100644 (file)
@@ -642,12 +642,12 @@ sub ConvertObjectFromPythonData($$$$$$)
 
 
        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "NTSTATUS") {
-               $self->pidl("$target = PyInt_AsLong($cvar);");
+               $self->pidl("$target = NT_STATUS(PyInt_AsLong($cvar));");
                return;
        }
 
        if ($actual_ctype->{TYPE} eq "SCALAR" and $actual_ctype->{NAME} eq "WERROR") {
-               $self->pidl("$target = PyInt_AsLong($cvar);");
+               $self->pidl("$target = W_ERROR(PyInt_AsLong($cvar));");
                return;
        }
 
@@ -690,16 +690,16 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
                        $self->pidl("}");
                }
        } elsif ($l->{TYPE} eq "ARRAY") {
+               my $pl = GetPrevLevel($e, $l);
+               if ($pl && $pl->{TYPE} eq "POINTER") {
+                       $var_name = get_pointer_to($var_name);
+               }
+
                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\"));");
+                       $self->pidl($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("{");