qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]