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

[Xen-changelog] [xen master] libxl: ocaml: avoid reserved words in type and field names.



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

    libxl: ocaml: avoid reserved words in type and field names.
    
    Do this by adding a "xl_" prefix to all names that are OCaml keywords.
    
    Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 tools/ocaml/libs/xl/genwrap.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py
index 1b68b6b..bdac6e9 100644
--- a/tools/ocaml/libs/xl/genwrap.py
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -70,8 +70,21 @@ def ocaml_type_of(ty):
     else:
         return ty.rawname
 
+ocaml_keywords = ['and', 'as', 'assert', 'begin', 'end', 'class', 'constraint',
+    'do', 'done', 'downto', 'else', 'if', 'end', 'exception', 'external', 
'false',
+    'for', 'fun', 'function', 'functor', 'if', 'in', 'include', 'inherit',
+    'initializer', 'lazy', 'let', 'match', 'method', 'module', 'mutable', 
'new',
+    'object', 'of', 'open', 'or', 'private', 'rec', 'sig', 'struct', 'then', 
'to',
+    'true', 'try', 'type', 'val', 'virtual', 'when', 'while', 'with']
+
+def munge_name(name):
+    if name in ocaml_keywords:
+        return "xl_" + name
+    else:
+        return name
+
 def ocaml_instance_of(type, name):
-    return "%s : %s" % (name, ocaml_type_of(type))
+    return "%s : %s" % (munge_name(name), ocaml_type_of(type))
 
 def gen_ocaml_ml(ty, interface, indent=""):
 
--
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®.