From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmg1l-0003T3-5E for qemu-devel@nongnu.org; Tue, 20 May 2014 05:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wmg1f-00082Z-AD for qemu-devel@nongnu.org; Tue, 20 May 2014 05:08:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wmg1f-000829-3M for qemu-devel@nongnu.org; Tue, 20 May 2014 05:07:59 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s4K97wid002619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 20 May 2014 05:07:58 -0400 From: Fam Zheng Date: Tue, 20 May 2014 17:07:58 +0800 Message-Id: <1400576881-6954-5-git-send-email-famz@redhat.com> In-Reply-To: <1400576881-6954-1-git-send-email-famz@redhat.com> References: <1400576881-6954-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH v2 4/7] qapi: Add c_val(t, val) for int List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi c_val should generate the C value for a value in a given type. Only handle int for now. Signed-off-by: Fam Zheng --- scripts/qapi.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/qapi.py b/scripts/qapi.py index 0f275f3..ca2f1cc 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -498,6 +498,12 @@ def find_enum(name): def is_enum(name): return find_enum(name) != None +def c_val(t, val): + if t == 'int': + return val + else: + assert False, "Unknown type: %s" % t + def c_type(name): if name == 'str': return 'char *' -- 1.9.2