Avoid using M_ID / M_OPFLAT in context where it could be used recursively
This commit is contained in:
1 parent
e71b19424b
commit
60734bdb2b
1 file changed
+10
-8
@@ -1009,12 +1009,12 @@ M_BEGIN_PROTECTED_CODE
|
||||
#define M_MIDI(f, ...) f(__VA_ARGS__)
|
||||
|
||||
|
||||
/* Return the value of the "array" associated to the given index (zero based).
|
||||
/* Return the value of the "arglist" associated to the given index (zero based).
|
||||
EXAMPLE: M_GET_AT((f_0,f_1,f_2),1) returns f_1
|
||||
Can be chained with NARGS().
|
||||
*/
|
||||
#define M_GET_AT(array, index) M_GETI_AT0(M_C(M_RET_ARG, M_INC(index)), array)
|
||||
#define M_GETI_AT0(func, array) func ( M_ID array , dummy )
|
||||
#define M_GET_AT(arglist, index) M_GETI_AT0(M_C(M_RET_ARG, M_INC(index)), arglist)
|
||||
#define M_GETI_AT0(func, arglist) func ( M_ID arglist , dummy )
|
||||
|
||||
|
||||
/* Convert an integer or a symbol into 0 (if 0) or 1 (if not 0).
|
||||
@@ -1728,7 +1728,8 @@ M_BEGIN_PROTECTED_CODE
|
||||
Generated by:
|
||||
for i in $(seq 52) ; do printf "#define M_MERGE_ARGLIST_%d_%d(" $i $i ; for j in $(seq 1 $i) ; do printf "a%d, " $j ; done ; for j in $(seq 1 $i) ; do printf "b%d" $j ; if test $i != $j ; then printf ", " ; fi ; done ; printf ") " ; for j in $(seq 1 $i) ; do printf "(a%d, b%d) " $j $j ; if (test $i != $j ) ; then printf ", " ; fi ; done ; printf "\n" ; done
|
||||
*/
|
||||
#define M_MERGE_ARGLIST(a, b) ( M_APPLY( M_C4(M_MERGE_ARGLIST_, M_NARGS a, _, M_NARGS b), M_OPFLAT a, M_OPFLAT b) )
|
||||
#define M_MERGE_ARGLIST(a, b) ( M_APPLY( M_C4(M_MERGE_ARGLIST_, M_NARGS a, _, M_NARGS b), M_MERGE_ARGLIST_ID a, M_MERGE_ARGLIST_ID b) )
|
||||
#define M_MERGE_ARGLIST_ID(...) __VA_ARGS__
|
||||
#define M_MERGE_ARGLIST_1_1(a1, b1) (a1, b1)
|
||||
#define M_MERGE_ARGLIST_2_2(a1, a2, b1, b2) (a1, b1) , (a2, b2)
|
||||
#define M_MERGE_ARGLIST_3_3(a1, a2, a3, b1, b2, b3) (a1, b1) , (a2, b2) , (a3, b3)
|
||||
@@ -1783,11 +1784,11 @@ M_BEGIN_PROTECTED_CODE
|
||||
#define M_MERGE_ARGLIST_52_52(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, a34, a35, a36, a37, a38, a39, a40, a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, a51, a52, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49, b50, b51, b52) (a1, b1) , (a2, b2) , (a3, b3) , (a4, b4) , (a5, b5) , (a6, b6) , (a7, b7) , (a8, b8) , (a9, b9) , (a10, b10) , (a11, b11) , (a12, b12) , (a13, b13) , (a14, b14) , (a15, b15) , (a16, b16) , (a17, b17) , (a18, b18) , (a19, b19) , (a20, b20) , (a21, b21) , (a22, b22) , (a23, b23) , (a24, b24) , (a25, b25) , (a26, b26) , (a27, b27) , (a28, b28) , (a29, b29) , (a30, b30) , (a31, b31) , (a32, b32) , (a33, b33) , (a34, b34) , (a35, b35) , (a36, b36) , (a37, b37) , (a38, b38) , (a39, b39) , (a40, b40) , (a41, b41) , (a42, b42) , (a43, b43) , (a44, b44) , (a45, b45) , (a46, b46) , (a47, b47) , (a48, b48) , (a49, b49) , (a50, b50) , (a51, b51) , (a52, b52)
|
||||
|
||||
|
||||
/* Remove the parenthesis if needed
|
||||
/* Remove the parenthesis if there are present.
|
||||
(internal macro) */
|
||||
#define M_REMOVE_PARENTHESIS(...) \
|
||||
M_IF(M_PARENTHESIS_P(__VA_ARGS__))(M_REMOVE_PARENTHESIS_2, M_REMOVE_PARENTHESIS_3)(__VA_ARGS__)
|
||||
#define M_REMOVE_PARENTHESIS_2(...) M_OPFLAT __VA_ARGS__
|
||||
#define M_REMOVE_PARENTHESIS_2(...) M_REMOVE_PARENTHESIS_3 __VA_ARGS__
|
||||
#define M_REMOVE_PARENTHESIS_3(...) __VA_ARGS__
|
||||
|
||||
/* Return the input (delay evaluation) */
|
||||
@@ -3068,7 +3069,8 @@ static inline size_t m_core_cstr_hash(const char str[])
|
||||
* Inject also the oplist of requested in orderlist
|
||||
*/
|
||||
#define M_REORDER_ARGLIST(arglist, orderlist) \
|
||||
M_MAP2_C( M_REORDER_ARGLIST_FUNC, arglist, M_OPFLAT orderlist)
|
||||
M_MAP2_C( M_REORDER_ARGLIST_FUNC, arglist, M_REORDER_ARGLIST_ID orderlist)
|
||||
#define M_REORDER_ARGLIST_ID(...) __VA_ARGS__
|
||||
#define M_REORDER_ARGLIST_FUNC(arglist, order) \
|
||||
M_RET_ARG2_BIS( M_C(M_REORDER_ARGLIST_FUNC_, order) (arglist), order, )
|
||||
|
||||
@@ -3483,7 +3485,7 @@ m_core_parse2_enum (const char str[], const char **endptr)
|
||||
OUT_STR(M_CSTR_OUT_STR) )
|
||||
|
||||
|
||||
/* From an oplist (...) return ... */
|
||||
/* From an oplist (...) return ... (Like M_ID but for OPLIST) */
|
||||
#define M_OPFLAT(...) __VA_ARGS__
|
||||
|
||||
/* Concat two oplists in one. op1 will have higher priority to op2 */
|
||||
|
||||
Reference in new issue
Block a user