Lines Matching defs:_c

48 def _c(fmt, *args):
59 _c(fmt, *args)
67 _c("%s%s", indent, str)
80 being sent to the output via _h und _c.
280 _c('#ifdef HAVE_CONFIG_H')
281 _c('#include "config.h"')
282 _c('#endif')
283 _c('#include <stdlib.h>')
284 _c('#include <string.h>')
285 _c('#include <assert.h>')
286 _c('#include <stddef.h> /* for offsetof() */')
287 _c('#include "xcbext.h"')
288 _c('#include "%s.h"', _ns.header)
290 _c('')
291 _c('#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)')
309 _c('')
310 _c('xcb_extension_t %s = { "%s", 0 };', _ns.c_ext_global_name, _ns.ext_xname)
1369 _c("%s)" % param_str[-1].rstrip(','))
1370 _c('{')
1380 _c(' %s *xcb_out = *_buffer;', self.c_type)
1381 _c(' unsigned int xcb_out_pad = -sizeof(%s) & 3;', self.c_type)
1382 _c(' unsigned int xcb_buffer_len = sizeof(%s) + xcb_out_pad;', self.c_type)
1383 _c(' unsigned int xcb_align_to = 0;')
1385 _c(' char *xcb_out = *_buffer;')
1386 _c(' unsigned int xcb_buffer_len = 0;')
1387 _c(' unsigned int xcb_align_to = 0;')
1389 _c(' unsigned int xcb_padding_offset = %d;',
1395 _c(' char *xcb_tmp = (char *)_buffer;')
1398 _c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type)
1401 _c(' %s xcb_out;', self.c_type)
1410 _c(' unsigned int xcb_buffer_len = 0;')
1411 _c(' unsigned int xcb_block_len = 0;')
1412 _c(' unsigned int xcb_pad = 0;')
1413 _c(' unsigned int xcb_align_to = 0;')
1415 _c(' unsigned int xcb_padding_offset = %d;',
1421 _c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type)
1426 _c(' return %s;', _c_accessor_get_expr(self.length_expr, field_mapping))
1427 _c('}')
1432 _c(' %s _aux;', self.c_type)
1433 _c(' return %s(%s, &_aux);', self.c_unpack_name, ", ".join(param_names))
1434 _c('}')
1439 _c(' return %s(%s, NULL);', self.c_unserialize_name, ", ".join(param_names))
1440 _c('}')
1444 _c(' char *xcb_tmp = (char *)_buffer;')
1447 _c(' unsigned int xcb_padding_offset = 0;')
1468 _c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type)
1470 _c(' %s *_aux = malloc(sizeof(%s));', self.c_type, self.c_type)
1472 _c(' unsigned int xcb_buffer_len = 0;')
1473 _c(' unsigned int xcb_block_len = 0;')
1474 _c(' unsigned int xcb_pad = 0;')
1475 _c(' unsigned int xcb_align_to = 0;')
1479 _c('')
1481 _c(t)
1482 _c('')
1484 _c(l)
1492 _c('')
1493 _c(' if (NULL == _aux)')
1494 _c(' return xcb_buffer_len;')
1496 _c('')
1497 _c(' if (NULL == %s) {', aux_ptr)
1498 _c(' /* allocate memory */')
1499 _c(' %s = malloc(xcb_buffer_len);', aux_ptr)
1501 _c(' *_buffer = xcb_out;')
1502 _c(' }')
1503 _c('')
1509 _c(' *xcb_out = *_aux;')
1514 _c(' xcb_tmp = (char*)++xcb_out;')
1515 _c(' xcb_tmp += xcb_out_pad;')
1517 _c(' xcb_tmp = xcb_out;')
1520 _c(' for(i=0; i<xcb_parts_idx; i++) {')
1521 _c(' if (0 != xcb_parts[i].iov_base && 0 != xcb_parts[i].iov_len)')
1522 _c(' memcpy(xcb_tmp, xcb_parts[i].iov_base, xcb_parts[i].iov_len);')
1523 _c(' if (0 != xcb_parts[i].iov_len)')
1524 _c(' xcb_tmp += xcb_parts[i].iov_len;')
1525 _c(' }')
1529 _c(' xcb_tmp = ((char *)*_aux)+xcb_buffer_len;')
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)
1535 _c(' *%s = xcb_out;', aux_ptr)
1537 _c('')
1538 _c(' return xcb_buffer_len;')
1539 _c('}')
1591 _c('')
1594 _c('%s (%s *i)', self.c_next_name, self.c_iterator_type)
1595 _c('{')
1598 _c(' %s *R = i->data;', self.c_type)
1602 _c(' /* FIXME - determine the size of the union %s */', self.c_type)
1610 _c(' xcb_generic_iterator_t child;')
1611 _c(' child.data = (%s *)(((char *)R) + %s(R%s));',
1613 _c(' i->index = (char *) child.data - (char *) i->data;')
1615 _c(' xcb_generic_iterator_t child = %s;', _c_iterator_get_end(self.last_varsized_field, 'R'))
1616 _c(' i->index = child.index;')
1617 _c(' --i->rem;')
1618 _c(' i->data = (%s *) child.data;', self.c_type)
1621 _c(' --i->rem;')
1622 _c(' ++i->data;')
1623 _c(' i->index += sizeof(%s);', self.c_type)
1625 _c('}')
1637 _c('')
1640 _c('%s (%s i)', self.c_end_name, self.c_iterator_type)
1641 _c('{')
1642 _c(' xcb_generic_iterator_t ret;')
1645 _c(' ret.data = i.data + i.rem;')
1646 _c(' ret.index = i.index + ((char *) ret.data - (char *) i.data);')
1647 _c(' ret.rem = 0;')
1649 _c(' while(i.rem > 0)')
1650 _c(' %s(&i);', self.c_next_name)
1651 _c(' ret.data = i.data;')
1652 _c(' ret.rem = i.rem;')
1653 _c(' ret.index = i.index;')
1655 _c(' return ret;')
1656 _c('}')
1790 _c('%s (const %s *R)', field.c_accessor_name, c_type)
1791 _c('{')
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'))
1796 _c(' return * (%s *) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);',
1798 _c('}')
1808 _c('%s (const %s *R)', field.c_accessor_name, c_type)
1809 _c('{')
1811 _c(' return (%s) (R + 1);', return_type)
1816 _c(' xcb_generic_iterator_t prev = %s;', _c_iterator_get_end(field.prev_varsized_field, 'R'))
1817 _c(' return (%s) ((char *) prev.data + XCB_TYPE_PAD(%s, prev.index) + %d);',
1819 _c('}')
1917 _c('%s (%s)', field.c_accessor_name, params[idx][0])
1919 _c('{')
1921 _c(' return %s;', fields[field.c_field_name][0])
1923 _c(' return (%s *) (R + 1);', field.c_field_type)
1931 _c(' xcb_generic_iterator_t prev = %s;',
1933 _c(' return (%s *) ((char *) prev.data + %s + %d);',
1935 _c('}')
1944 _c('%sconst %s *S%s)', spacing, S_obj.c_type, add_param_str)
1947 _c('%s (const %s *R%s)', field.c_length_name, c_type, add_param_str)
1948 _c('{')
1976 _c(' return %s;', get_length())
1977 _c('}')
1987 _c('%sconst %s *S%s)', spacing, S_obj.c_type, add_param_str)
1990 _c('%s (const %s *R%s)', field.c_end_name, c_type, add_param_str)
1991 _c('{')
1992 _c(' xcb_generic_iterator_t i;')
1996 _c(' i.data = %s + %s;', fields[field.c_field_name][0],
1999 _c(' i.data = ((%s *) (R + 1)) + (%s);', field.type.c_wiretype,
2008 _c(' xcb_generic_iterator_t prev = %s;',
2010 _c(' i.data = ((%s *) ((char*) prev.data + %s)) + (%s);',
2014 _c(' i.rem = 0;')
2015 _c(' i.index = (char *) i.data - (char *) %s;', param)
2016 _c(' return i;')
2017 _c('}')
2026 _c('%sconst %s *S%s)', spacing, S_obj.c_type, add_param_str)
2029 _c('%s (const %s *R%s)', field.c_iterator_name, c_type, add_param_str)
2030 _c('{')
2031 _c(' %s i;', field.c_iterator_type)
2038 _c(' i.data = %s;', fields[field.c_field_name][0])
2039 _c(' i.rem = %s;', length_expr_str)
2042 _c(' i.data = (%s *) (R + 1);', field.c_field_type)
2050 _c(' xcb_generic_iterator_t prev = %s;',
2053 _c(' i.data = (%s *) ((char *) prev.data + %s);',
2057 _c(' i.rem = %s;', length_expr_str)
2058 _c(' i.index = (char *) i.data - (char *) %s;', 'R' if switch_obj is None else 'S' )
2064 _c(' i.%s = %s;', iter_field[2], fields[iter_field[2]][0])
2066 _c(' return i;')
2067 _c('}')
2312 _c('')
2319 _c('%s (xcb_connection_t%s *c%s', func_name, spacing, comma)
2335 _c('%s%s%s %s%s%s', func_spacing, c_field_const_type,
2348 _c('{')
2349 _c(' static const xcb_protocol_request_t xcb_req = {')
2350 _c(' .count = %d,', count)
2351 _c(' .ext = %s,', func_ext_global)
2352 _c(' .opcode = %s,', self.c_request_name.upper())
2353 _c(' .isvoid = %d', 1 if void else 0)
2354 _c(' };')
2355 _c('')
2357 _c(' struct iovec xcb_parts[%d];', dimension)
2358 _c(' %s xcb_ret;', func_cookie)
2359 _c(' %s xcb_out;', self.c_type)
2361 _c(' /* in the protocol description, variable size fields are followed by fixed size fields */')
2362 _c(' void *xcb_aux = 0;')
2367 _c(' void *xcb_aux%d = 0;' % (idx))
2369 _c(' unsigned int xcb_tmp_len;')
2370 _c(' char *xcb_tmp;')
2382 _c(' unsigned int i;')
2388 _c(' int fds[%s];' % (num_fds))
2389 _c(' int fd_index = 0;')
2393 _c('')
2399 _c(' xcb_out.%s = %s;', field.c_field_name, _c_accessor_get_expr(field.type.expr, None))
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)
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)
2420 _c('')
2422 _c(' xcb_parts[2].iov_base = (char *) &xcb_out;')
2423 _c(' xcb_parts[2].iov_len = sizeof(xcb_out);')
2424 _c(' xcb_parts[3].iov_base = 0;')
2425 _c(' xcb_parts[3].iov_len = -xcb_parts[2].iov_len & 3;')
2431 _c(' /* %s %s */', field.type.c_type, field.c_field_name)
2434 _c(' xcb_parts[%d].iov_base = (char *) %s;', count, field.c_field_name)
2442 _c(' xcb_parts[%d].iov_len = %s * sizeof(%s);', count, lenfield,
2448 _c(" xcb_parts[%d].iov_len = 0;" % count)
2449 _c(" xcb_tmp = (char *)%s;", field.c_field_name)
2450 _c(" for(i=0; i<%s; i++) {" % list_length)
2451 _c(" xcb_tmp_len = %s(xcb_tmp);" %
2453 _c(" xcb_parts[%d].iov_len += xcb_tmp_len;" % count)
2454 _c(" xcb_tmp += xcb_tmp_len;")
2455 _c(" }")
2461 _c(' xcb_parts[%d].iov_base = (char *) %s;', count, field.c_field_name)
2465 _c(' xcb_parts[%d].iov_len =', count)
2468 _c(' %s (%s);', field.type.c_serialize_name, serialize_args)
2469 _c(' xcb_parts[%d].iov_base = xcb_aux%d;' % (count, idx))
2474 _c(' %s (%s);', func_name, serialize_args)
2479 _c(' xcb_parts[%d].iov_base = 0;', count)
2480 _c(' xcb_parts[%d].iov_len = -xcb_parts[%d].iov_len & 3;', count, count-1)
2485 _c(' xcb_parts[2].iov_base = (char *) &xcb_out;')
2487 _c(' xcb_parts[2].iov_len = 2*sizeof(uint8_t) + sizeof(uint16_t);')
2492 _c(' xcb_parts[%d].iov_len = %s (%s);', count, self.c_serialize_name, serialize_args)
2493 _c(' xcb_parts[%d].iov_base = (char *) xcb_aux;', count)
2497 _c('')
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)
2507 _c(' xcb_ret.sequence = xcb_send_request(c, %s, xcb_parts + 2, &xcb_req);', func_flags)
2509 _c(' xcb_ret.sequence = xcb_send_request_with_fds(c, %s, xcb_parts + 2, &xcb_req, %s, fds);', func_flags, num_fds)
2513 _c(f)
2514 _c(' return xcb_ret;')
2515 _c('}')
2562 _c('')
2567 _c('%sxcb_generic_error_t%s **e)', spacing3, spacing2)
2568 _c('{')
2572 _c(' %s *reply = (%s *) xcb_wait_for_reply(c, cookie.sequence, e);',
2574 _c(' int i;')
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)
2583 _c(' /* special cases: transform parts of the reply to match XCB data structures */')
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,
2590 _c(' %s(&%s_iter);', field.type.c_next_name, field.c_field_name)
2591 _c(' }')
2593 _c(' return reply;')
2596 _c(' return (%s *) xcb_wait_for_reply(c, cookie.sequence, e);', self.c_reply_type)
2598 _c('}')
2620 _c('')
2624 _c('%s%s *reply)', spacing3, self.c_reply_type)
2625 _c('{')
2627 _c(' return xcb_get_reply_fds(c, reply, sizeof(%s) + 4 * reply->length);', self.c_reply_type)
2629 _c('}')
3294 _c('')
3295 _c('int')
3296 _c('%s (const void *_buffer /**< */)', _n(name + ('sizeof',)))
3297 _c('{');
3298 _c(' return %s(_buffer);', _n(self.name + ('sizeof',)))
3299 _c('}');