diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-14 18:24:10 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-01-14 19:53:08 +0100 |
commit | 134e38ac28b30b7fb3f4efcf9985c17ff2f070ad (patch) | |
tree | ea3f5f413ddc3ea98a8e3a22d6877d0dd4f7dc75 /source4/pidl/lib | |
parent | 994e43e9ebd3922f2c3378edf0e73e912815230a (diff) | |
download | samba-134e38ac28b30b7fb3f4efcf9985c17ff2f070ad.tar.gz samba-134e38ac28b30b7fb3f4efcf9985c17ff2f070ad.tar.bz2 samba-134e38ac28b30b7fb3f4efcf9985c17ff2f070ad.zip |
python: Fix some corner cases handling scalars.
(This used to be commit b662c98a9ad461a33a27a918c0d544a96433e48c)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm index 73442be59d..8ff909a455 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -207,7 +207,7 @@ sub PythonStruct($$$$) my $nl = GetNextLevel($e, $l); if ($l->{TYPE} eq "POINTER" and not ($nl->{TYPE} eq "ARRAY" and ($nl->{IS_FIXED} or is_charset_array($e, $nl))) and - not ($nl->{TYPE} eq "SCALAR" and $nl->{TYPE} eq "string")) { + not ($nl->{TYPE} eq "DATA" and Parse::Pidl::Typelist::scalar_is_reference($nl->{DATA_TYPE}))) { $self->pidl("talloc_free($varname);"); } $self->ConvertObjectFromPython($env, $mem_ctx, $e, "value", $varname, "return -1;"); @@ -668,8 +668,13 @@ sub ConvertObjectFromPythonData($$$$$$) sub ConvertObjectFromPythonLevel($$$$$$$$) { my ($self, $env, $mem_ctx, $py_var, $e, $l, $var_name, $fail) = @_; + 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; @@ -679,7 +684,7 @@ sub ConvertObjectFromPythonLevel($$$$$$$$) $self->indent; } $self->pidl("$var_name = talloc_ptrtype($mem_ctx, $var_name);"); - $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, GetNextLevel($e, $l), get_value_of($var_name), $fail); + $self->ConvertObjectFromPythonLevel($env, $mem_ctx, $py_var, $e, $nl, get_value_of($var_name), $fail); if ($l->{POINTER_TYPE} ne "ref") { $self->deindent; $self->pidl("}"); @@ -802,8 +807,13 @@ sub ConvertObjectToPythonData($$$$$) sub ConvertObjectToPythonLevel($$$$$) { my ($self, $mem_ctx, $env, $e, $l, $var_name, $py_var) = @_; + 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); + return; + } if ($l->{POINTER_TYPE} ne "ref") { $self->pidl("if ($var_name == NULL) {"); $self->indent; @@ -812,7 +822,7 @@ sub ConvertObjectToPythonLevel($$$$$) $self->pidl("} else {"); $self->indent; } - $self->ConvertObjectToPythonLevel($var_name, $env, $e, GetNextLevel($e, $l), get_value_of($var_name), $py_var); + $self->ConvertObjectToPythonLevel($var_name, $env, $e, $nl, get_value_of($var_name), $py_var); if ($l->{POINTER_TYPE} ne "ref") { $self->deindent; $self->pidl("}"); |