From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1cFx-0000MG-8y for qemu-devel@nongnu.org; Tue, 23 Jul 2013 09:03:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1cFs-0007Tc-FY for qemu-devel@nongnu.org; Tue, 23 Jul 2013 09:03:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1cFs-0007TH-72 for qemu-devel@nongnu.org; Tue, 23 Jul 2013 09:03:52 -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 r6ND3pHO005344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Jul 2013 09:03:51 -0400 From: Kevin Wolf Date: Tue, 23 Jul 2013 15:03:17 +0200 Message-Id: <1374584606-5615-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1374584606-5615-1-git-send-email-kwolf@redhat.com> References: <1374584606-5615-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 09/18] qapi.py: Maintain a list of union types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, armbru@redhat.com, stefanha@redhat.com, lcapitulino@redhat.com Signed-off-by: Kevin Wolf --- scripts/qapi.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/qapi.py b/scripts/qapi.py index baf1321..3a54c7f 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -105,6 +105,7 @@ def parse_schema(fp): if expr_eval.has_key('enum'): add_enum(expr_eval['enum']) elif expr_eval.has_key('union'): + add_union(expr_eval) add_enum('%sKind' % expr_eval['union']) elif expr_eval.has_key('type'): add_struct(expr_eval) @@ -188,6 +189,7 @@ def type_name(name): enum_types = [] struct_types = [] +union_types = [] def add_struct(definition): global struct_types @@ -200,6 +202,17 @@ def find_struct(name): return struct return None +def add_union(definition): + global union_types + union_types.append(definition) + +def find_union(name): + global union_types + for union in union_types: + if union['union'] == name: + return union + return None + def add_enum(name): global enum_types enum_types.append(name) -- 1.8.1.4