aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/gentypes.py
diff options
context:
space:
mode:
authorIan Campbell <ian.campbell@citrix.com>2011-07-18 14:52:30 +0100
committerIan Campbell <ian.campbell@citrix.com>2011-07-18 14:52:30 +0100
commit22480b967b8880b17e3fc7974971a05d1a55912d (patch)
tree824f9fb4e5268d6ba77b05ba0e32403bfc076bcd /tools/libxl/gentypes.py
parent9949c1ba6964fb2230d02dfe8385091c13e3589c (diff)
downloadxen-22480b967b8880b17e3fc7974971a05d1a55912d.tar.gz
xen-22480b967b8880b17e3fc7974971a05d1a55912d.tar.bz2
xen-22480b967b8880b17e3fc7974971a05d1a55912d.zip
libxl: Keyed unions key off an enum instead of an arbitrary expression
Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson.citrix.com> Committed-by: Ian Jackson <ian.jackson.citrix.com>
Diffstat (limited to 'tools/libxl/gentypes.py')
-rw-r--r--tools/libxl/gentypes.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 120c6d357e..23406fceac 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -81,12 +81,13 @@ def libxl_C_type_destroy(ty, v, indent = " ", parent = None):
if isinstance(ty, libxltypes.KeyedUnion):
if parent is None:
raise Exception("KeyedUnion type must have a parent")
+ s += "switch (%s) {\n" % (parent + ty.keyvar_name)
for f in ty.fields:
(nparent,fexpr) = ty.member(v, f, parent is None)
- keyvar_expr = f.keyvar_expr % (parent + ty.keyvar_name)
- s += "if (" + keyvar_expr + ") {\n"
+ s += "case %s:\n" % f.enumname
s += libxl_C_type_destroy(f.type, fexpr, indent + " ", nparent)
- s += "}\n"
+ s += " break;\n"
+ s += "}\n"
elif isinstance(ty, libxltypes.Struct) and (parent is None or ty.destructor_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)