pidl:Samba4/Python.pm: don't handle scalar reference types special
authorStefan Metzmacher <metze@samba.org>
Fri, 10 Dec 2010 15:32:35 +0000 (16:32 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 10 Dec 2010 17:24:06 +0000 (18:24 +0100)
The only special thing is that don't need get_value_of(),
all other checks are needed.

metze

pidl/lib/Parse/Pidl/Samba4/Python.pm

index 1ed75ae..801c0bf 100644 (file)
@@ -981,10 +981,6 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
        my $nl = GetNextLevel($e, $l);
 
        if ($l->{TYPE} eq "POINTER") {
-               if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
-                       $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, $var_name, $fail);
-                       return;
-               }
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->pidl("if ($py_var == Py_None) {");
                        $self->indent;
@@ -1000,7 +996,10 @@ sub ConvertObjectFromPythonLevel($$$$$$$$)
                } else {
                        $self->pidl("$var_name = NULL;");
                }
-               $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, get_value_of($var_name), $fail);
+               unless ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
+                       $var_name = get_value_of($var_name);
+               }
+               $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, $var_name, $fail);
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->deindent;
                        $self->pidl("}");
@@ -1176,10 +1175,6 @@ sub ConvertObjectToPythonLevel($$$$$$)
        my $nl = GetNextLevel($e, $l);
 
        if ($l->{TYPE} eq "POINTER") {
-               if ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
-                       $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name, $py_var, $fail);
-                       return;
-               }
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->pidl("if ($var_name == NULL) {");
                        $self->indent;
@@ -1189,7 +1184,11 @@ sub ConvertObjectToPythonLevel($$$$$$)
                        $self->pidl("} else {");
                        $self->indent;
                }
-               $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, get_value_of($var_name), $py_var, $fail);
+               my $var_name2 = $var_name;
+               unless ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE})) {
+                       $var_name2 = get_value_of($var_name);
+               }
+               $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, $var_name2, $py_var, $fail);
                if ($l->{POINTER_TYPE} ne "ref") {
                        $self->deindent;
                        $self->pidl("}");