comparison tableprint.h @ 11980:263b4ef7ad87 libavcodec

tablegen: implement and use WRITE_ARRAY macros Two macros (WRITE_ARRAY and WRITE_ARRAY_2D) take the prefix (modifiers) (not all tables are static, and they might not be constant either), the type, and the name of the array. It'll be copied with same name and type, and with the correct size of the currently-defined object.
author flameeyes
date Sun, 27 Jun 2010 12:21:12 +0000
parents 59f399926c12
children
comparison
equal deleted inserted replaced
11979:59f399926c12 11980:263b4ef7ad87
23 #ifndef AVCODEC_TABLEPRINT_H 23 #ifndef AVCODEC_TABLEPRINT_H
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 #include "libavutil/common.h"
28 29
29 #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\ 30 #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\
30 void write_##type##_array(const type *data, int len)\ 31 void write_##type##_array(const type *data, int len)\
31 {\ 32 {\
32 int i;\ 33 int i;\
70 /** \} */ // end of printfuncs group 71 /** \} */ // end of printfuncs group
71 72
72 /** Write a standard file header */ 73 /** Write a standard file header */
73 void write_fileheader(void); 74 void write_fileheader(void);
74 75
76 #define WRITE_ARRAY(prefix, type, name) \
77 do { \
78 const size_t array_size = FF_ARRAY_ELEMS(name); \
79 printf(prefix" "#type" "#name"[%zu] = {\n", \
80 array_size); \
81 write_##type##_array(name, array_size); \
82 printf("};\n"); \
83 } while(0)
84
85 #define WRITE_2D_ARRAY(prefix, type, name) \
86 do { \
87 const size_t array_size1 = FF_ARRAY_ELEMS(name); \
88 const size_t array_size2 = FF_ARRAY_ELEMS(name[0]); \
89 printf(prefix" "#type" "#name"[%zu][%zu] = {\n", \
90 array_size1, array_size2 ); \
91 write_##type##_2d_array(name, array_size1, array_size2); \
92 printf("};\n"); \
93 } while(0)
94
75 #endif /* AVCODEC_TABLEPRINT_H */ 95 #endif /* AVCODEC_TABLEPRINT_H */