From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2oVQ-0001RJ-Uy for qemu-devel@nongnu.org; Fri, 26 Jul 2013 16:20:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2oVP-0007qO-MC for qemu-devel@nongnu.org; Fri, 26 Jul 2013 16:20:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2oVP-0007qH-CG for qemu-devel@nongnu.org; Fri, 26 Jul 2013 16:20:51 -0400 From: Kevin Wolf Date: Fri, 26 Jul 2013 22:20:22 +0200 Message-Id: <1374870032-31672-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1374870032-31672-1-git-send-email-kwolf@redhat.com> References: <1374870032-31672-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 08/18] qapi.py: Maintain a list of union types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- 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