Rename GET_SET_KEY operator in SAFE_GET_KEY operator

This commit is contained in:
Patrick Pelissier committed 2021-10-30 23:57:50 +02:00
1 parent 6b064870f5
commit a9fc7e15f8
8 files changed
+13 -12

No files matched your search

+1 -1
View File
@@ -549,7 +549,7 @@ Other documented operators are:
* DIV(obj1, obj2, obj3) : Set obj1 to the division of obj2 and obj3. Default is '/' C operator.
* GET\_KEY (container, key) --> &value: Return a pointer to the value object within the container associated to the key 'key' or return NULL if no object is associated to this key. The pointer to the value object remains valid until any modification of the container.
* SET\_KEY (container, key, value): Associate the key object 'key' to the value object 'value' in the given container.
* GET\_SET\_KEY (container, key) --> &value: return a pointer to the value object within the container associated to the key 'key' if it exists, or create a new entry in the container and associate it to the key 'key' with the default initialization before returning its pointer. The pointer to the object remains valid until any modification of the container. The returned pointer is therefore never NULL.
* SAFE\_GET\_KEY (container, key) --> &value: return a pointer to the value object within the container associated to the key 'key' if it exists, or create a new entry in the container and associate it to the key 'key' with the default initialization before returning its pointer. The pointer to the object remains valid until any modification of the container. The returned pointer is therefore never NULL.
* ERASE\_KEY (container, key) --> bool: Erase the object associated to the key 'key' within the container. Return true if successful, false if the key is not found (nothing is done).
* PUSH(obj, subobj) : Push 'subobj' (of type SUBTYPE() ) into the container 'obj'. How and where it is pushed is container dependent.
* POP(&subobj, obj) : Pop an object from the container 'obj' and save it in the object '*subobj' (of type SUBTYPE()) if subobj is not NULL (giving back the ownership of the sub object to the caller). Which object is popped is container dependent. The container shall have at least one object.
+1
View File
@@ -71,4 +71,5 @@ V0.5.*: * M_INVERT is renamed into M_REVERSE to be more coherent with the REVERS
* Make the _clean suffix for reseting the container to empty deprecated. Use new _reset suffix instead.
* Make the _get_at suffix for always getting a value deprecated. Use new _safe_get suffix instead.
* Rename CLEAN operator in RESET operator.
* Rename GET_SET_KEY operator in SAFE_GET_KEY operator.
+1 -1
View File
@@ -113,7 +113,7 @@
,VALUE_OPLIST(oplist) \
,M_IF_METHOD(SET, oplist)(SET_KEY(M_C(name, _set_at)) ,) \
,GET_KEY(M_C(name, _get)) \
,M_IF_METHOD(INIT, oplist)(GET_SET_KEY(M_C(name, _safe_get)) ,) \
,M_IF_METHOD(INIT, oplist)(SAFE_GET_KEY(M_C(name, _safe_get)) ,) \
,M_IF_AT_LEAST_METHOD(SET,INIT_MOVE,oplist)(ERASE_KEY(M_C(name, _erase)),) \
,GET_SIZE(M_C(name, _size)) \
,M_IF_METHOD(INIT_SET, oplist)(PUSH(M_C(name,_push_back)) ,) \
+1 -1
View File
@@ -234,7 +234,7 @@
VALUE_TYPE(M_C(name, _value_ct)), \
SET_KEY(M_C(name, _set_at)), \
GET_KEY(M_C(name, _get)), \
GET_SET_KEY(M_C(name, _safe_get)) \
SAFE_GET_KEY(M_C(name, _safe_get)) \
ERASE_KEY(M_C(name, _erase)), \
KEY_OPLIST(key_oplist), \
VALUE_OPLIST(value_oplist), \
+2 -2
View File
@@ -482,14 +482,14 @@
} \
,) \
\
M_IF_METHOD(GET_SET_KEY, oplist)( \
M_IF_METHOD(SAFE_GET_KEY, oplist)( \
static inline void \
M_C(name, _safe_get_copy)(M_GET_VALUE_TYPE oplist *out_data, concurrent_t out, M_GET_KEY_TYPE oplist const key) \
{ \
M_C0NCURRENT_CONTRACT(out); \
M_ASSERT (out_data != NULL); \
M_C(name, _write_lock)(out); \
M_GET_VALUE_TYPE oplist *p = M_CALL_GET_SET_KEY(oplist, out->data, key); \
M_GET_VALUE_TYPE oplist *p = M_CALL_SAFE_GET_KEY(oplist, out->data, key); \
M_ASSERT (p != NULL); \
M_CALL_SET(M_GET_VALUE_OPLIST oplist, *out_data, *p); \
M_C(name, _write_unlock)(out); \
+3 -3
View File
@@ -2757,7 +2757,7 @@ static inline size_t m_core_cstr_hash(const char str[])
#define M_VALUE_OPLIST_VALUE_OPLIST(a) ,a,
#define M_GET_KEY_GET_KEY(a) ,a,
#define M_SET_KEY_SET_KEY(a) ,a,
#define M_GET_SET_KEY_GET_SET_KEY(a) ,a,
#define M_SAFE_GET_KEY_SAFE_GET_KEY(a) ,a,
#define M_ERASE_KEY_ERASE_KEY(a) ,a,
#define M_GET_SIZE_GET_SIZE(a) ,a,
#define M_PUSH_PUSH(a) ,a,
@@ -2841,7 +2841,7 @@ static inline size_t m_core_cstr_hash(const char str[])
#define M_GET_VALUE_OPLIST(...) M_GET_METHOD(VALUE_OPLIST, M_NO_DEF_TYPE, __VA_ARGS__)
#define M_GET_GET_KEY(...) M_GET_METHOD(GET_KEY, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_SET_KEY(...) M_GET_METHOD(SET_KEY, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_GET_SET_KEY(...) M_GET_METHOD(GET_SET_KEY, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_SAFE_GET_KEY(...) M_GET_METHOD(SAFE_GET_KEY, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_ERASE_KEY(...) M_GET_METHOD(ERASE_KEY, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_GET_SIZE(...) M_GET_METHOD(GET_SIZE, M_NO_DEFAULT, __VA_ARGS__)
#define M_GET_PUSH(...) M_GET_METHOD(PUSH, M_NO_DEFAULT, __VA_ARGS__)
@@ -2911,7 +2911,7 @@ static inline size_t m_core_cstr_hash(const char str[])
#define M_CALL_RESET(oplist, ...) M_APPLY_API(M_GET_RESET oplist, oplist, __VA_ARGS__)
#define M_CALL_GET_KEY(oplist, ...) M_APPLY_API(M_GET_GET_KEY oplist, oplist, __VA_ARGS__)
#define M_CALL_SET_KEY(oplist, ...) M_APPLY_API(M_GET_SET_KEY oplist, oplist, __VA_ARGS__)
#define M_CALL_GET_SET_KEY(oplist, ...) M_APPLY_API(M_GET_GET_SET_KEY oplist, oplist, __VA_ARGS__)
#define M_CALL_SAFE_GET_KEY(oplist, ...) M_APPLY_API(M_GET_SAFE_GET_KEY oplist, oplist, __VA_ARGS__)
#define M_CALL_ERASE_KEY(oplist, ...) M_APPLY_API(M_GET_ERASE_KEY oplist, oplist, __VA_ARGS__)
#define M_CALL_GET_SIZE(oplist, ...) M_APPLY_API(M_GET_GET_SIZE oplist, oplist, __VA_ARGS__)
#define M_CALL_PUSH(oplist, ...) M_APPLY_API(M_GET_PUSH oplist, oplist, __VA_ARGS__)
+2 -2
View File
@@ -1079,7 +1079,7 @@
,VALUE_TYPE(M_C(name, _value_ct)) \
,SET_KEY(M_C(name, _set_at)) \
,GET_KEY(M_C(name, _get)) \
,GET_SET_KEY(M_C(name, _safe_get)) \
,SAFE_GET_KEY(M_C(name, _safe_get)) \
,ERASE_KEY(M_C(name, _erase)) \
,KEY_OPLIST(key_oplist) \
,VALUE_OPLIST(value_oplist) \
@@ -1129,7 +1129,7 @@
KEY_TYPE(M_C(name, _key_ct)), \
VALUE_TYPE(M_C(name, _key_ct)), \
GET_KEY(M_C(name, _get)), \
GET_SET_KEY(M_C(name, _safe_get)), \
SAFE_GET_KEY(M_C(name, _safe_get)), \
ERASE_KEY(M_C(name, _erase)), \
KEY_OPLIST(oplist), \
VALUE_OPLIST(oplist), \
+2 -2
View File
@@ -226,11 +226,11 @@ void test(int select_test, int index,
break;
#endif
#if M_TEST_METHOD_P(GET_SET_KEY, CONT_OPL)
#if M_TEST_METHOD_P(SAFE_GET_KEY, CONT_OPL)
case 14:
// To rework for dict
index = (1 + (c1.size() < 1000000)) * (index % ( c1.size() + 1) );
M_CALL_SET(M_GET_OPLIST CONT_OPL, b0, *M_CALL_GET_SET_KEY(CONT_OPL, c0, index));
M_CALL_SET(M_GET_OPLIST CONT_OPL, b0, *M_CALL_SAFE_GET_KEY(CONT_OPL, c0, index));
#ifndef HAVE_GET_KEY_THROUGH_FIND
if ((size_t) index >= c1.size() ) {
c1.resize(index+1);