Ian Campbell
2012-Nov-20 17:23 UTC
[PATCH 06 of 15] libxl/ocaml: avoid reserved words in type and field names
# HG changeset patch
# User Ian Campbell <ijc@hellion.org.uk>
# Date 1353432141 0
# Node ID f618acdeea1bf60b3b68da4062de018d8162fe8c
# Parent b7e2cd4a03f278c9abfec0812c88234f7e493646
libxl/ocaml: avoid reserved words in type and field names.
Current just s/type/ty/ and there are no such fields (yet) so no
change to generated code.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
diff -r b7e2cd4a03f2 -r f618acdeea1b tools/ocaml/libs/xl/genwrap.py
--- a/tools/ocaml/libs/xl/genwrap.py Tue Nov 20 17:22:21 2012 +0000
+++ b/tools/ocaml/libs/xl/genwrap.py Tue Nov 20 17:22:21 2012 +0000
@@ -70,8 +70,14 @@ def ocaml_type_of(ty):
else:
return ty.rawname
+def munge_name(name):
+ if name == "type":
+ return "ty"
+ 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=""):
Rob Hoes
2012-Nov-29 16:52 UTC
Re: [PATCH 06 of 15] libxl/ocaml: avoid reserved words in type and field names
> # HG changeset patch > # User Ian Campbell <ijc@hellion.org.uk> # Date 1353432141 0 # Node ID > f618acdeea1bf60b3b68da4062de018d8162fe8c > # Parent b7e2cd4a03f278c9abfec0812c88234f7e493646 > libxl/ocaml: avoid reserved words in type and field names. > > Current just s/type/ty/ and there are no such fields (yet) so no change to > generated code. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>Looks good to me. Acked-by: Rob Hoes <rob.hoes@citrix.com>> diff -r b7e2cd4a03f2 -r f618acdeea1b tools/ocaml/libs/xl/genwrap.py > --- a/tools/ocaml/libs/xl/genwrap.py Tue Nov 20 17:22:21 2012 +0000 > +++ b/tools/ocaml/libs/xl/genwrap.py Tue Nov 20 17:22:21 2012 +0000 > @@ -70,8 +70,14 @@ def ocaml_type_of(ty): > else: > return ty.rawname > > +def munge_name(name): > + if name == "type": > + return "ty" > + 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=""): > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel