Mercurial > libavcodec.hg
comparison tableprint.h @ 11979:59f399926c12 libavcodec
tableprint: use the type name as-is for the functions' names.
This drops one parameter from the functions' macros, and require structures
to be typedeffed, but ensures that it is possible to map 1-to-1 the type to
the function name.
author | flameeyes |
---|---|
date | Sun, 27 Jun 2010 12:20:39 +0000 |
parents | 8ad2b8f20e6a |
children | 263b4ef7ad87 |
comparison
equal
deleted
inserted
replaced
11978:db5c3a602ddd | 11979:59f399926c12 |
---|---|
24 #define AVCODEC_TABLEPRINT_H | 24 #define AVCODEC_TABLEPRINT_H |
25 | 25 |
26 #include <stdint.h> | 26 #include <stdint.h> |
27 #include <stdio.h> | 27 #include <stdio.h> |
28 | 28 |
29 #define WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, ...)\ | 29 #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\ |
30 void write_##name##_array(const type *data, int len)\ | 30 void write_##type##_array(const type *data, int len)\ |
31 {\ | 31 {\ |
32 int i;\ | 32 int i;\ |
33 printf(" ");\ | 33 printf(" ");\ |
34 for (i = 0; i < len - 1; i++) {\ | 34 for (i = 0; i < len - 1; i++) {\ |
35 printf(" "fmtstr",", __VA_ARGS__);\ | 35 printf(" "fmtstr",", __VA_ARGS__);\ |
36 if ((i & linebrk) == linebrk) printf("\n ");\ | 36 if ((i & linebrk) == linebrk) printf("\n ");\ |
37 }\ | 37 }\ |
38 printf(" "fmtstr"\n", __VA_ARGS__);\ | 38 printf(" "fmtstr"\n", __VA_ARGS__);\ |
39 } | 39 } |
40 | 40 |
41 #define WRITE_1D_FUNC(name, type, fmtstr, linebrk)\ | 41 #define WRITE_1D_FUNC(type, fmtstr, linebrk)\ |
42 WRITE_1D_FUNC_ARGV(name, type, linebrk, fmtstr, data[i]) | 42 WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, data[i]) |
43 | 43 |
44 #define WRITE_2D_FUNC(name, type)\ | 44 #define WRITE_2D_FUNC(type)\ |
45 void write_##name##_2d_array(const void *arg, int len, int len2)\ | 45 void write_##type##_2d_array(const void *arg, int len, int len2)\ |
46 {\ | 46 {\ |
47 const type *data = arg;\ | 47 const type *data = arg;\ |
48 int i;\ | 48 int i;\ |
49 printf(" {\n");\ | 49 printf(" {\n");\ |
50 for (i = 0; i < len; i++) {\ | 50 for (i = 0; i < len; i++) {\ |
51 write_##name##_array(data + i * len2, len2);\ | 51 write_##type##_array(data + i * len2, len2);\ |
52 printf(i == len - 1 ? " }\n" : " }, {\n");\ | 52 printf(i == len - 1 ? " }\n" : " }, {\n");\ |
53 }\ | 53 }\ |
54 } | 54 } |
55 | 55 |
56 /** | 56 /** |
57 * \defgroup printfuncs Predefined functions for printing tables | 57 * \defgroup printfuncs Predefined functions for printing tables |
58 * | 58 * |
59 * \{ | 59 * \{ |
60 */ | 60 */ |
61 void write_int8_array (const int8_t *, int); | 61 void write_int8_t_array (const int8_t *, int); |
62 void write_uint8_array (const uint8_t *, int); | 62 void write_uint8_t_array (const uint8_t *, int); |
63 void write_uint16_array (const uint16_t *, int); | 63 void write_uint16_t_array (const uint16_t *, int); |
64 void write_uint32_array (const uint32_t *, int); | 64 void write_uint32_t_array (const uint32_t *, int); |
65 void write_float_array (const float *, int); | 65 void write_float_array (const float *, int); |
66 void write_int8_2d_array (const void *, int, int); | 66 void write_int8_t_2d_array (const void *, int, int); |
67 void write_uint8_2d_array (const void *, int, int); | 67 void write_uint8_t_2d_array (const void *, int, int); |
68 void write_uint32_2d_array(const void *, int, int); | 68 void write_uint32_t_2d_array(const void *, int, int); |
69 void write_float_2d_array (const void *, int, int); | 69 void write_float_2d_array (const void *, int, int); |
70 /** \} */ // end of printfuncs group | 70 /** \} */ // end of printfuncs group |
71 | 71 |
72 /** Write a standard file header */ | 72 /** Write a standard file header */ |
73 void write_fileheader(void); | 73 void write_fileheader(void); |
74 | 74 |