From patchwork Fri Sep 29 13:49:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9978123 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0E1C660329 for ; Fri, 29 Sep 2017 13:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 000A8289D6 for ; Fri, 29 Sep 2017 13:51:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8DF92987D; Fri, 29 Sep 2017 13:51:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2ADAB289D6 for ; Fri, 29 Sep 2017 13:51:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxvfZ-00040b-OP; Fri, 29 Sep 2017 13:49:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxvfY-00040S-Ay for xen-devel@lists.xenproject.org; Fri, 29 Sep 2017 13:49:32 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 4D/E4-30935-B6F4EC95; Fri, 29 Sep 2017 13:49:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrEIsWRWlGSWpSXmKPExsVyMfS6s262/7l Ig/e7WSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owv95YyFTRyV3TcDGhgbOPoYuTiEBKYxiix 5OBMFhCHReAli8T7dTvZQBwJgX5WiVPztgFlOIGcLIn27bNZuxg5gOw0iZnfpCHCZRL3O6Ywg thCAvISB1sus0PYU5gkZnWDtbIJaEncv72CDcQWEVCSuLdqMhOIzSyQIrF3XRtYr7CAs8SEuw /BbBYBVYnb2y6D2bwC9hINB9+xQ+ySk7h5rpMZxOYUcJDo3r4Oaq+9xPSW+2wTGAUXMDKsYtQ oTi0qSy3SNTTRSyrKTM8oyU3MzNE1NDDVy00tLk5MT81JTCrWS87P3cQIDDcGINjBePa05yFG SQ4mJVFeN79zkUJ8SfkplRmJxRnxRaU5qcWHGDU4OAR+Pv3bwijFkpefl6okwTsTpE6wKDU9t SItMwcYETClEhw8SiK8l0DSvMUFibnFmekQqVOMlhwX7lz6w8RxYM8tINlx8+4fJiGweVLivL NAGgRAGjJK8+DGwaL2EqOslDAvI9CxQjwFqUW5mSWo8q8YxTkYlYR5F4NM4cnMK4Hb+groICa ggyZPPANyUEkiQkqqgXFm+hSX6tfL9iZ6mU/8dvDDjWf1xlHsW23Doud8dZrXobtqy0ULoQCt sJv5OVsyzu1ve7WwOmp7sMj/1NeV8XesE4qXNZZfcP71cvqBq3U7bq3Y+aihMtQwRuGUV6GLx JFlb1d99IgMOx523ZvjCqOu6sv1DOdnK8RNLkx2auJeZlCz6sJaF1UlluKMREMt5qLiRAAwNQ 8T1QIAAA== X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-14.tower-206.messagelabs.com!1506692970!75052658!1 X-Originating-IP: [209.85.215.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5216 invoked from network); 29 Sep 2017 13:49:31 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-14.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Sep 2017 13:49:30 -0000 Received: by mail-lf0-f67.google.com with SMTP id q132so63799lfe.4 for ; Fri, 29 Sep 2017 06:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U1iMghdEhkIEh7qE/6VAhvr9BIuLUIYLKBhjSGkWYXg=; b=UhjKa4hXzvl95D0o4hA/9PSweJhymJFoIJZKKpUq5IJ67E2pX5PAViTTmY7/1/qSFm 7R0xIdcGwWEYk9whzjMIP5BBaI6S/0erSFyMXOWcDtPh4mahC1sdf06gyGcTL/WYWQVj F5NnplGcHWsPIAU3xDJY3LNm/Ma+r6rlX4DBrqpbbybcXOehwtjZNWqZJ0QU3XHJ+wl9 doCkdeiAAz8zU7+jS94wgH9wlWY2leyy0An58v7R60ktdfkIU+diCO4IwCF/4LsHreNC 9J3vc6dAd4Hmn613mbZVseI3ISDc7QopUcTjs20/yjknOWw8KdyeSwb+yc6YfhgU/NAn pN2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U1iMghdEhkIEh7qE/6VAhvr9BIuLUIYLKBhjSGkWYXg=; b=Erw16x/11aZGxRj8Sm0QkhQP2ecRu9ogSB4ojgz/FyAow6hHBMlpaPP2ScwmBQQQnx ukYs7tmggmu9Z2LcsLenzpBaeCyYEO+L5YHZDocE0QzmSyojf1stAQ5fOgUNir8KoJPV lKGfuzoqEmKZGzmHZIudXtDzpDI12RYA+4gp11CSLvkV4bmVvff/03iHZcPtP8slHsdC +Uy8QkG0d2XQnQVgk2iSpNMK0/n1zqDYjY6JYAZz4qP1CW+816JIGU85o+jLXXLTRzE5 EjaBk/jsARc1N1JKgNSt/t+hm3Ud0UE1520jxXDFhuuJw32BC2tBubO7Wyxrjgt/7THi 9Bjw== X-Gm-Message-State: AHPjjUiRPUKpyRW5eYu4LyciTEFzW+RFrb1wftpvb0f9MBal1pN4I3vB 5m0BGlLT4BaDT9tBrDlSUj11YA== X-Google-Smtp-Source: AOwi7QAb07L8l1SGaOEg31PWXIysvL6UkrolyG7KZzMKOxrGOXD67Dm7qVlSsNkvY07lDTGjSZ5j3g== X-Received: by 10.46.84.67 with SMTP id y3mr3579017ljd.74.1506692970078; Fri, 29 Sep 2017 06:49:30 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-57.209.223.85.sovam.net.ua. [85.223.209.57]) by smtp.gmail.com with ESMTPSA id 18sm795063ljd.38.2017.09.29.06.49.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 06:49:29 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Fri, 29 Sep 2017 16:49:23 +0300 Message-Id: <1506692963-1762-2-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506692963-1762-1-git-send-email-al1img@gmail.com> References: <1506692963-1762-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH] libxl: fix generating array of enums in getypes.py X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov Enum always uses "x" value as input argument. In case of enum array "t" argument should be passed. Signed-off-by: Oleksandr Grytsov --- 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"