From patchwork Wed Nov 18 08:52:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 545899 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 B458E1402B4 for ; Wed, 18 Nov 2015 19:59:23 +1100 (AEDT) Received: from localhost ([::1]:34547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyyaH-0004ey-Oz for incoming@patchwork.ozlabs.org; Wed, 18 Nov 2015 03:59:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyyUX-0001Qz-5t for qemu-devel@nongnu.org; Wed, 18 Nov 2015 03:53:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyyUV-0003rS-Nu for qemu-devel@nongnu.org; Wed, 18 Nov 2015 03:53:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyyUV-0003qt-J8 for qemu-devel@nongnu.org; Wed, 18 Nov 2015 03:53:23 -0500 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 3D00A8E236; Wed, 18 Nov 2015 08:53:23 +0000 (UTC) Received: from red.redhat.com (ovpn-113-208.phx2.redhat.com [10.3.113.208]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAI8rHHL020742; Wed, 18 Nov 2015 03:53:22 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 18 Nov 2015 01:52:47 -0700 Message-Id: <1447836791-369-13-git-send-email-eblake@redhat.com> In-Reply-To: <1447836791-369-1-git-send-email-eblake@redhat.com> References: <1447836791-369-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: armbru@redhat.com, Michael Roth Subject: [Qemu-devel] [PATCH v12 12/36] 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 --- v12: no change v11: don't lose isinstance check, and don't hide type.check() inside check_clash() v10: rebase on new Variants.check_clash() v9: new patch, split off from v8 7/17 --- scripts/qapi.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index b2d071f..296b9bb 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -981,10 +981,8 @@ class QAPISchemaObjectType(QAPISchemaType): 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 +992,11 @@ class QAPISchemaObjectType(QAPISchemaType): assert self.variants.tag_member in self.members self.variants.check_clash(schema, seen) + def check_clash(self, schema, seen): + 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] == ':' @@ -1064,11 +1067,8 @@ 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 - for m in v.type.members: - m.check_clash(vseen) + v.type.check_clash(schema, dict(seen)) class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):