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 v6 05/16] qapi: Hide tag_name data member of variants
Date: Wed, 23 Dec 2015 13:55:34 -0700 [thread overview]
Message-ID: <1450904145-17721-6-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1450904145-17721-1-git-send-email-eblake@redhat.com>
Clean up the only remaining external use of the tag_name field of
QAPISchemaObjectTypeVariants, by explicitly listing the generated
'type' tag for all variants in the testsuite. Then we can mark the
tag_name field as private by adding a leading underscore to prevent
any further use.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v6: rebase to earlier changes; but may be worth dropping this patch
---
scripts/qapi.py | 8 ++++----
tests/qapi-schema/qapi-schema-test.out | 10 ++++++++++
tests/qapi-schema/test-qapi.py | 3 +--
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 87a650d..311bed9 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1072,7 +1072,7 @@ class QAPISchemaObjectTypeVariants(object):
assert len(variants) > 0
for v in variants:
assert isinstance(v, QAPISchemaObjectTypeVariant)
- self.tag_name = tag_name
+ self._tag_name = tag_name
self.tag_member = tag_member
self.variants = variants
@@ -1082,8 +1082,8 @@ class QAPISchemaObjectTypeVariants(object):
def check(self, schema, seen):
if not self.tag_member: # flat union
- self.tag_member = seen[c_name(self.tag_name)]
- assert self.tag_name == self.tag_member.name
+ self.tag_member = seen[c_name(self._tag_name)]
+ assert self._tag_name == self.tag_member.name
assert isinstance(self.tag_member.type, QAPISchemaEnumType)
for v in self.variants:
v.check(schema)
@@ -1123,7 +1123,7 @@ class QAPISchemaAlternateType(QAPISchemaType):
def __init__(self, name, info, variants):
QAPISchemaType.__init__(self, name, info)
assert isinstance(variants, QAPISchemaObjectTypeVariants)
- assert not variants.tag_name
+ assert variants.tag_member
variants.set_owner(name)
variants.tag_member.set_owner(self.name)
self.variants = variants
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index e6088a5..755393a 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -76,21 +76,27 @@ object :obj-user_def_cmd2-arg
member ud1a: UserDefOne optional=False
member ud1b: UserDefOne optional=True
alternate AltIntNum
+ tag type
case i: int
case n: number
alternate AltNumInt
+ tag type
case n: number
case i: int
alternate AltNumStr
+ tag type
case n: number
case s: str
alternate AltStrBool
+ tag type
case s: str
case b: bool
alternate AltStrInt
+ tag type
case s: str
case i: int
alternate AltStrNum
+ tag type
case s: str
case n: number
event EVENT_A :empty
@@ -133,6 +139,7 @@ object UserDefA
member boolean: bool optional=False
member a_b: int optional=True
alternate UserDefAlternate
+ tag type
case uda: UserDefA
case s: str
case i: int
@@ -159,6 +166,7 @@ object UserDefFlatUnion2
object UserDefNativeListUnion
base :empty
member type: UserDefNativeListUnionKind optional=False
+ tag type
case integer: :obj-intList-wrapper
case s8: :obj-int8List-wrapper
case s16: :obj-int16List-wrapper
@@ -207,6 +215,7 @@ object UserDefZero
member integer: int optional=False
event __ORG.QEMU_X-EVENT __org.qemu_x-Struct
alternate __org.qemu_x-Alt
+ tag type
case __org.qemu_x-branch: str
case b: __org.qemu_x-Base
object __org.qemu_x-Base
@@ -223,6 +232,7 @@ object __org.qemu_x-Struct2
object __org.qemu_x-Union1
base :empty
member type: __org.qemu_x-Union1Kind optional=False
+ tag type
case __org.qemu_x-branch: :obj-str-wrapper
enum __org.qemu_x-Union1Kind ['__org.qemu_x-branch']
object __org.qemu_x-Union2
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 649677e..bedd145 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -47,8 +47,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
@staticmethod
def _print_variants(variants):
if variants:
- if variants.tag_name:
- print ' tag %s' % variants.tag_name
+ print ' tag %s' % variants.tag_member.name
for v in variants.variants:
print ' case %s: %s' % (v.name, v.type.name)
--
2.4.3
next prev parent reply other threads:[~2015-12-23 20:55 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-23 20:55 [Qemu-devel] [PATCH v6 00/16] qapi netdev_add introspection (post-introspection cleanups subset F) Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 01/16] net: use Netdev instead of NetClientOptions in client init Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 02/16] qapi: Avoid use of 'data' member of qapi unions Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 03/16] qapi: Forbid empty unions and useless alternates Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 04/16] qapi: Drop useless 'data' member of unions Eric Blake
2015-12-23 20:55 ` Eric Blake [this message]
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 06/16] qapi: Plumb in 'box' to qapi generator lower levels Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 07/16] qapi: Implement boxed types for commands/events Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 08/16] qapi: support implicit structs in OptsVisitor Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 09/16] qapi: Change Netdev into a flat union Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 10/16] net: Use correct type for bool flag Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 11/16] net: Complete qapi-fication of netdev_add Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 12/16] qapi: Allow anonymous base for flat union Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 13/16] qapi: Use anonymous base in SchemaInfo Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 14/16] qapi: Use anonymous base in Netdev Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 15/16] qapi: Use anonymous base in CpuInfo Eric Blake
2015-12-23 20:55 ` [Qemu-devel] [PATCH v6 16/16] qapi: Populate info['name'] for each entity Eric Blake
2015-12-23 20:58 ` [Qemu-devel] [PATCH v6 00/16] qapi netdev_add introspection (post-introspection cleanups subset F) 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=1450904145-17721-6-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).