[Xcb] [PATCH libxcb 7/9] rename _c_helper_absolute_name to _c_helper_fieldaccess_expr

Christian Linhart chris at DemoRecorder.com
Sun Nov 2 04:46:38 PST 2014

The function _c_helper_absolute_name was named in
a misleading way.
It computes a C-expression for accessing a field of an xcb-type.

Therefore the name _c_helper_fieldaccess_expr is more appropriate.

Note: Patch 6 of this series has been removed during the review process.

Signed-off-by: Christian Linhart <chris at demorecorder.com>
Reviewed-by: Ran Benita <ran234 at gmail.com>
 src/c_client.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/c_client.py b/src/c_client.py
index 929d70e..aaaac0a 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -485,13 +485,13 @@ def _c_type_setup(self, name, postfix):
             if self.c_var_followed_by_fixed_fields:
                 if field.type.fixed_size():
                     field.prev_varsized_field = None
             # recurse into this field this has to be done here, i.e.,
             # after the field has been set up. Otherwise the function
-            # _c_helper_absolute_name will produce garbage or crash
+            # _c_helper_fieldaccess_expr will produce garbage or crash
             _c_type_setup(field.type, field.field_type, ())
             if field.type.is_list:
                 _c_type_setup(field.type.member, field.field_type, ())
                 if (field.type.nmemb is None):
                     self.c_need_sizeof = True
@@ -545,15 +545,15 @@ def _c_field_is_member_of_case_or_bitcase(field):
 def _c_field_needs_accessor(field):
     return (_c_field_needs_list_accessor(field) or
 def _c_field_is_member_of_case_or_bitcase(field):
     return field.parent and field.parent.is_case_or_bitcase
-def _c_helper_absolute_name(prefix, field=None):
+def _c_helper_fieldaccess_expr(prefix, field=None):
     turn prefix, which is a list of tuples (name, separator, Type obj) into a string
     representing a valid name in C (based on the context)
     if field is not None, append the field name as well
     prefix_str = ''
     last_sep =''
@@ -602,15 +602,15 @@ def _c_helper_field_mapping(complex_type, prefix, flat=False):
                 bitcase_prefix = prefix
             if (True==flat and not b.type.has_name) or False==flat:
                 all_fields.update(_c_helper_field_mapping(b.type, bitcase_prefix, flat))
         for f in complex_type.fields:
-            fname = _c_helper_absolute_name(prefix, f)
+            fname = _c_helper_fieldaccess_expr(prefix, f)
             if f.field_name in all_fields:
                 raise Exception("field name %s has been registered before" % f.field_name)
             all_fields[f.field_name] = (fname, f)
             if f.type.is_container and flat==False:
                 if f.type.is_case_or_bitcase and not f.type.has_name:
                     new_prefix = prefix
@@ -887,15 +887,15 @@ def _c_serialize_helper_switch(context, self, complex_name,
 def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, prefix):
     handle switch by calling _serialize() or _unpack(), depending on context
     # switch is handled by this function as a special case
     param_fields, wire_fields, params = get_serialize_params(context, self)
     field_mapping = _c_helper_field_mapping(self, prefix)
-    prefix_str = _c_helper_absolute_name(prefix)
+    prefix_str = _c_helper_fieldaccess_expr(prefix)
     # find the parameters that need to be passed to _serialize()/_unpack():
     # all switch expr fields must be given as parameters
     args = get_expr_fields(field.type)
     # length fields for variable size types in switch, normally only some of need
     # need to be passed as parameters
     switch_len_fields = resolve_expr_fields(field.type)
@@ -931,15 +931,15 @@ def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, pr
 def _c_serialize_helper_list_field(context, self, field,
                                    code_lines, temp_vars,
                                    space, prefix):
     helper function to cope with lists of variable length
     expr = field.type.expr
-    prefix_str = _c_helper_absolute_name(prefix)
+    prefix_str = _c_helper_fieldaccess_expr(prefix)
     param_fields, wire_fields, params = get_serialize_params('sizeof', self)
     param_names = [p[2] for p in params]
     expr_fields_names = [f.field_name for f in get_expr_fields(field.type)]
     resolved = list(filter(lambda x: x in param_names, expr_fields_names))
     unresolved = list(filter(lambda x: x not in param_names, expr_fields_names))
@@ -1002,15 +1002,15 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
     if not self.is_case_or_bitcase:
         code_lines.append('%s    /* %s.%s */' % (space, self.c_type, field.c_field_name))
         scoped_name = [p[2].c_type if idx==0 else p[0] for idx, p in enumerate(prefix)]
         typename = reduce(lambda x,y: "%s.%s" % (x, y), scoped_name)
         code_lines.append('%s    /* %s.%s */' % (space, typename, field.c_field_name))
-    abs_field_name = _c_helper_absolute_name(prefix, field)
+    abs_field_name = _c_helper_fieldaccess_expr(prefix, field)
     # default for simple cases: call sizeof()
     length = "sizeof(%s)" % field.c_field_type
     if context in ('unserialize', 'unpack', 'sizeof'):
         # default: simple cast
         value = '    %s = *(%s *)xcb_tmp;' % (abs_field_name, field.c_field_type)
@@ -1064,15 +1064,15 @@ def _c_serialize_helper_fields_fixed_size(context, self, field,
     return (value, length)
 # _c_serialize_helper_fields_fixed_size()
 def _c_serialize_helper_fields_variable_size(context, self, field,
                                              code_lines, temp_vars,
                                              space, prefix):
-    prefix_str = _c_helper_absolute_name(prefix)
+    prefix_str = _c_helper_fieldaccess_expr(prefix)
     if context in ('unserialize', 'unpack', 'sizeof'):
         value = ''
         var_field_name = 'xcb_tmp'
         # special case: intermixed fixed and variable size fields
         if self.c_var_followed_by_fixed_fields and 'unserialize' == context:

More information about the Xcb mailing list