[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 11/17] qapi-visit: Simplify visit of empty branch in
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH 11/17] qapi-visit: Simplify visit of empty branch in union |
Date: |
Fri, 19 Feb 2016 17:19:41 -0700 |
Now that we have is_empty() and gen_visit_fields_call(), it's
fairly easy to skip the visit of a variant type that has no
members. Only one such instance exists at the moment
(CpuInfoOther), but the idea of a union where some branches
add no fields beyond the base type is common enough that we
may add syntax for other cases, as in
{ 'union':'U', 'base':'B', 'discriminator':'D',
'data': { 'default': {}, 'extra':'Type' } }
Note that the Abort type is another example of an empty type,
but it is only used by a simple union rather than a flat
union; and with simple unions, the wrapper type providing
the 'data' QMP key is not empty.
Signed-off-by: Eric Blake <address@hidden>
---
scripts/qapi-visit.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index ab773f6..127c84e0 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -44,7 +44,9 @@ static void visit_type_%(c_type)s_fields(Visitor *v,
%(c_type)s *obj, Error **er
def gen_visit_fields_call(typ, c_name):
ret = ''
assert isinstance(typ, QAPISchemaObjectType)
- if typ.is_implicit():
+ if typ.is_empty():
+ pass
+ elif typ.is_implicit():
# TODO ugly special case for simple union
assert len(typ.members) == 1
assert not typ.variants
--
2.5.0
- Re: [Qemu-devel] [PATCH 02/17] chardev: Shorten references into ChardevBackend, (continued)
- [Qemu-devel] [PATCH 08/17] qapi-visit: Factor out gen_visit_fields_call(), Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 10/17] qapi: Fix command with named empty argument type, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 09/17] qapi: Add type.is_empty() helper, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 15/17] qapi: Use anonymous base in SchemaInfo, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 13/17] qapi-visit: Move error check into gen_visit_fields_call(), Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 16/17] qapi: Use anonymous base in CpuInfo, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 01/17] chardev: Properly initialize ChardevCommon components, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 11/17] qapi-visit: Simplify visit of empty branch in union,
Eric Blake <=
- [Qemu-devel] [PATCH 04/17] ui: Shorten references into InputEvent, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 05/17] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 03/17] util: Shorten references into SocketAddress, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 14/17] qapi: Allow anonymous base for flat union, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 17/17] qapi: Make c_type() more OO-like, Eric Blake, 2016/02/19
- [Qemu-devel] [PATCH 12/17] qapi: Don't special-case simple union wrappers, Eric Blake, 2016/02/19