From 5bfdc435c77cf5768437d7a42323e97f601ffa38 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Mon, 5 Mar 2018 13:33:44 -0800 Subject: [PATCH] eina: improve EINA_VALUE_ARRAY_FOREACH to not systematically require &. --- src/lib/eina/eina_value.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/lib/eina/eina_value.h b/src/lib/eina/eina_value.h index f413a73d94..49d0700a61 100644 --- a/src/lib/eina/eina_value.h +++ b/src/lib/eina/eina_value.h @@ -1828,6 +1828,7 @@ static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src, /** * @def EINA_VALUE_ARRAY_FOREACH * @brief Definition for the macro to iterate over an array contained in an Eina_Value. + * @since 1.21 * * @param array The list to iterate over. * @param length Contain the length of the array @@ -1843,21 +1844,16 @@ static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src, * Eina_Value array; * Eina_Error err; * unsigned int i, len; - * Eina_Value v = EINA_VALUE_EMPTY; * - * // array is already filled, + * // array is already filled with EINA_VALUE_TYPE_ERROR, * // its elements are unknown, * // EINA_VALUE_ARRAY_FOREACH will be used to check if there is no error * * - * EINA_VALUE_ARRAY_FOREACH(&array, len, i, &v) + * EINA_VALUE_ARRAY_FOREACH(&array, len, i, err) * { - * if (v.type == EINA_VALUE_TYPE_ERROR) - * { - * eina_value_get(&v, &err); - * fprintf(stderr, "Something has gone wrong: %s at index: %i\n", eina_error_msg_get(err), i); - * abort(); - * } + * eina_value_get(&v, &err); + * fprintf(stderr, "Something has gone wrong: %s at index: %i\n", eina_error_msg_get(err), i); * } * @endcode * @@ -1866,10 +1862,10 @@ static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src, #define EINA_VALUE_ARRAY_FOREACH(Array, Length, It, Value) \ for (Length = eina_value_array_count(Array), \ It = 0, \ - eina_value_array_get(Array, It, Value); \ + eina_value_array_get(Array, It, &Value); \ It < Length; \ It++, \ - eina_value_array_get(Array, It, Value)) + eina_value_array_get(Array, It, &Value)) /** * @}