From 9be2806c6e7969fb281ee2be537f4b19a98e4001 Mon Sep 17 00:00:00 2001 From: Christian Linhart Date: Mon, 20 Oct 2014 12:18:37 +0200 Subject: [PATCH] generator: fix absname for fields with only accessor function Fix _c_helper_absolute_name for fields which cannot be accessed as a struct/union member but which can be accessed by an accessor function. The fix calls the accessor function in these cases. Example: len The sumof-expression ( ) refers to mylist1 which is only acessible by an accessor function. Previously, sumof was only used inside bitcases, where such lists are accessible by members of the deserialized parent struct. (there is a difference between deserialization of switches and structs.) V2 of this patch: * replaced "!= None" with "is not None" because that's more pythonic. (according to suggestion from Ran Benita) Message-ID: <5444E17D.3040206@DemoRecorder.com> Patch-Thread-Subject: [Xcb] xinput: make ListInputDevices work, sumof with nested expr, ... Patch-Set: ListInputDevices Patch-Number: libxcb 1/6 Patch-Version: V2 Signed-off-by: Christian Linhart --- src/c_client.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/c_client.py b/src/c_client.py index 56a1766..49c40fc 100644 --- a/src/c_client.py +++ b/src/c_client.py @@ -434,16 +434,42 @@ def _c_helper_absolute_name(prefix, field=None): if field is not None, append the field name as well """ prefix_str = '' + last_sep ='' for name, sep, obj in prefix: + if '' != last_sep: + prefix_str += last_sep prefix_str += name if '' == sep: sep = '->' if ((obj.is_case_or_bitcase and obj.has_name) or # named bitcase (obj.is_switch and len(obj.parents)>1)): sep = '.' - prefix_str += sep + last_sep = sep + + prefix_str_without_lastsep = prefix_str + prefix_str += last_sep + if field is not None: prefix_str += _cpp(field.field_name) + + + if ( + field is not None + and hasattr(field, 'c_accessor_name') + and field.parent is not None + and field.parent.is_container + and not field.parent.is_switch + and not field.parent.is_case_or_bitcase + and (# the following conditions are taken from _c_accessors() + (field.type.is_list and not field.type.fixed_size()) + or + (field.prev_varsized_field is not None + or not field.type.fixed_size() + ) + ) + ): + prefix_str = field.c_accessor_name + "(" + prefix_str_without_lastsep + ")"; + return prefix_str # _c_absolute_name -- 2.34.1