Blame SOURCES/kvm-qapi-types-visit.py-Pass-whole-expr-dict-for-structs.patch

218e99
From 9dbd79c3095d98b66d30893fd1ba8b98366e9d41 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Tue, 5 Nov 2013 14:08:57 +0100
218e99
Subject: [PATCH 44/87] qapi-types/visit.py: Pass whole expr dict for structs
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1383660558-32096-4-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 55382
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 03/24] qapi-types/visit.py: Pass whole expr dict for structs
218e99
Bugzilla: 978402
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
(cherry picked from commit 14d36307ffdf949df9c1dd7f435e138b36f63bb0)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 scripts/qapi-types.py | 11 ++++++++---
218e99
 scripts/qapi-visit.py |  8 ++++++--
218e99
 2 files changed, 14 insertions(+), 5 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 scripts/qapi-types.py |   11 ++++++++---
218e99
 scripts/qapi-visit.py |    8 ++++++--
218e99
 2 files changed, 14 insertions(+), 5 deletions(-)
218e99
218e99
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
218e99
index 8680160..ff60dfb 100644
218e99
--- a/scripts/qapi-types.py
218e99
+++ b/scripts/qapi-types.py
218e99
@@ -65,7 +65,7 @@ def generate_struct_fields(members):
218e99
                          c_name=c_var(argname))
218e99
         if structured:
218e99
             push_indent()
218e99
-            ret += generate_struct("", argname, argentry)
218e99
+            ret += generate_struct({ "field": argname, "data": argentry})
218e99
             pop_indent()
218e99
         else:
218e99
             ret += mcgen('''
218e99
@@ -75,7 +75,12 @@ def generate_struct_fields(members):
218e99
 
218e99
     return ret
218e99
 
218e99
-def generate_struct(structname, fieldname, members):
218e99
+def generate_struct(expr):
218e99
+
218e99
+    structname = expr.get('type', "")
218e99
+    fieldname = expr.get('field', "")
218e99
+    members = expr['data']
218e99
+
218e99
     ret = mcgen('''
218e99
 struct %(name)s
218e99
 {
218e99
@@ -411,7 +416,7 @@ if do_builtins:
218e99
 for expr in exprs:
218e99
     ret = "\n"
218e99
     if expr.has_key('type'):
218e99
-        ret += generate_struct(expr['type'], "", expr['data']) + "\n"
218e99
+        ret += generate_struct(expr) + "\n"
218e99
         ret += generate_type_cleanup_decl(expr['type'] + "List")
218e99
         fdef.write(generate_type_cleanup(expr['type'] + "List") + "\n")
218e99
         ret += generate_type_cleanup_decl(expr['type'])
218e99
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
218e99
index 367cf7a..43d902c 100644
218e99
--- a/scripts/qapi-visit.py
218e99
+++ b/scripts/qapi-visit.py
218e99
@@ -120,7 +120,11 @@ if (!err) {
218e99
 ''')
218e99
     return ret
218e99
 
218e99
-def generate_visit_struct(name, members):
218e99
+def generate_visit_struct(expr):
218e99
+
218e99
+    name = expr['type']
218e99
+    members = expr['data']
218e99
+
218e99
     ret = generate_visit_struct_fields(name, "", "", members)
218e99
 
218e99
     ret += mcgen('''
218e99
@@ -448,7 +452,7 @@ exprs = parse_schema(sys.stdin)
218e99
 
218e99
 for expr in exprs:
218e99
     if expr.has_key('type'):
218e99
-        ret = generate_visit_struct(expr['type'], expr['data'])
218e99
+        ret = generate_visit_struct(expr)
218e99
         ret += generate_visit_list(expr['type'], expr['data'])
218e99
         fdef.write(ret)
218e99
 
218e99
-- 
218e99
1.7.1
218e99