From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUBl-0003x3-O5 for qemu-devel@nongnu.org; Thu, 17 Sep 2015 04:05:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcUBh-0001HH-S6 for qemu-devel@nongnu.org; Thu, 17 Sep 2015 04:05:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcUBh-0001Fo-O0 for qemu-devel@nongnu.org; Thu, 17 Sep 2015 04:05:01 -0400 From: Markus Armbruster References: <1442401589-24189-1-git-send-email-armbru@redhat.com> <1442401589-24189-10-git-send-email-armbru@redhat.com> <55F9A403.7030008@redhat.com> Date: Thu, 17 Sep 2015 10:04:58 +0200 In-Reply-To: <55F9A403.7030008@redhat.com> (Eric Blake's message of "Wed, 16 Sep 2015 11:16:51 -0600") Message-ID: <87bnd1fp3p.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v8 09/26] qapi: De-duplicate enum code generation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 09/16/2015 05:06 AM, Markus Armbruster wrote: >> Duplicated in commit 21cd70d. Yes, we can't import qapi-types, but >> that's no excuse. Move the helpers from qapi-types.py to qapi.py, and >> replace the duplicates in qapi-event.py. >> >> The generated event enumeration type's lookup table becomes >> const-correct (see commit 2e4450f), and uses explicit indexes instead >> of relying on order (see commit 912ae9c). >> >> Signed-off-by: Markus Armbruster >> --- >> docs/qapi-code-gen.txt | 9 ++++--- >> scripts/qapi-event.py | 67 +++----------------------------------------------- >> scripts/qapi-types.py | 55 ----------------------------------------- >> scripts/qapi.py | 55 +++++++++++++++++++++++++++++++++++++++++ >> 4 files changed, 64 insertions(+), 122 deletions(-) >> > >> +++ b/scripts/qapi.py >> @@ -1497,6 +1497,61 @@ def guardend(name): >> ''', >> name=guardname(name)) >> >> +def generate_enum_lookup(name, values, prefix=None): > > To keep pep8 happier, you could use two blank lines before def here... > >> + return ret >> + >> +def generate_enum(name, values, prefix=None): > > and here. Then again, 13/26 does more of these sorts of cleanups, and > v7 had the same use of 1 blank line. Up to you if it is worth avoiding > the churn; but it is whitespace either way so it doesn't affect review. Matches the code around it, which trumps pep8. pep8 is quite unhappy with qapi.py. This series makes it slightly happier by deleting unhappy code. Finishing the conversion to the new intermediate representation involves folding semantic analysis into QAPISchema, good opportunity to tidy up the moved code. After that, we should probably tidy up whatever's left. > Also, do you still need prefix=None, or can we rely on the fact that now > all callers supply prefix by virtue of the visitor callback, and make > the parameter non-optional? There are calls without prefix left in qapi-event.py. > Reviewed-by: Eric Blake Thanks!