From 0dbdfc2218c801b973a34fc810e5bb1b4509dd3c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 3 Jan 2008 21:21:16 -0600 Subject: r26657: pidl: Add basics for generating Python modules. (This used to be commit f1960ca7c4d1b75d64192efdd446482c6bbebcd9) --- source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 79 ++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 source4/pidl/lib/Parse/Pidl/Samba4/Python.pm (limited to 'source4/pidl/lib/Parse') 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 +#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; -- cgit