diff options
-rw-r--r-- | cppawk-include/case-priv.h | 14 | ||||
-rw-r--r-- | cppawk-include/narg-priv.h | 10 |
2 files changed, 16 insertions, 8 deletions
diff --git a/cppawk-include/case-priv.h b/cppawk-include/case-priv.h index 863fd00..e0572ba 100644 --- a/cppawk-include/case-priv.h +++ b/cppawk-include/case-priv.h @@ -42,10 +42,8 @@ #define __case_temps __ign #define __case(expr) switch (expr) -#define __of(...) __xcat(__rep_, __narg(__VA_ARGS__))(__casx, \ - __VA_ARGS__) {{{ -#define __matching(...) __xcat(__rep_, __narg(__VA_ARGS__))(__casx, \ - __VA_ARGS__) {{{ +#define __of(...) __varexpand_simple(__casx, __VA_ARGS__) {{{ +#define __matching(...) __varexpand_simple(__casx, __VA_ARGS__) {{{ #define __cbreak break; }}} #define __cfall }}} #define __cret(val) return val; }}} @@ -63,10 +61,10 @@ #define __case(expr) for ((__once = 1) && (__pass = 0) || (__val = expr); \ __once; \ __once = 0) -#define __of(...) __clause(__xcat(__repi_, __narg(__VA_ARGS__)) \ - (__of_first, __of_next, __VA_ARGS__)) {{{ -#define __matching(...) __clause(__xcat(__repi_, __narg(__VA_ARGS__)) \ - (__mtch_first, __mtch_next, __VA_ARGS__)) {{{ +#define __of(...) __clause(__varexpand_infix(__of_first, __of_next, \ + __VA_ARGS__)) {{{ +#define __matching(...) __clause(__varexpand_infix(__mtch_first, mtch_next, \ + __VA_ARGS__)) {{{ #define __cbreak break; }}} #define __creturn(val) return val; }}} #define __cfall }}} diff --git a/cppawk-include/narg-priv.h b/cppawk-include/narg-priv.h index 92065aa..2e1ac8c 100644 --- a/cppawk-include/narg-priv.h +++ b/cppawk-include/narg-priv.h @@ -28,6 +28,10 @@ #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 @@ -324,4 +328,10 @@ mac2(a23) mac2(a24) mac2(a25) mac2(a26) mac2(a27) mac2(a28) mac2(a29) \ mac2(a30) mac2(a31) mac2(a32) +#define __varexpand_simple(mac, ...) \ + __xcat(__rep_, __narg(__VA_ARGS__)) (mac, __VA_ARGS__) + +#define __varexpand_infix(mac1, mac2, ...) \ + __xcat(__repi_, __narg(__VA_ARGS__)) (mac1, mac2, __VA_ARGS__) + #endif |