r5479: Add ODL input support.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 21 Feb 2005 01:16:47 +0000 (01:16 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:10:49 +0000 (13:10 -0500)
The ODL module can convert an ODL structure to an IDL structure so that:
 - The COM subsystem can use the ODL structure
 - The DCE/RPC subsystem can use the IDL structure

source/build/pidl/idl.pm
source/build/pidl/idl.yp
source/build/pidl/ndr.pm
source/build/pidl/odl.pm [new file with mode: 0644]
source/build/pidl/pidl.pl
source/script/build_idl.sh

index 6ae7cb463f4970521d598f9cbf63f1608a658d59..5ba427e70c24a8ac3af85fce76f9e79871d8ad5a 100644 (file)
@@ -2383,8 +2383,6 @@ sub parse_idl($$)
        my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
 
        foreach my $x (@{$idl}) {
-               NdrParser::InterfaceORPC($x);
-
                # Do the inheritance
                if (defined($x->{BASE}) and $x->{BASE} ne "") {
                        my $parent = util::get_interface($idl, $x->{BASE});
index aff7f82f69f336c315b19c79daff5935c07a85b3..b12c45c34db9401cea2fabc91778e6633ac3c7ae 100644 (file)
@@ -374,8 +374,6 @@ sub parse_idl($$)
        my $idl = $self->YYParse( yylex => \&_Lexer, yyerror => \&_Error );
 
        foreach my $x (@{$idl}) {
-               NdrParser::InterfaceORPC($x);
-
                # Do the inheritance
                if (defined($x->{BASE}) and $x->{BASE} ne "") {
                        my $parent = util::get_interface($idl, $x->{BASE});
index 0d9b38d07be0d9c75be33fcb38c5fd0137c03532..019300d7843a7c8d64d9e1b18cfa9f402c527c4f 100644 (file)
@@ -2114,33 +2114,6 @@ sub LoadInterface($)
        }
 }
 
-# Add ORPC specific bits to an interface.
-sub InterfaceORPC($)
-{
-       my $x = shift;  
-       # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
-       # for 'object' interfaces
-       if (util::has_property($x, "object")) {
-               foreach my $e (@{$x->{DATA}}) {
-                       if($e->{TYPE} eq "FUNCTION") {
-                               $e->{PROPERTIES}->{object} = 1;
-                               unshift(@{$e->{ELEMENTS}}, 
-                       { 'NAME' => 'ORPCthis',
-                         'POINTERS' => 0,
-                         'PROPERTIES' => { 'in' => '1' },
-                         'TYPE' => 'ORPCTHIS'
-                       });
-                               unshift(@{$e->{ELEMENTS}},
-                       { 'NAME' => 'ORPCthat',
-                         'POINTERS' => 0,
-                         'PROPERTIES' => { 'out' => '1' },
-                                         'TYPE' => 'ORPCTHAT'
-                       });
-                       }
-               }
-       }
-}
-
 sub Load($)
 {
        my $idl = shift;
diff --git a/source/build/pidl/odl.pm b/source/build/pidl/odl.pm
new file mode 100644 (file)
index 0000000..37c8a5a
--- /dev/null
@@ -0,0 +1,59 @@
+##########################################
+# Converts ODL stuctures to IDL structures
+# (C) 2004-2005 Jelmer Vernooij <jelmer@samba.org>
+
+package ODL;
+
+use strict;
+
+sub FunctionAddObjArgs($)
+{
+       my $e = shift;
+       
+       unshift(@{$e->{ELEMENTS}}, {
+               'NAME' => 'ORPCthis',
+               'POINTERS' => 0,
+               'PROPERTIES' => { 'in' => '1' },
+               'TYPE' => 'ORPCTHIS'
+       });
+       unshift(@{$e->{ELEMENTS}}, {
+               'NAME' => 'ORPCthat',
+               'POINTERS' => 0,
+               'PROPERTIES' => { 'out' => '1' },
+               'TYPE' => 'ORPCTHAT'
+       });
+}
+
+sub ReplaceInterfacePointers($)
+{
+       my $e = shift;
+
+       foreach my $x (@{$e->{ELEMENTS}}) {
+               next unless typelist::hasType($x);
+               next unless typelist::getType($x)->{DATA}->{TYPE} eq "INTERFACE";
+               
+               $x->{TYPE} = "MInterfacePointer";
+       }
+}
+
+# Add ORPC specific bits to an interface.
+sub ODL2IDL($)
+{
+       my $odl = shift;
+       my @idl = @{$odl};
+       
+       foreach my $x (@idl) {
+               # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that
+               # for 'object' interfaces
+               if (util::has_property($x, "object")) {
+                       foreach my $e (@{$x->{DATA}}) {
+                               ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e);
+                               ReplaceInterfacePointers($e);
+                       }
+               }
+       }
+
+       return \@idl;
+}
+
+1;
index eedbb91d4ec093fea1143bcd70bd6d01a11df05e..b535215d030f450497bfed1adaff926b568efa4e 100755 (executable)
@@ -21,6 +21,7 @@ use client;
 use proxy;
 use stub;
 use ndr;
+use odl;
 use eparser;
 use validator;
 use typelist;
@@ -40,6 +41,7 @@ my($opt_parser) = 0;
 my($opt_eparser) = 0;
 my($opt_keep) = 0;
 my($opt_swig) = 0;
+my($opt_odl) = 0;
 my($opt_output);
 
 my $idl_parser = new idl;
@@ -79,6 +81,7 @@ sub ShowHelp()
              --swig                create swig wrapper file
              --diff                run diff on the idl and dumped output
              --keep                keep the .pidl file
+             --odl                 accept ODL input
            \n";
     exit(0);
 }
@@ -96,6 +99,7 @@ GetOptions (
         'client' => \$opt_client,
            'eparser' => \$opt_eparser,
            'diff' => \$opt_diff,
+               'odl' => \$opt_odl,
            'keep' => \$opt_keep,
            'swig' => \$opt_swig
            );
@@ -109,6 +113,7 @@ sub process_file($)
 {
        my $idl_file = shift;
        my $output;
+       my $podl;
        my $pidl;
 
        my $basename = basename($idl_file, ".idl");
@@ -143,6 +148,11 @@ sub process_file($)
                typelist::LoadIdl($pidl);
        }
 
+       if ($opt_odl) {
+               $podl = $pidl;
+               $pidl = ODL::ODL2IDL($podl);
+       }
+
        if ($opt_header) {
                my($header) = util::ChangeExtension($output, ".h");
                util::FileSave($header, IdlHeader::Parse($pidl));
index aaa0b12af426218c5901896980815b2df1caf1c2..7b49721a5c9bc280fc32c63345911c31de4151ee 100755 (executable)
@@ -4,7 +4,7 @@ FULLBUILD=$1
 
 [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
 
-PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server --client --swig"
+PIDL="$PERL ./build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --server --client --swig --odl"
 
 if [ x$FULLBUILD = xFULL ]; then
       echo Rebuilding all idl files in librpc/idl