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

[Xen-devel] [PATCH] libxl: fix generating array of enums in getypes.py



From: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>

Enum always uses "x" value as input argument. In
case of enum array "t" argument should be passed.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>
---
 tools/libxl/gentypes.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 4ea7091..51a5539 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -404,13 +404,16 @@ def libxl_C_type_parse_json(ty, w, v, indent = "    ", 
parent = None, discrimina
     elif isinstance(ty, idl.Enumeration):
         if discriminator is not None:
             raise Exception("Only KeyedUnion can have discriminator")
+        lv = "x"
+        if parent:
+            lv = w;
         s += "{\n"
         s += "    const char *enum_str;\n"
-        s += "    if (!libxl__json_object_is_string(x)) {\n"
+        s += "    if (!libxl__json_object_is_string(%s)) {\n" % lv
         s += "        rc = -1;\n"
         s += "        goto out;\n"
         s += "    }\n"
-        s += "    enum_str = libxl__json_object_get_string(x);\n"
+        s += "    enum_str = libxl__json_object_get_string(%s);\n" % lv
         s += "    rc = %s_from_string(enum_str, %s);\n" % (ty.typename, 
ty.pass_arg(v, parent is None, idl.PASS_BY_REFERENCE))
         s += "    if (rc)\n"
         s += "        goto out;\n"
-- 
2.7.4


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

 


Rackspace

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