summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pidl/lib/Parse/Pidl/Samba4.pm14
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm6
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/Python.pm3
3 files changed, 16 insertions, 7 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4.pm b/pidl/lib/Parse/Pidl/Samba4.pm
index d42e01cdb0..5bdb91ee25 100644
--- a/pidl/lib/Parse/Pidl/Samba4.pm
+++ b/pidl/lib/Parse/Pidl/Samba4.pm
@@ -7,7 +7,7 @@ package Parse::Pidl::Samba4;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong);
+@EXPORT = qw(is_intree choose_header NumStars ElementStars ArrayBrackets DeclLong ArrayDynamicallyAllocated);
use Parse::Pidl::Util qw(has_property is_constant);
use Parse::Pidl::NDR qw(GetNextLevel);
@@ -36,6 +36,14 @@ sub choose_header($$)
return "#include <$out>";
}
+sub ArrayDynamicallyAllocated($$)
+{
+ my ($e, $l) = @_;
+ die("Not an array") unless ($l->{TYPE} eq "ARRAY");
+ return 0 if ($l->{IS_FIXED} and not has_property($e, "charset"));
+ return 1;
+}
+
sub NumStars($;$)
{
my ($e, $d) = @_;
@@ -57,7 +65,7 @@ sub NumStars($;$)
foreach my $l (@{$e->{LEVELS}}) {
next unless ($l->{TYPE} eq "ARRAY");
- next if ($l->{IS_FIXED}) and not has_property($e, "charset");
+ next unless (ArrayDynamicallyAllocated($e, $l));
$n++;
}
@@ -87,7 +95,7 @@ sub ArrayBrackets($)
foreach my $l (@{$e->{LEVELS}}) {
next unless ($l->{TYPE} eq "ARRAY");
- next unless ($l->{IS_FIXED}) and not has_property($e, "charset");
+ next if ArrayDynamicallyAllocated($e, $l);
$res .= "[$l->{SIZE_IS}]";
}
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++) {");