From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enrHf-0002Qu-4o for qemu-devel@nongnu.org; Mon, 19 Feb 2018 14:39:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1enrHb-0003bc-9L for qemu-devel@nongnu.org; Mon, 19 Feb 2018 14:39:31 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34512 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1enrHb-0003ac-3d for qemu-devel@nongnu.org; Mon, 19 Feb 2018 14:39:27 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1JJceI9068009 for ; Mon, 19 Feb 2018 14:39:26 -0500 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2g820yyff9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 19 Feb 2018 14:39:26 -0500 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 Feb 2018 12:39:25 -0700 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <20180211093607.27351-6-armbru@redhat.com> References: <20180211093607.27351-1-armbru@redhat.com> <20180211093607.27351-6-armbru@redhat.com> Date: Fri, 16 Feb 2018 18:59:03 -0600 Message-Id: <151882914354.12376.14797462837938712408@sif> Subject: Re: [Qemu-devel] [PATCH v2 05/29] qapi: New classes QAPIGenC, QAPIGenH, QAPIGenDoc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, eblake@redhat.com Quoting Markus Armbruster (2018-02-11 03:35:43) > These classes encapsulate accumulating and writing output. > = > Convert C code generation to QAPIGenC and QAPIGenH. The conversion is > rather shallow: most of the output accumulation is not converted. > Left for later. > = > The indentation machinery uses a single global variable indent_level, > even though we generally interleave creation of a .c and its .h. It > should become instance variable of QAPIGenC. Also left for later. > = > Documentation generation isn't converted, and QAPIGenDoc isn't used. > This will change shortly. > = > Signed-off-by: Markus Armbruster > Reviewed-by: Eric Blake > Reviewed-by: Marc-Andr=C3=A9 Lureau 2 minor nits below, but in any case: Reviewed-by: Michael Roth > --- > scripts/qapi-commands.py | 23 +++++------ > scripts/qapi-event.py | 22 ++++++----- > scripts/qapi-introspect.py | 18 +++++---- > scripts/qapi-types.py | 22 ++++++----- > scripts/qapi-visit.py | 22 ++++++----- > scripts/qapi.py | 99 +++++++++++++++++++++++++---------------= ------ > 6 files changed, 112 insertions(+), 94 deletions(-) > = > diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py > index c3aa52fce1..8d38ade076 100644 > --- a/scripts/qapi-commands.py > +++ b/scripts/qapi-commands.py > @@ -260,12 +260,10 @@ blurb =3D ''' > * Schema-defined QAPI/QMP commands > ''' > = > -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, > - 'qmp-marshal.c', 'qmp-commands.h', > - blurb, __doc__) > - > -fdef.write(mcgen(''' > +genc =3D QAPIGenC(blurb, __doc__) > +genh =3D QAPIGenH(blurb, __doc__) > = > +genc.add(mcgen(''' > #include "qemu/osdep.h" > #include "qemu-common.h" > #include "qemu/module.h" > @@ -280,20 +278,23 @@ fdef.write(mcgen(''' > #include "%(prefix)sqmp-commands.h" > = > ''', > - prefix=3Dprefix)) > + prefix=3Dprefix)) > = > -fdecl.write(mcgen(''' > +genh.add(mcgen(''' > #include "%(prefix)sqapi-types.h" > #include "qapi/qmp/dispatch.h" > = > void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds); > ''', > - prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DF= alse))) > + prefix=3Dprefix, c_prefix=3Dc_name(prefix, protect=3DFals= e))) > = > schema =3D QAPISchema(input_file) > vis =3D QAPISchemaGenCommandVisitor() > schema.visit(vis) > -fdef.write(vis.defn) > -fdecl.write(vis.decl) > +genc.add(vis.defn) > +genh.add(vis.decl) > = > -close_output(fdef, fdecl) > +if do_c: > + genc.write(output_dir, prefix + 'qmp-marshal.c') > +if do_h: > + genh.write(output_dir, prefix + 'qmp-commands.h') > diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py > index edb9ddb650..bd7a9be3dc 100644 > --- a/scripts/qapi-event.py > +++ b/scripts/qapi-event.py > @@ -176,11 +176,10 @@ blurb =3D ''' > * Schema-defined QAPI/QMP events > ''' > = > -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, > - 'qapi-event.c', 'qapi-event.h', > - blurb, __doc__) > +genc =3D QAPIGenC(blurb, __doc__) > +genh =3D QAPIGenH(blurb, __doc__) > = > -fdef.write(mcgen(''' > +genc.add(mcgen(''' > #include "qemu/osdep.h" > #include "qemu-common.h" > #include "%(prefix)sqapi-event.h" > @@ -191,21 +190,24 @@ fdef.write(mcgen(''' > #include "qapi/qmp-event.h" > = > ''', > - prefix=3Dprefix)) > + prefix=3Dprefix)) > = > -fdecl.write(mcgen(''' > +genh.add(mcgen(''' > #include "qapi/util.h" > #include "%(prefix)sqapi-types.h" > = > ''', > - prefix=3Dprefix)) > + prefix=3Dprefix)) > = > event_enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DFalse) > = > schema =3D QAPISchema(input_file) > vis =3D QAPISchemaGenEventVisitor() > schema.visit(vis) > -fdef.write(vis.defn) > -fdecl.write(vis.decl) > +genc.add(vis.defn) > +genh.add(vis.decl) > = > -close_output(fdef, fdecl) > +if do_c: > + genc.write(output_dir, prefix + 'qapi-event.c') > +if do_h: > + genh.write(output_dir, prefix + 'qapi-event.h') > diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py > index ebe8706f41..3d65690fe3 100644 > --- a/scripts/qapi-introspect.py > +++ b/scripts/qapi-introspect.py > @@ -181,21 +181,23 @@ blurb =3D ''' > * QAPI/QMP schema introspection > ''' > = > -(fdef, fdecl) =3D open_output(output_dir, do_c, do_h, prefix, > - 'qmp-introspect.c', 'qmp-introspect.h', > - blurb, __doc__) > +genc =3D QAPIGenC(blurb, __doc__) > +genh =3D QAPIGenH(blurb, __doc__) > = > -fdef.write(mcgen(''' > +genc.add(mcgen(''' > #include "qemu/osdep.h" > #include "%(prefix)sqmp-introspect.h" > = > ''', > - prefix=3Dprefix)) > + prefix=3Dprefix)) > = > schema =3D QAPISchema(input_file) > vis =3D QAPISchemaGenIntrospectVisitor(opt_unmask) > schema.visit(vis) > -fdef.write(vis.defn) > -fdecl.write(vis.decl) > +genc.add(vis.defn) > +genh.add(vis.decl) > = > -close_output(fdef, fdecl) > +if do_c: > + genc.write(output_dir, prefix + 'qmp-introspect.c') > +if do_h: > + genh.write(output_dir, prefix + 'qmp-introspect.h') > diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py > index 4db8424da1..c0ac879beb 100644 > --- a/scripts/qapi-types.py > +++ b/scripts/qapi-types.py > @@ -180,7 +180,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor): > self.decl =3D '' > self.defn =3D '' > self._fwdecl =3D '' > - self._btin =3D guardstart('QAPI_TYPES_BUILTIN') > + self._btin =3D '\n' + guardstart('QAPI_TYPES_BUILTIN') Minor nit, but if we compensate for guardstart() change here, shouldn't we do the same in QAPISchemaGenVisitVisitor? Both are cosmetic (though Visit is in less need since it has extra an extra newline already, but changing one and not the other to compensate here makes the patch appear less mechanical, and the resulting formatting fix-up gets dropped later in the series anyway) > = > def visit_end(self): > self.decl =3D self._fwdecl + self.decl > +class QAPIGenDoc(QAPIGen): > + def _top(self, fname): > + return (QAPIGen._top(self, fname) > + + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') The whitespace change in "qapi/types qapi/visit: Generate built-in stuff into separate files" should probably be squashed in here: class QAPIGenDoc(QAPIGen): + def _top(self, fname): return (QAPIGen._top(self, fname) + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') > -- = > 2.13.6 >=20