|
|
9ae3a8 |
From 19832bf960bb31814a0d950b01fff45e2618be27 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 8 Nov 2013 06:13:57 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 2/4] qapi: qapi-visit.py, native list support
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1383891239-29531-3-git-send-email-akong@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55609
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 2/4] qapi: qapi-visit.py, native list support
|
|
|
9ae3a8 |
Bugzilla: 848203
|
|
|
9ae3a8 |
RH-Acked-by: Vlad Yasevich <vyasevic@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Teach visitor generators about native types so they can generate the
|
|
|
9ae3a8 |
appropriate visitor routines.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 7c946bc418db6b2a11f89b3465424fef48f714eb)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
scripts/qapi-visit.py | 34 +++++++++++++++++++++++++++++-----
|
|
|
9ae3a8 |
1 files changed, 29 insertions(+), 5 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
scripts/qapi-visit.py | 34 +++++++++++++++++++++++++++++-----
|
|
|
9ae3a8 |
1 files changed, 29 insertions(+), 5 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
|
|
|
9ae3a8 |
index fc2b67a..c39e628 100644
|
|
|
9ae3a8 |
--- a/scripts/qapi-visit.py
|
|
|
9ae3a8 |
+++ b/scripts/qapi-visit.py
|
|
|
9ae3a8 |
@@ -337,12 +337,14 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
return ret
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-def generate_declaration(name, members, genlist=True):
|
|
|
9ae3a8 |
- ret = mcgen('''
|
|
|
9ae3a8 |
+def generate_declaration(name, members, genlist=True, builtin_type=False):
|
|
|
9ae3a8 |
+ ret = ""
|
|
|
9ae3a8 |
+ if not builtin_type:
|
|
|
9ae3a8 |
+ ret += mcgen('''
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp);
|
|
|
9ae3a8 |
''',
|
|
|
9ae3a8 |
- name=name)
|
|
|
9ae3a8 |
+ name=name)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if genlist:
|
|
|
9ae3a8 |
ret += mcgen('''
|
|
|
9ae3a8 |
@@ -370,8 +372,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **e
|
|
|
9ae3a8 |
name=name)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
try:
|
|
|
9ae3a8 |
- opts, args = getopt.gnu_getopt(sys.argv[1:], "chp:o:",
|
|
|
9ae3a8 |
- ["source", "header", "prefix=", "output-dir="])
|
|
|
9ae3a8 |
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "chbp:o:",
|
|
|
9ae3a8 |
+ ["source", "header", "builtins", "prefix=",
|
|
|
9ae3a8 |
+ "output-dir="])
|
|
|
9ae3a8 |
except getopt.GetoptError, err:
|
|
|
9ae3a8 |
print str(err)
|
|
|
9ae3a8 |
sys.exit(1)
|
|
|
9ae3a8 |
@@ -383,6 +386,7 @@ h_file = 'qapi-visit.h'
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
do_c = False
|
|
|
9ae3a8 |
do_h = False
|
|
|
9ae3a8 |
+do_builtins = False
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
for o, a in opts:
|
|
|
9ae3a8 |
if o in ("-p", "--prefix"):
|
|
|
9ae3a8 |
@@ -393,6 +397,8 @@ for o, a in opts:
|
|
|
9ae3a8 |
do_c = True
|
|
|
9ae3a8 |
elif o in ("-h", "--header"):
|
|
|
9ae3a8 |
do_h = True
|
|
|
9ae3a8 |
+ elif o in ("-b", "--builtins"):
|
|
|
9ae3a8 |
+ do_builtins = True
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if not do_c and not do_h:
|
|
|
9ae3a8 |
do_c = True
|
|
|
9ae3a8 |
@@ -459,11 +465,29 @@ fdecl.write(mcgen('''
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#include "qapi/visitor.h"
|
|
|
9ae3a8 |
#include "%(prefix)sqapi-types.h"
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
''',
|
|
|
9ae3a8 |
prefix=prefix, guard=guardname(h_file)))
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
exprs = parse_schema(sys.stdin)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+# to avoid header dependency hell, we always generate declarations
|
|
|
9ae3a8 |
+# for built-in types in our header files and simply guard them
|
|
|
9ae3a8 |
+fdecl.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
|
|
9ae3a8 |
+for typename in builtin_types:
|
|
|
9ae3a8 |
+ fdecl.write(generate_declaration(typename, None, genlist=True,
|
|
|
9ae3a8 |
+ builtin_type=True))
|
|
|
9ae3a8 |
+fdecl.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DECL"))
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+# ...this doesn't work for cases where we link in multiple objects that
|
|
|
9ae3a8 |
+# have the functions defined, so we use -b option to provide control
|
|
|
9ae3a8 |
+# over these cases
|
|
|
9ae3a8 |
+if do_builtins:
|
|
|
9ae3a8 |
+ fdef.write(guardstart("QAPI_VISIT_BUILTIN_VISITOR_DEF"))
|
|
|
9ae3a8 |
+ for typename in builtin_types:
|
|
|
9ae3a8 |
+ fdef.write(generate_visit_list(typename, None))
|
|
|
9ae3a8 |
+ fdef.write(guardend("QAPI_VISIT_BUILTIN_VISITOR_DEF"))
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
for expr in exprs:
|
|
|
9ae3a8 |
if expr.has_key('type'):
|
|
|
9ae3a8 |
ret = generate_visit_struct(expr)
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|