From: Ian Campbell Subject: Re: [PATCH v3-RESEND 10/28] libxl: ocaml: generate string_of_* functions for enums Date: Thu, 31 Oct 2013 18:13:03 +0000 Message-ID: <1383243183.5436.50.camel@dagon.hellion.org.uk> References: <1382362365-6645-1-git-send-email-rob.hoes@citrix.com> <1382362365-6645-11-git-send-email-rob.hoes@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1382362365-6645-11-git-send-email-rob.hoes@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: Rob Hoes Cc: ian.jackson@eu.citrix.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2013-10-21 at 14:32 +0100, Rob Hoes wrote: > Signed-off-by: Rob Hoes > + if interface: > + s += "\nval string_of_%s : %s -> string\n" % (ty.rawname, ty.rawname) > + else: > + s += "\nlet string_of_%s = function\n" % ty.rawname > + n = len(ty.rawname) + 1 > + for v in ty.values: > + s += '\t| %s -> "%s"\n' % (v.rawname, v.rawname[n:]) Is n here trying to strip the libxl_ prefix? Oh no, its the enum name prefix. v.valuename is unhelpfully upper-cased (this might be an error in id.py TBH). But I think v.valuename.lower() (or whatever case munging ocaml requires) would be fine here. Or you could trivially add v.basename or something similar to tools/libxl/idl.{txt,py} I think. Ian.