aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2011-09-30 12:43:27 -0300
committerLuiz Capitulino <lcapitulino@redhat.com>2011-10-04 11:00:47 -0300
commit303b54b1a2611eda47abb28546869c49b5664f59 (patch)
treeb6d800d336afe2b461fb6f39f16d797af9a36caf
parentd2a80d6bb3fdf319d28f25eb034b32a9f3da7334 (diff)
downloadqemu-303b54b1a2611eda47abb28546869c49b5664f59.zip
qemu-303b54b1a2611eda47abb28546869c49b5664f59.tar.gz
qemu-303b54b1a2611eda47abb28546869c49b5664f59.tar.bz2
qapi: Automatically generate a _MAX value for enums
It's the last value in the enum and is very useful for the C implementation. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
-rw-r--r--scripts/qapi-types.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 3bacc0c..f64d84c 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -91,8 +91,11 @@ typedef enum %(name)s
''',
name=name)
+ # append automatically generated _MAX value
+ enum_values = values + [ 'MAX' ]
+
i = 0
- for value in values:
+ for value in enum_values:
enum_decl += mcgen('''
%(abbrev)s_%(value)s = %(i)d,
''',