From a6beb5286e7ca1d478ef391396be49b4f6d2ca35 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Tue, 31 Jan 2012 16:34:38 +0000 Subject: libxl: Rename libxl IDL infrastructure. Originally libxltypes.py provided the infrastructure and libxl.idl provided the specific types. In 23887:a543e10211f7 libxl.idl became libxl_types.idl (to allow for libxl_types_internal.idl) which means we now have libxl_types.FOO and libxltypes.FOO providing different things and annoying people in tab completion. Rename the infrastructure as idl. Signed-off-by: Ian Campbell Acked-by: Ian Jackson Committed-by: Ian Jackson --- tools/ocaml/libs/xl/Makefile | 2 +- tools/ocaml/libs/xl/genwrap.py | 35 +++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'tools/ocaml') diff --git a/tools/ocaml/libs/xl/Makefile b/tools/ocaml/libs/xl/Makefile index b1f12d058a..fe75abb582 100644 --- a/tools/ocaml/libs/xl/Makefile +++ b/tools/ocaml/libs/xl/Makefile @@ -46,7 +46,7 @@ xenlight.mli: xenlight.mli.in _libxl_types.mli.in $(Q)mv xenlight.mli.tmp xenlight.mli _libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py $(XEN_ROOT)/tools/libxl/libxl_types.idl \ - $(XEN_ROOT)/tools/libxl/libxltypes.py + $(XEN_ROOT)/tools/libxl/idl.py PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \ $(XEN_ROOT)/tools/libxl/libxl_types.idl \ _libxl_types.mli.in _libxl_types.ml.in _libxl_types.inc diff --git a/tools/ocaml/libs/xl/genwrap.py b/tools/ocaml/libs/xl/genwrap.py index 4e318bebc8..f83581848b 100644 --- a/tools/ocaml/libs/xl/genwrap.py +++ b/tools/ocaml/libs/xl/genwrap.py @@ -2,7 +2,7 @@ import sys,os -import libxltypes +import idl # typename -> ( ocaml_type, c_from_ocaml, ocaml_from_c ) builtins = { @@ -39,7 +39,7 @@ def stub_fn_name(ty, name): def ocaml_type_of(ty): if ty.rawname == "domid": return "domid" - elif isinstance(ty,libxltypes.UInt): + elif isinstance(ty,idl.UInt): if ty.width in [8, 16]: # handle as ints width = None @@ -52,14 +52,14 @@ def ocaml_type_of(ty): else: return "int" - elif isinstance(ty,libxltypes.Builtin): + elif isinstance(ty,idl.Builtin): if not builtins.has_key(ty.typename): raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) typename,_,_ = builtins[ty.typename] if not typename: raise NotImplementedError("No typename for Builtin %s (%s)" % (ty.typename, type(ty))) return typename - elif isinstance(ty,libxltypes.Aggregate): + elif isinstance(ty,idl.Aggregate): return ty.rawname.capitalize() + ".t" else: return ty.rawname @@ -73,11 +73,11 @@ def gen_ocaml_ml(ty, interface, indent=""): s = ("""(* %s interface *)\n""" % ty.typename) else: s = ("""(* %s implementation *)\n""" % ty.typename) - if isinstance(ty, libxltypes.Enumeration): + if isinstance(ty, idl.Enumeration): s = "type %s = \n" % ty.rawname for v in ty.values: s += "\t | %s\n" % v.rawname - elif isinstance(ty, libxltypes.Aggregate): + elif isinstance(ty, idl.Aggregate): s = "" if ty.typename is None: raise NotImplementedError("%s has no typename" % type(ty)) @@ -115,7 +115,7 @@ def gen_ocaml_ml(ty, interface, indent=""): def c_val(ty, c, o, indent="", parent = None): s = indent - if isinstance(ty,libxltypes.UInt): + if isinstance(ty,idl.UInt): if ty.width in [8, 16]: # handle as ints width = None @@ -127,14 +127,14 @@ def c_val(ty, c, o, indent="", parent = None): s += "%s = Int%d_val(%s);" % (c, width, o) else: s += "%s = Int_val(%s);" % (c, o) - elif isinstance(ty,libxltypes.Builtin): + elif isinstance(ty,idl.Builtin): if not builtins.has_key(ty.typename): raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) _,fn,_ = builtins[ty.typename] 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,libxltypes.Enumeration) and (parent is None): + elif isinstance(ty,idl.Enumeration) and (parent is None): n = 0 s += "switch(Int_val(%s)) {\n" % o for e in ty.values: @@ -142,7 +142,7 @@ def c_val(ty, c, o, indent="", parent = None): n += 1 s += " default: failwith_xl(\"cannot convert value to %s\", lg); break;\n" % ty.typename s += "}" - elif isinstance(ty, libxltypes.Aggregate) and (parent is None): + elif isinstance(ty, idl.Aggregate) and (parent is None): n = 0 for f in ty.fields: if f.type.private: @@ -151,14 +151,14 @@ def c_val(ty, c, o, indent="", parent = None): s += "%s\n" % c_val(f.type, fexpr, "Field(%s, %d)" % (o,n), parent=nparent) n = n + 1 else: - s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, ty.pass_arg(c, parent is None, passby=libxltypes.PASS_BY_REFERENCE), o) + s += "%s_val(gc, lg, %s, %s);" % (ty.rawname, ty.pass_arg(c, parent is None, passby=idl.PASS_BY_REFERENCE), o) return s.replace("\n", "\n%s" % indent) def gen_c_val(ty, indent=""): s = "/* Convert caml value to %s */\n" % ty.rawname - s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s, value v)\n" % (ty.rawname, ty.make_arg("c_val", passby=libxltypes.PASS_BY_REFERENCE)) + s += "static int %s_val (caml_gc *gc, struct caml_logger *lg, %s, value v)\n" % (ty.rawname, ty.make_arg("c_val", passby=idl.PASS_BY_REFERENCE)) s += "{\n" s += "\tCAMLparam1(v);\n" s += "\n" @@ -172,7 +172,7 @@ def gen_c_val(ty, indent=""): def ocaml_Val(ty, o, c, indent="", parent = None): s = indent - if isinstance(ty,libxltypes.UInt): + if isinstance(ty,idl.UInt): if ty.width in [8, 16]: # handle as ints width = None @@ -184,14 +184,14 @@ def ocaml_Val(ty, o, c, indent="", parent = None): s += "%s = caml_copy_int%d(%s);" % (o, width, c) else: s += "%s = Val_int(%s);" % (o, c) - elif isinstance(ty,libxltypes.Builtin): + elif isinstance(ty,idl.Builtin): if not builtins.has_key(ty.typename): raise NotImplementedError("Unknown Builtin %s (%s)" % (ty.typename, type(ty))) _,_,fn = builtins[ty.typename] 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,libxltypes.Enumeration) and (parent is None): + elif isinstance(ty,idl.Enumeration) and (parent is None): n = 0 s += "switch(%s) {\n" % c for e in ty.values: @@ -199,7 +199,7 @@ def ocaml_Val(ty, o, c, indent="", parent = None): n += 1 s += " default: failwith_xl(\"cannot convert value from %s\", lg); break;\n" % ty.typename s += "}" - elif isinstance(ty,libxltypes.Aggregate) and (parent is None): + elif isinstance(ty,idl.Aggregate) and (parent is None): s += "{\n" s += "\tvalue %s_field;\n" % ty.rawname s += "\n" @@ -258,8 +258,7 @@ if __name__ == '__main__': print >>sys.stderr, "Usage: genwrap.py " sys.exit(1) - idl = sys.argv[1] - (_,types) = libxltypes.parse(idl) + (_,types) = idl.parse(sys.argv[1]) # Do not generate these yet. blacklist = [ -- cgit v1.2.3