Lines Matching refs:field
439 for field in self.fields:
440 if field.type.is_event:
441 field.c_field_type = _t(field.field_type + ('event',))
443 field.c_field_type = _t(field.field_type)
445 field.c_field_const_type = ('' if field.type.nmemb == 1 else 'const ') + field.c_field_type
446 field.c_field_name = _cpp(field.field_name)
447 field.c_subscript = '[%d]' % field.type.nmemb if (field.type.nmemb and field.type.nmemb > 1) else ''
448 field.c_pointer = ' ' if field.type.nmemb == 1 else '*'
450 # correct the c_pointer field for variable size non-list types
451 if not field.type.fixed_size() and field.c_pointer == ' ':
452 field.c_pointer = '*'
453 if field.type.is_list and not field.type.member.fixed_size():
454 field.c_pointer = '*'
456 if field.type.is_switch:
457 field.c_pointer = '*'
458 field.c_field_const_type = 'const ' + field.c_field_type
461 if not field.type.fixed_size() and not field.type.is_case_or_bitcase and field.wire:
464 field.c_iterator_type = _t(field.field_type + ('iterator',)) # xcb_fieldtype_iterator_t
465 field.c_iterator_name = _n(name + (field.field_name, 'iterator')) # xcb_container_field_iterator
466 field.c_accessor_name = _n(name + (field.field_name,)) # xcb_container_field
467 field.c_length_name = _n(name + (field.field_name, 'length')) # xcb_container_field_length
468 field.c_end_name = _n(name + (field.field_name, 'end')) # xcb_container_field_end
470 field.prev_varsized_field = prev_varsized_field
471 field.prev_varsized_offset = prev_varsized_offset
474 first_field_after_varsized = field
475 field.first_field_after_varsized = first_field_after_varsized
477 if field.type.fixed_size():
478 if field.wire:
479 prev_varsized_offset += field.type.size
481 if prev_varsized_field is not None and not field.type.is_pad and field.wire:
486 self.last_varsized_field = field
487 prev_varsized_field = field
491 if field.type.fixed_size():
492 field.prev_varsized_field = None
494 # recurse into this field this has to be done here, i.e.,
495 # after the field has been set up. Otherwise the function
497 _c_type_setup(field.type, field.field_type, ())
498 if field.type.is_list:
499 _c_type_setup(field.type.member, field.field_type, ())
500 if (field.type.nmemb is None and field.wire):
518 # _c_iterator(field.type, field_name) necessary
538 # Functions for querying field properties
539 def _c_field_needs_list_accessor(field):
540 return field.type.is_list and not field.type.fixed_size()
542 def _c_field_needs_field_accessor(field):
543 if field.type.is_list:
546 return (field.prev_varsized_field is not None or
547 not field.type.fixed_size())
549 def _c_field_needs_accessor(field):
550 return (_c_field_needs_list_accessor(field) or
551 _c_field_needs_field_accessor(field))
553 def _c_field_is_member_of_case_or_bitcase(field):
554 return field.parent and field.parent.is_case_or_bitcase
556 def _c_helper_fieldaccess_expr(prefix, field=None):
559 representing a valid field-access-expression in C (based on the context)
560 if field is not None, append access to the field as well.
564 A field access expression can consist of the following components:
568 This is used when a xcb-field is not contained in a struct.
577 if field is None:
578 # add separator for access to a yet unknown field
581 if _c_field_needs_accessor(field):
582 if _c_field_is_member_of_case_or_bitcase(field):
588 prefix_str += last_sep + _cpp(field.field_name)
591 prefix_str = field.c_accessor_name + "(" + prefix_str + ")"
594 prefix_str += last_sep + _cpp(field.field_name)
618 raise Exception("field name %s has been registered before" % f.field_name)
635 get field names for all objects in the prefix array
655 returns a list of field names referenced in an expression
669 # we need that list's length field here
670 field = None
673 field = f
675 if field is None:
676 raise Exception("list field '%s' referenced by sumof not found" % expr.lenfield_name)
677 # referenced list + its length field
678 return [expr.lenfield_name] + get_expr_field_names(field.type.expr)
689 # resolve the field names with the parent structure(s)
714 for field in complex_obj.fields:
715 all_fields.append(field)
716 if field.type.is_switch or field.type.is_list:
717 expr_fields += get_expr_fields(field.type)
718 if field.type.is_container:
719 expr_fields += resolve_expr_fields(field.type)
739 for field in complex_obj.fields:
740 if field.type.is_list and field.type.expr.op == 'calculate_len':
741 dont_resolve_this = field.type.expr.lenfield_name
742 if field.wire:
743 all_fields.append(field)
769 for field in self.fields:
770 if field.visible:
771 # the field should appear as a parameter in the function call
772 param_fields.append(field)
773 if field.wire and not field.auto:
774 if field.type.fixed_size() and not self.is_switch:
775 # field in the xcb_out structure
776 wire_fields.append(field)
917 def _c_serialize_helper_switch_field(context, self, field, c_switch_variable, prefix):
927 args = get_expr_fields(field.type)
930 switch_len_fields = resolve_expr_fields(field.type)
932 # a switch field at this point _must_ be a bitcase field
947 length = "%s(&%s, %s&%s%s)" % (field.type.c_serialize_name, c_switch_variable,
948 c_field_names, prefix_str, field.c_field_name)
950 length = "%s(xcb_tmp, %s&%s%s)" % (field.type.c_unpack_name,
951 c_field_names, prefix_str, field.c_field_name)
955 length = "%s(xcb_tmp, %s)" % (field.type.c_sizeof_name, my_c_field_names)
972 helper function to get field mapping of a particular expression.
988 raise Exception("found an empty prefix while resolving expr field names for list %s",
989 field.c_field_name)
995 raise Exception('could not resolve the length fields required for list %s' % field.c_field_name)
1000 def _c_serialize_helper_list_field(context, self, field,
1006 expr = field.type.expr
1009 field_mapping = _c_get_field_mapping_for_expr(self, field.type.expr, prefix)
1012 list_length = field.type.expr.lenfield_name
1017 length = '%s * sizeof(%s)' % (list_length, field.type.member.c_wiretype)
1020 if not field.type.member.fixed_size():
1022 member_params = _c_get_additional_type_params(field.type.member)
1041 (space, field.type.c_sizeof_name, member_arg_str))
1048 code_lines.append('%s xcb_tmp = (char *) %s%s;' % (space, prefix_str, field.c_field_name))
1050 code_lines.append('%s xcb_block_len = %s(xcb_tmp%s);' % (space, field.type.c_sizeof_name, member_arg_str))
1057 def _c_serialize_helper_fields_fixed_size(context, self, field,
1060 # keep the C code a bit more readable by giving the field name
1062 code_lines.append('%s /* %s.%s */' % (space, self.c_type, field.c_field_name))
1066 code_lines.append('%s /* %s.%s */' % (space, typename, field.c_field_name))
1068 abs_field_name = _c_helper_fieldaccess_expr(prefix, field)
1070 length = "sizeof(%s)" % field.c_field_type
1074 value = ' %s = *(%s *)xcb_tmp;' % (abs_field_name, field.c_field_type)
1077 if field.type.is_pad and field.type.nmemb > 1:
1079 for i in range(field.type.nmemb):
1081 (space, abs_field_name, i, field.c_field_type))
1083 length += " * %d" % field.type.nmemb
1085 elif field.type.is_list:
1088 length += " * %d" % field.type.nmemb
1096 if field.type.is_expr:
1098 if field.type.c_type is None:
1099 raise Exception("type for field '%s' (expression '%s') unkown" %
1100 (field.field_name, _c_accessor_get_expr(field.type.expr)))
1102 temp_vars.append(' %s xcb_expr_%s = %s;' % (field.type.c_type, _cpp(field.field_name),
1103 _c_accessor_get_expr(field.type.expr, prefix)))
1104 value += "&xcb_expr_%s;" % _cpp(field.field_name)
1106 elif field.type.is_pad:
1107 if field.type.nmemb == 1:
1112 length += "*%d" % field.type.nmemb
1116 if field.type.nmemb == 1:
1122 length = '%d' % field.type.nmemb
1126 def _c_serialize_helper_fields_variable_size(context, self, field,
1137 value = ' %s = (%s *)xcb_tmp;' % (field.c_field_name, field.c_field_type)
1138 temp_vars.append(' %s *%s;' % (field.type.c_type, field.c_field_name))
1141 value = ' %s%s = (%s *)xcb_tmp;' % (prefix_str, field.c_field_name, field.c_field_type)
1147 var_field_name = "%s%s" % (prefix_string, field.c_field_name)
1152 code_lines.append('%s /* %s */' % (space, field.c_field_name))
1154 if field.type.is_list:
1159 length = _c_serialize_helper_list_field(context, self, field,
1163 elif field.type.is_switch:
1168 length = _c_serialize_helper_switch_field(context, self, field,
1174 length = "%s(%s)" % (field.type.c_sizeof_name, var_field_name)
1187 for field in self.fields:
1188 if not field.wire:
1190 if not field.visible:
1191 if not ((field.wire and not field.auto) or 'unserialize' == context):
1195 if field.type.fixed_size():
1206 value, length = _c_serialize_helper_fields_fixed_size(context, self, field,
1214 if not field.wire:
1216 elif field.type.is_pad:
1218 code_lines.append('%s xcb_align_to = %d;' % (space, field.type.align))
1230 value, length = _c_serialize_helper_fields_variable_size(context, self, field,
1239 if field.type.fixed_size():
1250 if (not field.type.fixed_size() and
1252 temp_vars.append(' int %s_len;' % field.c_field_name)
1253 code_lines.append('%s %s_len = %s;' % (space, field.c_field_name, length))
1254 code_lines.append('%s xcb_block_len += %s_len;' % (space, field.c_field_name))
1255 code_lines.append('%s xcb_tmp += %s_len;' % (space, field.c_field_name))
1272 if field.c_field_type == 'void' or field.type.is_switch
1273 else field.c_field_type))
1305 # all other data types can be evaluated one field a time
1349 for field in param_fields:
1351 if not field.type.fixed_size() or self.is_switch:
1531 for field in param_fields:
1532 if not field.type.fixed_size():
1533 _c(' xcb_tmp -= %s_len;', field.c_field_name)
1534 _c(' memmove(xcb_tmp, %s, %s_len);', field.c_field_name, field.c_field_name)
1541 def _c_iterator_get_end(field, accum):
1543 Figures out what C code is needed to find the end of a variable-length structure field.
1544 For nested structures, recurses into its last variable-sized field.
1547 if field.type.is_container:
1548 accum = field.c_accessor_name + '(' + accum + ')'
1549 return _c_iterator_get_end(field.type.last_varsized_field, accum)
1550 if field.type.is_list:
1552 if field.type.member.is_simple:
1553 return field.c_end_name + '(' + accum + ')'
1555 return field.type.member.c_end_name + '(' + field.c_iterator_name + '(' + accum + '))'
1660 Figures out what C code is needed to get a length field.
1661 The field_mapping parameter can be used to change the absolute name of a length field.
1662 For fields that follow a variable-length field, use the accessor.
1663 Otherwise, just reference the structure field directly.
1678 Figures out what C code is needed to get the length of a list field.
1679 The field_mapping parameter can be used to change the absolute name of a length field.
1682 Otherwise, uses the value of the length field.
1697 field = expr.lenfield
1698 list_name = field_mapping[field.c_field_name][0]
1699 c_length_func = "%s(%s)" % (field.c_length_name, list_name)
1700 c_length_func = _c_accessor_get_expr(field.type.expr, field_mapping)
1711 _c_pre.tempvar("const %s* %s; /* sumof list ptr */", field.c_field_type, listvar)
1724 field.c_field_type, listvar)
1733 # field mapping for the subexpression needs to include
1736 if not field.type.member.is_simple:
1739 field.type.member,
1740 [(listvar, '->', field.type.member)]))
1773 def _c_accessors_field(self, field):
1775 Declares the accessor functions for a non-list field that follows a variable-length field.
1786 if field.type.is_simple:
1788 _hc('%s', field.c_field_type)
1789 _h('%s (const %s *R);', field.c_accessor_name, c_type)
1790 _c('%s (const %s *R)', field.c_accessor_name, c_type)
1792 if field.prev_varsized_field is None:
1793 _c(' return (%s *) (R + 1);', field.c_field_type)
1795 _c(' xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
1797 field.c_field_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
1801 if field.type.is_switch and switch_obj is None:
1804 return_type = '%s *' % field.c_field_type
1807 _h('%s (const %s *R);', field.c_accessor_name, c_type)
1808 _c('%s (const %s *R)', field.c_accessor_name, c_type)
1810 if field.prev_varsized_field is None:
1816 _c(' xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
1818 return_type, type_pad_type(field.first_field_after_varsized.type.c_type), field.prev_varsized_offset)
1822 def _c_accessors_list(self, field):
1824 Declares the accessor functions for a list field.
1829 def get_align_pad(field):
1830 prev = field.prev_varsized_field
1831 prev_prev = field.prev_varsized_field.prev_varsized_field
1838 list = field.type
1846 # so whenever we need to access a length field, we might need to refer to some anchestor type
1914 _hc('%s *', field.c_field_type)
1916 _h('%s (%s);', field.c_accessor_name, params[idx][0])
1917 _c('%s (%s)', field.c_accessor_name, params[idx][0])
1921 _c(' return %s;', fields[field.c_field_name][0])
1922 elif field.prev_varsized_field is None:
1923 _c(' return (%s *) (R + 1);', field.c_field_type)
1925 (prev_varsized_field, align_pad) = get_align_pad(field)
1929 type_pad_type(field.first_field_after_varsized.type.c_type))
1934 field.c_field_type, align_pad, field.prev_varsized_offset)
1939 spacing = ' '*(len(field.c_length_name)+2)
1942 _hc('%s (const %s *R,', field.c_length_name, R_obj.c_type)
1946 _h('%s (const %s *R%s);', field.c_length_name, c_type, add_param_str)
1947 _c('%s (const %s *R%s)', field.c_length_name, c_type, add_param_str)
1951 if field.type.expr.op == 'calculate_len':
1952 if field.type.member.fixed_size():
1953 if field.prev_varsized_field is None:
1957 return '(((R->length * 4) - sizeof('+ self.c_type + '))/'+'sizeof('+field.type.member.c_wiretype+'))'
1964 start_of_list = '%s(R)' % (field.c_accessor_name)
1966 return '(%s) / sizeof(%s)' % (bytesize_of_list, field.type.member.c_wiretype)
1971 (field.c_field_name)
1974 return _c_accessor_get_expr(field.type.expr, fields)
1979 if field.type.member.is_simple:
1982 spacing = ' '*(len(field.c_end_name)+2)
1985 _hc('%s (const %s *R,', field.c_end_name, R_obj.c_type)
1989 _h('%s (const %s *R%s);', field.c_end_name, c_type, add_param_str)
1990 _c('%s (const %s *R%s)', field.c_end_name, c_type, add_param_str)
1996 _c(' i.data = %s + %s;', fields[field.c_field_name][0],
1998 elif field.prev_varsized_field == None:
1999 _c(' i.data = ((%s *) (R + 1)) + (%s);', field.type.c_wiretype,
2002 (prev_varsized_field, align_pad) = get_align_pad(field)
2006 type_pad_type(field.first_field_after_varsized.type.c_type))
2011 field.type.c_wiretype, align_pad,
2021 _hc('%s', field.c_iterator_type)
2022 spacing = ' '*(len(field.c_iterator_name)+2)
2024 _hc('%s (const %s *R,', field.c_iterator_name, R_obj.c_type)
2028 _h('%s (const %s *R%s);', field.c_iterator_name, c_type, add_param_str)
2029 _c('%s (const %s *R%s)', field.c_iterator_name, c_type, add_param_str)
2031 _c(' %s i;', field.c_iterator_type)
2038 _c(' i.data = %s;', fields[field.c_field_name][0])
2040 elif field.prev_varsized_field == None:
2042 _c(' i.data = (%s *) (R + 1);', field.c_field_type)
2044 (prev_varsized_field, align_pad) = get_align_pad(field)
2048 type_pad_type(field.c_field_type))
2054 field.c_field_type, align_pad)
2062 additional_iter_fields = _c_get_additional_type_params(field.type.member)
2079 for field in self.fields:
2080 if not field.type.is_pad:
2081 if _c_field_needs_list_accessor(field):
2082 _c_accessors_list(self, field)
2083 elif _c_field_needs_field_accessor(field):
2084 _c_accessors_field(self, field)
2118 for field in self.fields:
2119 if field.wire and (field.type.fixed_size() or self.is_switch or self.is_union):
2120 struct_fields.append(field)
2122 for field in struct_fields:
2123 length = len(field.c_field_type)
2125 if not field.type.fixed_size() and not self.is_union:
2129 def _c_complex_field(self, field, space=''):
2130 if (field.type.fixed_size() or self.is_union or
2131 # in case of switch with switch children, don't make the field a pointer
2133 (self.is_switch and field.type.is_switch)):
2134 spacing = ' ' * (maxtypelen - len(field.c_field_type))
2135 _h('%s %s%s %s%s;', space, field.c_field_type, spacing, field.c_field_name, field.c_subscript)
2136 elif (not field.type.is_pad) or field.type.serialize:
2138 spacing = ' ' * (maxtypelen - (len(field.c_field_type) + 1))
2139 _h('%s %s%s *%s%s;', space, field.c_field_type, spacing, field.c_field_name, field.c_subscript)
2142 for field in struct_fields:
2143 _c_complex_field(self, field)
2150 for field in b.type.fields:
2151 _c_complex_field(self, field, space)
2226 for field in self.fields:
2227 if field.visible:
2228 # The field should appear as a call parameter
2229 param_fields.append(field)
2230 if field.wire and not field.auto:
2231 # We need to set the field up in the structure
2232 wire_fields.append(field)
2233 if field.type.c_need_serialize or field.type.c_need_sizeof:
2234 serial_fields.append(field)
2236 for field in param_fields:
2237 c_field_const_type = field.c_field_const_type
2238 if field.type.c_need_serialize and not aux:
2242 if field.type.is_list and not field.type.member.fixed_size():
2259 for field in param_fields:
2262 if base_func_name == 'xcb_change_gc' and field.c_field_name == 'value_mask':
2263 field.enum = 'GC'
2264 elif base_func_name == 'xcb_change_window_attributes' and field.c_field_name == 'value_mask':
2265 field.enum = 'CW'
2266 elif base_func_name == 'xcb_create_window' and field.c_field_name == 'value_mask':
2267 field.enum = 'CW'
2268 if field.enum:
2270 key = (*self.name[:-1], field.enum)
2275 _h(' * @param %s A bitmask of #%s values.', field.c_field_name, tname)
2277 if self.doc and field.field_name in self.doc.fields:
2278 desc = self.doc.fields[field.field_name]
2283 _h(' * @param %s %s', field.c_field_name, "\n * ".join(desc))
2323 for field in param_fields:
2325 c_field_const_type = field.c_field_const_type
2326 c_pointer = field.c_pointer
2327 if field.type.c_need_serialize and not aux:
2333 spacing, c_pointer, field.c_field_name, comma)
2336 spacing, c_pointer, field.c_field_name, comma)
2340 for field in param_fields:
2341 if not field.type.fixed_size() and field.wire:
2343 if field.type.c_need_serialize or field.type.c_need_sizeof:
2374 for field in param_fields:
2375 if field.isfd:
2376 if not field.type.is_list:
2379 num_fds_expr.append(_c_accessor_get_expr(field.type.expr, None))
2396 for field in wire_fields:
2397 if field.type.fixed_size():
2398 if field.type.is_expr:
2399 _c(' xcb_out.%s = %s;', field.c_field_name, _c_accessor_get_expr(field.type.expr, None))
2400 elif field.type.is_pad:
2401 if field.type.nmemb == 1:
2402 _c(' xcb_out.%s = 0;', field.c_field_name)
2404 _c(' memset(xcb_out.%s, 0, %d);', field.c_field_name, field.type.nmemb)
2406 if field.type.nmemb == 1:
2407 _c(' xcb_out.%s = %s;', field.c_field_name, field.c_field_name)
2409 _c(' memcpy(xcb_out.%s, %s, %d);', field.c_field_name, field.c_field_name, field.type.nmemb)
2429 for field in param_fields:
2430 if field.wire and not field.type.fixed_size():
2431 _c(' /* %s %s */', field.type.c_type, field.c_field_name)
2433 if not field.type.c_need_serialize and not field.type.c_need_sizeof:
2434 _c(' xcb_parts[%d].iov_base = (char *) %s;', count, field.c_field_name)
2435 if field.type.is_list:
2436 if field.type.member.fixed_size():
2437 if field.type.expr.op == 'calculate_len':
2438 lenfield = field.type.expr.lenfield_name
2440 lenfield = _c_accessor_get_expr(field.type.expr, None)
2443 field.type.member.c_wiretype)
2445 list_length = _c_accessor_get_expr(field.type.expr, None)
2449 _c(" xcb_tmp = (char *)%s;", field.c_field_name)
2452 (field.type.c_sizeof_name))
2458 raise Exception("unhandled variable size field %s" % field.c_field_name)
2461 _c(' xcb_parts[%d].iov_base = (char *) %s;', count, field.c_field_name)
2462 idx = serial_fields.index(field)
2467 serialize_args = get_serialize_args(field.type, aux_var, field.c_field_name, context)
2468 _c(' %s (%s);', field.type.c_serialize_name, serialize_args)
2472 serialize_args = get_serialize_args(field.type, field.c_field_name, aux_var, context)
2473 func_name = field.type.c_sizeof_name
2477 if not (field.type.c_need_serialize or field.type.c_need_sizeof):
2498 for field in param_fields:
2499 if field.isfd:
2500 if not field.type.is_list:
2501 _c(' fds[fd_index++] = %s;', field.c_field_name)
2503 _c(' for (i = 0; i < %s; i++)', _c_accessor_get_expr(field.type.expr, None))
2504 _c(' fds[fd_index++] = %s[i];', field.c_field_name)
2525 # check if _unserialize() has to be called for any field
2530 for field in complex_obj.fields:
2531 # three cases: 1. field with special case
2532 # 2. container that contains special case field
2534 if field.type.c_var_followed_by_fixed_fields:
2535 unserialize_fields.append(field)
2536 elif field.type.is_container:
2537 unserialize_fields += look_for_special_cases(field.type)
2538 elif field.type.is_list:
2539 if field.type.member.c_var_followed_by_fixed_fields:
2540 unserialize_fields.append(field)
2541 if field.type.member.is_container:
2542 unserialize_fields += look_for_special_cases(field.type.member)
2575 for field in unserialize_fields:
2576 if field.type.is_list:
2577 _c(' %s %s_iter = %s(reply);', field.c_iterator_type, field.c_field_name, field.c_iterator_name)
2578 _c(' int %s_len = %s(reply);', field.c_field_name, field.c_length_name)
2579 _c(' %s *%s_data;', field.c_field_type, field.c_field_name)
2581 raise Exception('not implemented: call _unserialize() in reply for non-list type %s', field.c_field_type)
2584 for field in unserialize_fields:
2585 if field.type.is_list:
2586 _c(' for(i=0; i<%s_len; i++) {', field.c_field_name)
2587 _c(' %s_data = %s_iter.data;', field.c_field_name, field.c_field_name)
2588 _c(' %s((const void *)%s_data, &%s_data);', field.type.c_unserialize_name,
2589 field.c_field_name, field.c_field_name)
2590 _c(' %s(&%s_iter);', field.type.c_next_name, field.c_field_name)
2601 return any(field.isfd for field in self.fields)
2685 for field in param_fields:
2687 c_field_const_type = field.c_field_const_type
2688 c_pointer = field.c_pointer
2691 if field.type.c_need_serialize and not aux:
2695 prototype += '%s\\ %s\\fI%s\\fP%s' % (c_field_const_type, c_pointer, field.c_field_name, comma)
2712 for field in self.reply.fields:
2713 if not field.type.fixed_size() and not self.is_switch and not self.is_union:
2715 if field.wire:
2716 struct_fields.append(field)
2718 for field in struct_fields:
2719 length = len(field.c_field_type)
2721 if not field.type.fixed_size():
2725 def _c_complex_field(self, field, space=''):
2726 if (field.type.fixed_size() or
2727 # in case of switch with switch children, don't make the field a pointer
2729 (self.is_switch and field.type.is_switch)):
2730 spacing = ' ' * (maxtypelen - len(field.c_field_type))
2731 f.write('%s %s%s \\fI%s\\fP%s;\n' % (space, field.c_field_type, spacing, field.c_field_name, field.c_subscript))
2733 spacing = ' ' * (maxtypelen - (len(field.c_field_type) + 1))
2734 f.write('ELSE %s = %s\n' % (field.c_field_type, field.c_field_name))
2735 #_h('%s %s%s *%s%s; /**< */', space, field.c_field_type, spacing, field.c_field_name, field.c_subscript)
2738 for field in struct_fields:
2739 _c_complex_field(self, field)
2745 for field in b.type.fields:
2746 _c_complex_field(self, field, space)
2761 for field in self.reply.fields:
2762 if field.type.is_list and not field.type.fixed_size():
2764 elif field.prev_varsized_field is not None or not field.type.fixed_size():
2770 def _c_accessors_field(self, field):
2772 Declares the accessor functions for a non-list field that follows a variable-length field.
2783 if field.type.is_simple:
2784 f.write('%s %s (const %s *reply)\n' % (field.c_field_type, field.c_accessor_name, c_type))
2785 create_link('%s' % field.c_accessor_name)
2787 f.write('%s *%s (const %s *reply)\n' % (field.c_field_type, field.c_accessor_name, c_type))
2788 create_link('%s' % field.c_accessor_name)
2790 def _c_accessors_list(self, field):
2792 Declares the accessor functions for a list field.
2796 list = field.type
2804 # so whenever we need to access a length field, we might need to refer to some anchestor type
2843 (field.c_field_type, field.c_accessor_name, params[idx][0]))
2844 create_link('%s' % field.c_accessor_name)
2848 (field.c_length_name, c_type))
2849 create_link('%s' % field.c_length_name)
2851 if field.type.member.is_simple:
2854 (field.c_end_name, c_type))
2855 create_link('%s' % field.c_end_name)
2859 (field.c_iterator_type, field.c_iterator_name,
2861 create_link('%s' % field.c_iterator_name)
2863 for field in self.reply.fields:
2864 if field.type.is_list and not field.type.fixed_size():
2865 _c_accessors_list(self, field)
2866 elif field.prev_varsized_field is not None or not field.type.fixed_size():
2867 _c_accessors_field(self, field)
2878 for field in param_fields:
2879 f.write('.IP \\fI%s\\fP 1i\n' % (field.c_field_name))
2882 if base_func_name == 'xcb_change_gc' and field.c_field_name == 'value_mask':
2883 field.enum = 'GC'
2884 elif base_func_name == 'xcb_change_window_attributes' and field.c_field_name == 'value_mask':
2885 field.enum = 'CW'
2886 elif base_func_name == 'xcb_create_window' and field.c_field_name == 'value_mask':
2887 field.enum = 'CW'
2888 if hasattr(field, "enum") and field.enum:
2890 key = ('xcb', field.enum)
2908 if hasattr(self, "doc") and self.doc and field.field_name in self.doc.fields:
2909 desc = self.doc.fields[field.field_name]
2924 f.write(('The type of this reply, in this case \\fI%s\\fP. This field '
2932 for field in self.reply.fields:
2933 if (field.c_field_name in frozenset(['response_type', 'sequence', 'length']) or
2934 field.c_field_name.startswith('pad')):
2937 if field.type.is_list and not field.type.fixed_size():
2939 elif field.prev_varsized_field is not None or not field.type.fixed_size():
2941 f.write('.IP \\fI%s\\fP 1i\n' % (field.c_field_name))
2943 if hasattr(field, "enum") and field.enum:
2945 key = ('xcb', field.enum)
2963 if hasattr(self.reply, "doc") and self.reply.doc and field.field_name in self.reply.doc.fields:
2964 desc = self.reply.doc.fields[field.field_name]
3058 for field in self.fields:
3059 if not field.type.fixed_size() and not self.is_switch and not self.is_union:
3061 if field.wire:
3062 struct_fields.append(field)
3064 for field in struct_fields:
3065 length = len(field.c_field_type)
3067 if not field.type.fixed_size():
3071 def _c_complex_field(self, field, space=''):
3072 if (field.type.fixed_size() or
3073 # in case of switch with switch children, don't make the field a pointer
3075 (self.is_switch and field.type.is_switch)):
3076 spacing = ' ' * (maxtypelen - len(field.c_field_type))
3077 f.write('%s %s%s \\fI%s\\fP%s;\n' % (space, field.c_field_type, spacing, field.c_field_name, field.c_subscript))
3082 for field in struct_fields:
3083 _c_complex_field(self, field)
3089 for field in b.type.fields:
3090 _c_complex_field(self, field, space)
3106 f.write(('The type of this event, in this case \\fI%s\\fP. This field is '
3113 for field in struct_fields:
3116 if field.c_field_name in ('response_type', 'sequence'):
3118 if isinstance(field.type, PadType):
3120 f.write('.IP \\fI%s\\fP 1i\n' % (field.c_field_name))
3121 if hasattr(self, "doc") and self.doc and field.field_name in self.doc.fields:
3122 desc = self.doc.fields[field.field_name]
3204 for field in self.fields:
3205 if not field.type.is_pad and field.wire:
3206 if _c_field_needs_list_accessor(field):
3207 _c_accessors_list(self, field)
3208 elif _c_field_needs_field_accessor(field):
3209 _c_accessors_field(self, field)
3220 #TODO: add header of ge-events as an extra field
3225 #correct the format of the field names
3226 for field in self.fields:
3227 field.c_field_name = _n_item(field.c_field_name).lower()
3241 # The generic event structure xcb_ge_event_t has the full_sequence field
3242 # at the 32byte boundary. That's why we've to inject this field into GE
3249 for field in self.fields:
3250 if field.type.size != None and field.type.nmemb != None:
3251 event_size += field.type.size * field.type.nmemb
3254 idx = self.fields.index(field)