From: Wei Liu Subject: Re: [PATCH v6 11/18] libxl/gentypes.py: don't generate default values Date: Tue, 10 Jun 2014 16:59:25 +0100 Message-ID: <20140610155924.GQ11959@zion.uk.xensource.com> References: <1402317809-26833-1-git-send-email-wei.liu2@citrix.com> <1402317809-26833-12-git-send-email-wei.liu2@citrix.com> <1402406714.1250.121.camel@kazak.uk.xensource.com> <20140610134300.GJ11959@zion.uk.xensource.com> <1402412170.20641.19.camel@kazak.uk.xensource.com> <20140610154928.GP11959@zion.uk.xensource.com> <1402415666.9559.2.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1402415666.9559.2.camel@kazak.uk.xensource.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: Ian Campbell Cc: ian.jackson@eu.citrix.com, Wei Liu , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Tue, Jun 10, 2014 at 04:54:26PM +0100, Ian Campbell wrote: [...] > > > > IIRC with this line Enumeration type doesn't have a default value. > > > ^out (per your other mail) > > > > > > It should be None, which I think is set by the following Type.__init__. > > > > > > > Yes, it's None if it's not explicitly set. > > > > If I make get_init_val function return 0 when it encounters None then I > > don't need this hunk anymore. > > I think it should return None in this case and then you use > if init_val: > s += "if (%s != %s) {\n" % (fexpr, init_val) > else: > s += "if (%s) {\n" % (fexpr) > > as discussed previously. Or maybe you could make get_init_val return the > complete appropriate expression and call it get_default_expr (or > something better than that) > Oh I was talking nonsense in my previous email. get_init_val is in fact returning the expression and your suggestion to change it to get_default_expr is good. Anyway, I will figure this out. Sorry for the confusion. Wei.