Add internal method M_GET_OPPROPERTY to get the subproperty of an oplist
Add test for such macro Rename operator CLASS into PROPERTIES
This commit is contained in:
1 parent
a950e15625
commit
e688f0b1df
3 files changed
+20
-5
No files matched your search
@@ -567,7 +567,7 @@ Other documented operators are:
|
|||||||
* REVERSE(obj) : Reverse the order of the items in the container 'obj'.
|
* REVERSE(obj) : Reverse the order of the items in the container 'obj'.
|
||||||
* SEPARATOR() --> character: Return the character used to separate items for I/O methods (default is ',') (for internal use only).
|
* SEPARATOR() --> character: Return the character used to separate items for I/O methods (default is ',') (for internal use only).
|
||||||
* EXT\_ALGO(name, container oplist, object oplist): Define additional algorithms functions specialized for the containers (for internal use only).
|
* EXT\_ALGO(name, container oplist, object oplist): Define additional algorithms functions specialized for the containers (for internal use only).
|
||||||
* CLASS() --> ( properties): Return internal properties of a container (for internal use only) in an oplist format.
|
* PROPERTIES() --> ( properties): Return internal properties of a container (for internal use only) in an oplist format.
|
||||||
|
|
||||||
The operator names listed above shall not be defined as macro.
|
The operator names listed above shall not be defined as macro.
|
||||||
|
|
||||||
|
|||||||
@@ -1120,7 +1120,7 @@ M_BEGIN_PROTECTED_CODE
|
|||||||
#define M_PATTERN_MAP_MAP ,
|
#define M_PATTERN_MAP_MAP ,
|
||||||
#define M_PATTERN_KEYVAL_KEYVAL ,
|
#define M_PATTERN_KEYVAL_KEYVAL ,
|
||||||
#define M_PATTERN_KEYVAL_PTR_KEYVAL_PTR ,
|
#define M_PATTERN_KEYVAL_PTR_KEYVAL_PTR ,
|
||||||
|
#define M_PATTERN_priority_priority ,
|
||||||
|
|
||||||
/* Necessary macros to handle recursivity,
|
/* Necessary macros to handle recursivity,
|
||||||
delaying the evaluation by one (or more) level of macro expansion.
|
delaying the evaluation by one (or more) level of macro expansion.
|
||||||
@@ -2638,7 +2638,7 @@ static inline size_t m_core_cstr_hash(const char str[])
|
|||||||
#define M_OOR_SET_OOR_SET(a) ,a,
|
#define M_OOR_SET_OOR_SET(a) ,a,
|
||||||
#define M_OOR_EQUAL_OOR_EQUAL(a) ,a,
|
#define M_OOR_EQUAL_OOR_EQUAL(a) ,a,
|
||||||
#define M_LIMITS_LIMITS(a) ,a,
|
#define M_LIMITS_LIMITS(a) ,a,
|
||||||
#define M_CLASS_CLASS(a) ,a,
|
#define M_PROPERTIES_PROPERTIES(a) ,a,
|
||||||
|
|
||||||
/* From an oplist - an unorded list of methods : like "INIT(mpz_init),CLEAR(mpz_clear),SET(mpz_set)" -
|
/* From an oplist - an unorded list of methods : like "INIT(mpz_init),CLEAR(mpz_clear),SET(mpz_set)" -
|
||||||
Return the given method in the oplist or the default method.
|
Return the given method in the oplist or the default method.
|
||||||
@@ -2720,7 +2720,7 @@ static inline size_t m_core_cstr_hash(const char str[])
|
|||||||
#define M_GET_OOR_SET(...) M_GET_METHOD(OOR_SET, M_NO_DEFAULT, __VA_ARGS__)
|
#define M_GET_OOR_SET(...) M_GET_METHOD(OOR_SET, M_NO_DEFAULT, __VA_ARGS__)
|
||||||
#define M_GET_OOR_EQUAL(...) M_GET_METHOD(OOR_EQUAL, M_NO_DEFAULT, __VA_ARGS__)
|
#define M_GET_OOR_EQUAL(...) M_GET_METHOD(OOR_EQUAL, M_NO_DEFAULT, __VA_ARGS__)
|
||||||
#define M_GET_LIMITS(...) M_GET_METHOD(LIMITS, M_LIMITS_DEFAULT, __VA_ARGS__)
|
#define M_GET_LIMITS(...) M_GET_METHOD(LIMITS, M_LIMITS_DEFAULT, __VA_ARGS__)
|
||||||
#define M_GET_CLASS(...) M_GET_METHOD(CLASS, (), __VA_ARGS__)
|
#define M_GET_PROPERTIES(...) M_GET_METHOD(PROPERTIES, (), __VA_ARGS__)
|
||||||
|
|
||||||
// Calling method with support of defined transformation API
|
// Calling method with support of defined transformation API
|
||||||
// operators that are not methods are commented
|
// operators that are not methods are commented
|
||||||
@@ -2791,7 +2791,7 @@ static inline size_t m_core_cstr_hash(const char str[])
|
|||||||
#define M_CALL_OOR_SET(oplist, ...) M_APPLY_API(M_GET_OOR_SET oplist, oplist, __VA_ARGS__)
|
#define M_CALL_OOR_SET(oplist, ...) M_APPLY_API(M_GET_OOR_SET oplist, oplist, __VA_ARGS__)
|
||||||
#define M_CALL_OOR_EQUAL(oplist, ...) M_APPLY_API(M_GET_OOR_EQUAL oplist, oplist, __VA_ARGS__)
|
#define M_CALL_OOR_EQUAL(oplist, ...) M_APPLY_API(M_GET_OOR_EQUAL oplist, oplist, __VA_ARGS__)
|
||||||
//#define M_CALL_LIMITS(oplist, ...) M_APPLY_API(M_GET_LIMITS oplist, oplist, __VA_ARGS__)
|
//#define M_CALL_LIMITS(oplist, ...) M_APPLY_API(M_GET_LIMITS oplist, oplist, __VA_ARGS__)
|
||||||
//#define M_CALL_CLASS(oplist, ...) M_APPLY_API(M_GET_CLASS oplist, oplist, __VA_ARGS__)
|
//#define M_CALL_PROPERTIES(oplist, ...) M_APPLY_API(M_GET_PROPERTIES oplist, oplist, __VA_ARGS__)
|
||||||
|
|
||||||
/* API transformation support:
|
/* API transformation support:
|
||||||
transform the call to the method into the supported API by the method.
|
transform the call to the method into the supported API by the method.
|
||||||
@@ -3179,6 +3179,12 @@ m_core_parse2_enum (const char str[], const char **endptr)
|
|||||||
/* Extend an oplist by adding some methods */
|
/* Extend an oplist by adding some methods */
|
||||||
#define M_OPEXTEND(op, ...) (__VA_ARGS__, M_OPFLAT op)
|
#define M_OPEXTEND(op, ...) (__VA_ARGS__, M_OPFLAT op)
|
||||||
|
|
||||||
|
/* Return the content of a property named 'propname'
|
||||||
|
in the PROPERTIES field of oplist
|
||||||
|
or 0, if it is not defined */
|
||||||
|
#define M_GET_OPPROPERTY(oplist, propname) \
|
||||||
|
M_GET_METHOD (propname, 0, M_OPFLAT M_GET_PROPERTIES oplist)
|
||||||
|
|
||||||
/* Test if a method is present in an oplist.
|
/* Test if a method is present in an oplist.
|
||||||
Return 0 (method is absent or disabled) or 1 (method is present and not disabled).
|
Return 0 (method is absent or disabled) or 1 (method is present and not disabled).
|
||||||
NOTE: Does not work if method is OPLIST, KEY_OPLIST or VALUE_OPLIST.
|
NOTE: Does not work if method is OPLIST, KEY_OPLIST or VALUE_OPLIST.
|
||||||
|
|||||||
@@ -706,6 +706,14 @@ static void test_M_CSTR(void)
|
|||||||
assert (r == 0);
|
assert (r == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_properties(void)
|
||||||
|
{
|
||||||
|
#define OP_PROP() ( INIT(init), PROPERTIES((INIT(1), IT_TYPE(2), INIT_WITH(priority))) )
|
||||||
|
assert( M_GET_OPPROPERTY (OP_PROP(), INIT ) == 1);
|
||||||
|
assert( M_GET_OPPROPERTY (OP_PROP(), CLEAR ) == 0);
|
||||||
|
assert( M_GET_OPPROPERTY (OP_PROP(), IT_TYPE ) == 2);
|
||||||
|
assert( M_KEYWORD_P( M_GET_OPPROPERTY (OP_PROP(), INIT_WITH ), priority));
|
||||||
|
}
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
test_cat();
|
test_cat();
|
||||||
@@ -730,5 +738,6 @@ int main(void)
|
|||||||
test_builtin();
|
test_builtin();
|
||||||
test_str_hash();
|
test_str_hash();
|
||||||
test_M_CSTR();
|
test_M_CSTR();
|
||||||
|
test_properties();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user