On Tue, Jun 30, 2009 at 4:18 AM, Hanspeter Portner<[email protected]> wrote:
> hey there
>
> I'd like to seriailze this structure with Eet
>
> <code>
> typedef enum _Type Type;
> typedef struct _Value Value;
>
> enum _Type {NUMBER, STRING, ARRAY, OBJECT};
>
> struct _Value {
>    Type type;
>    union {
>       float number;
>       char *string;
>       Eina_List *array;
>       Eina_Hash *object;
>    } data;
> };
> </code>
>
> if the union instead would be a struct, I could use
>
> <code>
> EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Value, "type", type, EET_T_INT);
> EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Value, "data.number", data.number,
> EET_T_FLOAT);
> EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Value, "data.string", data.string,
> EET_T_FLOAT);
> EET_DATA_DESCRIPTOR_ADD_LIST(edd, Value, "data.array", data.array, edd);
> EET_DATA_DESCRIPTOR_ADD_HASH(edd, Value, "data.object", data.object, edd);
> </code>
>
> but what if I'd like to use the union to safe some space?
> with the code above I'd have four entries for the same address :-(
> is there a method/workaround to do this without changing the structure?

Sorry, but Eet does not handle unions, at least at this point. We had
this requirement for ETK based description language, so you're not the
first one to ask for it.

But no one have time to implement it at this point. It should not be
so difficult, you'd need something like the list/hash/array with
sub-descriptors. But since EET must know the type, it should be eet
type (EET_T_UINT, etc... including sub-types).

So far, if you don't have huge amount of elements, I'd suggest to use
the struct and live with those spare bytes being lost, 24bytes in your
case for 64bits machine.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
enlightenment-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-users

Reply via email to