Fix the problem with pidl generating invalid C for enums. According
authorJeremy Allison <jra@samba.org>
Thu, 17 Sep 2009 18:08:42 +0000 (11:08 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 17 Sep 2009 18:11:06 +0000 (11:11 -0700)
to the C standard an enum is guarenteed to be an (int), which means
for 4 byte ints specifying a type of 0x80000000 is an invalid value.
The Solaris compiler complains about this. Fix by adding an (int)
cast in front of the value generation.
Jeremy.

pidl/lib/Parse/Pidl/Samba4/Header.pm

index 53159579463368b518ce4ded67e1d9a9d918e8e0..bb497bb3a77471e331bdf91128efec86b26bae3e 100644 (file)
@@ -120,10 +120,18 @@ sub HeaderEnum($$;$)
                pidl " {\n";
                $tab_depth++;
                foreach my $e (@{$enum->{ELEMENTS}}) {
+                       my @enum_els = ();
                        unless ($first) { pidl ",\n"; }
                        $first = 0;
                        pidl tabs();
-                       pidl $e;
+                       @enum_els = split(/=/, $e);
+                       if (@enum_els == 2) {
+                               pidl $enum_els[0];
+                               pidl "=(int)";
+                               pidl $enum_els[1];
+                       } else {
+                               pidl $e;
+                       }
                }
                pidl "\n";
                $tab_depth--;