diff options
-rw-r--r-- | pidl/lib/Parse/Pidl/Samba4/SWIG.pm | 177 | ||||
-rwxr-xr-x | pidl/pidl | 13 |
2 files changed, 1 insertions, 189 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba4/SWIG.pm b/pidl/lib/Parse/Pidl/Samba4/SWIG.pm deleted file mode 100644 index 14424cf260..0000000000 --- a/pidl/lib/Parse/Pidl/Samba4/SWIG.pm +++ /dev/null @@ -1,177 +0,0 @@ -################################################### -# Samba4 parser generator for swig wrappers -# Copyright tpot@samba.org 2004,2005 -# Copyright jelmer@samba.org 2006 -# released under the GNU GPL - -package Parse::Pidl::Samba4::SWIG; - -use vars qw($VERSION); -use Parse::Pidl::Samba4 qw(DeclLong); -use Parse::Pidl::Typelist qw(mapTypeName); -use Parse::Pidl::Util qw(has_property); -$VERSION = '0.01'; - -use strict; - -my $ret = ""; -my $tabs = ""; - -sub pidl($) -{ - my $p = shift; - $ret .= $tabs. $p . "\n"; -} - -sub indent() { $tabs.=" "; } -sub deindent() { $tabs = substr($tabs,0,-2); } - -sub IgnoreInterface($$) -{ - my ($basename,$if) = @_; - - foreach (@{$if->{TYPES}}) { - next unless (has_property($_, "public")); - pidl "\%types($_->{NAME});"; - } -} - -sub GenerateResultTypemap($) -{ - my $name = shift; - pidl "%typemap(in,numinputs=0) $name*result ($name tmp) {"; - indent; - pidl "\$1 = &tmp;"; - deindent; - pidl "}"; - pidl ""; - pidl "%typemap(argout) $name*result {"; - indent; - pidl "\$result = SWIG_NewPointerObj(*\$1, \$1_descriptor, 0);"; - deindent; - pidl "}"; -} - -sub ParseInterface($$) -{ - my ($basename,$if) = @_; - - pidl "\%inline {"; - pidl "typedef struct $if->{NAME} { struct dcerpc_pipe *pipe; } $if->{NAME};"; - pidl "}"; - pidl ""; - pidl "%talloctype($if->{NAME});"; - pidl ""; - pidl "\%extend $if->{NAME} {"; - indent(); - pidl "$if->{NAME} () {"; - indent; - pidl "return talloc(NULL, struct $if->{NAME});"; - deindent; - pidl "}"; - pidl ""; - pidl "NTSTATUS connect (const char *binding, struct cli_credentials *cred, struct event_context *event)"; - pidl "{"; - indent; - pidl "return dcerpc_pipe_connect(\$self, &\$self->pipe, binding, &ndr_table_$if->{NAME}, cred, event);"; - deindent; - pidl "}"; - pidl ""; - - foreach my $fn (@{$if->{FUNCTIONS}}) { - pidl "/* $fn->{NAME} */"; - my $args = ""; - foreach (@{$fn->{ELEMENTS}}) { - $args .= DeclLong($_) . ", "; - } - my $name = $fn->{NAME}; - $name =~ s/^$if->{NAME}_//g; - $name =~ s/^$basename\_//g; - $args .= "TALLOC_CTX *mem_ctx, " . mapTypeName($fn->{RETURN_TYPE}) . " *result"; - pidl "NTSTATUS $name($args)"; - pidl "{"; - indent; - pidl "struct $fn->{NAME} r;"; - pidl "NTSTATUS status;"; - pidl ""; - pidl "/* Fill r structure */"; - - foreach (@{$fn->{ELEMENTS}}) { - if (grep(/in/, @{$_->{DIRECTION}})) { - pidl "r.in.$_->{NAME} = $_->{NAME};"; - } - } - - pidl ""; - pidl "status = dcerpc_$fn->{NAME}(\$self->pipe, mem_ctx, &r);"; - pidl "if (NT_STATUS_IS_ERR(status)) {"; - indent; pidl "return status;"; deindent; - pidl "}"; - pidl ""; - pidl "/* Set out arguments */"; - foreach (@{$fn->{ELEMENTS}}) { - next unless (grep(/out/, @{$_->{DIRECTION}})); - - pidl ("/* FIXME: $_->{NAME} [out] argument is not a pointer */") if ($_->{LEVELS}[0]->{TYPE} ne "POINTER"); - - pidl "*$_->{NAME} = *r.out.$_->{NAME};"; - } - - if (defined($fn->{RETURN_TYPE})) { - pidl "*result = r.out.result;"; - } - pidl "return NT_STATUS_OK;"; - deindent; - pidl "}"; - pidl ""; - } - - deindent(); - pidl "};"; - pidl ""; - - foreach (@{$if->{TYPES}}) { - pidl "/* $_->{NAME} */"; - } - - pidl ""; -} - -sub Parse($$$$) -{ - my($ndr,$basename,$header,$gen_header) = @_; - - $ret = ""; - - pidl "/* This file is autogenerated by pidl. DO NOT EDIT */"; - - pidl "\%module $basename"; - - pidl ""; - - pidl "\%{"; - pidl "#include \"includes.h\""; - pidl "#include \"$header\""; - pidl "#include \"$gen_header\""; - pidl "%}"; - pidl "\%import \"../rpc/dcerpc.i\""; - pidl "\%import \"../../libcli/util/errors.i\""; - pidl "\%import \"../../lib/talloc/talloc.i\""; - pidl ""; - foreach (@$ndr) { - IgnoreInterface($basename, $_) if ($_->{TYPE} eq "INTERFACE"); - } - pidl ""; - - pidl ""; - - foreach (@$ndr) { - ParseInterface($basename, $_) if ($_->{TYPE} eq "INTERFACE"); - } - #FIXME: Foreach ref pointer, set NONNULL - #FIXME: Foreach unique/full pointer, set MAYBENULL - #FIXME: Foreach [out] parameter, set OUTPARAM - return $ret; -} - -1; @@ -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]] [--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]] [--typelib=[OUTPUT]] [<idlfile>.idl]... +pidl [--outputdir[=OUTNAME]] [--includedir DIR...] [--parse-idl-tree] [--dump-idl-tree] [--dump-ndr-tree] [--header[=OUTPUT]] [--python[=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]] [--typelib=[OUTPUT]] [<idlfile>.idl]... =head1 DESCRIPTION @@ -477,7 +477,6 @@ my($opt_server); my($opt_ndr_parser); my($opt_tdr_parser); my($opt_ws_parser); -my($opt_swig); my($opt_python); my($opt_quiet) = 0; my($opt_outputdir) = '.'; @@ -521,7 +520,6 @@ 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] --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 --dcom-proxy[=OUTFILE] create DCOM proxy [ndr_BASENAME_p.c] @@ -567,7 +565,6 @@ my $result = GetOptions ( 'ws-parser:s' => \$opt_ws_parser, 'python' => \$opt_python, 'diff' => \$opt_diff, - 'swig:s' => \$opt_swig, 'dcom-proxy:s' => \$opt_dcom_proxy, 'com-header:s' => \$opt_com_header, 'quiet' => \$opt_quiet, @@ -666,7 +663,6 @@ sub process_file($) defined($opt_samba3_header) or defined($opt_samba3_parser) or defined($opt_samba3_server) or - defined($opt_swig) or defined($opt_samba3_ndr_client) or defined($opt_samba3_ndr_server)) { require Parse::Pidl::NDR; @@ -698,13 +694,6 @@ sub process_file($) FileSave($c_header, $hdrd); } - if (defined($opt_swig)) { - require Parse::Pidl::Samba4::SWIG; - my($filename) = ($opt_swig or "$outputdir/$basename.i"); - my $code = Parse::Pidl::Samba4::SWIG::Parse($ndr, $basename, "$outputdir/ndr_$basename\_c.h", $gen_header); - FileSave($filename, $code); - } - if (defined($opt_python)) { require Parse::Pidl::Samba4::Python; my $generator = new Parse::Pidl::Samba4::Python(); |