[PATCH] pidl: allow enums mixing value assignment and value enumeration
Ralph Böhme
slow at samba.org
Thu Jan 19 10:44:25 UTC 2017
Hi!
As discussed in the ringbuf thread, here's the patch to allow pidl to process
IDL files with enums mixing assigned values with value enumeration.
Please review & push if ok.
Volker was reluctant to convert messaging.idl to use automatic enumeration, any
other IDL where we want to exercise this on? :)
Cheerio!
-slow
-------------- next part --------------
From 151d5b5060567434f31036287f488d62dbd4144e Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sun, 8 Jan 2017 13:57:51 +0100
Subject: [PATCH] pidl: allow mixing enum entries with and without values
Signed-off-by: Ralph Boehme <slow at samba.org>
---
pidl/lib/Parse/Pidl/Samba4/Header.pm | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/pidl/lib/Parse/Pidl/Samba4/Header.pm b/pidl/lib/Parse/Pidl/Samba4/Header.pm
index e9b7bee..f73c30c 100644
--- a/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -140,8 +140,7 @@ sub HeaderEnum($$;$)
pidl "\n";
pidl "#else\n";
my $count = 0;
- my $with_val = 0;
- my $without_val = 0;
+ my $fstr = "%d";
pidl " { __do_not_use_enum_$name=0x7FFFFFFF}\n";
foreach my $e (@{$enum->{ELEMENTS}}) {
my $t = "$e";
@@ -150,15 +149,16 @@ sub HeaderEnum($$;$)
if ($t =~ /(.*)=(.*)/) {
$name = $1;
$value = $2;
- $with_val = 1;
- fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!")
- unless ($without_val == 0);
+ $count = oct($value) if $value =~ /^0/;
+ $count++;
+ if ($value =~ /^0x/) {
+ $fstr = "0x%x";
+ } else {
+ $fstr = "%d";
+ }
} else {
$name = $t;
- $value = $count++;
- $without_val = 1;
- fatal($e->{ORIGINAL}, "you can't mix enum member with values and without values!")
- unless ($with_val == 0);
+ $value = sprintf $fstr, $count++;
}
pidl "#define $name ( $value )\n";
}
--
2.7.4
More information about the samba-technical
mailing list