summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-04-08 14:19:26 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-04-08 14:19:26 +0200
commit5db62a16ff9b784c11c704b8083da9bf6e736f08 (patch)
treef3b090be8ecb851baa8eb5f059eb4dbadd309114 /source4/pidl/lib/Parse
parentdcc44f1757e24e169ca7730a5c56a0488cd5b110 (diff)
downloadsamba-5db62a16ff9b784c11c704b8083da9bf6e736f08.tar.gz
samba-5db62a16ff9b784c11c704b8083da9bf6e736f08.tar.bz2
samba-5db62a16ff9b784c11c704b8083da9bf6e736f08.zip
Array lengths can be obtained from Python objects so remove them from the Python API.
(This used to be commit 652810ff46c6db9034e930d0fb018a02ee385f15)
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm26
1 files changed, 25 insertions, 1 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index c04324e992..5d514c5f09 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -272,7 +272,21 @@ sub PythonFunctionBody($$$)
my $signature = "S.$prettyname(";
+ my %metadata_args = ();
+
+ sub get_var($) { my $x = shift; $x =~ s/\*//g; return $x; }
+
+ # Determine arguments that are metadata for other arguments (size_is/length_is)
+ foreach my $e (@{$fn->{ELEMENTS}}) {
+ if (has_property($e, "length_is")) {
+ $metadata_args{get_var($e->{PROPERTIES}->{length_is})} = $e->{NAME};
+ } elsif (has_property($e, "size_is")) {
+ $metadata_args{get_var($e->{PROPERTIES}->{size_is})} = $e->{NAME};
+ }
+ }
+
foreach my $e (@{$fn->{ELEMENTS}}) {
+ next if ($metadata_args{$e->{NAME}});
$self->pidl("PyObject *py_$e->{NAME};");
if (grep(/out/,@{$e->{DIRECTION}})) {
$result_size++;
@@ -307,7 +321,16 @@ sub PythonFunctionBody($$$)
}
foreach my $e (@{$fn->{ELEMENTS}}) {
- if (grep(/in/,@{$e->{DIRECTION}})) {
+ next unless (grep(/in/,@{$e->{DIRECTION}}));
+ if ($metadata_args{$e->{NAME}}) {
+ my $val = "PyList_Size(py_".$metadata_args{$e->{NAME}}.")";
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ $self->pidl("r->in.$e->{NAME} = talloc_ptrtype(mem_ctx, r->in.$e->{NAME});");
+ $self->pidl("*r->in.$e->{NAME} = $val;");
+ } else {
+ $self->pidl("r->in.$e->{NAME} = PyList_Size(py_".$metadata_args{$e->{NAME}}.");");
+ }
+ } else {
$self->ConvertObjectFromPython($env, "mem_ctx", $e, "py_$e->{NAME}", "r->in.$e->{NAME}", "talloc_free(mem_ctx); return NULL;");
}
}
@@ -325,6 +348,7 @@ sub PythonFunctionBody($$$)
}
foreach my $e (@{$fn->{ELEMENTS}}) {
+ next if ($metadata_args{$e->{NAME}});
my $py_name = "py_$e->{NAME}";
if (grep(/out/,@{$e->{DIRECTION}})) {
$self->ConvertObjectToPython("r", $env, $e, "r->out.$e->{NAME}", $py_name);