WIP on BI-F list. Still an issue to fix

This commit is contained in:
Patrick Pelissier committed 2025-07-26 10:38:28 +02:00
1 parent 089b8b3c61
commit 522f37f66d
2 files changed
+81 -19

No files matched your search

+39 -18
View File
@@ -62,17 +62,17 @@
/* Define a singly linked list of a given type allowing both push and one pop (front)
USAGE: LIST_BI_PUSH_DEF(name, type [, oplist_of_the_type]) */
#define M_LIST_BI_PUSH_DEF(name, ...) \
M_LIST_BI_PUSH_DEF_AS(name, M_F(name,_t), M_F(name, _it_t), __VA_ARGS__)
USAGE: LIST_BIF_DEF(name, type [, oplist_of_the_type]) */
#define M_LIST_BIF_DEF(name, ...) \
M_LIST_BIF_DEF_AS(name, M_F(name,_t), M_F(name, _it_t), __VA_ARGS__)
/* Define a singly linked list of a given type allowing both push and one pop (front)
as the provided type name_t with the iterator named it_t
USAGE: LIST_BI_PUSH_DEF_AS(name, name_t, type [, oplist_of_the_type]) */
#define M_LIST_BI_PUSH_DEF_AS(name, name_t, it_t, ...) \
USAGE: LIST_BIF_DEF_AS(name, name_t, type [, oplist_of_the_type]) */
#define M_LIST_BIF_DEF_AS(name, name_t, it_t, ...) \
M_BEGIN_PROTECTED_CODE \
M_L1ST_BI_PUSH_DEF_P1(M_IF_NARGS_EQ1(__VA_ARGS__) \
M_L1ST_BIF_DEF_P1(M_IF_NARGS_EQ1(__VA_ARGS__) \
((name, __VA_ARGS__, M_GLOBAL_OPLIST_OR_DEF(__VA_ARGS__)(), name_t, it_t ), \
(name, __VA_ARGS__, name_t, it_t ))) \
M_END_PROTECTED_CODE
@@ -144,8 +144,8 @@
IT_INSERT(M_F(name, _insert)), \
IT_REMOVE(M_F(name,_remove)), \
RESET(M_F(name,_reset)), \
PUSH(M_F(name,_push_back)), \
POP(M_F(name,_pop_back)), \
PUSH(M_F(name,_push)), \
POP(M_F(name,_pop)), \
PUSH_MOVE(M_F(name,_push_move)), \
POP_MOVE(M_F(name,_pop_move)) \
,SPLICE_BACK(M_F(name,_splice_back)) \
@@ -188,8 +188,8 @@
IT_INSERT(API_0P(M_F(name, _insert))), \
IT_REMOVE(API_0P(M_F(name,_remove))), \
RESET(API_0P(M_F(name,_reset))), \
PUSH(API_0P(M_F(name,_push_back))), \
POP(API_0P(M_F(name,_pop_back))), \
PUSH(API_0P(M_F(name,_push))), \
POP(API_0P(M_F(name,_pop))), \
PUSH_MOVE(API_0P(M_F(name,_push_move))), \
POP_MOVE(API_0P(M_F(name,_pop_move))) \
,SPLICE_BACK(M_F(name,_splice_back)) \
@@ -334,6 +334,11 @@
} \
} \
\
M_P(void, name, _push, list_t v, type const x) \
{ \
M_F(name, _push_back)M_R(v, x); \
} \
\
M_IF_METHOD(INIT, oplist)( \
M_P(type *, name, _push_new, list_t v) \
{ \
@@ -363,6 +368,11 @@
M_L1ST_CONTRACT(v); \
} \
\
M_P(void, name, _pop, type *data, list_t v) \
{ \
M_F(name, _pop_back)M_R(data, v); \
} \
\
M_P(void, name, _push_move, list_t v, type *x) \
{ \
M_ASSERT (x != NULL); \
@@ -1094,6 +1104,11 @@
} \
} \
\
M_P(void, name, _push, list_t v, type const x) \
{ \
M_F(name, push_strong)M_R(v, x); \
} \
\
M_IF_METHOD(INIT, oplist)( \
M_P(type *, name, push_strong_new, list_t v) \
{ \
@@ -1142,6 +1157,11 @@
M_L1ST_DUAL_PUSH_CONTRACT(v); \
} \
\
M_P(void, name, _pop, type *data, list_t v) \
{ \
M_F(name, pop_strong)M_R(data, v); \
} \
\
M_P(void, name, _pop_move, type *data, list_t v) \
{ \
M_L1ST_DUAL_PUSH_CONTRACT(v); \
@@ -1431,6 +1451,7 @@
M_INLINE void \
M_F(name, _splice_back)(list_t list1, list_t list2, it_t it) \
{ \
/* FIXME back ==> strong */ \
M_L1ST_DUAL_PUSH_CONTRACT(list1); \
M_L1ST_DUAL_PUSH_CONTRACT(list2); \
M_ASSERT (it->current != NULL); \
@@ -1547,15 +1568,15 @@
/* Deferred evaluation for the bi-push list definition,
so that all arguments are evaluated before further expansion */
#define M_L1ST_BI_PUSH_DEF_P1(arg) M_ID( M_L1ST_BI_PUSH_DEF_P2 arg )
#define M_L1ST_BIF_DEF_P1(arg) M_ID( M_L1ST_BIF_DEF_P2 arg )
/* Validate the oplist before going further */
#define M_L1ST_BI_PUSH_DEF_P2(name, type, oplist, list_t, it_t) \
M_IF_OPLIST(oplist)(M_L1ST_BI_PUSH_DEF_P3, M_L1ST_BI_PUSH_DEF_FAILURE)(name, type, oplist, list_t, it_t)
#define M_L1ST_BIF_DEF_P2(name, type, oplist, list_t, it_t) \
M_IF_OPLIST(oplist)(M_L1ST_BIF_DEF_P3, M_L1ST_BIF_DEF_FAILURE)(name, type, oplist, list_t, it_t)
/* Stop processing with a compilation failure */
#define M_L1ST_BI_PUSH_DEF_FAILURE(name, type, oplist, list_t, it_t) \
M_STATIC_FAILURE(M_LIB_NOT_AN_OPLIST, "(LIST_BI_PUSH_DEF): the given argument is not a valid oplist: " #oplist)
#define M_L1ST_BIF_DEF_FAILURE(name, type, oplist, list_t, it_t) \
M_STATIC_FAILURE(M_LIB_NOT_AN_OPLIST, "(LIST_BIF_DEF): the given argument is not a valid oplist: " #oplist)
/* Internal bi-push list definition (like dual-push but inverts front & back)
- name: prefix to be used
@@ -1564,7 +1585,7 @@
- list_t: alias for M_F(name, _t) [ type of the container ]
- it_t: alias for M_F(name, _it_t) [ iterator of the container ]
*/
#define M_L1ST_BI_PUSH_DEF_P3(name, type, oplist, list_t, it_t) \
#define M_L1ST_BIF_DEF_P3(name, type, oplist, list_t, it_t) \
M_L1ST_DUAL_PUSH_DEF_TYPE(name, type, oplist, list_t, it_t) \
M_CHECK_COMPATIBLE_OPLIST(name, 1, type, oplist) \
M_L1ST_DUAL_PUSH_DEF_P4(name, type, oplist, list_t, it_t, _front, _push_front_raw, _push_front, _push_front_move, _push_front_new, _pop_front, _back, _push_back_raw, _push_back, _push_back_move, _push_back_new) \
@@ -1577,8 +1598,8 @@
#define LIST_DEF_AS M_LIST_DEF_AS
#define LIST_DUAL_PUSH_DEF M_LIST_DUAL_PUSH_DEF
#define LIST_DUAL_PUSH_DEF_AS M_LIST_DUAL_PUSH_DEF_AS
#define LIST_BI_PUSH_DEF M_LIST_BI_PUSH_DEF
#define LIST_BI_PUSH_DEF_AS M_LIST_BI_PUSH_DEF_AS
#define LIST_BIF_DEF M_LIST_BIF_DEF
#define LIST_BIF_DEF_AS M_LIST_BIF_DEF_AS
#define LIST_OPLIST M_LIST_OPLIST
#define LIST_INIT_VALUE M_LIST_INIT_VALUE
#define LIST_DUAL_PUSH_INIT_VALUE M_LIST_DUAL_PUSH_INIT_VALUE