Add M_TEST_DISABLED_METHOD_P
This commit is contained in:
1 parent
d08e2bba95
commit
df1a9e9c88
2 files changed
+16
-2
No files matched your search
@@ -984,10 +984,18 @@ m_core_hash (const void *str, size_t length)
|
||||
#define M_OPEXTEND(op, ...) (__VA_ARGS__, M_OPFLAT op)
|
||||
|
||||
/* Test if a method is present in an oplist.
|
||||
Return 0 or 1 */
|
||||
#define M_TEST_METHOD_P(method, oplist) \
|
||||
Return 0 (method is absent or disabled) or 1 (method is present and not disabled) */
|
||||
#define M_TEST_METHOD_P(method, oplist) \
|
||||
M_BOOL(M_GET_METHOD (method, 0, M_OPFLAT oplist))
|
||||
|
||||
/* Test if a method is disabled in an oplist.
|
||||
To disable an oplist, just put '0' in the method like this:
|
||||
Example: (INIT(0), CLEAR(clear))
|
||||
Here INIT is disabled, whereas CLEAR is not.
|
||||
Return 1 (method is disabled) or 0 (method is not disabled - absent or present) */
|
||||
#define M_TEST_DISABLED_METHOD_P(method, oplist) \
|
||||
M_INV(M_BOOL(M_GET_METHOD (method, 1, M_OPFLAT oplist)))
|
||||
|
||||
/* Perfom a preprocessing M_IF, if the method is present in the oplist.
|
||||
Example: M_IF_METHOD(HASH, oplist)(define function with HASH method, ) */
|
||||
#define M_IF_METHOD(method, oplist) M_IF(M_TEST_METHOD_P(method, oplist))
|
||||
|
||||
@@ -233,6 +233,12 @@ static void test_oplist(void)
|
||||
assert (!M_OPLIST_P());
|
||||
assert (!M_OPLIST_P((())));
|
||||
assert (!M_OPLIST_P(INIT(init)));
|
||||
|
||||
#define a (INIT(0), CLEAR(clear))
|
||||
assert (M_TEST_DISABLED_METHOD_P(INIT, a));
|
||||
assert (!M_TEST_DISABLED_METHOD_P(INIT2, a));
|
||||
assert (!M_TEST_DISABLED_METHOD_P(CLEAR, a));
|
||||
assert (!M_TEST_DISABLED_METHOD_P(INIT, ()));
|
||||
}
|
||||
|
||||
static void test_cast(void)
|
||||
|
||||
Reference in new issue
Block a user