From patchwork Mon Sep 21 21:57:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 520621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8618A14012C for ; Tue, 22 Sep 2015 08:10:32 +1000 (AEST) Received: from localhost ([::1]:34280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze9I6-0002Ri-Lw for incoming@patchwork.ozlabs.org; Mon, 21 Sep 2015 18:10:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze96a-00087t-CC for qemu-devel@nongnu.org; Mon, 21 Sep 2015 17:58:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ze96X-00015K-J9 for qemu-devel@nongnu.org; Mon, 21 Sep 2015 17:58:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ze96X-000155-Aw for qemu-devel@nongnu.org; Mon, 21 Sep 2015 17:58:33 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id EF8158EA2F; Mon, 21 Sep 2015 21:58:32 +0000 (UTC) Received: from red.redhat.com (ovpn-113-166.phx2.redhat.com [10.3.113.166]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8LLw4bs027229; Mon, 21 Sep 2015 17:58:32 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 21 Sep 2015 15:57:48 -0600 Message-Id: <1442872682-6523-33-git-send-email-eblake@redhat.com> In-Reply-To: <1442872682-6523-1-git-send-email-eblake@redhat.com> References: <1442872682-6523-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Michael Roth , marcandre.lureau@redhat.com, DirtY.iCE.hu@gmail.com, armbru@redhat.com, ehabkost@redhat.com Subject: [Qemu-devel] [PATCH v5 32/46] qapi: Hide tag_name data member of variants X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 | 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 []