From patchwork Wed Oct 5 13:21:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 117862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 85503B6F99 for ; Thu, 6 Oct 2011 01:30:04 +1100 (EST) Received: from localhost ([::1]:59482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBRRT-0005RW-FE for incoming@patchwork.ozlabs.org; Wed, 05 Oct 2011 09:23:23 -0400 Received: from eggs.gnu.org ([140.186.70.92]:51896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBRQo-0003vi-1S for qemu-devel@nongnu.org; Wed, 05 Oct 2011 09:22:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBRQl-0001mQ-8L for qemu-devel@nongnu.org; Wed, 05 Oct 2011 09:22:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3414) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBRQk-0001m1-IR for qemu-devel@nongnu.org; Wed, 05 Oct 2011 09:22:39 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p95DMbtr030736 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Oct 2011 09:22:37 -0400 Received: from localhost (ovpn-113-108.phx2.redhat.com [10.3.113.108]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p95DMaj7027010; Wed, 5 Oct 2011 09:22:37 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Wed, 5 Oct 2011 10:21:57 -0300 Message-Id: <1317820931-25872-13-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1317820931-25872-1-git-send-email-lcapitulino@redhat.com> References: <1317820931-25872-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 12/26] qapi: Automatically generate a _MAX value for enums 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 It's the last value in the enum and is very useful for the C implementation. Signed-off-by: Luiz Capitulino --- scripts/qapi-types.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 3bacc0c..f64d84c 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -91,8 +91,11 @@ typedef enum %(name)s ''', name=name) + # append automatically generated _MAX value + enum_values = values + [ 'MAX' ] + i = 0 - for value in values: + for value in enum_values: enum_decl += mcgen(''' %(abbrev)s_%(value)s = %(i)d, ''',