1 #ifndef _WRAPPER_MACROS_H_ 2 #define _WRAPPER_MACROS_H_ 22 #define VA_DECLARE_ARG(type_t, x) type_t x 24 #define VA_DECLARE_ARGS20(type_t, x, ...) \ 25 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS18(__VA_ARGS__) 27 #define VA_DECLARE_ARGS18(type_t, x, ...) \ 28 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS16(__VA_ARGS__) 30 #define VA_DECLARE_ARGS16(type_t, x, ...) \ 31 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS14(__VA_ARGS__) 33 #define VA_DECLARE_ARGS14(type_t, x, ...) \ 34 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS12(__VA_ARGS__) 36 #define VA_DECLARE_ARGS12(type_t, x, ...) \ 37 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS10(__VA_ARGS__) 39 #define VA_DECLARE_ARGS10(type_t, x, ...) \ 40 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS8(__VA_ARGS__) 42 #define VA_DECLARE_ARGS8(type_t, x, ...) \ 43 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS6(__VA_ARGS__) 45 #define VA_DECLARE_ARGS6(type_t, x, ...) \ 46 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS4(__VA_ARGS__) 48 #define VA_DECLARE_ARGS4(type_t, x, ...) \ 49 VA_DECLARE_ARG(type_t, x), VA_DECLARE_ARGS2(__VA_ARGS__) 51 #define VA_DECLARE_ARGS2(type_t, x, ...) \ 52 VA_DECLARE_ARG(type_t, x) 54 #define VA_DECLARE_ARGS1(type_t, ...) type_t 56 #define VA_DECLARE_ARGS0(...) void 64 #define VA_CALL_ARG(type_t, x) x 66 #define VA_CALL_ARGS20(type_t, x, ...) \ 67 VA_CALL_ARG(type_t, x), VA_CALL_ARGS18(__VA_ARGS__) 69 #define VA_CALL_ARGS18(type_t, x, ...) \ 70 VA_CALL_ARG(type_t, x), VA_CALL_ARGS16(__VA_ARGS__) 72 #define VA_CALL_ARGS16(type_t, x, ...) \ 73 VA_CALL_ARG(type_t, x), VA_CALL_ARGS14(__VA_ARGS__) 75 #define VA_CALL_ARGS14(type_t, x, ...) \ 76 VA_CALL_ARG(type_t, x), VA_CALL_ARGS12(__VA_ARGS__) 78 #define VA_CALL_ARGS12(type_t, x, ...) \ 79 VA_CALL_ARG(type_t, x), VA_CALL_ARGS10(__VA_ARGS__) 81 #define VA_CALL_ARGS10(type_t, x, ...) \ 82 VA_CALL_ARG(type_t, x), VA_CALL_ARGS8(__VA_ARGS__) 84 #define VA_CALL_ARGS8(type_t, x, ...) \ 85 VA_CALL_ARG(type_t, x), VA_CALL_ARGS6(__VA_ARGS__) 87 #define VA_CALL_ARGS6(type_t, x, ...) \ 88 VA_CALL_ARG(type_t, x), VA_CALL_ARGS4(__VA_ARGS__) 90 #define VA_CALL_ARGS4(type_t, x, ...) \ 91 VA_CALL_ARG(type_t, x), VA_CALL_ARGS2(__VA_ARGS__) 93 #define VA_CALL_ARGS2(type_t, x, ...) \ 94 VA_CALL_ARG(type_t, x) 96 #define VA_CALL_ARGS1(type_t, ...) 98 #define VA_CALL_ARGS0(...) 112 #define _VA_CONCAT2(name,x) name##x 119 #define _VA_CONCAT3(x,y,z,...) x##y##z 127 #define __twentyone_and_0__ \ 128 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0 138 #define _VA_SELECT22_INTERNAL(_0,_1,_2,_3,_4,_5,_6,_7, \ 139 _8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,...) _21 141 #define _VA_SELECT22(...) _VA_SELECT22_INTERNAL(__VA_ARGS__) 148 #define VA_COUNT_ARGS(...) \ 149 _VA_SELECT22(_VA_CONCAT3(__twentyone,_and_0__,__VA_ARGS__), \ 150 __VA_ARGS__,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1) 153 #define X_ARGS(...) \ 154 _VA_CONCAT3(__twentyone,_and_0__,__VA_ARGS__) 159 #define ONE_IF_NONEMPTY(...) \ 160 _VA_SELECT22(_VA_CONCAT3(__twentyone,_and_0__,__VA_ARGS__), \ 161 __VA_ARGS__,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) 168 #define VA_CONCAT2_EVAL(name,x) _VA_CONCAT2(name,x) 175 #define VA_COMMA_IF_NONEMPTY(...) \ 176 VA_CONCAT2_EVAL(VA_COMMA,ONE_IF_NONEMPTY(__VA_ARGS__)) 183 #define VA_DECLARE_ARGS(...) \ 184 VA_CONCAT2_EVAL(VA_DECLARE_ARGS,VA_COUNT_ARGS(__VA_ARGS__))( \ 192 #define VA_CALL_ARGS(...) \ 193 VA_CONCAT2_EVAL(VA_CALL_ARGS,VA_COUNT_ARGS(__VA_ARGS__))( \ 196 #define VA_FN_CALL(fn, ...) \ 197 fn(VA_CONCAT2_EVAL(VA_CALL_ARGS,VA_COUNT_ARGS(__VA_ARGS__))( \ 201 #define VA_FN_DECLARE(tfn, fn, ...) \ 202 tfn fn(VA_CONCAT2_EVAL(VA_DECLARE_ARGS,VA_COUNT_ARGS(__VA_ARGS__))( \ 214 VA_FN_CALL( Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5)
215 VA_FN_CALL( Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6)
216 VA_FN_CALL( Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7)
217 VA_FN_CALL( Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7, t8, 8)
218 VA_FN_CALL( Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7, t8, 8 , t9, 9)
219 VA_FN_CALL( Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7, t8, 8 , t9, 9, t10 *, 10)
227 VA_FN_DECLARE(ret, Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5)
228 VA_FN_DECLARE(ret, Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6)
229 VA_FN_DECLARE(ret, Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7)
230 VA_FN_DECLARE(ret, Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7, t8, 8)
231 VA_FN_DECLARE(ret, Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7, t8, 8 , t9, 9)
232 VA_FN_DECLARE(ret, Fun, t1, 1, t2, 2, t3, 3, t4, 4, t5, 5, t6, 6, t7, 7, t8, 8 , t9, 9, t10 *, 10)
#define VA_FN_CALL(fn,...)
#define VA_FN_DECLARE(tfn, fn,...)