changelog & news...

On Thu, Mar 1, 2012 at 6:15 PM, Enlightenment SVN
<no-re...@enlightenment.org> wrote:
> Log:
> Eina: Add eina_value_array_value_get().
>
>  Since k-s is on the road this days, we'd better write some code ourselves.
>  This is array counterpart of eina_value_struct_value_get(), and retrieves
>  an item from an Eina_Value_Array as an Eina_Value.
>
>  Code writing the setter is welcome.
>
>  Patch by: "Raphael Kubo da Costa" <k...@profusion.mobi>
>
>
> Author:       bdilly
> Date:         2012-03-01 09:15:54 -0800 (Thu, 01 Mar 2012)
> New Revision: 68581
> Trac:         http://trac.enlightenment.org/e/changeset/68581
>
> Modified:
>  trunk/eina/src/include/eina_inline_value.x 
> trunk/eina/src/include/eina_value.h trunk/eina/src/tests/eina_test_value.c
>
> Modified: trunk/eina/src/include/eina_inline_value.x
> ===================================================================
> --- trunk/eina/src/include/eina_inline_value.x  2012-03-01 16:42:03 UTC (rev 
> 68580)
> +++ trunk/eina/src/include/eina_inline_value.x  2012-03-01 17:15:54 UTC (rev 
> 68581)
> @@ -823,6 +823,29 @@
>    return EINA_FALSE;
>  }
>
> +static inline Eina_Bool
> +eina_value_array_value_get(const Eina_Value *src, unsigned int position, 
> Eina_Value *dst)
> +{
> +   Eina_Value_Array desc;
> +
> +   EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(src, EINA_FALSE);
> +   EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
> +
> +   if (!eina_value_pget(src, &desc))
> +     return EINA_FALSE;
> +   if (position >= eina_inarray_count(desc.array))
> +     return EINA_FALSE;
> +   if (!eina_value_setup(dst, desc.subtype))
> +     return EINA_FALSE;
> +   if (!eina_value_pset(dst, eina_inarray_nth(desc.array, position)))
> +     {
> +        eina_value_flush(dst);
> +        return EINA_FALSE;
> +     }
> +
> +   return EINA_TRUE;
> +}
> +
>  #undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL
>
>  #define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval)   \
>
> Modified: trunk/eina/src/include/eina_value.h
> ===================================================================
> --- trunk/eina/src/include/eina_value.h 2012-03-01 16:42:03 UTC (rev 68580)
> +++ trunk/eina/src/include/eina_value.h 2012-03-01 17:15:54 UTC (rev 68581)
> @@ -1720,6 +1720,22 @@
>                                                  const void *ptr) 
> EINA_ARG_NONNULL(1);
>
>  /**
> + * @brief Retrieves a value from the array as an Eina_Value copy.
> + * @param value source value object
> + * @param position index of the member
> + * @param dst where to return the array member
> + * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
> + *
> + * The argument @a dst is considered uninitialized and it's setup to
> + * the type of the member.
> + *
> + * @since 1.2
> + */
> +static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src,
> +                                                   unsigned int position,
> +                                                   Eina_Value *dst) 
> EINA_ARG_NONNULL(1, 3);
> +
> +/**
>  * @}
>  */
>
>
> Modified: trunk/eina/src/tests/eina_test_value.c
> ===================================================================
> --- trunk/eina/src/tests/eina_test_value.c      2012-03-01 16:42:03 UTC (rev 
> 68580)
> +++ trunk/eina/src/tests/eina_test_value.c      2012-03-01 17:15:54 UTC (rev 
> 68581)
> @@ -1750,7 +1750,7 @@
>      EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH,
>      myst_members, 4, sizeof(struct myst)
>    };
> -   Eina_Value *value;
> +   Eina_Value *value, array_item;
>    char *str;
>    int i;
>
> @@ -1792,6 +1792,17 @@
>                       "]") == 0);
>    free(str);
>
> +   eina_value_array_value_get(value, 2, &array_item);
> +   eina_value_struct_get(&array_item, "a", &i);
> +   ck_assert_int_eq(i, 2);
> +   eina_value_struct_get(&array_item, "b", &i);
> +   ck_assert_int_eq(i, 20);
> +   eina_value_struct_get(&array_item, "c", &i);
> +   ck_assert_int_eq(i, 200);
> +   eina_value_struct_get(&array_item, "s", &str);
> +   ck_assert_str_eq(str, "item02");
> +   eina_value_flush(&array_item);
> +
>    eina_value_free(value);
>    eina_shutdown();
>  }
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> enlightenment-svn mailing list
> enlightenment-...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to