From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGMbZ-00057w-Ja for qemu-devel@nongnu.org; Thu, 20 Feb 2014 00:55:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGMbN-00016a-IO for qemu-devel@nongnu.org; Thu, 20 Feb 2014 00:55:29 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:46044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGMbM-00016N-W2 for qemu-devel@nongnu.org; Thu, 20 Feb 2014 00:55:17 -0500 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 20 Feb 2014 11:25:13 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 45352E0057 for ; Thu, 20 Feb 2014 11:28:38 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1K5t3Ak65536228 for ; Thu, 20 Feb 2014 11:25:03 +0530 Received: from d28av02.in.ibm.com (localhost [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1K5tA5J002122 for ; Thu, 20 Feb 2014 11:25:10 +0530 From: Wenchao Xia Date: Thu, 20 Feb 2014 00:54:49 -0500 Message-Id: <1392875695-15627-6-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1392875695-15627-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1392875695-15627-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V7 05/11] qapi script: code move for generate_enum_name() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, lcapitulino@redhat.com, Wenchao Xia Later both qapi-types.py and qapi-visit.py need a common function for enum name generation. Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- scripts/qapi-types.py | 10 ---------- scripts/qapi.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index 2c6e0dc..35ad993 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -127,16 +127,6 @@ const char *%(name)s_lookup[] = { ''') return ret -def generate_enum_name(name): - if name.isupper(): - return c_fun(name, False) - new_name = '' - for c in c_fun(name, False): - if c.isupper(): - new_name += '_' - new_name += c - return new_name.lstrip('_').upper() - def generate_enum(name, values): lookup_decl = mcgen(''' extern const char *%(name)s_lookup[]; diff --git a/scripts/qapi.py b/scripts/qapi.py index 8af8cfd..c334ad3 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -467,3 +467,13 @@ def guardend(name): ''', name=guardname(name)) + +def generate_enum_name(name): + if name.isupper(): + return c_fun(name, False) + new_name = '' + for c in c_fun(name, False): + if c.isupper(): + new_name += '_' + new_name += c + return new_name.lstrip('_').upper() -- 1.7.1