Mailing List Archive

[PATCH 2/9] ocaml, libxl: support "private" fields
The changeset
24378:b4365e2c2595 libxl: idl: support new "private" type attribute
is not complete. Actually using this feature does not work because
the ocaml idl generator does not know about it.

So add that support.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
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 5f8639a..61abecf 100644
--- a/tools/ocaml/libs/xl/genwrap.py
+++ b/tools/ocaml/libs/xl/genwrap.py
@@ -91,6 +91,8 @@ def gen_ocaml_ml(ty, interface, indent=""):
s += "\t{\n"

for f in ty.fields:
+ if f.type.private:
+ continue
x = ocaml_instance_of(f.type, f.name)
x = x.replace("\n", "\n\t\t")
s += "\t\t" + x + ";\n"
@@ -146,6 +148,8 @@ def c_val(ty, c, o, indent="", parent = None):
elif isinstance(ty, libxltypes.Aggregate) and (parent is None):
n = 0
for f in ty.fields:
+ if f.type.private:
+ continue
s += "%s\n" % c_val(f.type, "%s->%s" % (c, f.name), "Field(%s, %d)" % (o,n), parent="%s->" % (c))
n = n + 1
else:
@@ -210,6 +214,8 @@ def ocaml_Val(ty, o, c, indent="", parent = None):

n = 0
for f in ty.fields:
+ if f.type.private:
+ continue
s += "\n"
s += "\t%s\n" % ocaml_Val(f.type, "%s_field" % ty.rawname, "%s->%s" % (c,f.name), parent="%s->" % c)
s += "\tStore_field(%s, %d, %s);\n" % (o, n, "%s_field" % ty.rawname)
@@ -288,6 +294,8 @@ if __name__ == '__main__':
cinc.write(autogen_header("/*", "*/"))

for ty in types:
+ if ty.private:
+ continue
#sys.stdout.write(" TYPE %-20s " % ty.rawname)
ml.write(gen_ocaml_ml(ty, False))
ml.write("\n")
--
1.7.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: [PATCH 2/9] ocaml, libxl: support "private" fields [ In reply to ]
On Fri, 2012-01-13 at 19:25 +0000, Ian Jackson wrote:
> The changeset
> 24378:b4365e2c2595 libxl: idl: support new "private" type attribute
> is not complete. Actually using this feature does not work because
> the ocaml idl generator does not know about it.
>
> So add that support.
>
> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
> 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 5f8639a..61abecf 100644
> --- a/tools/ocaml/libs/xl/genwrap.py
> +++ b/tools/ocaml/libs/xl/genwrap.py
> @@ -91,6 +91,8 @@ def gen_ocaml_ml(ty, interface, indent=""):
> s += "\t{\n"
>
> for f in ty.fields:
> + if f.type.private:
> + continue
> x = ocaml_instance_of(f.type, f.name)
> x = x.replace("\n", "\n\t\t")
> s += "\t\t" + x + ";\n"
> @@ -146,6 +148,8 @@ def c_val(ty, c, o, indent="", parent = None):
> elif isinstance(ty, libxltypes.Aggregate) and (parent is None):
> n = 0
> for f in ty.fields:
> + if f.type.private:
> + continue
> s += "%s\n" % c_val(f.type, "%s->%s" % (c, f.name), "Field(%s, %d)" % (o,n), parent="%s->" % (c))
> n = n + 1
> else:
> @@ -210,6 +214,8 @@ def ocaml_Val(ty, o, c, indent="", parent = None):
>
> n = 0
> for f in ty.fields:
> + if f.type.private:
> + continue
> s += "\n"
> s += "\t%s\n" % ocaml_Val(f.type, "%s_field" % ty.rawname, "%s->%s" % (c,f.name), parent="%s->" % c)
> s += "\tStore_field(%s, %d, %s);\n" % (o, n, "%s_field" % ty.rawname)
> @@ -288,6 +294,8 @@ if __name__ == '__main__':
> cinc.write(autogen_header("/*", "*/"))
>
> for ty in types:
> + if ty.private:
> + continue
> #sys.stdout.write(" TYPE %-20s " % ty.rawname)
> ml.write(gen_ocaml_ml(ty, False))
> ml.write("\n")



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