From 1838a490ba4383b7d2dd7f3d7e22522eb564ebc8 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 8 Sep 2018 09:47:47 +0200 Subject: [PATCH] Update doc --- README.md | 5 ++++- m-core.h | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8623f595..b7678c0b 100644 --- a/README.md +++ b/README.md @@ -1911,6 +1911,7 @@ The following methods are automatically and properly created by the previous mac ##### void name\_init(name\_t tuple) Initialize the tuple 'tuple' (aka constructor) to an empty tuple. +This method is defined if all methods define an INIT method. ##### void name\_init\_set(name\_t tuple, const name\_t ref) @@ -2055,7 +2056,7 @@ After-wise 'ref' is cleared. This method is created only if all oplists of the variant define INIT\_MOVE method. ##### void name\_move(name\_t variant, name\_t ref) -##### void name\_move_elementN(name\_t variant, typeN ref) +##### void name\_move\_elementN(name\_t variant, typeN ref) Set the variant 'variant' by stealing as many resources from 'ref' as possible. After-wise 'ref' is cleared. @@ -2072,6 +2073,7 @@ Clean the variant 'variant and make it empty. ##### void name\_init_elementN(name\_t variant) Initialize the variant 'variant' to the type of 'element1' +This method is defined if all methods define an INIT method. ##### void name\_init\_set_elementN(name\_t variant, const typeN elementN) @@ -2133,6 +2135,7 @@ Read a string representation of the variant from the stream 'file' and update the object variant with it. All types associated to the variant shall have a in\_str function for this function to be defined. +This method is defined if all methods define an INIT method. ### M-RBTREE diff --git a/m-core.h b/m-core.h index 813a47d2..71a36f6d 100644 --- a/m-core.h +++ b/m-core.h @@ -2107,6 +2107,13 @@ m_core_hash (const void *str, size_t length) #define M_IF_METHOD_ALL(method, ...) \ M_IF(M_REDUCE2(M_TEST_METHOD_P, M_AND, method, __VA_ARGS__)) +/* Perform a preprocessing M_IF if both methods exist for all oplist. + Example: M_IF_METHOD2_ALL(HASH, INIT, oplist1, oplist2) (define function with HASH & INIT methods, ) */ +#define M_IF_METHOD2_ALL(method1, method2, ...) \ + M_IF(M_REDUCE2(M_TEST_METHOD2_P, M_AND, (method1, method2), __VA_ARGS__)) +#define M_TEST_METHOD2_P(method_pair, oplist) \ + M_AND(M_TEST_METHOD_P(M_PAIR_1 method_pair, oplist), M_TEST_METHOD_P(M_PAIR_2 method_pair, oplist)) + /* By putting this after a method in an oplist, we transform the argument list so that the first argument becomes a pointer to the destination. */ #define M_IPTR(...) ( & __VA_ARGS__ )