From patchwork Wed Nov 11 06:51:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 542806 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 E2D8C140761 for ; Wed, 11 Nov 2015 17:58:14 +1100 (AEDT) Received: from localhost ([::1]:38243 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwPMC-0001vz-Lm for incoming@patchwork.ozlabs.org; Wed, 11 Nov 2015 01:58:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwPFw-0006BN-Qa for qemu-devel@nongnu.org; Wed, 11 Nov 2015 01:51:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZwPFq-0005c0-1h for qemu-devel@nongnu.org; Wed, 11 Nov 2015 01:51:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZwPFp-0005bj-Rw for qemu-devel@nongnu.org; Wed, 11 Nov 2015 01:51:37 -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 7E0F03B70A; Wed, 11 Nov 2015 06:51:37 +0000 (UTC) Received: from red.redhat.com (ovpn-113-115.phx2.redhat.com [10.3.113.115]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAB6pW2s007377; Wed, 11 Nov 2015 01:51:37 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 10 Nov 2015 23:51:11 -0700 Message-Id: <1447224690-9743-10-git-send-email-eblake@redhat.com> In-Reply-To: <1447224690-9743-1-git-send-email-eblake@redhat.com> References: <1447224690-9743-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 v11 09/28] qapi: Factor out QAPISchemaObjectTypeMember.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 From: Markus Armbruster While there, stick in a TODO change key of seen from QAPI name to C name. Can't do it right away, because it would fail the assertion for tests/qapi-schema/args-has-clash.json. Signed-off-by: Markus Armbruster Message-Id: <1446559499-26984-6-git-send-email-armbru@redhat.com> Signed-off-by: Eric Blake --- v11: no change v10: redo closer to Markus' original proposal v9: new patch --- scripts/qapi.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 44d08c1..2a73b2b 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -984,12 +984,10 @@ class QAPISchemaObjectType(QAPISchemaType): assert not self.base.variants # not implemented self.base.check(schema) for m in self.base.members: - assert m.name not in seen - seen[m.name] = m + m.check_clash(seen) for m in self.local_members: m.check(schema) - assert m.name not in seen - seen[m.name] = m + m.check_clash(seen) if self.variants: self.variants.check(schema, seen) self.members = seen.values() @@ -1030,6 +1028,11 @@ class QAPISchemaObjectTypeMember(object): self.type = schema.lookup_type(self._type_name) assert self.type + def check_clash(self, seen): + # TODO change key of seen from QAPI name to C name + assert self.name not in seen + seen[self.name] = self + class QAPISchemaObjectTypeVariants(object): def __init__(self, tag_name, tag_member, variants):