From patchwork Wed Nov 4 06:20:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 539730 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 89C831402D0 for ; Wed, 4 Nov 2015 17:30:47 +1100 (AEDT) Received: from localhost ([::1]:52898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ztran-0005Vh-I7 for incoming@patchwork.ozlabs.org; Wed, 04 Nov 2015 01:30:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtrRQ-00047Z-5a for qemu-devel@nongnu.org; Wed, 04 Nov 2015 01:21:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZtrRP-0006Cc-Ez for qemu-devel@nongnu.org; Wed, 04 Nov 2015 01:21:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZtrRP-0006CX-AB for qemu-devel@nongnu.org; Wed, 04 Nov 2015 01:21:03 -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 E06648CF6E; Wed, 4 Nov 2015 06:21:02 +0000 (UTC) Received: from red.redhat.com (ovpn-113-189.phx2.redhat.com [10.3.113.189]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA46KqVi022634; Wed, 4 Nov 2015 01:21:02 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 3 Nov 2015 23:20:43 -0700 Message-Id: <1446618049-13596-22-git-send-email-eblake@redhat.com> In-Reply-To: <1446618049-13596-1-git-send-email-eblake@redhat.com> References: <1446618049-13596-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 v9 21/27] 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 --- v9: new patch, split off from v8 7/17 --- scripts/qapi.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 6653c70..843e364 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) @@ -993,6 +989,12 @@ class QAPISchemaObjectType(QAPISchemaType): self.variants.check(schema, seen) assert self.variants.tag_member in self.members + 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] == ':' @@ -1071,11 +1073,7 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember): if seen: # This variant is used within a union; ensure each qapi member # field does not collide with the union's non-variant members. - assert isinstance(self.type, QAPISchemaObjectType) - assert not self.type.variants # not implemented - self.type.check(schema) - for m in self.type.members: - m.check_clash(seen) + self.type.check_clash(schema, seen) # This function exists to support ugly simple union special cases # TODO get rid of them, and drop the function