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

[Xen-devel] [PATCH 1 of 9] libxl: Rename libxl IDL infrastructure



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1327510508 0
# Node ID 9a366717e0c0a0e0261796669e9e96c0ba514923
# Parent  9b126ae26d95ff9c54beb7ff0908558d423ba098
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 <ian.campbell@xxxxxxxxxx>

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -107,7 +107,7 @@ libxl_internal_json.h: _libxl_types_inte
 $(LIBXL_OBJS) $(LIBXLU_OBJS) $(XL_OBJS): libxl.h
 $(LIBXL_OBJS): libxl_internal.h
 
-_libxl_type%.h _libxl_type%_json.h _libxl_type%.c: libxl_type%.idl gentypes.py 
libxltypes.py
+_libxl_type%.h _libxl_type%_json.h _libxl_type%.c: libxl_type%.idl gentypes.py 
idl.py
        $(PYTHON) gentypes.py libxl_type$*.idl __libxl_type$*.h 
__libxl_type$*_json.h __libxl_type$*.c
        $(call move-if-changed,__libxl_type$*.h,_libxl_type$*.h)
        $(call move-if-changed,__libxl_type$*_json.h,_libxl_type$*_json.h)
diff --git a/tools/libxl/gentest.py b/tools/libxl/gentest.py
--- a/tools/libxl/gentest.py
+++ b/tools/libxl/gentest.py
@@ -4,7 +4,7 @@ import sys
 import re
 import random
 
-import libxltypes
+import idl
 
 def randomize_char(c):
     if random.random() < 0.5:
@@ -25,9 +25,9 @@ handcoded = ["libxl_cpumap", "libxl_key_
 
 def gen_rand_init(ty, v, indent = "    ", parent = None):
     s = ""
-    if isinstance(ty, libxltypes.Enumeration):
+    if isinstance(ty, idl.Enumeration):
         s += "%s = %s;\n" % (ty.pass_arg(v, parent is None), 
randomize_enum(ty))
-    elif isinstance(ty, libxltypes.KeyedUnion):
+    elif isinstance(ty, idl.KeyedUnion):
         if parent is None:
             raise Exception("KeyedUnion type must have a parent")
         s += "switch (%s) {\n" % (parent + ty.keyvar_name)
@@ -37,7 +37,7 @@ def gen_rand_init(ty, v, indent = "    "
             s += gen_rand_init(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
         s += "}\n"
-    elif isinstance(ty, libxltypes.Struct) \
+    elif isinstance(ty, idl.Struct) \
      and (parent is None or ty.json_fn is None):
         for f in [f for f in ty.fields if not f.const]:
             (nparent,fexpr) = ty.member(v, f, parent is None)
@@ -45,10 +45,10 @@ def gen_rand_init(ty, v, indent = "    "
     elif hasattr(ty, "rand_init") and ty.rand_init is not None:
         s += "%s(%s);\n" % (ty.rand_init,
                             ty.pass_arg(v, isref=parent is None,
-                                        passby=libxltypes.PASS_BY_REFERENCE))
+                                        passby=idl.PASS_BY_REFERENCE))
     elif ty.typename in ["libxl_uuid", "libxl_mac", "libxl_hwcap"]:
         s += "rand_bytes((uint8_t *)%s, sizeof(*%s));\n" % (v,v)
-    elif ty.typename in ["libxl_domid"] or isinstance(ty, libxltypes.Number):
+    elif ty.typename in ["libxl_domid"] or isinstance(ty, idl.Number):
         s += "%s = rand() %% (sizeof(%s)*8);\n" % \
              (ty.pass_arg(v, parent is None),
               ty.pass_arg(v, parent is None))
@@ -74,8 +74,7 @@ if __name__ == '__main__':
 
     random.seed()
 
-    idl = sys.argv[1]
-    (builtins,types) = libxltypes.parse(idl)
+    (builtins,types) = idl.parse(sys.argv[1])
 
     impl = sys.argv[2]
     f = open(impl, "w")
@@ -215,10 +214,10 @@ static void libxl_cpuarray_rand_init(lib
         if ty.typename not in handcoded:
             f.write("static void %s_rand_init(%s);\n" % \
                     (ty.typename,
-                     ty.make_arg("p", passby=libxltypes.PASS_BY_REFERENCE)))
+                     ty.make_arg("p", passby=idl.PASS_BY_REFERENCE)))
             f.write("static void %s_rand_init(%s)\n" % \
                     (ty.typename,
-                     ty.make_arg("p", passby=libxltypes.PASS_BY_REFERENCE)))
+                     ty.make_arg("p", passby=idl.PASS_BY_REFERENCE)))
             f.write("{\n")
             f.write(gen_rand_init(ty, "p"))
             f.write("}\n")
