generator: fix absname for fields with only accessor function
[free-sw/xcb/libxcb] / src / c_client.py
index 56a1766..49c40fc 100644 (file)
@@ -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