From patchwork Fri Nov 6 06:35: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: 540835 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 783BF140311 for ; Fri, 6 Nov 2015 17:49:09 +1100 (AEDT) Received: from localhost ([::1]:37008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zuapf-0007gu-FS for incoming@patchwork.ozlabs.org; Fri, 06 Nov 2015 01:49:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45967) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuadD-0000Iz-Lc for qemu-devel@nongnu.org; Fri, 06 Nov 2015 01:36:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zuad8-0004DJ-Im for qemu-devel@nongnu.org; Fri, 06 Nov 2015 01:36:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zuad5-0004Bc-KO for qemu-devel@nongnu.org; Fri, 06 Nov 2015 01:36:10 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5540D2195; Fri, 6 Nov 2015 06:36:07 +0000 (UTC) Received: from red.redhat.com (ovpn-113-80.phx2.redhat.com [10.3.113.80]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA66Ztn3008894; Fri, 6 Nov 2015 01:36:06 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Thu, 5 Nov 2015 23:35:48 -0700 Message-Id: <1446791754-23823-25-git-send-email-eblake@redhat.com> In-Reply-To: <1446791754-23823-1-git-send-email-eblake@redhat.com> References: <1446791754-23823-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: armbru@redhat.com, Michael Roth Subject: [Qemu-devel] [PATCH v10 24/30] qapi: Factor out QAPISchemaObjectType.check_clash() 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 Consolidate two common sequences of clash detection into a new QAPISchemaObjectType.check_clash() helper method. No change to generated code. Signed-off-by: Eric Blake --- v10: rebase on new Variants.check_clash() v9: new patch, split off from v8 7/17 --- scripts/qapi.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 4c56935..6d8c4c7 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -980,11 +980,7 @@ class QAPISchemaObjectType(QAPISchemaType): seen = OrderedDict() if self._base_name: self.base = schema.lookup_type(self._base_name) - assert isinstance(self.base, QAPISchemaObjectType) - assert not self.base.variants # not implemented - self.base.check(schema) - for m in self.base.members: - m.check_clash(seen) + self.base.check_clash(schema, seen) for m in self.local_members: m.check(schema) m.check_clash(seen) @@ -994,6 +990,12 @@ class QAPISchemaObjectType(QAPISchemaType): assert self.variants.tag_member in self.members self.variants.check_clash(schema, seen) + def check_clash(self, schema, seen): + self.check(schema) + assert not self.variants # not implemented + for m in self.members: + m.check_clash(seen) + def is_implicit(self): # See QAPISchema._make_implicit_object_type() return self.name[0] == ':' @@ -1062,12 +1064,7 @@ class QAPISchemaObjectTypeVariants(object): for v in self.variants: # Reset seen map for each variant, since qapi names from one # branch do not affect another branch - vseen = dict(seen) - assert isinstance(v.type, QAPISchemaObjectType) - assert not v.type.variants # not implemented - v.type.check(schema) - for m in v.type.members: - m.check_clash(vseen) + v.type.check_clash(schema, dict(seen)) class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):