From 0f8d749144b60c62bbc9e0b934aecc2825d5d0d5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 12 Dec 2008 11:16:36 +0100 Subject: Add convenience function for determining if an array should be allocated with talloc. --- pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 6 +++--- pidl/lib/Parse/Pidl/Samba4/Python.pm | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'pidl/lib/Parse/Pidl/Samba4') diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index fb73075f1a..ee81e51f25 100644 --- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -16,7 +16,7 @@ use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str); 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 qw(is_intree choose_header ArrayDynamicallyAllocated); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); use Parse::Pidl qw(warning); @@ -376,7 +376,7 @@ sub ParseArrayPullHeader($$$$$$) $self->defer("}"); } - if (not $l->{IS_FIXED} and not is_charset_array($e, $l)) { + if (ArrayDynamicallyAllocated($e,$l) and not is_charset_array($e,$l)) { $self->AllocateArrayLevel($e,$l,$ndr,$var_name,$size); } @@ -917,7 +917,7 @@ sub ParseMemCtxPullFlags($$$$) return undef unless ($l->{TYPE} eq "POINTER" or $l->{TYPE} eq "ARRAY"); - return undef if ($l->{TYPE} eq "ARRAY" and $l->{IS_FIXED}); + return undef unless ($l->{TYPE} ne "ARRAY" or ArrayDynamicallyAllocated($e,$l)); return undef if has_fast_array($e, $l); return undef if is_charset_array($e, $l); diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index a3107d4672..90dcba0780 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -14,6 +14,7 @@ use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias use Parse::Pidl::Util qw(has_property ParseExpr unmake_str); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::CUtil qw(get_value_of get_pointer_to); +use Parse::Pidl::Samba4 qw(ArrayDynamicallyAllocated); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); use vars qw($VERSION); @@ -942,7 +943,7 @@ sub ConvertObjectFromPythonLevel($$$$$$$$) $self->pidl("{"); $self->indent; $self->pidl("int $counter;"); - if (!$l->{IS_FIXED}) { + if (ArrayDynamicallyAllocated($e, $l)) { $self->pidl("$var_name = talloc_array_ptrtype($mem_ctx, $var_name, PyList_Size($py_var));"); } $self->pidl("for ($counter = 0; $counter < PyList_Size($py_var); $counter++) {"); -- cgit