TUPLE: Oplist is now optional for tuple definition.
This commit is contained in:
1 parent
7e4d51bab0
commit
7d83603646
2 files changed
+54
-18
No files matched your search
@@ -105,24 +105,56 @@ namespace m_tuple {
|
||||
#define TUPLE_ORDER_CONVERT_ASC(x) M_C3(_,x,_value)
|
||||
#define TUPLE_ORDER_CONVERT_DSC(x) M_C3(_,x,_value)*-1
|
||||
|
||||
#define TUPLE_GET_FIELD(f,t,o) f
|
||||
#define TUPLE_GET_TYPE(f,t,o) t
|
||||
#define TUPLE_GET_OPLIST(f,t,o) o
|
||||
#define TUPLE_GET_INIT(f,t,o) M_GET_INIT o
|
||||
#define TUPLE_GET_INIT_SET(f,t,o) M_GET_INIT_SET o
|
||||
#define TUPLE_GET_INIT_MOVE(f,t,o) M_GET_INIT_MOVE o
|
||||
#define TUPLE_GET_MOVE(f,t,o) M_GET_MOVE o
|
||||
#define TUPLE_GET_SET(f,t,o) M_GET_SET o
|
||||
#define TUPLE_GET_CLEAR(f,t,o) M_GET_CLEAR o
|
||||
#define TUPLE_GET_CMP(f,t,o) M_GET_CMP o
|
||||
#define TUPLE_GET_HASH(f,t,o) M_GET_HASH o
|
||||
#define TUPLE_GET_EQUAL(f,t,o) M_GET_EQUAL o
|
||||
#define TUPLE_GET_STR(f,t,o) M_GET_GET_STR o
|
||||
#define TUPLE_GET_OUT_STR(f,t,o) M_GET_OUT_STR o
|
||||
#define TUPLE_GET_IN_STR(f,t,o) M_GET_IN_STR o
|
||||
#define TUPLE_GET_PARSE_STR(f,t,o) M_GET_PARSE_STR o
|
||||
#define TUPLE_GET_SWAP(f,t,o) M_GET_SWAP o
|
||||
/* Get the field name, the type, the oplist or the methods
|
||||
based on the tuple (field, type, oplist) */
|
||||
#define TUPLE_GET_FIELD2(f,t,o) f
|
||||
#define TUPLE_GET_TYPE2(f,t,o) t
|
||||
#define TUPLE_GET_OPLIST2(f,t,o) o
|
||||
#define TUPLE_GET_INIT2(f,t,o) M_GET_INIT o
|
||||
#define TUPLE_GET_INIT_SET2(f,t,o) M_GET_INIT_SET o
|
||||
#define TUPLE_GET_INIT_MOVE2(f,t,o) M_GET_INIT_MOVE o
|
||||
#define TUPLE_GET_MOVE2(f,t,o) M_GET_MOVE o
|
||||
#define TUPLE_GET_SET2(f,t,o) M_GET_SET o
|
||||
#define TUPLE_GET_CLEAR2(f,t,o) M_GET_CLEAR o
|
||||
#define TUPLE_GET_CMP2(f,t,o) M_GET_CMP o
|
||||
#define TUPLE_GET_HASH2(f,t,o) M_GET_HASH o
|
||||
#define TUPLE_GET_EQUAL2(f,t,o) M_GET_EQUAL o
|
||||
#define TUPLE_GET_STR2(f,t,o) M_GET_GET_STR o
|
||||
#define TUPLE_GET_OUT_STR2(f,t,o) M_GET_OUT_STR o
|
||||
#define TUPLE_GET_IN_STR2(f,t,o) M_GET_IN_STR o
|
||||
#define TUPLE_GET_PARSE_STR2(f,t,o) M_GET_PARSE_STR o
|
||||
#define TUPLE_GET_SWAP2(f,t,o) M_GET_SWAP o
|
||||
|
||||
/* Transform (f,t) into (f,t,oplist) or (f,t,o) into (f,t,o).
|
||||
USAGE:
|
||||
TUPLEI_EVAL(GET_MACRO, tuple)
|
||||
*/
|
||||
#define TUPLEI_EVAL_FIELD(f, ...) \
|
||||
M_IF_NARGS_EQ1(__VA_ARGS__)( (f, __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__)), (f, __VA_ARGS__) )
|
||||
#define TUPLEI_EVAL2(f, a) f a
|
||||
#define TUPLEI_EVAL(f, a) TUPLEI_EVAL2(f, TUPLEI_EVAL_FIELD a)
|
||||
|
||||
/* Get the field name, the type, the oplist or the methods
|
||||
based on the tuple (field, type, oplist) or the typle (field, type)
|
||||
In the last case, it get the oplist from a global one or a default one.
|
||||
*/
|
||||
#define TUPLE_GET_FIELD(...) TUPLEI_EVAL(TUPLE_GET_FIELD2, (__VA_ARGS__))
|
||||
#define TUPLE_GET_TYPE(...) TUPLEI_EVAL(TUPLE_GET_TYPE2, (__VA_ARGS__))
|
||||
#define TUPLE_GET_OPLIST(...) TUPLEI_EVAL(TUPLE_GET_OPLIST2, (__VA_ARGS__))
|
||||
#define TUPLE_GET_INIT(...) TUPLEI_EVAL(TUPLE_GET_INIT2, (__VA_ARGS__))
|
||||
#define TUPLE_GET_INIT_SET(...) TUPLEI_EVAL(TUPLE_GET_INIT_SET2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_INIT_MOVE(...) TUPLEI_EVAL(TUPLE_GET_INIT_MOVE2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_MOVE(...) TUPLEI_EVAL(TUPLE_GET_MOVE2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_SET(...) TUPLEI_EVAL(TUPLE_GET_SET2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_CLEAR(...) TUPLEI_EVAL(TUPLE_GET_CLEAR2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_CMP(...) TUPLEI_EVAL(TUPLE_GET_CMP2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_HASH(...) TUPLEI_EVAL(TUPLE_GET_HASH2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_EQUAL(...) TUPLEI_EVAL(TUPLE_GET_EQUAL2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_STR(...) TUPLEI_EVAL(TUPLE_GET_STR2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_OUT_STR(...) TUPLEI_EVAL(TUPLE_GET_OUT_STR2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_IN_STR(...) TUPLEI_EVAL(TUPLE_GET_IN_STR2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_PARSE_STR(...) TUPLEI_EVAL(TUPLE_GET_PARSE_STR2,(__VA_ARGS__))
|
||||
#define TUPLE_GET_SWAP(...) TUPLEI_EVAL(TUPLE_GET_SWAP2,(__VA_ARGS__))
|
||||
|
||||
#define TUPLE_DEFINE_TYPE(name, ...) \
|
||||
typedef struct M_C(name, _s) { \
|
||||
@@ -388,7 +420,7 @@ namespace m_tuple {
|
||||
#define TUPLE_TEST_METHOD2_P(method, f, t, op) \
|
||||
M_TEST_METHOD_P(method, op)
|
||||
#define TUPLE_TEST_METHOD_P(method, trio) \
|
||||
M_APPLY(TUPLE_TEST_METHOD2_P, method, M_OPFLAT trio)
|
||||
M_APPLY(TUPLE_TEST_METHOD2_P, method, TUPLEI_EVAL(M_OPFLAT, trio))
|
||||
|
||||
#define TUPLE_ALL_CMP(...) \
|
||||
M_REDUCE2(TUPLE_TEST_METHOD_P, M_AND, CMP, __VA_ARGS__)
|
||||
|
||||
@@ -50,6 +50,10 @@ TUPLE_DEF2(pair_str,
|
||||
|
||||
TUPLE_DEF2(single_str, (vala, string_t, STRING_OPLIST))
|
||||
|
||||
TUPLE_DEF2(pair2_str,
|
||||
(str, string_t),
|
||||
(value, unsigned long))
|
||||
|
||||
static void check_swap(void)
|
||||
{
|
||||
pair_str_t p1, p2;
|
||||
|
||||
Reference in new issue
Block a user