Rename M_SUFFIX_FUNCTION_BY_NARGS in M_BY_NARGS

and updates suffix with __NARGS_
in order to be more explicit.
This commit is contained in:
Patrick Pelissier committed 2023-07-10 00:58:31 +02:00
1 parent 31ac3999a1
commit e049b83a9e
3 files changed
+15 -13

No files matched your search

+8 -6
View File
@@ -3419,7 +3419,7 @@ M_INLINE size_t m_core_cstr_hash(const char str[])
#define M_FREE_FREE(a) ,a,
#define M_MEMPOOL_MEMPOOL(a) ,a,
#define M_MEMPOOL_LINKAGE_MEMPOOL_LINKAGE(a) ,a,
#define M_FIXED_SIZE_FIXED_SIZE(a) ,a,
#define M_SIZE_SIZE(a) ,a,
#define M_CONTEXT_CONTEXT(a) ,a,
#define M_POLICY_POLICY(a) ,a,
// As properties only
@@ -3508,7 +3508,7 @@ M_INLINE size_t m_core_cstr_hash(const char str[])
#define M_GET_FREE(...) M_GET_METHOD(FREE, M_FREE_DEFAULT, __VA_ARGS__)
#define M_GET_MEMPOOL(...) M_GET_METHOD(MEMPOOL, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_MEMPOOL_LINKAGE(...) M_GET_METHOD(MEMPOOL_LINKAGE, , __VA_ARGS__)
#define M_GET_FIXED_SIZE(...) M_GET_METHOD(FIXED_SIZE, 0, __VA_ARGS__)
#define M_GET_SIZE(...) M_GET_METHOD(SIZE, 0, __VA_ARGS__)
#define M_GET_CONTEXT(...) M_GET_METHOD(CONTEXT, 0, __VA_ARGS__)
#define M_GET_POLICY(...) M_GET_METHOD(POLICY, 0, __VA_ARGS__)
@@ -3583,7 +3583,7 @@ M_INLINE size_t m_core_cstr_hash(const char str[])
#define M_CALL_FREE(oplist, ...) M_APPLY_API(M_GET_FREE oplist, oplist, __VA_ARGS__)
#define M_CALL_MEMPOOL(oplist, ...) M_APPLY_API(M_GET_MEMPOOL oplist, oplist, __VA_ARGS__)
#define M_CALL_MEMPOOL_LINKAGE(oplist, ...) M_APPLY_API(M_GET_MEMPOOL_LINKAGE oplist, oplist, __VA_ARGS__)
//#define M_CALL_FIXED_SIZE(oplist, ...) M_APPLY_API(M_GET_FIXED_SIZE oplist, oplist, __VA_ARGS__)
//#define M_CALL_SIZE(oplist, ...) M_APPLY_API(M_GET_SIZE oplist, oplist, __VA_ARGS__)
//#define M_CALL_CONTEXT(oplist, ...) M_APPLY_API(M_GET_CONTEXT oplist, oplist, __VA_ARGS__)
//#define M_CALL_POLICY(oplist, ...) M_APPLY_API(M_GET_POLICY oplist, oplist, __VA_ARGS__)
@@ -4409,8 +4409,10 @@ m_core_parse2_enum (const char str[], const char **endptr)
/************************************************************/
/* Add as suffix for the given function the number of arguments of the calls.
Can be used to call different function in function of the number of arguments. */
#define M_SUFFIX_FUNCTION_BY_NARGS(function, ...) M_C3(function, _, M_NARGS(__VA_ARGS__))
Can be used to call different function in function of the number of arguments.
It doesn't call the function with the argument in order to be able to chain the
macro */
#define M_BY_NARGS(function, ...) M_C3(function, __NARGS_, M_NARGS(__VA_ARGS__))
/* Call different INIT_WITH method in function of the number of arguments of the call,
* to be used in an OPLIST.
@@ -4419,7 +4421,7 @@ m_core_parse2_enum (const char str[], const char **endptr)
* All INIT_WITH methods shall be named as name ## _init_with_ ## NARGS
*/
#define M_INIT_WITH_NVAR(oplist, ...) \
M_SUFFIX_FUNCTION_BY_NARGS(M_C(M_GET_NAME oplist, _init_with), __VA_ARGS__)(__VA_ARGS__)
M_BY_NARGS(M_C(M_GET_NAME oplist, _init_with), __VA_ARGS__)(__VA_ARGS__)
/* Initialize the container 'dest' as per 'oplist' INIT operator
+5 -5
View File
@@ -188,11 +188,11 @@ typedef struct m_worker_sync_s {
input is (fieldname, type) or (fieldname, type, oplist)
Output shall be : M_OPEXTEND(M_GLOBAL_OPLIST_OR_DEF(type_or_oplist)(), TYPE(type)) / M_OPEXTEND(oplist, TYPE(type))
*/
#define M_WORK3R_SPAWN_EXTEND_P0(...) M_SUFFIX_FUNCTION_BY_NARGS(M_WORK3R_SPAWN_EXTEND_P0, M_ID __VA_ARGS__) __VA_ARGS__
#define M_WORK3R_SPAWN_EXTEND_P0_2(field, type) M_OPEXTEND(M_GLOBAL_OPLIST_OR_DEF(type)(), TYPE(type))
#define M_WORK3R_SPAWN_EXTEND_P0_3(field, type, oplist) M_IF_OPLIST(oplist)(M_WORK3R_SPAWN_EXTEND_P0_3_OK, M_WORK3R_SPAWN_EXTEND_P0_3_KO)(field, type, oplist)
#define M_WORK3R_SPAWN_EXTEND_P0_3_OK(field, type, oplist) M_OPEXTEND(oplist, TYPE(type))
#define M_WORK3R_SPAWN_EXTEND_P0_3_KO(field, type, oplist) \
#define M_WORK3R_SPAWN_EXTEND_P0(...) M_BY_NARGS(M_WORK3R_SPAWN_EXTEND_P0, M_ID __VA_ARGS__) __VA_ARGS__
#define M_WORK3R_SPAWN_EXTEND_P0__NARGS_2(field, type) M_OPEXTEND(M_GLOBAL_OPLIST_OR_DEF(type)(), TYPE(type))
#define M_WORK3R_SPAWN_EXTEND_P0__NARGS_3(field, type, oplist) M_IF_OPLIST(oplist)(M_WORK3R_SPAWN_EXTEND_P0__NARGS_3_OK, M_WORK3R_SPAWN_EXTEND_P0__NARGS_3_KO)(field, type, oplist)
#define M_WORK3R_SPAWN_EXTEND_P0__NARGS_3_OK(field, type, oplist) M_OPEXTEND(oplist, TYPE(type))
#define M_WORK3R_SPAWN_EXTEND_P0__NARGS_3_KO(field, type, oplist) \
M_STATIC_FAILURE(M_LIB_NOT_AN_OPLIST, "(M_WORKER_SPAWN_EXTEND): the argument is not a valid oplist: " M_MAP(M_AS_STR, oplist))
/* Deferred evaluation for the definition,
+2 -2
View File
@@ -570,8 +570,8 @@ static void test_oplist(void)
assert (M_ID (M_GET_NAME A5));
#define A6 (NAME(A6), INIT_WITH(API_1(M_INIT_WITH_NVAR)))
#define A6_init_with_1(x) 1
#define A6_init_with_2(x, y) 0
#define A6_init_with__NARGS_1(x) 1
#define A6_init_with__NARGS_2(x, y) 0
assert (M_ID(M_CALL_INIT_WITH (A6, 0)));
assert (M_ID(!M_CALL_INIT_WITH (A6, 0, 0)));
}