[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/19] qapi-visit: Simplify visit of empty branch
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v2 13/19] qapi-visit: Simplify visit of empty branch in union |
Date: |
Thu, 25 Feb 2016 16:38:42 -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>
---
v2: no change
---
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 dbae00c..a9de393 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -37,7 +37,9 @@ void visit_type_%(c_name)s_members(Visitor *v, %(c_name)s
*obj, Error **errp);
def gen_visit_members_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
- [Qemu-devel] [PATCH v2 02/19] qapi-visit: Expose visit_type_FOO_members(), (continued)
- [Qemu-devel] [PATCH v2 02/19] qapi-visit: Expose visit_type_FOO_members(), Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 01/19] qapi: Rename 'fields' to 'members' in internal interface, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 03/19] qapi: Update docs to match recent generator changes, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 06/19] ui: Shorten references into InputEvent, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 10/19] qapi-visit: Factor out gen_visit_members_call(), Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 07/19] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 08/19] chardev: Drop useless ChardevDummy type, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 09/19] qapi: Drop useless 'data' member of unions, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 05/19] util: Shorten references into SocketAddress, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 12/19] qapi: Fix command with named empty argument type, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 13/19] qapi-visit: Simplify visit of empty branch in union,
Eric Blake <=
- [Qemu-devel] [PATCH v2 11/19] qapi: Add type.is_empty() helper, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 15/19] qapi-visit: Move error check into gen_visit_members_call(), Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 16/19] qapi: Allow anonymous base for flat union, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 19/19] qapi: Make c_type() more OO-like, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 17/19] qapi: Use anonymous base in SchemaInfo, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 18/19] qapi: Use anonymous base in CpuInfo, Eric Blake, 2016/02/25
- [Qemu-devel] [PATCH v2 14/19] qapi: Don't special-case simple union wrappers, Eric Blake, 2016/02/25