@@ -252,7 +251,7 @@ int main(int argc, char **argv)
     for ty in [t for t in types if t.json_fn is not None]:
         arg = ty.typename + "_val"
         f.write("    %s_rand_init(%s);\n" % (ty.typename, \
-            ty.pass_arg(arg, isref=False, 
passby=libxltypes.PASS_BY_REFERENCE)))
+            ty.pass_arg(arg, isref=False, passby=idl.PASS_BY_REFERENCE)))
         f.write("    s = %s_to_json(ctx, %s);\n" % \
                 (ty.typename, ty.pass_arg(arg, isref=False)))
         f.write("    printf(\"%%s: %%s\\n\", \"%s\", s);\n" % ty.typename)
@@ -265,7 +264,7 @@ int main(int argc, char **argv)
     f.write("    printf(\"Testing Enumerations\\n\");\n")
     f.write("    printf(\"--------------------\\n\");\n")
     f.write("    printf(\"\\n\");\n")
-    for ty in [t for t in types if isinstance(t,libxltypes.Enumeration)]:
+    for ty in [t for t in types if isinstance(t,idl.Enumeration)]:
         f.write("    printf(\"%s -- to string:\\n\");\n" % (ty.typename))
         for v in ty.values:
             f.write("    printf(\"\\t%s = %%d = \\\"%%s\\\"\\n\", " \
diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -3,10 +3,10 @@
 import sys
 import re
 
-import libxltypes
+import idl
 
 def libxl_C_instance_of(ty, instancename):
-    if isinstance(ty, libxltypes.Aggregate) and ty.typename is None:
+    if isinstance(ty, idl.Aggregate) and ty.typename is None:
         if instancename is None:
             return libxl_C_type_define(ty)
         else:
@@ -16,7 +16,7 @@ def libxl_C_instance_of(ty, instancename
 
 def libxl_C_type_define(ty, indent = ""):
     s = ""
-    if isinstance(ty, libxltypes.Enumeration):
+    if isinstance(ty, idl.Enumeration):
         if ty.typename is None:
             s += "enum {\n"
         else:
@@ -31,7 +31,7 @@ def libxl_C_type_define(ty, indent = "")
         else:
             s += "} %s" % ty.typename
 
-    elif isinstance(ty, libxltypes.Aggregate):
+    elif isinstance(ty, idl.Aggregate):
         if ty.typename is None:
             s += "%s {\n" % ty.kind
         else:
@@ -53,7 +53,7 @@ def libxl_C_type_define(ty, indent = "")
 
 def libxl_C_type_dispose(ty, v, indent = "    ", parent = None):
     s = ""
-    if isinstance(ty, libxltypes.KeyedUnion):
+    if isinstance(ty, idl.KeyedUnion):
         if parent is None:
             raise Exception("KeyedUnion type must have a parent")
         s += "switch (%s) {\n" % (parent + ty.keyvar_name)
@@ -63,7 +63,7 @@ def libxl_C_type_dispose(ty, v, indent =
             s += libxl_C_type_dispose(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
         s += "}\n"
-    elif isinstance(ty, libxltypes.Struct) and (parent is None or 
ty.dispose_fn is None):
+    elif isinstance(ty, idl.Struct) and (parent is None or ty.dispose_fn is 
None):
         for f in [f for f in ty.fields if not f.const]:
             (nparent,fexpr) = ty.member(v, f, parent is None)
             s += libxl_C_type_dispose(f.type, fexpr, "", nparent)
@@ -79,11 +79,11 @@ def libxl_C_type_gen_json(ty, v, indent 
     s = ""
     if parent is None:
         s += "yajl_gen_status s;\n"
-    if isinstance(ty, libxltypes.Enumeration):
+    if isinstance(ty, idl.Enumeration):
         s += "s = libxl__yajl_gen_enum(hand, %s_to_string(%s));\n" % 
(ty.typename, ty.pass_arg(v, parent is None))
         s += "if (s != yajl_gen_status_ok)\n"
         s += "    goto out;\n"
-    elif isinstance(ty, libxltypes.KeyedUnion):
+    elif isinstance(ty, idl.KeyedUnion):
         if parent is None:
             raise Exception("KeyedUnion type must have a parent")
         s += "switch (%s) {\n" % (parent + ty.keyvar_name)
@@ -93,7 +93,7 @@ def libxl_C_type_gen_json(ty, v, indent 
             s += libxl_C_type_gen_json(f.type, fexpr, indent + "    ", nparent)
             s += "    break;\n"
         s += "}\n"
-    elif isinstance(ty, libxltypes.Struct) and (parent is None or ty.json_fn 
is None):
+    elif isinstance(ty, idl.Struct) and (parent is None or ty.json_fn is None):
         s += "s = yajl_gen_map_open(hand);\n"
         s += "if (s != yajl_gen_status_ok)\n"
         s += "    goto out;\n"
@@ -123,7 +123,7 @@ def libxl_C_type_gen_json(ty, v, indent 
 def libxl_C_type_to_json(ty, v, indent = "    "):
     s = ""
     gen = "(libxl__gen_json_callback)&%s_gen_json" % ty.typename
-    s += "return libxl__object_to_json(ctx, \"%s\", %s, (void *)%s);\n" % 
(ty.typename, gen, ty.pass_arg(v, passby=libxltypes.PASS_BY_REFERENCE))
+    s += "return libxl__object_to_json(ctx, \"%s\", %s, (void *)%s);\n" % 
(ty.typename, gen, ty.pass_arg(v, passby=idl.PASS_BY_REFERENCE))
 
     if s != "":
         s = indent + s
@@ -171,9 +171,9 @@ if __name__ == '__main__':
         print >>sys.stderr, "Usage: gentypes.py <idl> <header> <header-json> 
<implementation>"
         sys.exit(1)
 
-    (_, idl, header, header_json, impl) = sys.argv
+    (_, idlname, header, header_json, impl) = sys.argv
 
-    (builtins,types) = libxltypes.parse(idl)
+    (builtins,types) = idl.parse(idlname)
 
     print "outputting libxl type definitions to %s" % header
 
@@ -198,9 +198,9 @@ if __name__ == '__main__':
             f.write("void %s(%s);\n" % (ty.dispose_fn, ty.make_arg("p")))
         if ty.json_fn is not None:
             f.write("char *%s_to_json(libxl_ctx *ctx, %s);\n" % (ty.typename, 
ty.make_arg("p")))
-        if isinstance(ty, libxltypes.Enumeration):
+        if isinstance(ty, idl.Enumeration):
             f.write("const char *%s_to_string(%s);\n" % (ty.typename, 
ty.make_arg("p")))
-            f.write("int %s_from_string(const char *s, %s);\n" % (ty.typename, 
ty.make_arg("e", passby=libxltypes.PASS_BY_REFERENCE)))
+            f.write("int %s_from_string(const char *s, %s);\n" % (ty.typename, 
ty.make_arg("e", passby=idl.PASS_BY_REFERENCE)))
             f.write("extern libxl_enum_string_table %s_string_table[];\n" % 
(ty.typename))
         f.write("\n")
 
@@ -225,7 +225,7 @@ if __name__ == '__main__':
 """ % (header_json_define, header_json_define, " ".join(sys.argv)))
 
     for ty in [ty for ty in types+builtins if ty.json_fn is not None]:
-        f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s);\n" % 
(ty.typename, ty.make_arg("p", passby=libxltypes.PASS_BY_REFERENCE)))
+        f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s);\n" % 
(ty.typename, ty.make_arg("p", passby=idl.PASS_BY_REFERENCE)))
 
     f.write("\n")
     f.write("""#endif /* %s */\n""" % header_json_define)
@@ -262,7 +262,7 @@ if __name__ == '__main__':
         f.write("}\n")
         f.write("\n")
 
-    for ty in [t for t in types if isinstance(t,libxltypes.Enumeration)]:
+    for ty in [t for t in types if isinstance(t,idl.Enumeration)]:
         f.write("const char *%s_to_string(%s e)\n" % (ty.typename, 
ty.typename))
         f.write("{\n")
         f.write(libxl_C_enum_to_string(ty, "e"))
@@ -278,7 +278,7 @@ if __name__ == '__main__':
         f.write("\n")
 
     for ty in [t for t in types if t.json_fn is not None]:
-        f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s)\n" % 
(ty.typename, ty.make_arg("p", passby=libxltypes.PASS_BY_REFERENCE)))
+        f.write("yajl_gen_status %s_gen_json(yajl_gen hand, %s)\n" % 
(ty.typename, ty.make_arg("p", passby=idl.PASS_BY_REFERENCE)))
         f.write("{\n")
         f.write(libxl_C_type_gen_json(ty, "p"))
         f.write("}\n")
diff --git a/tools/libxl/libxltypes.py b/tools/libxl/idl.py
rename from tools/libxl/libxltypes.py
rename to tools/libxl/idl.py
diff --git a/tools/libxl/idl.txt b/tools/libxl/idl.txt
--- a/tools/libxl/idl.txt
+++ b/tools/libxl/idl.txt
@@ -1,10 +1,10 @@
-libxltypes IDL
---------------
+libxl IDL
+---------
 
 Each type in the libxl interface is represented by an object of type
-libxltypes.Type (or a subclass thereof). Every local variable defined
-by the .idl file must be an instance of libxltypes.Type (e.g. you may
-not define Python functions or any other construct other than defining
+idl.Type (or a subclass thereof). Every local variable defined by
+the .idl file must be an instance of idl.Type (e.g. you may not
+define Python functions or any other construct other than defining
 variables)
 
 The name of the type must be passed as the first argument to the
@@ -16,9 +16,9 @@ The Type.typename contains the C name of
 namespace element while Type.rawname is always set to the 'base' name
 of the type.
 
-The libxltypes.Type base class has several other properties which
-apply to all types. The properties are set by passing a named
-parameter to the constructor.
+The idl.Type base class has several other properties which apply
+to all types. The properties are set by passing a named parameter to
+the constructor.
 
 Type.namespace: (default: "libxl_")
 
@@ -28,12 +28,12 @@ Type.namespace: (default: "libxl_")
  If the typename is not None then the namespace is prepended to the
  type.
  
-Type.passby: (default: libxltypes.PASS_BY_VALUE)
+Type.passby: (default: idl.PASS_BY_VALUE)
 
  Defines the manner in which a type should be passed to C
  functions. Valid values for this fields are:
-   libxltypes.PASS_BY_VALUE
-   libxltypes.PASS_BY_REFERENCE
+   idl.PASS_BY_VALUE
+   idl.PASS_BY_REFERENCE
 
 Type.dispose_fn: (default: typename + "_dispose" or None if type == None)
 
@@ -106,7 +106,7 @@ libxltype.Aggregate
 
  Each field has the following properties:
 
-  Field.type   The type of the member (a libxltypes.Type).
+  Field.type   The type of the member (a idl.Type).
   Field.name    The name of the member (can be None for anonymous
                fields).
   Field.const  Boolean, true if the member is const.
diff --git a/tools/ocaml/libs/xl/Makefile b/tools/ocaml/libs/xl/Makefile
--- a/tools/ocaml/libs/xl/Makefile
+++ b/tools/ocaml/libs/xl/Makefile
@@ -46,7 +46,7 @@ xenlight.mli: xenlight.mli.in _libxl_typ
        $(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
--- 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))
@@ -113,7 +113,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
@@ -125,14 +125,14 @@ def c_val(ty, c, o, indent="", parent = 
             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:
@@ -140,21 +140,21 @@ def c_val(ty, c, o, indent="", parent = 
             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:
             (nparent,fexpr) = ty.member(c, f, parent is 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"
@@ -168,7 +168,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
@@ -180,14 +180,14 @@ def ocaml_Val(ty, o, c, indent="", paren
             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:
@@ -195,7 +195,7 @@ def ocaml_Val(ty, o, c, indent="", paren
             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"
@@ -251,8 +251,7 @@ if __name__ == '__main__':
         print >>sys.stderr, "Usage: genwrap.py <idl> <mli> <ml> <c-inc>"
         sys.exit(1)
 
-    idl = sys.argv[1]
-    (_,types) = libxltypes.parse(idl)
+    (_,types) = idl.parse(sys.argv[1])
 
     # Do not generate these yet.
     blacklist = [
diff --git a/tools/python/Makefile b/tools/python/Makefile
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -11,7 +11,7 @@ genpath-target = $(call buildmakevars2fi
 
 .PHONY: build
 build: genpath 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 \
                xen/lowlevel/xl/_pyxl_types.h \
diff --git a/tools/python/genwrap.py b/tools/python/genwrap.py
--- a/tools/python/genwrap.py
+++ b/tools/python/genwrap.py
@@ -2,23 +2,23 @@
 
 import sys,os
 
-import libxltypes
+import idl
 
 (TYPE_BOOL, TYPE_INT, TYPE_UINT, TYPE_STRING, TYPE_AGGREGATE) = range(5)
 
 def py_type(ty):
-    if ty == libxltypes.bool:
+    if ty == idl.bool:
         return TYPE_BOOL
-    if isinstance(ty, libxltypes.Enumeration):
+    if isinstance(ty, idl.Enumeration):
         return TYPE_UINT
-    if isinstance(ty, libxltypes.Number):
+    if isinstance(ty, idl.Number):
         if ty.signed:
             return TYPE_INT
         else:
             return TYPE_UINT
-    if isinstance(ty, libxltypes.Aggregate):
+    if isinstance(ty, idl.Aggregate):
         return TYPE_AGGREGATE
-    if ty == libxltypes.string:
+    if ty == idl.string:
         return TYPE_STRING
     return None
 
@@ -38,7 +38,7 @@ def fsanitize(name):
 
 def py_decls(ty):
     l = []
-    if isinstance(ty, libxltypes.Aggregate):
+    if isinstance(ty, idl.Aggregate):
         l.append('_hidden Py_%s *Py%s_New(void);\n'%(ty.rawname, ty.rawname))
         l.append('_hidden int Py%s_Check(PyObject *self);\n'%ty.rawname)
         for f in ty.fields:
@@ -211,10 +211,10 @@ def py_initfuncs(types):
     l.append('void genwrap__init(PyObject *m)')
     l.append('{')
     for ty in types:
-        if isinstance(ty, libxltypes.Enumeration):
+        if isinstance(ty, idl.Enumeration):
             for v in ty.values:
                 l.append('    PyModule_AddIntConstant(m, "%s", %s);' % 
(v.rawname, v.name))
-        elif isinstance(ty, libxltypes.Aggregate):
+        elif isinstance(ty, idl.Aggregate):
             l.append('    if (PyType_Ready(&Py%s_Type) >= 0) {'%ty.rawname)
             l.append('        Py_INCREF(&Py%s_Type);'%ty.rawname)
             l.append('        PyModule_AddObject(m, "%s", (PyObject 
*)&Py%s_Type);'%(ty.rawname, ty.rawname))
@@ -227,7 +227,7 @@ def py_initfuncs(types):
 
 def tree_frob(types):
     ret = types[:]
-    for ty in [ty for ty in ret if isinstance(ty, libxltypes.Aggregate)]:
+    for ty in [ty for ty in ret if isinstance(ty, idl.Aggregate)]:
         ty.fields = filter(lambda f:f.name is not None and f.type.typename is 
not None, ty.fields)
     return ret
 
@@ -236,8 +236,7 @@ if __name__ == '__main__':
         print >>sys.stderr, "Usage: genwrap.py <idl> <decls> <defns>"
         sys.exit(1)
 
-    idl = sys.argv[1]
-    (_,types) = libxltypes.parse(idl)
+    (_,types) = idl.parse(sys.argv[1])
 
     types = tree_frob(types)
 
@@ -278,7 +277,7 @@ _hidden PyObject *genwrap__ll_get(long l
 _hidden int genwrap__ll_set(PyObject *v, long long *val, long long mask);
 
 """ % " ".join(sys.argv))
-    for ty in [ty for ty in types if isinstance(ty, libxltypes.Aggregate)]:
+    for ty in [ty for ty in types if isinstance(ty, idl.Aggregate)]:
         f.write('/* Internal API for %s wrapper */\n'%ty.typename)
         f.write(py_wrapstruct(ty))
         f.write(py_decls(ty))
@@ -307,7 +306,7 @@ _hidden int genwrap__ll_set(PyObject *v,
     for ty in types:
         if ty.private:
             continue
-        if isinstance(ty, libxltypes.Aggregate):
+        if isinstance(ty, idl.Aggregate):
             f.write('/* Attribute get/set functions for %s */\n'%ty.typename)
             for a in ty.fields:
                 if a.type.private:

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.