mirror of
https://github.com/samba-team/samba.git
synced 2025-12-14 20:23:54 +03:00
r26657: pidl: Add basics for generating Python modules.
This commit is contained in:
committed by
Stefan Metzmacher
parent
5c86cc6648
commit
f1960ca7c4
79
source/pidl/lib/Parse/Pidl/Samba4/Python.pm
Normal file
79
source/pidl/lib/Parse/Pidl/Samba4/Python.pm
Normal file
@@ -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;
|
||||
Reference in New Issue
Block a user