# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1310646156 -3600
# Node ID 1e703a6ad764d820dc2d5a70d36b567237ee9aaf
# Parent 4bb89ae75a3a2288b4996908fc11b71d36a169d3
libxl: IDL: refactor code to massage a type into a function argument
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
---
diff -r 4bb89ae75a3a -r 1e703a6ad764 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 @@
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 @@
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 4bb89ae75a3a -r 1e703a6ad764 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 @@
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-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|