[Spice-devel] [PATCH v3 39/51] Allows to have two type with different size to point to same field name
Christophe Fergeau
cfergeau at redhat.com
Thu Jul 23 06:36:17 PDT 2015
Can you add a short "why ?" explanation to the commit log ?
On Tue, Jul 21, 2015 at 05:46:09PM +0100, Frediano Ziglio wrote:
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> python_modules/dissector.py | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/python_modules/dissector.py b/python_modules/dissector.py
> index c88118f..554f59c 100644
> --- a/python_modules/dissector.py
> +++ b/python_modules/dissector.py
> @@ -45,17 +45,14 @@ class HF:
> hf_writer.variable_def("static int", "%s = -1" % self.hf_name)
>
> def create(self):
> - other = self.fields.get(self.ws_name)
> + other = self.fields.get(self.hf_name)
> if other:
> - for f in 'hf_name desc ws_name base vals mask'.split():
> + for f in 'hf_name desc ws_name f_type base vals mask'.split():
> if other.__dict__[f] != self.__dict__[f]:
> raise Exception('HF Field different from previous for\n\t%s\n\t%s' % (other, self))
> - if other.f_type != self.f_type:
> - if other.f_type[:7] != 'FT_UINT' or self.f_type[:7] != 'FT_UINT':
> - raise Exception('HF Field different from previous for\n\t%s\n\t%s' % (other, self))
> return
>
> - self.fields[self.ws_name] = self
> + self.fields[self.hf_name] = self
>
> self.add_wireshark_field()
>
> @@ -297,6 +294,8 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding
>
> assert(member and container)
>
> + size_name = ''
> +
> # compute proper type
> f_type = 'FT_NONE'
> base = 'BASE_NONE'
> @@ -305,6 +304,7 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding
> assert(t.is_primitive())
> base = 'BASE_DEC'
> f_type = get_primitive_ft_type(t)
> + size_name = str(t.get_fixed_nw_size() * 8)
> if isinstance(t, ptypes.FlagsType):
> # show flag as hexadecimal for now
> base = 'BASE_HEX'
> @@ -342,7 +342,7 @@ def write_wireshark_field(writer, container, member, t, ws, tree, size, encoding
> hf_name = member_hf_name(container, member)
> ws_name = 'auto.' + hf_name[3:]
> else:
> - hf_name = 'hf_%s' % ws_name.replace('.', '_')
> + hf_name = 'hf_%s%s' % (ws_name.replace('.', '_'), size_name)
>
> writer.statement("%sproto_tree_add_item(%s, %s, glb->tvb, offset, %s, %s)" %
> (prefix, tree, hf_name, size, encoding))
> --
> 2.1.0
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150723/3757080b/attachment.sig>
More information about the Spice-devel
mailing list