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

Christian Linhart chris at demorecorder.com
Thu Oct 30 07:31:58 PDT 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.

Signed-off-by: Christian Linhart <chris at demorecorder.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
@@ -480,15 +480,15 @@ 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
+            # Otherwise the function _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
 
@@ -555,15 +555,15 @@ def _c_field_is_member_of_case_or_bitcase(field):
     elif field.parent.is_case_or_bitcase:
         return True
     else:
         return False
 
 # end of Functions for querying field properties
 
-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 =''
@@ -612,15 +612,15 @@ def _c_helper_field_mapping(complex_type, prefix, flat=False):
             else:
                 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))
     else:
         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
@@ -897,15 +897,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)
@@ -941,15 +941,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))
 
@@ -1012,15 +1012,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))
     else:
         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)
 
@@ -1074,15 +1074,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:
-- 
2.0.1



More information about the Xcb mailing list