summaryrefslogtreecommitdiffstats
path: root/python_modules
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-06-23 16:18:21 +0200
committerAlexander Larsson <alexl@redhat.com>2010-06-23 16:33:07 +0200
commit929245bacd8e9f1ba170e019f107738e75a599ad (patch)
tree85d01342317ec1f6183187f75749bb65a0a3eb85 /python_modules
parent06fe6a91c2e5eb91ae97b4f3b09c02aa07953768 (diff)
downloadspice-929245bacd8e9f1ba170e019f107738e75a599ad.tar.gz
spice-929245bacd8e9f1ba170e019f107738e75a599ad.tar.xz
spice-929245bacd8e9f1ba170e019f107738e75a599ad.zip
marshaller: Correctly determine if switches are fixed size
Switches are fixed size only if all cases have the same size *and* it has a default case or all the valid cases are listed.
Diffstat (limited to 'python_modules')
-rw-r--r--python_modules/ptypes.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py
index 9141539c..2ee17898 100644
--- a/python_modules/ptypes.py
+++ b/python_modules/ptypes.py
@@ -630,14 +630,22 @@ class Switch(Containee):
return True
size = None
+ has_default = False
for c in self.cases:
+ for v in c.values:
+ if v == None:
+ has_default = True
if not c.member.is_fixed_nw_size():
return False
if size == None:
size = c.member.get_fixed_nw_size()
elif size != c.member.get_fixed_nw_size():
return False
- return True
+ # Fixed size if all elements listed, or has default
+ if has_default:
+ return True
+ key = self.container.lookup_member(self.variable)
+ return len(self.cases) == len(key.member_type.values)
def is_extra_size(self):
return self.has_end_attr()