From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sbi8f-0001E3-OE for qemu-devel@nongnu.org; Mon, 04 Jun 2012 21:00:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sbi8c-0002rL-4I for qemu-devel@nongnu.org; Mon, 04 Jun 2012 21:00:49 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:39431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sbi8b-0002oW-I5 for qemu-devel@nongnu.org; Mon, 04 Jun 2012 21:00:45 -0400 Received: by mail-pz0-f45.google.com with SMTP id v2so7118161dad.4 for ; Mon, 04 Jun 2012 18:00:44 -0700 (PDT) Sender: fluxion From: Michael Roth Date: Mon, 4 Jun 2012 20:00:07 -0500 Message-Id: <1338858018-17189-7-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1338858018-17189-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1338858018-17189-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 06/17] qapi: qapi-visit.py, add gen support for existing types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, quintela@redhat.com, owasserm@redhat.com, yamahata@valinux.co.jp, pbonzini@redhat.com, akong@redhat.com, afaerber@suse.de 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 --- 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