Received: from eggs.gnu.org ([2001:4830:134:3::10]:33965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZt8K-0002vH-M1 for qemu-devel@nongnu.org; Thu, 10 Sep 2015 00:06:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZt8I-0004zz-Rq for qemu-devel@nongnu.org; Thu, 10 Sep 2015 00:06:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZt8I-0004zl-Ko for qemu-devel@nongnu.org; Thu, 10 Sep 2015 00:06:46 -0400 From: Eric Blake Date: Wed, 9 Sep 2015 22:06:11 -0600 Message-Id: <1441857991-7309-10-git-send-email-eblake@redhat.com> In-Reply-To: <1441857991-7309-1-git-send-email-eblake@redhat.com> References: <1441857991-7309-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH RFC v4 09/29] qapi: Hide tag_name data member of variants List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Roth , marcandre.lureau@redhat.com, armbru@redhat.com, DirtY.iCE.hu@gmail.com 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 --- 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