From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v6 12/18] libxl IDL: generate code to parse libxl__json_object to libxl_FOO struct Date: Tue, 10 Jun 2014 14:32:48 +0100 Message-ID: <1402407168.1250.126.camel@kazak.uk.xensource.com> References: <1402317809-26833-1-git-send-email-wei.liu2@citrix.com> <1402317809-26833-13-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1402317809-26833-13-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Wei Liu Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2014-06-09 at 13:43 +0100, Wei Liu wrote: > libxl_FOO_parse_json functions are generated. > > Note that these functions are used to parse libxl__json_object to > libxl__FOO struct. They don't consume JSON string. > > Signed-off-by: Wei Liu Acked-by: Ian Campbell One small thought: > + for f in [f for f in ty.fields if not f.const and not f.type.private]: > + saved_var_name = "saved_%s" % f.name > + s += "{\n" > + s += " const libxl__json_object *%s = NULL;\n" % saved_var_name > + s += " %s = x;\n" % saved_var_name You could do the assign and the declaration on one line.