[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/17] qapi: qapi-visit.py, add gen support for exis
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 06/17] qapi: qapi-visit.py, add gen support for existing types |
Date: |
Mon, 4 Jun 2012 20:00:07 -0500 |
For qidl-annotated devices, we generate visitors for existing types,
rather than defined the types via qapi. Modify qapi-visit.py so that we
can pass it a header containing the type definition rather that having
it expect a generated one.
Signed-off-by: Michael Roth <address@hidden>
---
scripts/qapi-visit.py | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 6562226..a319e66 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -229,8 +229,10 @@ void visit_type_%(name)s(Visitor *m, %(name)s * obj, const
char *name, Error **e
name=name)
try:
- opts, args = getopt.gnu_getopt(sys.argv[1:], "chp:o:",
- ["source", "header", "prefix=",
"output-dir="])
+ opts, args = getopt.gnu_getopt(sys.argv[1:], "chp:o:ei:",
+ ["source", "header", "prefix=",
+ "output-dir=", "existing-types",
+ "include="])
except getopt.GetoptError, err:
print str(err)
sys.exit(1)
@@ -239,9 +241,11 @@ output_dir = ""
prefix = ""
c_file = 'qapi-visit.c'
h_file = 'qapi-visit.h'
+includes = []
do_c = False
do_h = False
+existing_types = False
for o, a in opts:
if o in ("-p", "--prefix"):
@@ -252,6 +256,10 @@ for o, a in opts:
do_c = True
elif o in ("-h", "--header"):
do_h = True
+ elif o in ("-e", "--existing-types"):
+ existing_types = True
+ elif o in ("-i", "--include"):
+ includes.append(a)
if not do_c and not do_h:
do_c = True
@@ -316,19 +324,35 @@ fdecl.write(mcgen('''
#define %(guard)s
#include "qapi/qapi-visit-core.h"
-#include "%(prefix)sqapi-types.h"
''',
prefix=prefix, guard=guardname(h_file)))
+if not existing_types:
+ fdecl.write(mcgen('''
+#include "%(prefix)sqapi-types.h"
+''',
+ prefix=prefix))
+
+for include in includes:
+ fdecl.write(mcgen('''
+#include "%(include)s"
+''',
+ include=include))
+
+
exprs = parse_schema(sys.stdin)
for expr in exprs:
if expr.has_key('type'):
ret = generate_visit_struct(expr['type'], expr['data'])
- ret += generate_visit_list(expr['type'], expr['data'])
+ if not existing_types:
+ ret += generate_visit_list(expr['type'], expr['data'])
fdef.write(ret)
- ret = generate_declaration(expr['type'], expr['data'])
+ if existing_types:
+ ret = generate_declaration(expr['type'], expr['data'], False)
+ else:
+ ret = generate_declaration(expr['type'], expr['data'], True)
fdecl.write(ret)
elif expr.has_key('union'):
ret = generate_visit_union(expr['union'], expr['data'])
--
1.7.4.1
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, (continued)
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Avi Kivity, 2012/06/06
- Re: [Qemu-devel] [PATCH 01/17] qidl: add QEMU IDL processor, Anthony Liguori, 2012/06/06
[Qemu-devel] [PATCH 06/17] qapi: qapi-visit.py, add gen support for existing types,
Michael Roth <=
[Qemu-devel] [PATCH 05/17] qapi: qapi-visit.py, support arrays and complex qapi definitions, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 07/17] qapi: add open-coded visitors for QEMUTimer/struct tm types, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 08/17] rtc: move RTCState declaration to header, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 09/17] rtc: add qc annotations, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 10/17] Makefile: add infrastructure to incorporate qidl-generated files, Michael Roth, 2012/06/04
[Qemu-devel] [PATCH 15/17] Makefile: add qidl-generation of vmstate field descriptions, Michael Roth, 2012/06/04