[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH V2 3/4] libxl/gentypes.py: generate empty map for None field in keyed-union



Without this the generated JSON is malformed.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/gentypes.py |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 1a3b91c..bfb95e2 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -220,6 +220,13 @@ def libxl_C_type_gen_json(ty, v, indent = "    ", parent = 
None):
             s += "case %s:\n" % f.enumname
             if f.type is not None:
                 s += libxl_C_type_gen_json(f.type, fexpr, indent + "    ", 
nparent)
+            else:
+                s += "    yajl_gen_map_open(hand);\n"
+                s += "    if (s != yajl_gen_status_ok)\n"
+                s += "        goto out;\n"
+                s += "    yajl_gen_map_close(hand);\n"
+                s += "    if (s != yajl_gen_status_ok)\n"
+                s += "        goto out;\n"
             s += "    break;\n"
         s += "}\n"
     elif isinstance(ty, idl.Struct) and (parent is None or ty.json_fn is None):
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.