[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] libxl: ocaml: generate string_of_* functions for enums



commit 40d0e13db68ecfa382144da10b281906af570e4f
Author:     Rob Hoes <rob.hoes@xxxxxxxxxx>
AuthorDate: Wed Nov 6 17:49:48 2013 +0000
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Mon Nov 11 15:38:45 2013 +0000

    libxl: ocaml: generate string_of_* functions for enums
    
    Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
    Acked-by: David Scott <dave.scott@xxxxxxxxxxxxx>
    Acked-by:Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/ocaml/libs/xl/genwrap.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

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 += ""
         
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.