summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-06-01 00:12:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:21 -0500
commitcc89874f521532721e8ccb402c638c558e409811 (patch)
tree8f9b905211cd22f3984b17ec91e87d0be992166a /source4/build/pidl
parent03c2d642a620380d96a9e745ceb1cd19ffea2160 (diff)
downloadsamba-cc89874f521532721e8ccb402c638c558e409811.tar.gz
samba-cc89874f521532721e8ccb402c638c558e409811.tar.bz2
samba-cc89874f521532721e8ccb402c638c558e409811.zip
r7160: Initial work on an esp function wrapper generator
(This used to be commit aaf097ec101b5e31b00e6e9a211e247ee69a118a)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/esp.pm76
-rwxr-xr-xsource4/build/pidl/pidl.pl20
2 files changed, 91 insertions, 5 deletions
diff --git a/source4/build/pidl/esp.pm b/source4/build/pidl/esp.pm
new file mode 100644
index 0000000000..8625544fda
--- /dev/null
+++ b/source4/build/pidl/esp.pm
@@ -0,0 +1,76 @@
+###################################################
+# ESP function wrapper generator
+# Copyright jelmer@samba.org 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;
diff --git a/source4/build/pidl/pidl.pl b/source4/build/pidl/pidl.pl
index a1089f90b1..fcc58de51e 100755
--- a/source4/build/pidl/pidl.pl
+++ b/source4/build/pidl/pidl.pl
@@ -31,6 +31,7 @@ use pidl::util;
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_keep) = 0;
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 @@ Options:
--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 @@ GetOptions (
'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 @@ sub process_file($)
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 @@ sub process_file($)
$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 @@ sub process_file($)
}
}
+
if (defined($opt_eth_header)) {
my($eparserhdr) = $opt_eth_header;
if ($eparserhdr eq "") {
@@ -218,15 +223,20 @@ sub process_file($)
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}) {