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 | db5b8fa673d72c5726f4e358c04e9f1f97039a7f (patch) | |
| tree | 060a50b038309d6d8d8a6cb5c927a322a7b4624e /python_modules | |
| parent | 32dbd8a6a551345a829622ab92b356b6a3798839 (diff) | |
| download | spice-protocol-db5b8fa673d72c5726f4e358c04e9f1f97039a7f.tar.gz spice-protocol-db5b8fa673d72c5726f4e358c04e9f1f97039a7f.tar.xz spice-protocol-db5b8fa673d72c5726f4e358c04e9f1f97039a7f.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() |
