Author: jelmer
Date: 2005-06-01 00:12:34 +0000 (Wed, 01 Jun 2005)
New Revision: 7160

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7160

Log:
Initial work on an esp function wrapper generator

Added:
   branches/SAMBA_4_0/source/build/pidl/esp.pm
Modified:
   branches/SAMBA_4_0/source/build/pidl/pidl.pl


Changeset:
Added: branches/SAMBA_4_0/source/build/pidl/esp.pm
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/esp.pm 2005-06-01 00:00:50 UTC (rev 
7159)
+++ branches/SAMBA_4_0/source/build/pidl/esp.pm 2005-06-01 00:12:34 UTC (rev 
7160)
@@ -0,0 +1,76 @@
+###################################################
+# ESP function wrapper generator
+# Copyright [EMAIL PROTECTED] 2005
+# released under the GNU GPL
+
+package EspClient;
+
+use strict;
+use pidl::typelist;
+
+my($res);
+
+sub pidl ($)
+{
+       $res .= shift;
+}
+
+sub ESPFunction($)
+{
+       my $d = shift;
+
+       pidl "static int esp_$d->{NAME}(struct EspRequest *ep, int argc, struct 
MprVar **argv)\n";
+       pidl "{\n";
+
+       # FIXME
+
+       pidl "\treturn 0;\n";
+       pidl "}\n\n";
+}
+
+#####################################################################
+# parse the interface definitions
+sub ESPInterface($)
+{
+       my($interface) = shift;
+       my @fns = ();
+
+       foreach my $d (@{$interface->{FUNCTIONS}}) {
+               next if not defined($d->{OPNUM});
+               
+               ESPFunction($d);
+
+               push (@fns, $d->{NAME});
+       }
+       
+       return @fns;
+}
+
+#####################################################################
+# parse a parsed IDL into a C header
+sub Parse($$)
+{
+    my($ndr) = shift;
+       my $hdr = shift;
+       my @fns = ();
+
+       $res = "";
+       pidl "#include \"$hdr\"\n\n";
+    pidl "/* ESP wrapper functions auto-generated by pidl */\n\n";
+    foreach my $x (@{$ndr}) {
+           if ($x->{TYPE} eq "INTERFACE") {
+                   push (@fns, ESPInterface($x));
+           }
+    }
+
+       pidl "void setup_ejs_functions(void)\n";
+       pidl "{\n";
+       foreach (@fns) {
+               pidl "\tespDefineCFunction(NULL, \"$_\", esp_$_, NULL);\n";
+       }
+       pidl "}\n";
+       
+    return $res;
+}
+
+1;

Modified: branches/SAMBA_4_0/source/build/pidl/pidl.pl
===================================================================
--- branches/SAMBA_4_0/source/build/pidl/pidl.pl        2005-06-01 00:00:50 UTC 
(rev 7159)
+++ branches/SAMBA_4_0/source/build/pidl/pidl.pl        2005-06-01 00:12:34 UTC 
(rev 7160)
@@ -31,6 +31,7 @@
 use pidl::template;
 use pidl::swig;
 use pidl::compat;
+use pidl::esp;
 
 my($opt_help) = 0;
 my($opt_parse) = 0;
@@ -47,6 +48,7 @@
 my($opt_swig) = 0;
 my($opt_dcom_proxy) = 0;
 my($opt_com_header) = 0;
+my($opt_esp);
 my($opt_odl) = 0;
 my($opt_quiet) = 0;
 my($opt_output);
@@ -70,6 +72,7 @@
  --dump                dump a pidl file back to idl
  --header[=OUTFILE]    create a C NDR header file
  --parser[=OUTFILE]    create a C NDR parser
+ --esp[=OUTFILE]       create esp wrapper file
  --client              create a C NDR client
  --server              create server boilerplate
  --template            print a template for a pipe
@@ -100,6 +103,7 @@
         'client' => \$opt_client,
            'eth-parser:s' => \$opt_eth_parser,
                'eth-header:s' => \$opt_eth_header,
+               'esp:s' => \$opt_esp,
            'diff' => \$opt_diff,
                'odl' => \$opt_odl,
            'keep' => \$opt_keep,
@@ -161,8 +165,8 @@
        if ($opt_com_header) {
                my $res = COMHeader::Parse($pidl);
                if ($res) {
-                       my $h_filename = dirname($output) . "/com_$basename.h";
-                       util::FileSave($h_filename, 
+                       my $comh_filename = dirname($output) . 
"/com_$basename.h";
+                       util::FileSave($comh_filename, 
                        "#include \"librpc/gen_ndr/ndr_orpc.h\"\n" . 
                        "#include \"librpc/gen_ndr/ndr_$basename.h\"\n" . 
                        $res);
@@ -190,7 +194,7 @@
                $pidl = ODL::ODL2IDL($pidl);
        }
 
-       if (defined($opt_header) or defined($opt_eth_parser) or 
defined($opt_eth_header) or $opt_client or $opt_server or defined($opt_parser)) 
{
+       if (defined($opt_header) or defined($opt_eth_parser) or 
defined($opt_eth_header) or $opt_client or $opt_server or defined($opt_parser) 
or defined($opt_esp)) {
                $ndr = Ndr::Parse($pidl);
 #              print util::MyDumper($ndr);
        }
@@ -209,6 +213,7 @@
                }
        }
 
+
        if (defined($opt_eth_header)) {
          my($eparserhdr) = $opt_eth_header;
          if ($eparserhdr eq "") {
@@ -218,15 +223,20 @@
          util::FileSave($eparserhdr, EthHeader::Parse($ndr));
        }
 
+       my $h_filename = util::ChangeExtension($output, ".h");
        if ($opt_client) {
                my ($client) = util::ChangeExtension($output, "_c.c");
-               my $h_filename = util::ChangeExtension($output, ".h");
 
                util::FileSave($client, NdrClient::Parse($ndr,$h_filename));
        }
 
+       if (defined($opt_esp)) {
+               my $esp = $opt_esp;
+               if ($esp eq "") { $esp = util::ChangeExtension($output, 
"_esp.c"); }
+               util::FileSave($esp, EspClient::Parse($ndr, $h_filename));
+       }
+
        if ($opt_server) {
-               my $h_filename = util::ChangeExtension($output, ".h");
                my $dcom = "";
 
                foreach my $x (@{$pidl}) {

Reply via email to