Blob Blame History Raw
From 798796e641d7e1146b9d6679958f8264efd1494e Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 5 Nov 2013 14:08:55 +0100
Subject: [PATCH 42/87] qapi-types.py: Split off generate_struct_fields()

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1383660558-32096-2-git-send-email-kwolf@redhat.com>
Patchwork-id: 55380
O-Subject: [RHEL-7.0 qemu-kvm PATCH 01/24] qapi-types.py: Split off generate_struct_fields()
Bugzilla: 978402
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>

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

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

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

diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 20f4bdf..e9bd638 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -51,12 +51,8 @@ typedef struct %(name)sList
 ''',
                  name=name)
 
-def generate_struct(structname, fieldname, members):
-    ret = mcgen('''
-struct %(name)s
-{
-''',
-          name=structname)
+def generate_struct_fields(members):
+    ret = ''
 
     for argname, argentry, optional, structured in parse_args(members):
         if optional:
@@ -74,6 +70,17 @@ struct %(name)s
 ''',
                      c_type=c_type(argentry), c_name=c_var(argname))
 
+    return ret
+
+def generate_struct(structname, fieldname, members):
+    ret = mcgen('''
+struct %(name)s
+{
+''',
+          name=structname)
+
+    ret += generate_struct_fields(members)
+
     if len(fieldname):
         fieldname = " " + fieldname
     ret += mcgen('''
-- 
1.7.1