Introduce a libxltypes.Number class to be inherited by all numeric types
regardless of whether they are fixed width or int/long. Also maintain a
rawname attribute for types so that we can find the name without the
namespace prefix. This is in preparation for using the IDL code to
auto-generate (a lot of) boilerplate for language bindings.
Signed-off-by: Gianni Tedesco <gianni.tedesco@xxxxxxxxxx>
diff -r 08c31875bc5d tools/libxl/libxltypes.py
--- a/tools/libxl/libxltypes.py Mon Sep 06 15:16:03 2010 +0100
+++ b/tools/libxl/libxltypes.py Mon Sep 06 16:37:27 2010 +0100
@@ -14,10 +14,13 @@ class Type(object):
if typename is None: # Anonymous type
self.typename = None
+ self.rawname = None
elif self.namespace is None: # e.g. system provided types
self.typename = typename
+ self.rawname = typename
else:
self.typename = self.namespace + typename
+ self.rawname = typename
if self.typename is not None:
self.destructor_fn = kwargs.setdefault('destructor_fn',
self.typename + "_destroy")
@@ -32,11 +35,17 @@ class Builtin(Type):
kwargs.setdefault('destructor_fn', None)
Type.__init__(self, typename, **kwargs)
-class UInt(Type):
+class Number(Type):
+ def __init__(self, ctype, **kwargs):
+ kwargs.setdefault('namespace', None)
+ kwargs.setdefault('destructor_fn', None)
+ Type.__init__(self, ctype, **kwargs)
+
+class UInt(Number):
def __init__(self, w, **kwargs):
kwargs.setdefault('namespace', None)
kwargs.setdefault('destructor_fn', None)
- Type.__init__(self, "uint%d_t" % w, **kwargs)
+ Number.__init__(self, "uint%d_t" % w, **kwargs)
self.width = w
@@ -128,12 +137,12 @@ class Reference(Type):
void = Builtin("void *", namespace = None)
bool = Builtin("bool", namespace = None)
-size_t = Builtin("size_t", namespace = None)
+size_t = Number("size_t", namespace = None)
-integer = Builtin("int", namespace = None)
-unsigned_integer = Builtin("unsigned int", namespace = None)
-unsigned = Builtin("unsigned int", namespace = None)
-unsigned_long = Builtin("unsigned long", namespace = None)
+integer = Number("int", namespace = None)
+unsigned_integer = Number("unsigned int", namespace = None)
+unsigned = Number("unsigned int", namespace = None)
+unsigned_long = Number("unsigned long", namespace = None)
uint8 = UInt(8)
uint16 = UInt(16)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|