[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC v4 09/29] qapi: Hide tag_name data member of var
From: |
Eric Blake |
Subject: |
[Qemu-devel] [PATCH RFC v4 09/29] qapi: Hide tag_name data member of variants |
Date: |
Wed, 9 Sep 2015 22:06:11 -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 | 6 +++---
tests/qapi-schema/qapi-schema-test.out | 2 ++
tests/qapi-schema/test-qapi.py | 4 ++--
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 228bc3f..a0eca74 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -966,7 +966,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
@@ -978,8 +978,8 @@ class QAPISchemaObjectTypeVariants(object):
self.variants = variants
def check(self, schema, members, seen):
- if self.tag_name:
- self.tag_member = seen[self.tag_name]
+ if self._tag_name:
+ self.tag_member = seen[self._tag_name]
elif self.tag_member:
self.tag_member.check(schema, members, seen)
typ = None
diff --git a/tests/qapi-schema/qapi-schema-test.out
b/tests/qapi-schema/qapi-schema-test.out
index 0f73e49..a44d570 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -109,6 +109,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
@@ -163,6 +164,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 4602da7..75f8da8 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -45,8 +45,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)
--
2.4.3
- [Qemu-devel] [PATCH RFC v4 00/29] qapi-ify netdev_add, and other post-introspection cleanups, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 01/29] qapi: Provide nicer array names in introspection, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 04/29] vnc: hoist allocation of VncBasicInfo to callers, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 06/29] qapi-visit: Remove redundant functions for flat union base, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 02/29] net: use Netdev instead of NetClientOptions in client init, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 05/29] qapi: Unbox base members, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 07/29] qapi: Test use of 'number' within alternates, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 09/29] qapi: Hide tag_name data member of variants,
Eric Blake <=
- [Qemu-devel] [PATCH RFC v4 08/29] qapi: Simplify visiting of alternate types, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 12/29] qapi: Use consistent generated code patterns, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 17/29] qapi: Drop useless 'data' member of unions, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 11/29] qapi: Don't pass pre-existing error to later call, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 14/29] qapi: Rework deallocation of partial struct, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 10/29] qapi: Fix alternates that accept 'number' but not 'int', Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 13/29] qapi: Add tests for empty unions, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 16/29] qapi: Forbid empty unions and useless alternates, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 15/29] qapi: Avoid use of 'data' member of qapi unions, Eric Blake, 2015/09/10
- [Qemu-devel] [PATCH RFC v4 18/29] qapi: Remove dead visitor code, Eric Blake, 2015/09/10