qapi: Automatically generate a _MAX value for enums
authorLuiz Capitulino <lcapitulino@redhat.com>
Fri, 30 Sep 2011 15:43:27 +0000 (12:43 -0300)
committerLuiz Capitulino <lcapitulino@redhat.com>
Tue, 4 Oct 2011 14:00:47 +0000 (11:00 -0300)
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

index 3bacc0c0da4de6e58b3b48707aee0209b3108e87..f64d84c39ea7ae7b6f5f60ef997e0a7ae9b9cc5f 100644 (file)
@@ -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,
 ''',