[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4 of 9] libxl: IDL: refactor code to massage a type into a function argument
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1310646156 -3600 # Node ID 2c49e182becc028a95d67363dd06654c7f717eec # Parent 3b2827da23585a7fa93d1e6fc4db4d196706ebf8 libxl: IDL: refactor code to massage a type into a function argument Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 3b2827da2358 -r 2c49e182becc tools/libxl/gentypes.py --- a/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100 +++ b/tools/libxl/gentypes.py Thu Jul 14 13:22:36 2011 +0100 @@ -84,11 +84,6 @@ def libxl_C_type_destroy(ty, v, indent = else: deref = v + "." - if ty.passby == libxltypes.PASS_BY_REFERENCE and parent is not None: - makeref = "&" - else: - makeref = "" - s = "" if isinstance(ty, libxltypes.KeyedUnion): if parent is None: @@ -107,7 +102,7 @@ def libxl_C_type_destroy(ty, v, indent = s += libxl_C_type_destroy(f.type, deref + f.name, "", deref) else: if ty.destructor_fn is not None: - s += "%s(%s);\n" % (ty.destructor_fn, makeref + v) + s += "%s(%s);\n" % (ty.destructor_fn, ty.pass_arg(v, parent is None)) if s != "": s = indent + s diff -r 3b2827da2358 -r 2c49e182becc tools/libxl/libxltypes.py --- a/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100 +++ b/tools/libxl/libxltypes.py Thu Jul 14 13:22:36 2011 +0100 @@ -50,6 +50,21 @@ class Type(object): else: return "%s %s" % (self.typename, n) + def pass_arg(self, n, isref=None, passby=None): + if passby is None: passby = self.passby + if isref is None: isref = self.passby == PASS_BY_REFERENCE + + if passby == PASS_BY_REFERENCE: + if isref: + return "%s" % (n) + else: + return "&%s" % (n) + else: + if isref: + return "*%s" % (n) + else: + return "%s" % (n) + class Builtin(Type): """Builtin type""" def __init__(self, typename, **kwargs): _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |