[PATCH] pidl/Python: don't assume presence of client header
David Disseldorp
ddiss at samba.org
Wed Mar 11 12:39:41 MDT 2015
As of c660845737f454713f60f01d015125b053435b2c, the PIDL Python back-end
unconditionally includes the client NDR header, regardless of whether it
was generated by PIDL via --client or not.
This change sees the Python back-end only include the corresponding
client NDR header if PIDL is run with --client.
Signed-off-by: David Disseldorp <ddiss at samba.org>
---
pidl/lib/Parse/Pidl/Samba4/Python.pm | 12 +++++++-----
pidl/pidl | 6 +++++-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm
index 920d10a..e906185 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Python.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -1377,11 +1377,11 @@ sub ConvertObjectToPython($$$$$$)
sub Parse($$$$$)
{
- my($self,$basename,$ndr,$ndr_hdr,$hdr) = @_;
+ my ($self, $basename, $ndr, $ndr_client_hdr, $hdr) = @_;
$self->{BASENAME} = $basename;
- $self->pidl_hdr("
+ $self->pidl_hdr("
/* Python wrapper functions auto-generated by pidl */
#include <Python.h>
#include \"includes.h\"
@@ -1389,15 +1389,17 @@ sub Parse($$$$$)
#include \"librpc/rpc/pyrpc.h\"
#include \"librpc/rpc/pyrpc_util.h\"
#include \"$hdr\"
-#include \"$ndr_hdr\"
-
");
+ if (defined($ndr_client_hdr)) {
+ # pidl called with --client, include the corresponding header
+ $self->pidl_hdr("#include \"$ndr_client_hdr\"\n");
+ }
foreach my $x (@$ndr) {
($x->{TYPE} eq "IMPORT") && $self->Import(@{$x->{PATHS}});
($x->{TYPE} eq "INTERFACE") && $self->Interface($x, $basename);
}
-
+
$self->pidl("static PyMethodDef $basename\_methods[] = {");
$self->indent;
foreach (@{$self->{module_methods}}) {
diff --git a/pidl/pidl b/pidl/pidl
index 28a1531..dd77d1b 100755
--- a/pidl/pidl
+++ b/pidl/pidl
@@ -708,9 +708,13 @@ sub process_file($)
if (defined($opt_python)) {
require Parse::Pidl::Samba4::Python;
+ my $py_c_header = undef;
+ if (defined($opt_client)) {
+ $py_c_header = $c_header;
+ }
my $generator = new Parse::Pidl::Samba4::Python();
my ($prsr) = $generator->Parse($basename, $ndr,
- "$outputdir/ndr_$basename\_c.h", $h_filename);
+ $py_c_header, $h_filename);
FileSave("$outputdir/py_$basename.c", $prsr);
}
--
2.1.4
More information about the samba-technical
mailing list