diff options
| author | Alexander Larsson <alexl@redhat.com> | 2010-06-23 16:18:21 +0200 |
|---|---|---|
| committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-20 15:25:45 +0100 |
| commit | 8b5726ecfae65b923bee3e5055efa31ae13a52c6 (patch) | |
| tree | e79b535cb2bc8e54acd9f534ab7a8388e79a32b1 /python_modules | |
| parent | 21c7a6d278570adc7cabdf08b75d35cd85bd4ca6 (diff) | |
| download | spice-common-8b5726ecfae65b923bee3e5055efa31ae13a52c6.tar.gz spice-common-8b5726ecfae65b923bee3e5055efa31ae13a52c6.tar.xz spice-common-8b5726ecfae65b923bee3e5055efa31ae13a52c6.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.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py index 9141539..2ee1789 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() |
