[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 32/46] qapi: Hide tag_name data member of variant
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH v5 32/46] qapi: Hide tag_name data member of variants |
Date: |
Mon, 21 Sep 2015 15:57:48 -0600 |
Clean up the only remaining external use of the tag_name field of
QAPISchemaObjectTypeVariants, by explicitly listing the generated
'type' tag for simple unions in the testsuite. Since alternate
types no longer use the tag_member field, we can now mark the
tag_name field as private by adding a leading underscore to
prevent any further use.
Signed-off-by: Eric Blake <address@hidden>
---
scripts/qapi.py | 8 ++++----
tests/qapi-schema/qapi-schema-test.out | 2 ++
tests/qapi-schema/test-qapi.py | 4 ++--
tests/qapi-schema/union-clash2.out | 1 +
tests/qapi-schema/union-empty.out | 1 +
5 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index a91bdf2..18cfde1 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1015,7 +1015,7 @@ class QAPISchemaObjectTypeVariants(object):
assert tag_enum is None or isinstance(tag_enum, str)
for v in variants:
assert isinstance(v, QAPISchemaObjectTypeVariant)
- self.tag_name = tag_name
+ self._tag_name = tag_name
if tag_name: # flat union
assert not tag_enum
self.tag_member = None
@@ -1028,9 +1028,9 @@ class QAPISchemaObjectTypeVariants(object):
self.variants = variants
def check(self, schema, info, members, seen):
- if self.tag_name:
- self.tag_member = seen[c_name(self.tag_name)]
- assert self.tag_name == self.tag_member.name
+ if self._tag_name:
+ self.tag_member = seen[c_name(self._tag_name)]
+ assert self._tag_name == self.tag_member.name
elif self.tag_member:
self.tag_member.check(schema, info, members, seen)
typ = None
diff --git a/tests/qapi-schema/qapi-schema-test.out
b/tests/qapi-schema/qapi-schema-test.out
index 4405658..2036df5 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -113,6 +113,7 @@ object UserDefFlatUnion2
case value2: UserDefB
case value3: UserDefA
object UserDefNativeListUnion
+ tag type
case integer: :obj-intList-wrapper
case s8: :obj-int8List-wrapper
case s16: :obj-int16List-wrapper
@@ -167,6 +168,7 @@ object __org.qemu_x-Struct
object __org.qemu_x-Struct2
member array: __org.qemu_x-Union1List optional=False
object __org.qemu_x-Union1
+ 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 f2cce64..3f0c2bc 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -47,8 +47,8 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
@staticmethod
def _print_variants(variants):
if variants:
- if variants.tag_name:
- print ' tag %s' % variants.tag_name
+ if variants.tag_member:
+ print ' tag %s' % variants.tag_member.name
for v in variants.variants:
print ' case %s: %s' % (v.name, v.type.name)
diff --git a/tests/qapi-schema/union-clash2.out
b/tests/qapi-schema/union-clash2.out
index 6277239..689ee74 100644
--- a/tests/qapi-schema/union-clash2.out
+++ b/tests/qapi-schema/union-clash2.out
@@ -2,5 +2,6 @@ object :empty
object :obj-int-wrapper
member data: int optional=False
object TestUnion
+ tag type
case data: :obj-int-wrapper
enum TestUnionKind ['data']
diff --git a/tests/qapi-schema/union-empty.out
b/tests/qapi-schema/union-empty.out
index 8b5a7bf..c5500da 100644
--- a/tests/qapi-schema/union-empty.out
+++ b/tests/qapi-schema/union-empty.out
@@ -1,3 +1,4 @@
object :empty
object Union
+ tag type
enum UnionKind []
--
2.4.3
- [Qemu-devel] [PATCH v5 22/46] qapi: Don't abuse stack to track qmp-output root, (continued)
- [Qemu-devel] [PATCH v5 22/46] qapi: Don't abuse stack to track qmp-output root, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 26/46] qapi: Test failure in middle of array parse, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 23/46] qapi: Remove dead visitor code, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 27/46] qapi: Simplify visits of optional fields, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 25/46] qapi: Plug leaks in test-qmp-input-visitor, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 24/46] qapi: Document visitor interfaces, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 28/46] qapi: Rework deallocation of partial struct, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 29/46] qapi: Change visit_type_FOO() to no longer return partial objects, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 30/46] net: use Netdev instead of NetClientOptions in client init, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 33/46] vnc: hoist allocation of VncBasicInfo to callers, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 32/46] qapi: Hide tag_name data member of variants,
Eric Blake <=
- [Qemu-devel] [PATCH v5 35/46] qapi-visit: Remove redundant functions for flat union base, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 34/46] qapi: Unbox base members, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 36/46] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 38/46] qapi: Drop useless 'data' member of unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 37/46] qapi: Forbid empty unions and useless alternates, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 39/46] qapi: Plumb in 'box' to qapi generator lower levels, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 41/46] qapi: Support boxed unions, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 40/46] qapi: Implement boxed structs for commands/events, Eric Blake, 2015/09/21
- [Qemu-devel] [PATCH v5 42/46] qapi: support implicit structs in OptsVisitor, Eric Blake, 2015/09/21