summaryrefslogtreecommitdiff
path: root/pidl/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-12-17 07:17:54 +1100
committerAndrew Tridgell <tridge@samba.org>2008-12-17 07:17:54 +1100
commit1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3 (patch)
treecee337a9c93890605fb12490faec2a7f0b2188d8 /pidl/lib
parente294c4799bf6ad8da043aadf8341391644147056 (diff)
parent54dc421f5820099531a77879f52a904c2fefcf49 (diff)
downloadsamba-1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3.tar.gz
samba-1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3.tar.bz2
samba-1b3a084d60cc0004f84bc56dedbe1d87cda2a8b3.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'pidl/lib')
-rw-r--r--pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm8
-rw-r--r--pidl/lib/Parse/Pidl/Samba4.pm4
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/COM/Header.pm7
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm6
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/SWIG.pm177
5 files changed, 19 insertions, 183 deletions
diff --git a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
index 4109ce9962..9a7a037b54 100644
--- a/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
+++ b/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm
@@ -12,7 +12,7 @@ use Exporter;
@EXPORT_OK = qw(ParseFunction $res $res_hdr ParseOutputArgument);
use strict;
-use Parse::Pidl qw(fatal warning);
+use Parse::Pidl qw(fatal warning error);
use Parse::Pidl::Util qw(has_property ParseExpr);
use Parse::Pidl::Samba4 qw(DeclLong);
use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv);
@@ -76,7 +76,11 @@ sub ParseOutputArgument($$$)
my ($self, $fn, $e) = @_;
my $level = 0;
- fatal($e->{ORIGINAL}, "[out] argument is not a pointer or array") if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY");
+ if ($e->{LEVELS}[0]->{TYPE} ne "POINTER" and $e->{LEVELS}[0]->{TYPE} ne "ARRAY") {
+ $self->pidl("return NT_STATUS_NOT_SUPPORTED;");
+ error($e->{ORIGINAL}, "[out] argument is not a pointer or array");
+ return;
+ }
if ($e->{LEVELS}[0]->{TYPE} eq "POINTER") {
$level = 1;
diff --git a/pidl/lib/Parse/Pidl/Samba4.pm b/pidl/lib/Parse/Pidl/Samba4.pm
index 5bdb91ee25..20c518dceb 100644
--- a/pidl/lib/Parse/Pidl/Samba4.pm
+++ b/pidl/lib/Parse/Pidl/Samba4.pm
@@ -12,7 +12,7 @@ require Exporter;
use Parse::Pidl::Util qw(has_property is_constant);
use Parse::Pidl::NDR qw(GetNextLevel);
use Parse::Pidl::Typelist qw(mapTypeName scalar_is_reference);
-use Parse::Pidl qw(fatal);
+use Parse::Pidl qw(fatal error);
use strict;
use vars qw($VERSION);
@@ -69,7 +69,7 @@ sub NumStars($;$)
$n++;
}
- fatal($e->{ORIGINAL}, "Too few pointers $n < $d") if ($n < $d);
+ error($e->{ORIGINAL}, "Too few pointers $n < $d") if ($n < $d);
$n -= $d;
diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
index 996689b4b6..de7d4547a5 100644
--- a/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm
@@ -127,6 +127,7 @@ sub Parse($$)
{
my ($idl,$ndr_header) = @_;
my $res = "";
+ my $has_obj = 0;
$res .= "#include \"librpc/gen_ndr/orpc.h\"\n" .
"#include \"$ndr_header\"\n\n";
@@ -135,6 +136,7 @@ sub Parse($$)
{
if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) {
$res .="struct $_->{NAME};\n";
+ $has_obj = 1;
}
}
@@ -142,14 +144,17 @@ sub Parse($$)
{
if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) {
$res.=ParseInterface($_);
+ $has_obj = 1;
}
if ($_->{TYPE} eq "COCLASS") {
$res.=ParseCoClass($_);
+ $has_obj = 1;
}
}
- return $res;
+ return $res if ($has_obj);
+ return undef;
}
1;
diff --git a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
index ca9f37a053..27e1e5d424 100644
--- a/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm
@@ -201,6 +201,7 @@ sub Parse($$)
{
my ($pidl,$comh_filename) = @_;
my $res = "";
+ my $has_obj = 0;
$res .= "#include \"includes.h\"\n" .
"#include \"lib/com/dcom/dcom.h\"\n" .
@@ -213,9 +214,12 @@ sub Parse($$)
next unless has_property($_, "object");
$res .= ParseInterface($_);
+
+ $has_obj = 1;
}
- return $res;
+ return $res if ($has_obj);
+ return undef;
}
1;
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;