On Wed, Jan 11, 2012 at 11:41 AM, Vincent Torri <[email protected]> wrote:
> On Wed, Jan 11, 2012 at 11:37 AM, Enlightenment SVN
> <[email protected]> wrote:
>> Log:
>> eina: massiv fix for Eina_Value.
>>
>> Should be more portable and work with C++.
>>
>> NOTE: I still see an aliasing break in eina_value_pset, but wasn't
>> able to figure how to solve it.
>>
>>
>> Author: cedric
>> Date: 2012-01-11 02:37:13 -0800 (Wed, 11 Jan 2012)
>> New Revision: 67065
>> Trac: http://trac.enlightenment.org/e/changeset/67065
>>
>> Modified:
>> trunk/eina/src/include/eina_inline_value.x
>> trunk/eina/src/include/eina_value.h trunk/eina/src/lib/eina_value.c
>>
>> Modified: trunk/eina/src/include/eina_inline_value.x
>> ===================================================================
>> --- trunk/eina/src/include/eina_inline_value.x 2012-01-11 10:35:52 UTC (rev
>> 67064)
>> +++ trunk/eina/src/include/eina_inline_value.x 2012-01-11 10:37:13 UTC (rev
>> 67065)
>> @@ -20,6 +20,8 @@
>> #define EINA_INLINE_VALUE_X_
>>
>> #include <string.h>
>> +#include <alloca.h>
>
> aaaaaaaaarrrrrrrrggggggg : not portable at all !!!!!!!
Damn forgot that one. It was just a missing header. Hum, we need to
have an EINA_HAVE_ALLOCA or something like that now, I guess.
>> +
>> #include "eina_stringshare.h"
>>
>> /* NOTE: most of value is implemented here for performance reasons */
>> @@ -127,7 +129,7 @@
>> {
>> if (type == EINA_VALUE_TYPE_STRINGSHARE)
>> {
>> - if (value->value.ptr) eina_stringshare_del(value->value.ptr);
>> + if (value->value.ptr) eina_stringshare_del((const char*)
>> value->value.ptr);
>> }
>> else if (type == EINA_VALUE_TYPE_STRING)
>> {
>> @@ -161,7 +163,7 @@
>> #ifndef EINA_VALUE_NO_OPTIMIZE
>> if (type == EINA_VALUE_TYPE_UCHAR)
>> {
>> - unsigned char *ta = pa, *tb = pb;
>> + unsigned char *ta = (unsigned char *) pa, *tb = (unsigned char *)
>> pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -170,7 +172,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_USHORT)
>> {
>> - unsigned short *ta = pa, *tb = pb;
>> + unsigned short *ta = (unsigned short *) pa, *tb = (unsigned short
>> *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -179,7 +181,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_UINT)
>> {
>> - unsigned int *ta = pa, *tb = pb;
>> + unsigned int *ta = (unsigned int *) pa, *tb = (unsigned int *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -188,7 +190,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_ULONG)
>> {
>> - unsigned long *ta = pa, *tb = pb;
>> + unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *)
>> pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -197,7 +199,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_UINT64)
>> {
>> - uint64_t *ta = pa, *tb = pb;
>> + uint64_t *ta = (uint64_t *) pa, *tb = (uint64_t *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -206,7 +208,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_CHAR)
>> {
>> - char *ta = pa, *tb = pb;
>> + char *ta = (char *) pa, *tb = (char *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -215,7 +217,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_SHORT)
>> {
>> - short *ta = pa, *tb = pb;
>> + short *ta = (short *) pa, *tb = (short *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -224,7 +226,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_INT)
>> {
>> - int *ta = pa, *tb = pb;
>> + int *ta = (int *) pa, *tb = (int *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -233,7 +235,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_LONG)
>> {
>> - long *ta = pa, *tb = pb;
>> + long *ta = (long *) pa, *tb = (long *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -242,7 +244,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_INT64)
>> {
>> - int64_t *ta = pa, *tb = pb;
>> + int64_t *ta = (int64_t *) pa, *tb = (int64_t *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -251,7 +253,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_FLOAT)
>> {
>> - float *ta = pa, *tb = pb;
>> + float *ta = (float *) pa, *tb = (float *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -260,7 +262,7 @@
>> }
>> else if (type == EINA_VALUE_TYPE_DOUBLE)
>> {
>> - double *ta = pa, *tb = pb;
>> + double *ta = (double *) pa, *tb = (double *) pb;
>> if (*ta < *tb)
>> return -1;
>> else if (*ta > *tb)
>> @@ -322,84 +324,84 @@
>> #ifndef EINA_VALUE_NO_OPTIMIZE
>> if (type == EINA_VALUE_TYPE_UCHAR)
>> {
>> - unsigned char *tmem = mem;
>> + unsigned char *tmem = (unsigned char *) mem;
>> *tmem = va_arg(args, unsigned int); /* promoted by va_arg */
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_USHORT)
>> {
>> - unsigned short *tmem = mem;
>> + unsigned short *tmem = (unsigned short *) mem;
>> *tmem = va_arg(args, unsigned int); /* promoted by va_arg */
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_UINT)
>> {
>> - unsigned int *tmem = mem;
>> + unsigned int *tmem = (unsigned int *) mem;
>> *tmem = va_arg(args, unsigned int);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_ULONG)
>> {
>> - unsigned long *tmem = mem;
>> + unsigned long *tmem = (unsigned long *) mem;
>> *tmem = va_arg(args, unsigned long);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_UINT64)
>> {
>> - uint64_t *tmem = mem;
>> + uint64_t *tmem = (uint64_t *) mem;
>> *tmem = va_arg(args, uint64_t);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_CHAR)
>> {
>> - char *tmem = mem;
>> + char *tmem = (char *) mem;
>> *tmem = va_arg(args, int); /* promoted by va_arg */
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_SHORT)
>> {
>> - short *tmem = mem;
>> + short *tmem = (short *) mem;
>> *tmem = va_arg(args, int); /* promoted by va_arg */
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_INT)
>> {
>> - int *tmem = mem;
>> + int *tmem = (int *) mem;
>> *tmem = va_arg(args, int);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_LONG)
>> {
>> - long *tmem = mem;
>> + long *tmem = (long *) mem;
>> *tmem = va_arg(args, long);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_INT64)
>> {
>> - int64_t *tmem = mem;
>> + int64_t *tmem = (int64_t *) mem;
>> *tmem = va_arg(args, int64_t);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_FLOAT)
>> {
>> - float *tmem = mem;
>> + float *tmem = (float *) mem;
>> *tmem = va_arg(args, double); /* promoted by va_arg */
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_DOUBLE)
>> {
>> - double *tmem = mem;
>> + double *tmem = (double *) mem;
>> *tmem = va_arg(args, double);
>> return EINA_TRUE;
>> }
>> else if (type == EINA_VALUE_TYPE_STRINGSHARE)
>> {
>> - const char *str = va_arg(args, const char *);
>> + const char *str = (const char *) va_arg(args, const char *);
>> return eina_stringshare_replace((const char **)&value->value.ptr,
>> str);
>> }
>> else if (type == EINA_VALUE_TYPE_STRING)
>> {
>> - const char *str = va_arg(args, const char *);
>> + const char *str = (const char *) va_arg(args, const char *);
>> free(value->value.ptr);
>> if (!str)
>> value->value.ptr = NULL;
>> @@ -460,19 +462,23 @@
>> {
>> if (type == EINA_VALUE_TYPE_STRINGSHARE)
>> {
>> - const char * const *str = ptr;
>> + const char * const *pstr = (const char * const *) ptr;
>> + const char *str = *pstr;
>> +
>> return eina_stringshare_replace((const char
>> **)&value->value.ptr,
>> - *str);
>> + str);
>> }
>> else if (type == EINA_VALUE_TYPE_STRING)
>> {
>> - const char * const *str = ptr;
>> + const char * const * pstr = (const char * const *) ptr;
>> + const char *str = *pstr;
>> +
>> free(value->value.ptr);
>> - if (!*str)
>> + if (!str)
>> value->value.ptr = NULL;
>> else
>> {
>> - value->value.ptr = strdup(*str);
>> + value->value.ptr = strdup(str);
>> if (!value->value.ptr)
>> {
>> eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
>> @@ -526,7 +532,7 @@
>> static inline Eina_Bool
>> eina_value_array_setup(Eina_Value *value, const Eina_Value_Type *subtype,
>> unsigned int step)
>> {
>> - Eina_Value_Array desc = {subtype, step, NULL};
>> + Eina_Value_Array desc = { subtype, step, NULL };
>> if (!eina_value_setup(value, EINA_VALUE_TYPE_ARRAY))
>> return EINA_FALSE;
>> if (!eina_value_pset(value, &desc))
>>
>> Modified: trunk/eina/src/include/eina_value.h
>> ===================================================================
>> --- trunk/eina/src/include/eina_value.h 2012-01-11 10:35:52 UTC (rev 67064)
>> +++ trunk/eina/src/include/eina_value.h 2012-01-11 10:37:13 UTC (rev 67065)
>> @@ -681,7 +681,7 @@
>> const Eina_Value_Type *subtype; /**< how to allocate and access items */
>> unsigned int step; /**< how to grow the members array */
>> Eina_Inarray *array; /**< the array that holds data, members are of
>> subtype->value_size bytes. */
>> - };
>> +};
>>
>> /**
>> * @brief Create generic value storage of type array.
>>
>> Modified: trunk/eina/src/lib/eina_value.c
>> ===================================================================
>> --- trunk/eina/src/lib/eina_value.c 2012-01-11 10:35:52 UTC (rev 67064)
>> +++ trunk/eina/src/lib/eina_value.c 2012-01-11 10:37:13 UTC (rev 67065)
>> @@ -28,10 +28,9 @@
>> # include "config.h"
>> #endif
>>
>> -/* _GNU_SOURCE: asprintf() */
>> -#ifndef _GNU_SOURCE
>> -#define _GNU_SOURCE
>> -#endif
>> +#include <stdio.h> /* asprintf() */
>> +#include <inttypes.h> /* PRId64 and PRIu64 */
>> +
>> #include "eina_config.h"
>> #include "eina_private.h"
>> #include "eina_error.h"
>> @@ -42,9 +41,6 @@
>> #include "eina_safety_checks.h"
>> #include "eina_value.h"
>>
>> -#include <stdio.h> /* asprintf() */
>> -#include <inttypes.h> /* PRId64 and PRIu64 */
>> -
>> /*============================================================================*
>> * Local
>> *
>> *============================================================================*/
>> @@ -981,7 +977,7 @@
>> static Eina_Bool
>> _eina_value_type_char_convert_to(const Eina_Value_Type *type __UNUSED__,
>> const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
>> {
>> - const char v = *(const char *)type_mem;
>> + const signed char v = *(const signed char *)type_mem;
>>
>> eina_error_set(0);
>>
>> @@ -1518,7 +1514,7 @@
>> unsigned char other_mem = v;
>> if (EINA_UNLIKELY(v < 0))
>> return EINA_FALSE;
>> - if (EINA_UNLIKELY(v > eina_value_uchar_max))
>> + if (EINA_UNLIKELY((unsigned long) v > eina_value_uchar_max))
>> return EINA_FALSE;
>> return eina_value_type_pset(convert, convert_mem, &other_mem);
>> }
>> @@ -1527,7 +1523,7 @@
>> unsigned short other_mem = v;
>> if (EINA_UNLIKELY(v < 0))
>> return EINA_FALSE;
>> - if (EINA_UNLIKELY(v > eina_value_ushort_max))
>> + if (EINA_UNLIKELY((unsigned long) v > eina_value_ushort_max))
>> return EINA_FALSE;
>> return eina_value_type_pset(convert, convert_mem, &other_mem);
>> }
>> @@ -1536,7 +1532,7 @@
>> unsigned int other_mem = v;
>> if (EINA_UNLIKELY(v < 0))
>> return EINA_FALSE;
>> - if (EINA_UNLIKELY(v > eina_value_uint_max))
>> + if (EINA_UNLIKELY((unsigned long) v > eina_value_uint_max))
>> return EINA_FALSE;
>> return eina_value_type_pset(convert, convert_mem, &other_mem);
>> }
>>
>>
>> ------------------------------------------------------------------------------
>> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
>> infrastructure or vast IT resources to deliver seamless, secure access to
>> virtual desktops. With this all-in-one solution, easily deploy virtual
>> desktops for less than the cost of PCs and save 60% on VDI infrastructure
>> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
>> _______________________________________________
>> enlightenment-svn mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-svn
>
> ------------------------------------------------------------------------------
> Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
> infrastructure or vast IT resources to deliver seamless, secure access to
> virtual desktops. With this all-in-one solution, easily deploy virtual
> desktops for less than the cost of PCs and save 60% on VDI infrastructure
> costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
> _______________________________________________
> enlightenment-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
--
Cedric BAIL
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel