summaryrefslogtreecommitdiff
path: root/source4/pidl/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2008-04-15 16:56:15 +0200
committerAndrew Bartlett <abartlet@samba.org>2008-04-15 16:56:15 +0200
commitdfedfae1cd1c1af54609fd56dafe8eb026f9382c (patch)
tree7a07bcd46bf711f5ed5ed5d2dd5774f22bf5df94 /source4/pidl/lib
parentcb5873f36d5f67b51afd9327df114ff7c1b529d0 (diff)
parent7bb2ebb884c35676a6cf03efe6ecc15b3e232a43 (diff)
downloadsamba-dfedfae1cd1c1af54609fd56dafe8eb026f9382c.tar.gz
samba-dfedfae1cd1c1af54609fd56dafe8eb026f9382c.tar.bz2
samba-dfedfae1cd1c1af54609fd56dafe8eb026f9382c.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into 4-0-abartlet
(This used to be commit 66327b8bd8dbde140b93f000a81ba13e743f27b0)
Diffstat (limited to 'source4/pidl/lib')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm65
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm11
2 files changed, 41 insertions, 35 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
index 7a2575b897..87ed29b54e 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
@@ -9,7 +9,7 @@ package Parse::Pidl::Samba3::ClientNDR;
use Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(ParseFunction $res $res_hdr);
+@EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);
use strict;
use Parse::Pidl qw(fatal warning);
@@ -73,6 +73,40 @@ sub HeaderProperties($$)
}
}
+sub ParseOutputArgument($$$)
+{
+ my ($self, $fn, $e) = @_;
+ my $level = 0;
+
+ fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
+
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ $level = 1;
+ if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
+ $self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
+ $self->indent;
+ }
+ }
+
+ if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
+ # This is a call to GenerateFunctionInEnv intentionally.
+ # Since the data is being copied into a user-provided data
+ # structure, the user should be able to know the size beforehand
+ # to allocate a structure of the right size.
+ my $env = GenerateFunctionInEnv($fn, "r.");
+ my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
+ $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is * sizeof(*$e->{NAME}));");
+ } else {
+ $self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
+ }
+
+ if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
+ if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
+ $self->deindent;
+ $self->pidl("}");
+ }
+ }
+}
sub ParseFunction($$$)
{
@@ -147,36 +181,9 @@ sub ParseFunction($$$)
$self->pidl("/* Return variables */");
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/out/, @{$e->{DIRECTION}}));
- my $level = 0;
- fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
-
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- $level = 1;
- if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
- $self->pidl("if ($e->{NAME} && r.out.$e->{NAME}) {");
- $self->indent;
- }
- }
+ $self->ParseOutputArgument($fn, $e);
- if ($e->{LEVELS}[$level]->{TYPE} eq "ARRAY") {
- # This is a call to GenerateFunctionInEnv intentionally.
- # Since the data is being copied into a user-provided data
- # structure, the user should be able to know the size beforehand
- # to allocate a structure of the right size.
- my $env = GenerateFunctionInEnv($fn, "r.");
- my $size_is = ParseExpr($e->{LEVELS}[$level]->{SIZE_IS}, $env, $e->{ORIGINAL});
- $self->pidl("memcpy($e->{NAME}, r.out.$e->{NAME}, $size_is);");
- } else {
- $self->pidl("*$e->{NAME} = *r.out.$e->{NAME};");
- }
-
- if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
- if ($e->{LEVELS}[0]->{POINTER_TYPE} ne "ref") {
- $self->deindent;
- $self->pidl("}");
- }
- }
}
$self->pidl("");
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
index acaea99f6d..2d12da358c 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -952,16 +952,15 @@ sub ConvertObjectToPythonLevel($$$$$)
$self->pidl("}");
}
} elsif ($l->{TYPE} eq "ARRAY") {
- if (is_charset_array($e, $l)) {
+ my $pl = GetPrevLevel($e, $l);
+ if ($pl && $pl->{TYPE} eq "POINTER") {
$var_name = get_pointer_to($var_name);
+ }
+
+ if (is_charset_array($e, $l)) {
# FIXME: Use Unix charset setting rather than utf-8
$self->pidl("$py_var = PyUnicode_Decode($var_name, strlen($var_name), \"utf-8\", \"ignore\");");
} else {
- my $pl = GetPrevLevel($e, $l);
- if ($pl && $pl->{TYPE} eq "POINTER") {
- $var_name = get_pointer_to($var_name);
- }
-
die("No SIZE_IS for array $var_name") unless (defined($l->{SIZE_IS}));
my $length = $l->{SIZE_IS};
if (defined($l->{LENGTH_IS})) {