thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qapi-visit.py-Split-off-generate_visit_struct_fields.patch

218e99
From 0c8fb6c71c02e202235933781430efac5c0d7314 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Mon, 9 Sep 2013 14:28:08 +0200
218e99
Subject: [PATCH 17/38] qapi-visit.py: Split off generate_visit_struct_fields()
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1378736903-18489-18-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 54204
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 17/32] qapi-visit.py: Split off generate_visit_struct_fields()
218e99
Bugzilla: 1005818
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
218e99
Bugzilla: 1005818
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
(cherry picked from commit d131c897f3dea8b76d7a487af0f7f5f11d0500a3)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 scripts/qapi-visit.py | 62 ++++++++++++++++++++++++++++-----------------------
218e99
 1 file changed, 34 insertions(+), 28 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 scripts/qapi-visit.py |   62 ++++++++++++++++++++++++++----------------------
218e99
 1 files changed, 34 insertions(+), 28 deletions(-)
218e99
218e99
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
218e99
index a276540..5adc2af 100644
218e99
--- a/scripts/qapi-visit.py
218e99
+++ b/scripts/qapi-visit.py
218e99
@@ -17,34 +17,9 @@ import os
218e99
 import getopt
218e99
 import errno
218e99
 
218e99
-def generate_visit_struct_body(field_prefix, name, members):
218e99
-    ret = mcgen('''
218e99
-if (!error_is_set(errp)) {
218e99
-''')
218e99
-    push_indent()
218e99
-
218e99
-    if len(field_prefix):
218e99
-        field_prefix = field_prefix + "."
218e99
-        ret += mcgen('''
218e99
-Error **errp = &err; /* from outer scope */
218e99
-Error *err = NULL;
218e99
-visit_start_struct(m, NULL, "", "%(name)s", 0, &err;;
218e99
-''',
218e99
-                name=name)
218e99
-    else:
218e99
-        ret += mcgen('''
218e99
-Error *err = NULL;
218e99
-visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err;;
218e99
-''',
218e99
-                name=name)
218e99
+def generate_visit_struct_fields(field_prefix, members):
218e99
+    ret = ''
218e99
 
218e99
-    ret += mcgen('''
218e99
-if (!err) {
218e99
-    if (!obj || *obj) {
218e99
-''')
218e99
-
218e99
-    push_indent()
218e99
-    push_indent()
218e99
     for argname, argentry, optional, structured in parse_args(members):
218e99
         if optional:
218e99
             ret += mcgen('''
218e99
@@ -72,9 +47,40 @@ visit_type_%(type)s(m, obj ? &(*obj)->%(c_prefix)s%(c_name)s : NULL, "%(name)s",
218e99
 visit_end_optional(m, &err;;
218e99
 ''')
218e99
 
218e99
-    pop_indent()
218e99
+    return ret
218e99
+
218e99
+
218e99
+def generate_visit_struct_body(field_prefix, name, members):
218e99
+    ret = mcgen('''
218e99
+if (!error_is_set(errp)) {
218e99
+''')
218e99
+    push_indent()
218e99
+
218e99
+    if len(field_prefix):
218e99
+        field_prefix = field_prefix + "."
218e99
+        ret += mcgen('''
218e99
+Error **errp = &err; /* from outer scope */
218e99
+Error *err = NULL;
218e99
+visit_start_struct(m, NULL, "", "%(name)s", 0, &err;;
218e99
+''',
218e99
+                name=name)
218e99
+    else:
218e99
+        ret += mcgen('''
218e99
+Error *err = NULL;
218e99
+visit_start_struct(m, (void **)obj, "%(name)s", name, sizeof(%(name)s), &err;;
218e99
+''',
218e99
+                name=name)
218e99
+
218e99
     ret += mcgen('''
218e99
+if (!err) {
218e99
+    if (!obj || *obj) {
218e99
+''')
218e99
+    push_indent()
218e99
+    push_indent()
218e99
 
218e99
+    ret += generate_visit_struct_fields(field_prefix, members)
218e99
+    pop_indent()
218e99
+    ret += mcgen('''
218e99
     error_propagate(errp, err);
218e99
     err = NULL;
218e99
 }
218e99
-- 
218e99
1.7.1
218e99