summaryrefslogtreecommitdiff
path: root/source4/build/pidl
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-08 04:55:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:21 -0500
commitc11204339ae86604a6edd6491f5ee03bf5e3c950 (patch)
treedea831ae95df9afda92768e3397e8579ebe4a71f /source4/build/pidl
parentd105d5e9e40d9950f0c8e61ac17d352c4cb4e6e2 (diff)
downloadsamba-c11204339ae86604a6edd6491f5ee03bf5e3c950.tar.gz
samba-c11204339ae86604a6edd6491f5ee03bf5e3c950.tar.bz2
samba-c11204339ae86604a6edd6491f5ee03bf5e3c950.zip
r8220: added auto-generation of ENUM constants in ejs wrapper. So we can now use the enum name
instead of a integer in ejs scripts making rpc calls (This used to be commit a61cdee384c3002860016c1740276529493d318d)
Diffstat (limited to 'source4/build/pidl')
-rw-r--r--source4/build/pidl/ejs.pm30
1 files changed, 29 insertions, 1 deletions
diff --git a/source4/build/pidl/ejs.pm b/source4/build/pidl/ejs.pm
index 3fe9579aba..24204b79b3 100644
--- a/source4/build/pidl/ejs.pm
+++ b/source4/build/pidl/ejs.pm
@@ -10,6 +10,7 @@ use strict;
use pidl::typelist;
my($res);
+my %constants;
sub pidl ($)
{
@@ -409,6 +410,17 @@ sub EjsEnumPush($$)
{
my $name = shift;
my $d = shift;
+ my $v = 0;
+ # put the enum elements in the constants array
+ foreach my $e (@{$d->{ELEMENTS}}) {
+ chomp $e;
+ if ($e =~ /^(.*)=\s*(.*)\s*$/) {
+ $e = $1;
+ $v = $2;
+ }
+ $constants{$e} = $v;
+ $v++;
+ }
pidl "\nstatic NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const enum $name *r)\n{\n";
pidl "\tunsigned e = *r;\n";
pidl "\tNDR_CHECK(ejs_push_enum(ejs, v, name, &e));\n";
@@ -420,7 +432,9 @@ sub EjsEnumPush($$)
# push a bitmap
sub EjsBitmapPush($$)
{
- # ignored for now
+ my $name = shift;
+ my $e = shift;
+# print util::MyDumper($e);
}
@@ -486,6 +500,8 @@ sub EjsInterface($)
my @fns = ();
my $name = $interface->{NAME};
+ %constants = ();
+
foreach my $d (@{$interface->{TYPEDEFS}}) {
EjsTypedefPush($d);
EjsTypedefPull($d);
@@ -506,6 +522,18 @@ sub EjsInterface($)
foreach (@fns) {
pidl "\tejsDefineCFunction(-1, \"dcerpc_$_\", ejs_$_, NULL, MPR_VAR_SCRIPT_HANDLE);\n";
}
+ pidl "}\n\n";
+
+ pidl "void setup_ejs_constants_$name(int eid)\n";
+ pidl "{\n";
+ foreach my $v (keys %constants) {
+ my $value = $constants{$v};
+ if (substr($value, 0, 1) eq "\"") {
+ pidl "\tejs_set_constant_string(eid, \"$v\", $value);\n";
+ } else {
+ pidl "\tejs_set_constant_int(eid, \"$v\", $value);\n";
+ }
+ }
pidl "}\n";
}