aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2012-01-31 16:34:38 +0000
committerIan Campbell <ian.campbell@citrix.com>2012-01-31 16:34:38 +0000
commita6beb5286e7ca1d478ef391396be49b4f6d2ca35 (patch)
treee649090f00988dde2ca2b569980a1b8f5f330131 /tools/libxl
parent15873321439d3588e0276c7cfddb0a11f71c897d (diff)
downloadxen-a6beb5286e7ca1d478ef391396be49b4f6d2ca35.tar.gz
xen-a6beb5286e7ca1d478ef391396be49b4f6d2ca35.tar.bz2
xen-a6beb5286e7ca1d478ef391396be49b4f6d2ca35.zip
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@citrix.com> Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl')
-rw-r--r--tools/libxl/Makefile2
-rw-r--r--tools/libxl/gentest.py23
-rw-r--r--tools/libxl/gentypes.py34
-rw-r--r--tools/libxl/idl.py (renamed from tools/libxl/libxltypes.py)0
-rw-r--r--tools/libxl/idl.txt50
5 files changed, 54 insertions, 55 deletions
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 113b7c2e50..d5893d7ef2 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -111,7 +111,7 @@ libxl_internal_json.h: _libxl_types_internal_json.h
$(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
index ac7a400060..06d35369cf 100644
--- 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_value_list",
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 = " ", parent = None):
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 = " ", parent = None):
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(libxl_cpuarray *p)
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
index 7ecc11d572..ae4a6b6a7a 100644
--- 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 = " ", parent = None):
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 = " ", parent = None):
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 = " ", parent = None):
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 = " ", parent = None):
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
index 880b7ca71d..880b7ca71d 100644
--- a/tools/libxl/libxltypes.py
+++ b/tools/libxl/idl.py
diff --git a/tools/libxl/idl.txt b/tools/libxl/idl.txt
index 6f2d05bf26..adf872d6be 100644
--- 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 the type _including_ the
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)
@@ -57,12 +57,12 @@ Type.autogenerate_json: (default: True)
Other simple type-Classes
-------------------------
-libxltype.Builtin
+idl.Builtin
Instances of this class represent types which are predefined within
the system.
-libxltype.UInt
+idl.UInt
Instances of this class represent the standard uint<N>_t types.
@@ -72,12 +72,12 @@ libxltype.UInt
Complex type-Classes
--------------------
-libxltype.Enumeration
+idl.Enumeration
A class representing an enumeration (named integer values).
The values are available in the list Enumeration.values. Each
- element in the list is of type libxltype.EnumerationValue.
+ element in the list is of type idl.EnumerationValue.
Each EnumerationValue has the following properties:
@@ -95,37 +95,37 @@ libxltype.Enumeration
and any namespace (e.g. "VALUE")
EnumerationValue.value The integer value associated with this name.
-libxltype.Aggregate
+idl.Aggregate
Base class for type-Classes which contain a number of other types
(e.g. structs and unions).
The contained types are available in the list Aggregate.fields. Each
- element in the list is of type libxltype.Field representing a member
- of the aggregate.
+ element in the list is of type idl.Field representing a member of the
+ 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.
-libxltype.Struct
+idl.Struct
- A subclass of libxltype.Aggregate representing the C struct type.
+ A subclass of idl.Aggregate representing the C struct type.
Struct.kind == "struct"
-libxltype.Union
+idl.Union
- A subclass of libxltype.Aggregate representing the C union type.
+ A subclass of idl.Aggregate representing the C union type.
Union.kind == "union"
-libxltype.KeyedUnion
+idl.KeyedUnion
- A subclass of libxltype.Aggregate which represents the C union type
+ A subclass of idl.Aggregate which represents the C union type
where the currently valid member of the union can be determined based
upon another member in the containing type.