diff options
Diffstat (limited to 'source4/build/pidl/ejs.pm')
-rw-r--r-- | source4/build/pidl/ejs.pm | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/source4/build/pidl/ejs.pm b/source4/build/pidl/ejs.pm new file mode 100644 index 0000000000..4a106f6176 --- /dev/null +++ b/source4/build/pidl/ejs.pm @@ -0,0 +1,75 @@ +################################################### +# EJS function wrapper generator +# Copyright jelmer@samba.org 2005 +# released under the GNU GPL + +package EjsClient; + +use strict; +use pidl::typelist; + +my($res); + +sub pidl ($) +{ + $res .= shift; +} + +sub EJSFunction($) +{ + my $d = shift; + + pidl "static int ejs_$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 EJSInterface($) +{ + my($interface) = shift; + my @fns = (); + + foreach my $d (@{$interface->{FUNCTIONS}}) { + next if not defined($d->{OPNUM}); + + EJSFunction($d); + + push (@fns, $d->{NAME}); + } + + return @fns; +} + +##################################################################### +# parse a parsed IDL into a C header +sub Parse($$) +{ + my($ndr,$hdr) = @_; + my @fns = (); + + $res = ""; + pidl "#include \"$hdr\"\n\n"; + pidl "/* EJS wrapper functions auto-generated by pidl */\n\n"; + foreach my $x (@{$ndr}) { + if ($x->{TYPE} eq "INTERFACE") { + push (@fns, EJSInterface($x)); + } + } + + pidl "void setup_ejs_functions(void)\n"; + pidl "{\n"; + foreach (@fns) { + pidl "\tespDefineCFunction(NULL, \"$_\", esp_$_, NULL);\n"; + } + pidl "}\n"; + + return $res; +} + +1; |