qemu-devel
[Top][All Lists]
Advanced

[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




reply via email to

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