Patchwork [12/26] qapi: Automatically generate a _MAX value for enums

login
register
mail settings
Submitter Luiz Capitulino
Date Oct. 5, 2011, 1:21 p.m.
Message ID <1317820931-25872-13-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/117862/
State New
Headers show

Comments

Luiz Capitulino - Oct. 5, 2011, 1:21 p.m.
It's the last value in the enum and is very useful for the C
implementation.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 scripts/qapi-types.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

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,
 ''',