From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOL1d-0002kO-I8 for qemu-devel@nongnu.org; Wed, 27 Jan 2016 03:00:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOL1Z-00006v-Ht for qemu-devel@nongnu.org; Wed, 27 Jan 2016 03:00:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOL1Z-00006c-CJ for qemu-devel@nongnu.org; Wed, 27 Jan 2016 03:00:21 -0500 From: Markus Armbruster References: <1453219845-30939-1-git-send-email-eblake@redhat.com> <1453219845-30939-31-git-send-email-eblake@redhat.com> <87bn891nwr.fsf@blackfin.pond.sub.org> <8760yguwx2.fsf@blackfin.pond.sub.org> Date: Wed, 27 Jan 2016 09:00:17 +0100 In-Reply-To: <8760yguwx2.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Tue, 26 Jan 2016 17:29:13 +0100") Message-ID: <87pownpi3y.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v9 30/37] qapi: Canonicalize missing object to :empty List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org, Michael Roth Markus Armbruster writes: > Markus Armbruster writes: > >> Eric Blake writes: >> >>> Now that we elide unnecessary visits of empty types, we can >>> start using the special ':empty' type in more places. By using >>> the empty type as the base class of every explicit struct or >>> union, and as the default data for any command or event, we can >>> simplify later logic in qapi-{visit,commands,event} by merely >>> checking whether the type is empty, without also having to worry >>> whether a type was even supplied. You rewrite a command's arg_type from None to ':empty', bit not its ret_type. Deepens the assymmetry between the two. >>> Note that gen_object() in qapi-types still has to check for a >>> base, because it is also called for alternates (which have no >>> base). >> >> What about the one in gen_visit_struct()? >> >> if (base and not base.is_empty()) or members: >> ret += mcgen(''' >> visit_type_%(c_name)s_fields(v, obj, &err); >> ''', >> c_name=c_name(name)) >> >>> No change to generated code. >>> >>> Signed-off-by: Eric Blake >>> >>> --- >>> v9: squash in more related changes >>> v8: rebase to earlier changes >>> v7: rebase to earlier changes >>> v6: new patch >>> --- >>> scripts/qapi-commands.py | 17 +++++++------ >>> scripts/qapi-event.py | 5 ++-- >>> scripts/qapi-types.py | 4 +-- >>> scripts/qapi-visit.py | 12 +++++---- >>> scripts/qapi.py | 25 +++++++++--------- >>> tests/qapi-schema/event-case.out | 2 +- >>> tests/qapi-schema/flat-union-empty.out | 1 + >>> tests/qapi-schema/ident-with-escape.out | 1 + >>> tests/qapi-schema/indented-expr.out | 4 +-- >>> tests/qapi-schema/qapi-schema-test.out | 45 ++++++++++++++++++++++++++++++--- >>> tests/qapi-schema/union-clash-data.out | 2 ++ >>> tests/qapi-schema/union-empty.out | 1 + >>> 12 files changed, 83 insertions(+), 36 deletions(-) > > Missing: update to qapi-introspect.py. At least the expressions like > > arg_type or self._schema.the_empty_object_type > > need updating. But so far not the ret_type or self._schema.the_empty_object_type. [...]