From: Ian Campbell Subject: Re: [PATCH v4 10/27] libxl: ocaml: generate string_of_* functions for enums Date: Mon, 11 Nov 2013 14:33:33 +0000 Message-ID: <1384180413.19117.35.camel@kazak.uk.xensource.com> References: <1383760205-20397-1-git-send-email-rob.hoes@citrix.com> <1383760205-20397-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: <1383760205-20397-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 Wed, 2013-11-06 at 17:49 +0000, Rob Hoes wrote: > Signed-off-by: Rob Hoes > Acked-by: David Scott Acked-by:Ian Campbell > > --- > v4: Now using v.valuename, as suggested by Ian. > --- > tools/ocaml/libs/xl/genwrap.py | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py > index bdae886..0f73e26 100644 > --- a/tools/ocaml/libs/xl/genwrap.py > +++ b/tools/ocaml/libs/xl/genwrap.py > @@ -162,6 +162,14 @@ def gen_ocaml_ml(ty, interface, indent=""): > s += "type %s = \n" % ty.rawname > for v in ty.values: > s += "\t | %s\n" % v.rawname > + > + if interface: > + s += "\nval string_of_%s : %s -> string\n" % (ty.rawname, ty.rawname) > + else: > + s += "\nlet string_of_%s = function\n" % ty.rawname > + for v in ty.values: > + s += '\t| %s -> "%s"\n' % (v.rawname, v.valuename) > + > elif isinstance(ty, idl.Aggregate): > s += "" >