]> xenbits.xensource.com Git - xen.git/commitdiff
libxl/gentypes.py: generate empty map for None field in keyed-union
authorWei Liu <wei.liu2@citrix.com>
Thu, 10 Apr 2014 15:18:00 +0000 (16:18 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 16 Apr 2014 16:06:45 +0000 (17:06 +0100)
Without this the generated JSON is malformed.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/gentypes.py

index 1a3b91cf6891fe5962dbb24718bd178bf874565a..917e2c257258439994b648978fb87d587c01624e 100644 (file)
@@ -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 += "    s = yajl_gen_map_open(hand);\n"
+                s += "    if (s != yajl_gen_status_ok)\n"
+                s += "        goto out;\n"
+                s += "    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):