Patchwork [08/28] qapi: qapi_visit.py, support for q_string annotations

login
register
mail settings
Submitter Michael Roth
Date Oct. 31, 2012, 10:35 p.m.
Message ID <1351722972-17801-9-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/196054/
State New
Headers show

Comments

Michael Roth - Oct. 31, 2012, 10:35 p.m.
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 scripts/qapi_visit.py |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Patch

diff --git a/scripts/qapi_visit.py b/scripts/qapi_visit.py
index c531a5a..b3c6bfe 100644
--- a/scripts/qapi_visit.py
+++ b/scripts/qapi_visit.py
@@ -18,6 +18,14 @@  import getopt
 import errno
 import types
 
+def generate_visit_carray_as_string(name, info):
+    return mcgen('''
+char *%(name)s_ptr = (char *)&(*obj)->%(name)s;
+visit_type_str(m, &%(name)s_ptr, "%(name)s", errp);
+''',
+                 name=name)
+
+
 def generate_visit_carray_body(name, info):
     if info['array_size'][0].isdigit():
         array_size = info['array_size']
@@ -144,7 +152,10 @@  if (obj && (*obj)->%(prefix)shas_%(c_name)s) {
         else:
             if annotated:
                 if isinstance(argentry['type'], types.ListType):
-                    ret += generate_visit_carray_body(argname, argentry)
+                    if argentry.has_key('is_string') and argentry['is_string'] == 'true':
+                        ret += generate_visit_carray_as_string(argname, argentry)
+                    else:
+                        ret += generate_visit_carray_body(argname, argentry)
                 elif argentry.has_key('embedded') and argentry['embedded'] == 'true':
                     tmp_ptr_name = "%s_%s_ptr" % (c_var(field_prefix).replace(".", ""), c_var(argname))
                     ret += mcgen('''