// cppawk: C preprocessor wrapper around awk // Kaz Kylheku // // BSD-2 License // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. #ifndef __CPPAWK_NARG_PRIV_H #define __CPPAWK_NARG_PRIV_H #ifndef __CPPAWK_BASE_H #include "base.h" #endif #define __narg_34(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, \ A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, \ A26, A27, A28, A29, A30, A31, A32, A33, N, ...) N #define __xnarg_34(...) __narg_34(__VA_ARGS__) #define __narg(...) __xnarg_34(__dummy, ## __VA_ARGS__, 32, 31, 30, 29, 28, \ 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, \ 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, \ 3, 2, 1, 0) #define __repn_1(mac1, mac2, a1) \ mac1(a1) #define __repn_2(mac1, mac2, a1, a2) \ mac2(mac1(a1), a2) #define __repn_3(mac1, mac2, a1, a2, a3) \ mac2(mac2(mac1(a1), a2), a3) #define __repn_4(mac1, mac2, a1, a2, a3, a4) \ mac2(mac2(mac2(mac1(a1), a2), a3), a4) #define __repn_5(mac1, mac2, a1, a2, a3, a4, a5) \ mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5) #define __repn_6(mac1, mac2, a1, a2, a3, a4, a5, a6) \ mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6) #define __repn_7(mac1, mac2, a1, a2, a3, a4, a5, a6, a7) \ mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7) #define __repn_8(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8) #define __repn_9(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9) #define __repn_10(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10) #define __repn_11(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11) #define __repn_12(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12) #define __repn_13(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13) #define __repn_14(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14) #define __repn_15(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15) #define __repn_16(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16) #define __repn_17(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17) #define __repn_18(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18) #define __repn_19(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19) #define __repn_20(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20) #define __repn_21(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21) #define __repn_22(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22) #define __repn_23(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23) #define __repn_24(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24) #define __repn_25(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25) #define __repn_26(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26) #define __repn_27(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26, a27) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27) #define __repn_28(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26, a27, a28) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28) #define __repn_29(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26, a27, a28, a29) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29) #define __repn_30(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26, a27, a28, a29, a30) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29), a30) #define __repn_31(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26, a27, a28, a29, a30, a31) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29), a30), a31) #define __repn_32(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \ a24, a25, a26, a27, a28, a29, a30, a31, a32) \ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29), a30), a31), a32) #define __varexpand(mac1, mac2, ...) \ __xcat(__repn_, __narg(__VA_ARGS__)) (mac1, mac2, __VA_ARGS__) #define __rev_first(arg) arg #define __rev_next(args, arg) arg, args #define __revargs(...) __varexpand(__rev_first, __rev_next, __VA_ARGS__) #endif