diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-03 21:21:16 -0600 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-01-03 15:27:02 -0600 |
commit | 0dbdfc2218c801b973a34fc810e5bb1b4509dd3c (patch) | |
tree | d8c292e9db424dbb44b910371c38b13092d15061 /source4/pidl/lib/Parse | |
parent | 6ed5fc0919d2f43ad28f9fff08e2a3c8f09bbecd (diff) | |
download | samba-0dbdfc2218c801b973a34fc810e5bb1b4509dd3c.tar.gz samba-0dbdfc2218c801b973a34fc810e5bb1b4509dd3c.tar.bz2 samba-0dbdfc2218c801b973a34fc810e5bb1b4509dd3c.zip |
r26657: pidl: Add basics for generating Python modules.
(This used to be commit f1960ca7c4d1b75d64192efdd446482c6bbebcd9)
Diffstat (limited to 'source4/pidl/lib/Parse')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Python.pm | 79 |
1 files changed, 79 insertions, 0 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; |