qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH v5 01/14] qapi: Assert in places where variants are not handled
Date: Wed,  9 Mar 2016 17:55:22 -0700	[thread overview]
Message-ID: <1457571335-10938-2-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1457571335-10938-1-git-send-email-eblake@redhat.com>

We are getting closer to the point where we could use one union
as the base or variant type within another union type (as long
as there are no collisions between any possible combination of
member names allowed across all discriminator choices).  But
until we get to that point, it is worth asserting that variants
are not present in places where we are not prepared to handle
them: when exploding a type into a parameter list, we do not
expect variants.  The qapi.py code is already checking this,
via the older check_type() method; but someday we hope to get
rid of that and move checking into QAPISchema*.check().  The
two asserts added here make sure any refactoring still catches
problems, and makes it locally obvious why we can iterate over
only type.members without worrying about type.variants.

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v5: drop redundant hunk, improve commit message
v4: new patch, split out from .is_empty() patch
---
 scripts/qapi-commands.py | 3 ++-
 scripts/qapi-event.py    | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index f44e01f..edcbd10 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -2,7 +2,7 @@
 # QAPI command marshaller generator
 #
 # Copyright IBM, Corp. 2011
-# Copyright (C) 2014-2015 Red Hat, Inc.
+# Copyright (C) 2014-2016 Red Hat, Inc.
 #
 # Authors:
 #  Anthony Liguori <aliguori@us.ibm.com>
@@ -30,6 +30,7 @@ def gen_call(name, arg_type, ret_type):

     argstr = ''
     if arg_type:
+        assert not arg_type.variants
         for memb in arg_type.members:
             if memb.optional:
                 argstr += 'has_%s, ' % c_name(memb.name)
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index fb579dd..c03cb78 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -59,6 +59,7 @@ def gen_event_send(name, arg_type):
                  name=name)

     if arg_type and arg_type.members:
+        assert not arg_type.variants
         ret += mcgen('''
     qov = qmp_output_visitor_new();
     v = qmp_output_get_visitor(qov);
-- 
2.5.0

  reply	other threads:[~2016-03-10  0:55 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10  0:55 [Qemu-devel] [PATCH v5 00/14] easier unboxed visits/qapi implicit types Eric Blake
2016-03-10  0:55 ` Eric Blake [this message]
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 02/14] qapi: Fix command with named empty argument type Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 03/14] qapi: Make c_type() more OO-like Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 04/14] qapi: Adjust names of implicit types Eric Blake
2016-03-10 13:39   ` Markus Armbruster
2016-03-10 16:11     ` Eric Blake
2016-03-11  7:48       ` Markus Armbruster
2016-03-11 17:29         ` Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 05/14] qapi: Emit implicit structs in generated C Eric Blake
2016-03-10 14:25   ` Markus Armbruster
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 06/14] qapi-event: Slightly shrink generated code Eric Blake
2016-03-10 18:50   ` Markus Armbruster
2016-03-10 20:14     ` Eric Blake
2016-03-16 14:41   ` Markus Armbruster
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 07/14] qapi: Utilize implicit struct visits Eric Blake
2016-03-10 19:05   ` Markus Armbruster
2016-03-10 20:16     ` Eric Blake
2016-03-16 14:45   ` Markus Armbruster
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 08/14] qapi-commands: Inline single-use helpers of gen_marshal() Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 09/14] qapi: Inline gen_visit_members() into lone caller Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 10/14] qapi: Drop unused c_null() Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 11/14] qapi: Don't special-case simple union wrappers Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 12/14] qapi: Make BlockdevOptions doc example closer to reality Eric Blake
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 13/14] qapi: Allow anonymous base for flat union Eric Blake
2016-03-10 20:22   ` Markus Armbruster
2016-03-10 20:50     ` Eric Blake
2016-03-16 15:21       ` Markus Armbruster
2016-03-10  0:55 ` [Qemu-devel] [PATCH v5 14/14] qapi: Use anonymous bases in QMP flat unions Eric Blake
2016-03-10 20:36 ` [Qemu-devel] [PATCH v5 00/14] easier unboxed visits/qapi implicit types Markus Armbruster
2016-03-16 15:24   ` Markus Armbruster
2016-03-17 15:36     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457571335-10938-2-git-send-email-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).