aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-08-24 10:46:07 +0200
committerMarkus Armbruster <armbru@redhat.com>2017-09-04 13:09:13 +0200
commit5b5f825d44306b18509cd10ba9ac6983e90d6e0f (patch)
tree4eaa8543ba0c568929b6879ff239b70ddfcef056 /scripts
parent1c236ba5319d6141964fddb38f1d942cebcaed05 (diff)
qapi: Generate FOO_str() macro for QAPI enum FOO
The next commit will put it to use. May look pointless now, but we're going to change the FOO_lookup's type, and then it'll help. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1503564371-26090-13-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi-event.py1
-rw-r--r--scripts/qapi-types.py4
-rw-r--r--scripts/qapi.py3
3 files changed, 8 insertions, 0 deletions
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index bcbef1035f..07b4b70199 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -217,6 +217,7 @@ fdef.write(mcgen('''
fdecl.write(mcgen('''
#include "qapi/error.h"
+#include "qapi/util.h"
#include "qapi/qmp/qdict.h"
#include "%(prefix)sqapi-types.h"
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index b45e7b5634..7e3051dbb9 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -292,6 +292,10 @@ fdef.write(mcgen('''
''',
prefix=prefix))
+fdecl.write(mcgen('''
+#include "qapi/util.h"
+'''))
+
schema = QAPISchema(input_file)
gen = QAPISchemaGenTypeVisitor()
schema.visit(gen)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 3693b520da..8736b9c786 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1894,6 +1894,9 @@ typedef enum %(c_name)s {
ret += mcgen('''
+#define %(c_name)s_str(val) \\
+ qapi_enum_lookup(%(c_name)s_lookup, (val))
+
extern const char *const %(c_name)s_lookup[];
''',
c_name=c_name(name))