summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-12 14:33:20 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-15 17:39:42 +0200
commit1ca80d037d767230f28aea12f58c4afbaa86b71c (patch)
tree29a2c571f5cb3df787f197673da53766aae184ac /source4
parent30be012bfdc9c9139fb573232ccb28ec74a8bfd2 (diff)
downloadsamba-1ca80d037d767230f28aea12f58c4afbaa86b71c.tar.gz
samba-1ca80d037d767230f28aea12f58c4afbaa86b71c.tar.bz2
samba-1ca80d037d767230f28aea12f58c4afbaa86b71c.zip
Re-Import ODL support.
Diffstat (limited to 'source4')
-rw-r--r--source4/pidl/lib/Parse/Pidl/ODL.pm106
-rwxr-xr-xsource4/pidl/pidl4
2 files changed, 109 insertions, 1 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/ODL.pm b/source4/pidl/lib/Parse/Pidl/ODL.pm
new file mode 100644
index 0000000000..897d921485
--- /dev/null
+++ b/source4/pidl/lib/Parse/Pidl/ODL.pm
@@ -0,0 +1,106 @@
+##########################################
+# Converts ODL stuctures to IDL structures
+# (C) 2004-2005, 2008 Jelmer Vernooij <jelmer@samba.org>
+
+package Parse::Pidl::ODL;
+
+use Parse::Pidl qw(error);
+use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::Typelist qw(hasType getType);
+use strict;
+
+use vars qw($VERSION);
+$VERSION = '0.01';
+
+#####################################################################
+# find an interface in an array of interfaces
+sub get_interface($$)
+{
+ my($if,$n) = @_;
+
+ foreach(@$if) {
+ next if ($_->{TYPE} ne "INTERFACE");
+ return $_ if($_->{NAME} eq $n);
+ }
+
+ return undef;
+}
+
+sub FunctionAddObjArgs($)
+{
+ my $e = shift;
+
+ unshift(@{$e->{ELEMENTS}}, {
+ 'NAME' => 'ORPCthis',
+ 'POINTERS' => 0,
+ 'PROPERTIES' => { 'in' => '1' },
+ 'TYPE' => 'ORPCTHIS',
+ 'FILE' => $e->{FILE},
+ 'LINE' => $e->{LINE}
+ });
+ unshift(@{$e->{ELEMENTS}}, {
+ 'NAME' => 'ORPCthat',
+ 'POINTERS' => 1,
+ 'PROPERTIES' => { 'out' => '1', 'ref' => '1' },
+ 'TYPE' => 'ORPCTHAT',
+ 'FILE' => $e->{FILE},
+ 'LINE' => $e->{LINE}
+ });
+}
+
+sub ReplaceInterfacePointers($)
+{
+ my $e = shift;
+ foreach my $x (@{$e->{ELEMENTS}}) {
+ next unless (hasType($x->{TYPE}));
+ next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE";
+
+ $x->{TYPE} = "MInterfacePointer";
+ }
+}
+
+# Add ORPC specific bits to an interface.
+sub ODL2IDL($)
+{
+ my $odl = shift;
+ my $addedorpc = 0;
+
+ foreach my $x (@$odl) {
+ next if ($x->{TYPE} ne "INTERFACE");
+ # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
+ # and replace interfacepointers with MInterfacePointer
+ # for 'object' interfaces
+ if (has_property($x, "object")) {
+ foreach my $e (@{$x->{DATA}}) {
+ ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e);
+ ReplaceInterfacePointers($e);
+ }
+ $addedorpc = 1;
+ }
+
+ if ($x->{BASE}) {
+ my $base = get_interface($odl, $x->{BASE});
+
+ unless (defined($base)) {
+ error($x, "Undefined base interface `$x->{BASE}'");
+ } else {
+ foreach my $fn (reverse @{$base->{DATA}}) {
+ next unless ($fn->{TYPE} eq "FUNCTION");
+ unshift (@{$x->{DATA}}, $fn);
+ push (@{$x->{INHERITED_FUNCTIONS}}, $fn->{NAME});
+ }
+ }
+ }
+ }
+
+ unshift (@$odl, {
+ TYPE => "IMPORT",
+ PATHS => [ "\"orpc.idl\"" ],
+ FILE => undef,
+ LINE => undef
+ }) if ($addedorpc);
+
+ return $odl;
+}
+
+1;
diff --git a/source4/pidl/pidl b/source4/pidl/pidl
index af6c6cca89..646f7952e9 100755
--- a/source4/pidl/pidl
+++ b/source4/pidl/pidl
@@ -409,6 +409,7 @@ use Getopt::Long;
use File::Basename;
use Parse::Pidl qw ( $VERSION );
use Parse::Pidl::Util;
+use Parse::Pidl::ODL;
#####################################################################
# save a data structure into a file
@@ -650,12 +651,13 @@ sub process_file($)
}
}
-
if ($opt_warn_compat) {
require Parse::Pidl::Compat;
Parse::Pidl::Compat::Check($pidl);
}
+ $pidl = Parse::Pidl::ODL::ODL2IDL($pidl);
+
if (defined($opt_ws_parser) or
defined($opt_client) or
defined($opt_server) or