From 811fa57cbc0e73725a488c33fc3ab45109243d31 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Thu, 17 Mar 2022 19:33:46 +0100 Subject: [PATCH] Fix generic API: remove the need of superfluous () --- m-core.h | 4 ++-- tests/test-mcore.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/m-core.h b/m-core.h index 38a8fa7f..4a758d9b 100644 --- a/m-core.h +++ b/m-core.h @@ -3084,9 +3084,9 @@ static inline size_t m_core_cstr_hash(const char str[]) #define M_REORDER_RET_ARG9(...) M_RET_ARG9(__VA_ARGS__) = /* Integrate the generic API in the API transformation framework */ -#define M_OPLAPI(method, oplist, ...) , ( M_C( M_REORDER_RET_, M_HEAD_2 method)(__VA_ARGS__, ) M_DELAY2(M_HEAD method)( M_REORDER_ARGLIST( (oplist, __VA_ARGS__), ( M_TAIL_2 method ) ) ) ) +#define M_OPLAPI(method, oplist, ...) , ( M_C( M_REORDER_RET_, M_DELAY2(M_HEAD_2 method))(__VA_ARGS__, ) M_DELAY2(M_HEAD method)( M_REORDER_ARGLIST( (oplist, __VA_ARGS__), ( M_TAIL_2 method ) ) ) ) #define M_OPLAPI_INDIRECT_API(...) M_OPLAPI -#define M_OPLAPI_EXTRACT_API(...) __VA_ARGS__ +#define M_OPLAPI_EXTRACT_API(...) ( __VA_ARGS__ ) /* Define the no default function that generates a compiler error diff --git a/tests/test-mcore.c b/tests/test-mcore.c index 3d37e2d2..fc7193eb 100644 --- a/tests/test-mcore.c +++ b/tests/test-mcore.c @@ -782,10 +782,10 @@ static void test_generic_api(void) assert( M_HEAD_2(18, 17, 0) == 17); assert( M_TAIL_2(18, 17, 8) == 8); -#define GO1 (INIT(API( (init3, ARG1, ARGPTR2, 17, 43) ))) -#define GO2 (INIT(API( (init3, NONE, ARGPTR2, 0, ARG1) ))) -#define GO3 (EQUAL(API( (cmp2, EQ(0), ARGPTR1, ARGPTR2) ))) -#define GO4 (EQUAL(API( (cmp1, EQ(0), ARG1, ARG2) ))) +#define GO1 (INIT(API( init3, ARG1, ARGPTR2, 17, 43 ))) +#define GO2 (INIT(API( init3, NONE, ARGPTR2, 0, ARG1 ))) +#define GO3 (EQUAL(API( cmp2, EQ(0), ARGPTR1, ARGPTR2 ))) +#define GO4 (EQUAL(API( cmp1, EQ(0), ARG1, ARG2 ))) int x = 0, y = 0; M_CALL_INIT(GO1, x, y);