diff mbox

libxl: fix generating array of enums in getypes.py

Message ID 1506692963-1762-2-git-send-email-al1img@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Grytsov Sept. 29, 2017, 1:49 p.m. UTC
From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>

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@epam.com>
---
 tools/libxl/gentypes.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox

Patch

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"