diff options
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; |