From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StnS1-0005W2-Pn for qemu-devel@nongnu.org; Tue, 24 Jul 2012 18:19:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StnS0-0005rV-GR for qemu-devel@nongnu.org; Tue, 24 Jul 2012 18:19:33 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:51616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StnS0-0005rR-8H for qemu-devel@nongnu.org; Tue, 24 Jul 2012 18:19:32 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Jul 2012 16:19:30 -0600 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 0AC983E4003C for ; Tue, 24 Jul 2012 22:19:09 +0000 (WET) Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6OMJ9Yp093206 for ; Tue, 24 Jul 2012 16:19:09 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6OMJ9Pt030703 for ; Tue, 24 Jul 2012 16:19:09 -0600 From: Anthony Liguori In-Reply-To: <1343150454-4677-8-git-send-email-mdroth@linux.vnet.ibm.com> References: <1343150454-4677-1-git-send-email-mdroth@linux.vnet.ibm.com> <1343150454-4677-8-git-send-email-mdroth@linux.vnet.ibm.com> Date: Tue, 24 Jul 2012 17:19:06 -0500 Message-ID: <871uk0ls4l.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 07/22] qapi: qapi_visit.py, support generating static functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth , qemu-devel@nongnu.org Cc: quintela@redhat.com, owasserm@redhat.com, yamahata@valinux.co.jp, pbonzini@redhat.com, akong@redhat.com, afaerber@suse.de Michael Roth writes: Reviewed-by: Anthony Liguori Regards, Anthony Liguori > qidl embeds visitor code into object files rather than linking against > seperate files, so allow for static declarations when we're using > qapi_visit.py as a library as we do with qidl.py > > Signed-off-by: Michael Roth > --- > scripts/qapi_visit.py | 51 ++++++++++++++++++++++++++++++++----------------- > 1 file changed, 33 insertions(+), 18 deletions(-) > > diff --git a/scripts/qapi_visit.py b/scripts/qapi_visit.py > index bf93bfe..864acb2 100644 > --- a/scripts/qapi_visit.py > +++ b/scripts/qapi_visit.py > @@ -139,13 +139,16 @@ visit_end_optional(m, &err); > ''') > return ret > > -def generate_visit_struct(name, members): > +def generate_visit_struct(name, members, static=False): > + ret_type = "void" > + if static: > + ret_type = "static " + ret_type > ret = mcgen(''' > > -void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp) > +%(ret_type)s visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp) > { > ''', > - name=name) > + name=name, ret_type=ret_type) > > push_indent() > ret += generate_visit_struct_body("", name, members) > @@ -156,10 +159,13 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** > ''') > return ret > > -def generate_visit_list(name, members): > +def generate_visit_list(name, members, static=False): > + ret_type = "void" > + if static: > + ret_type = "static " + ret_type > return mcgen(''' > > -void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp) > +%(ret_type)s visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp) > { > GenericList *i, **prev = (GenericList **)obj; > Error *err = NULL; > @@ -181,19 +187,22 @@ void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, > } > } > ''', > - name=name) > + name=name, ret_type=ret_type) > > -def generate_visit_enum(name, members): > +def generate_visit_enum(name, members, static=False): > + ret_type = "void" > + if static: > + ret_type = "static " + ret_type > return mcgen(''' > > -void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp) > +%(ret_type)s visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp) > { > visit_type_enum(m, (int *)obj, %(name)s_lookup, "%(name)s", name, errp); > } > ''', > - name=name) > + name=name, ret_type=ret_type) > > -def generate_visit_union(name, members): > +def generate_visit_union(name, members, static=False): > ret = generate_visit_enum('%sKind' % name, members.keys()) > > ret += mcgen(''' > @@ -250,27 +259,33 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** > > return ret > > -def generate_declaration(name, members, genlist=True): > +def generate_declaration(name, members, genlist=True, static=False): > + ret_type = "void" > + if static: > + ret_type = "static " + ret_type > ret = mcgen(''' > > -void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp); > +%(ret_type)s visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error **errp); > ''', > - name=name) > + name=name, ret_type=ret_type) > > if genlist: > ret += mcgen(''' > -void visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp); > +%(ret_type)s visit_type_%(name)sList(Visitor *m, %(name)sList ** obj, const char *name, Error **errp); > ''', > - name=name) > + name=name, ret_type=ret_type) > > return ret > > -def generate_decl_enum(name, members, genlist=True): > +def generate_decl_enum(name, members, genlist=True, static=False): > + ret_type = "void" > + if static: > + ret_type = "static " + ret_type > return mcgen(''' > > -void visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp); > +%(ret_type)s visit_type_%(name)s(Visitor *m, %(name)s * obj, const char *name, Error **errp); > ''', > - name=name) > + name=name, ret_type=ret_type) > > def main(argv=[]): > try: > -- > 1.7.9.5