Merge branch 'master' of https://github.com/P-p-H-d/mlib
This commit is contained in:
commit
b0ec9680a1
2 files changed
+15
-10
No files matched your search
@@ -679,7 +679,8 @@
|
|||||||
#define M_IFI_1(true_macro, ...) true_macro
|
#define M_IFI_1(true_macro, ...) true_macro
|
||||||
#define M_IF(c) M_C(M_IFI_, M_BOOL(c))
|
#define M_IF(c) M_C(M_IFI_, M_BOOL(c))
|
||||||
|
|
||||||
/* Return 1 if there is a comma inside the argument list, 0 otherwise */
|
/* Return 1 if there is a comma inside the argument list,
|
||||||
|
0 otherwise. */
|
||||||
#define M_COMMA_P(...) M_RET_ARG53(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, useless)
|
#define M_COMMA_P(...) M_RET_ARG53(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, useless)
|
||||||
|
|
||||||
/* Return the string representation of the evaluated x.
|
/* Return the string representation of the evaluated x.
|
||||||
@@ -705,9 +706,9 @@
|
|||||||
#define M_PARENTHESISI_DETECT(...) 0, 1,
|
#define M_PARENTHESISI_DETECT(...) 0, 1,
|
||||||
#define M_PARENTHESIS_P(...) M_AND(M_COMMA_P(M_PARENTHESISI_DETECT __VA_ARGS__), M_INV(M_COMMA_P(__VA_ARGS__)))
|
#define M_PARENTHESIS_P(...) M_AND(M_COMMA_P(M_PARENTHESISI_DETECT __VA_ARGS__), M_INV(M_COMMA_P(__VA_ARGS__)))
|
||||||
|
|
||||||
/* Necessary macros to handle recursivity */
|
/* Necessary macros to handle recursivity,
|
||||||
/* Delay the evaluation by one level or two or three or ... */
|
delaying the evaluation by one (or more) level of macro expansion.
|
||||||
/* The argument is a macro-function which has to be deferred */
|
The argument is a macro-function which has to be deferred */
|
||||||
#define M_DELAY0()
|
#define M_DELAY0()
|
||||||
#define M_DELAY1(...) __VA_ARGS__ M_DELAY0 ()
|
#define M_DELAY1(...) __VA_ARGS__ M_DELAY0 ()
|
||||||
#define M_DELAY2(...) __VA_ARGS__ M_DELAY1 (M_DELAY0) ()
|
#define M_DELAY2(...) __VA_ARGS__ M_DELAY1 (M_DELAY0) ()
|
||||||
@@ -719,10 +720,11 @@
|
|||||||
#define M_DELAY8(...) __VA_ARGS__ M_DELAY7 (M_DELAY0) ()
|
#define M_DELAY8(...) __VA_ARGS__ M_DELAY7 (M_DELAY0) ()
|
||||||
#define M_DELAY9(...) __VA_ARGS__ M_DELAY8 (M_DELAY0) ()
|
#define M_DELAY9(...) __VA_ARGS__ M_DELAY8 (M_DELAY0) ()
|
||||||
|
|
||||||
/* Perform 3^5 evaluation
|
/* Perform 3^5 evaluation,
|
||||||
NOTE: There can be only one eval per complete macro-evaluation pass.
|
forcing the pre-processor to expand the given macro a lot of times.
|
||||||
If there is multiple macro using recursivity, only one M_EVAL
|
NOTE: There can be only one EVAL macro per complete macro-evaluation pass.
|
||||||
can exist.*/
|
As such the given macro cannot contain M_EVAL itself.
|
||||||
|
*/
|
||||||
#define M_EVAL(...) M_EVAL1(M_EVAL1(M_EVAL1(__VA_ARGS__)))
|
#define M_EVAL(...) M_EVAL1(M_EVAL1(M_EVAL1(__VA_ARGS__)))
|
||||||
#define M_EVAL1(...) M_EVAL2(M_EVAL2(M_EVAL2(__VA_ARGS__)))
|
#define M_EVAL1(...) M_EVAL2(M_EVAL2(M_EVAL2(__VA_ARGS__)))
|
||||||
#define M_EVAL2(...) M_EVAL3(M_EVAL3(M_EVAL3(__VA_ARGS__)))
|
#define M_EVAL2(...) M_EVAL3(M_EVAL3(M_EVAL3(__VA_ARGS__)))
|
||||||
@@ -734,8 +736,10 @@
|
|||||||
It allows that a won't be evaluated until all arguments of 'a' have been already evaluated */
|
It allows that a won't be evaluated until all arguments of 'a' have been already evaluated */
|
||||||
#define M_APPLY(a, ...) a (__VA_ARGS__)
|
#define M_APPLY(a, ...) a (__VA_ARGS__)
|
||||||
|
|
||||||
/* Map: apply the given macro to all arguments (non recursive version) */
|
/* MAP: apply the given macro to all arguments.
|
||||||
/* Example: M_MAP(f,a, b, c) ==> f(a) f(b) f(c) */
|
It is a non recursive version that is much faster than the recursive one.
|
||||||
|
Example:
|
||||||
|
M_MAP(f,a, b, c) ==> f(a) f(b) f(c) */
|
||||||
/* Generated by:
|
/* Generated by:
|
||||||
for i in $(seq 1 52) ; do printf "#define M_MAP_%d(f" $i ; for j in $(seq 1 $i) ; do printf ", _%d" $j ; done ; printf ") " ; for j in $(seq 1 $i) ; do printf "f(_%d) " $j ; done ; printf "\n"; done
|
for i in $(seq 1 52) ; do printf "#define M_MAP_%d(f" $i ; for j in $(seq 1 $i) ; do printf ", _%d" $j ; done ; printf ") " ; for j in $(seq 1 $i) ; do printf "f(_%d) " $j ; done ; printf "\n"; done
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ static void test_empty(void)
|
|||||||
assert (M_EMPTY_P(,) == false);
|
assert (M_EMPTY_P(,) == false);
|
||||||
assert (M_EMPTY_P(()) == false);
|
assert (M_EMPTY_P(()) == false);
|
||||||
assert (M_EMPTY_P("123") == false);
|
assert (M_EMPTY_P("123") == false);
|
||||||
|
assert (M_EMPTY_P(,1,2,3) == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define f(n) (n)*(n) +
|
#define f(n) (n)*(n) +
|
||||||
|
|||||||
Reference in new issue
Block a user