diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-07-06 13:17:40 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-07-06 13:17:40 +0100 |
commit | 618a40391f353f236c007038147a7b3771032f15 (patch) | |
tree | 267bb62e7d4ced046abafc8bfc49d63fe3d9706d /tools/ocaml | |
parent | 334f50ccc4e3f3a045874de9aca77adc76e900be (diff) | |
download | xen-618a40391f353f236c007038147a7b3771032f15.tar.gz xen-618a40391f353f236c007038147a7b3771032f15.tar.bz2 xen-618a40391f353f236c007038147a7b3771032f15.zip |
libxl: add a new Array type to the IDL
And make all the required infrastructure updates to enable this.
Since there are currently no uses of this type there is no change to
the generated code.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Diffstat (limited to 'tools/ocaml')
-rw-r--r-- | 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 b379b57108..42f374eaee 100644 --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -55,7 +55,8 @@ def ocaml_type_of(ty): return "int%d" % ty.width else: return "int" - + elif isinstance(ty,idl.Array): + return "%s array" % ocaml_type_of(ty.elem_type) elif isinstance(ty,idl.Builtin): if not builtins.has_key(ty.typename): raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) @@ -138,6 +139,8 @@ def c_val(ty, c, o, indent="", parent = None): if not fn: raise NotImplementedError("No c_val fn for Builtin %s (%s)" % (ty.typename, type(ty))) s += "%s;" % (fn % { "o": o, "c": c }) + elif isinstance (ty,idl.Array): + raise("Cannot handle Array type\n") elif isinstance(ty,idl.Enumeration) and (parent is None): n = 0 s += "switch(Int_val(%s)) {\n" % o @@ -195,6 +198,16 @@ def ocaml_Val(ty, o, c, indent="", parent = None): if not fn: raise NotImplementedError("No ocaml Val fn for Builtin %s (%s)" % (ty.typename, type(ty))) s += "%s = %s;" % (o, fn % { "c": c }) + elif isinstance(ty, idl.Array): + s += "{\n" + s += "\t int i;\n" + s += "\t value array_elem;\n" + s += "\t %s = caml_alloc(%s,0);\n" % (o, parent + ty.lenvar.name) + s += "\t for(i=0; i<%s; i++) {\n" % (parent + ty.lenvar.name) + s += "\t %s\n" % ocaml_Val(ty.elem_type, "array_elem", c + "[i]", "") + s += "\t Store_field(%s, i, array_elem);\n" % o + s += "\t }\n" + s += "\t}" elif isinstance(ty,idl.Enumeration) and (parent is None): n = 0 s += "switch(%s) {\n" % c |