r8283: make sure we build constant variables for both pull and push side of enums
authorAndrew Tridgell <tridge@samba.org>
Sun, 10 Jul 2005 08:07:12 +0000 (08:07 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:19:31 +0000 (13:19 -0500)
(This used to be commit 529370ed92f5a683ae7bd34d0cd2ce01c2bda81a)

source4/build/pidl/Parse/Pidl/Samba/EJS.pm

index 4411324b0560c3b2f4468a803e315ec24fe92de0..b50646595e49aae7ef96b1dd448cf9e42bae63e3 100644 (file)
@@ -289,12 +289,31 @@ sub EjsUnionPull($$)
        pidl "}";
 }
 
+##############################################
+# put the enum elements in the constants array
+sub EjsEnumConstant($)
+{
+       my $d = shift;
+       my $v = 0;
+       foreach my $e (@{$d->{ELEMENTS}}) {
+               my $el = $e;
+               chomp $el;
+               if ($el =~ /^(.*)=\s*(.*)\s*$/) {
+                       $el = $1;
+                       $v = $2;
+               }
+               $constants{$el} = $v;
+               $v++;
+       }
+}
+
 ###########################
 # pull a enum
 sub EjsEnumPull($$)
 {
        my $name = shift;
        my $d = shift;
+       EjsEnumConstant($d);
        pidl fn_prefix($d);
        pidl "NTSTATUS ejs_pull_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, enum $name *r)\n{";
        indent;
@@ -536,18 +555,7 @@ sub EjsEnumPush($$)
 {
        my $name = shift;
        my $d = shift;
-       my $v = 0;
-       # put the enum elements in the constants array
-       foreach my $e (@{$d->{ELEMENTS}}) {
-               my $el = $e;
-               chomp $el;
-               if ($el =~ /^(.*)=\s*(.*)\s*$/) {
-                       $el = $1;
-                       $v = $2;
-               }
-               $constants{$el} = $v;
-               $v++;
-       }
+       EjsEnumConstant($d);
        pidl fn_prefix($d);
        pidl "NTSTATUS ejs_push_$name(struct ejs_rpc *ejs, struct MprVar *v, const char *name, const enum $name *r)\n{";
        indent;