summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba4/Python.pm79
-rwxr-xr-xsource4/pidl/pidl14
-rwxr-xr-xsource4/script/build_idl.sh2
3 files changed, 93 insertions, 2 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
new file mode 100644
index 0000000000..4110a94dfd
--- /dev/null
+++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm
@@ -0,0 +1,79 @@
+###################################################
+# Python function wrapper generator
+# Copyright jelmer@samba.org 2007
+# released under the GNU GPL
+
+package Parse::Pidl::Samba4::Python;
+
+use Exporter;
+@ISA = qw(Exporter);
+
+use strict;
+use Parse::Pidl::Typelist;
+use Parse::Pidl::Util qw(has_property ParseExpr);
+
+use vars qw($VERSION);
+$VERSION = '0.01';
+
+sub new($) {
+ my ($class) = @_;
+ my $self = { res => "", res_hdr => "", tabs => "", constants => {}};
+ bless($self, $class);
+}
+
+sub pidl_hdr ($$)
+{
+ my $self = shift;
+ $self->{res_hdr} .= shift;
+}
+
+sub pidl($$)
+{
+ my ($self, $d) = @_;
+ if ($d) {
+ $self->{res} .= $self->{tabs};
+ $self->{res} .= $d;
+ }
+ $self->{res} .= "\n";
+}
+
+sub indent($)
+{
+ my ($self) = @_;
+ $self->{tabs} .= "\t";
+}
+
+sub deindent($)
+{
+ my ($self) = @_;
+ $self->{tabs} = substr($self->{tabs}, 0, -1);
+}
+
+sub Parse($$$$)
+{
+ my($self,$basename,$ndr,$hdr) = @_;
+
+ my $py_hdr = $hdr;
+ $py_hdr =~ s/^/py_/g;
+
+ $self->pidl_hdr("/* header auto-generated by pidl */\n\n");
+
+ $self->pidl("
+/* Python wrapper functions auto-generated by pidl */
+#include \"includes.h\"
+#include <Python.h>
+#include \"$hdr\"
+#include \"$py_hdr\"
+
+");
+
+ $self->pidl("void init$basename(void)");
+ $self->pidl("{");
+ $self->indent;
+ # FIXME
+ $self->deindent;
+ $self->pidl("}");
+ return ($self->{res_hdr}, $self->{res});
+}
+
+1;
diff --git a/source4/pidl/pidl b/source4/pidl/pidl
index 4150ff7720..4395df2020 100755
--- a/source4/pidl/pidl
+++ b/source4/pidl/pidl
@@ -17,7 +17,7 @@ pidl - An IDL compiler written in Perl
pidl --help
-pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--ejs[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [<idlfile>.idl]...
+pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--ejs[=OUTPUT]] [--python[=OUTPUT]] [--swig[=OUTPUT]] [--ndr-parser[=OUTPUT]] [--client] [--server] [--warn-compat] [--quiet] [--verbose] [--template] [--ws-parser[=OUTPUT]] [--diff] [--dump-idl] [--tdr-parser[=OUTPUT]] [--samba3-ndr-client[=OUTPUT]] [--samba3-ndr-server[=OUTPUT]] [<idlfile>.idl]...
=head1 DESCRIPTION
@@ -468,6 +468,7 @@ my($opt_tdr_parser);
my($opt_ws_parser);
my($opt_swig);
my($opt_ejs);
+my($opt_python);
my($opt_quiet) = 0;
my($opt_outputdir) = '.';
my($opt_verbose) = 0;
@@ -504,6 +505,7 @@ Samba 4 output:
--client[=OUTFILE] create a C NDR client [ndr_BASENAME_c.c]
--tdr-parser[=OUTFILE] create a C TDR parser [tdr_BASENAME.c]
--ejs[=OUTFILE] create ejs wrapper file [BASENAME_ejs.c]
+ --python[=OUTFILE] create python wrapper file [py_BASENAME.c]
--swig[=OUTFILE] create swig wrapper file [BASENAME.i]
--server[=OUTFILE] create server boilerplate [ndr_BASENAME_s.c]
--template print a template for a pipe
@@ -538,6 +540,7 @@ my $result = GetOptions (
'client:s' => \$opt_client,
'ws-parser:s' => \$opt_ws_parser,
'ejs' => \$opt_ejs,
+ 'python' => \$opt_python,
'diff' => \$opt_diff,
'swig:s' => \$opt_swig,
'quiet' => \$opt_quiet,
@@ -606,6 +609,7 @@ sub process_file($)
defined($opt_header) or
defined($opt_ndr_parser) or
defined($opt_ejs) or
+ defined($opt_python) or
defined($opt_dump_ndr_tree) or
defined($opt_samba3_header) or
defined($opt_samba3_parser) or
@@ -657,6 +661,14 @@ sub process_file($)
FileSave("$outputdir/ndr_$basename\_ejs.h", $hdr);
}
+ if (defined($opt_python)) {
+ require Parse::Pidl::Samba4::Python;
+ my $generator = new Parse::Pidl::Samba4::Python();
+ my ($hdr,$prsr) = $generator->Parse($basename, $ndr, $h_filename);
+ FileSave("$outputdir/py_$basename.c", $prsr);
+ FileSave("$outputdir/py_$basename.h", $hdr);
+ }
+
if (defined($opt_server)) {
require Parse::Pidl::Samba4::NDR::Server;
diff --git a/source4/script/build_idl.sh b/source4/script/build_idl.sh
index ecf6657836..ea0cb78b0e 100755
--- a/source4/script/build_idl.sh
+++ b/source4/script/build_idl.sh
@@ -6,7 +6,7 @@ PIDL_EXTRA_ARGS="$*"
[ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
-PIDL="$PERL $srcdir/pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --swig --ejs $PIDL_EXTRA_ARGS"
+PIDL="$PERL $srcdir/pidl/pidl --outputdir librpc/gen_ndr --header --ndr-parser --server --client --swig --ejs --python $PIDL_EXTRA_ARGS"
if [ x$FULLBUILD = xFULL ]; then
echo Rebuilding all idl files in librpc/idl