Received: from eggs.gnu.org ([2001:4830:134:3::10]:48894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcTwR-0008Pq-Fa for qemu-devel@nongnu.org; Thu, 17 Sep 2015 03:49:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZcTwN-00040a-Eg for qemu-devel@nongnu.org; Thu, 17 Sep 2015 03:49:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZcTwN-00040U-9R for qemu-devel@nongnu.org; Thu, 17 Sep 2015 03:49:11 -0400 From: Markus Armbruster References: <1442401589-24189-1-git-send-email-armbru@redhat.com> <1442401589-24189-6-git-send-email-armbru@redhat.com> <55F98A76.9020106@redhat.com> Date: Thu, 17 Sep 2015 09:49:08 +0200 In-Reply-To: <55F98A76.9020106@redhat.com> (Eric Blake's message of "Wed, 16 Sep 2015 09:27:50 -0600") Message-ID: <87k2rpfpu3.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v8 05/26] tests/qapi-schema: Convert test harness to QAPISchemaVisitor 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: >> The old code prints the result of parsing (list of expression >> dictionaries), and partial results of semantic analysis (list of enum >> dictionaries, list of struct dictionaries). >> >> The new code prints a trace of a schema visit, i.e. what the back-ends >> are going to use. Built-in and array types are omitted, because >> they're boring. >> >> Signed-off-by: Markus Armbruster >> --- > >> +class QAPISchemaTestVisitor(QAPISchemaVisitor): >> + def visit_enum_type(self, name, info, values, prefix): >> + print 'enum %s %s prefix=%s' % (name, values, prefix) >> + >> + def visit_object_type(self, name, info, base, members, variants): >> + print 'object %s' % name >> + if base: >> + print ' base %s' % base.name > > For consistency with other visitors, I might have done: > > if prefix: > print ' prefix %s' % prefix > > instead of printing prefix=None for most enums. In particular, > >> +enum EnumOne ['value1', 'value2', 'value3'] prefix=None >> +object EventStructOne >> + member struct1: UserDefOne optional=False >> + member string: str optional=False >> + member enum2: EnumOne optional=True >> +object NestedEnumsOne >> + member enum1: EnumOne optional=False >> + member enum2: EnumOne optional=True >> + member enum3: EnumOne optional=False >> + member enum4: EnumOne optional=True >> +enum QEnumTwo ['value1', 'value2'] prefix=QENUM_TWO > > the fact that prefix=None and prefix=QENUM_TWO doesn't offer any visual > clues on whether the string was user-supplied, means that the following > would result in ambiguous output: > { 'enum':'Foo', 'prefix':'None', 'data':[] } No big deal. But avoiding it is no big deal, either. I'll give it a try. > But it's not necessarily a strong enough reason for a respin. > > Reviewed-by: Eric Blake Thanks!