Blob Blame History Raw
From 7fa89ebb4c2f761a8df462cf9ffcb6174b4a4a26 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Mon, 9 Sep 2013 14:28:14 +0200
Subject: [PATCH 23/38] qapi.py: Maintain a list of union types

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1378736903-18489-24-git-send-email-kwolf@redhat.com>
Patchwork-id: 54210
O-Subject: [RHEL-7.0 qemu-kvm PATCH 23/32] qapi.py: Maintain a list of union types
Bugzilla: 1005818
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>

Bugzilla: 1005818

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit ea66c6d8819c8fc5f73a28554992be64e5399fed)

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 scripts/qapi.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 scripts/qapi.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 0c3bd84..03c42a9 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -99,6 +99,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)
@@ -182,6 +183,7 @@ def type_name(name):
 
 enum_types = []
 struct_types = []
+union_types = []
 
 def add_struct(definition):
     global struct_types
@@ -194,6 +196,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.7.1