eet: added EET_DATA_DESCRIPTOR_ADD_SUB_NESTED().

This commit is contained in:
Christophe Sadoine 2013-09-06 11:30:37 +09:00 committed by Cedric Bail
parent a7fe49139d
commit 87b17f1ce9
4 changed files with 57 additions and 9 deletions

View File

@ -1,3 +1,7 @@
2013-09-06 Christophe Sadoine
* Eet: Added EET_DATA_DESCRIPTOR_ADD_SUB_NESTED().
2013-09-24 Jorge Zapata
* Eina: add a substraction in rectangles and more helpers,

1
NEWS
View File

@ -45,6 +45,7 @@ Additions:
- Add eet_mmap()
- Add eet_data_descriptor_name_get()
- Add support EET_T_VALUE
- Add EET_DATA_DESCRIPTOR_ADD_SUB_NESTED()
* Eo:
- Add generic efl object infrastructure
- Add debugging facility

View File

@ -2391,7 +2391,8 @@ eet_identity_certificate_print(const unsigned char *certificate,
#define EET_G_HASH 104 /**< Hash table group type */
#define EET_G_UNION 105 /**< Union group type */
#define EET_G_VARIANT 106 /**< Selectable subtype group */
#define EET_G_LAST 107 /**< Last group type */
#define EET_G_UNKNOWN_NESTED 107 /**< Unknown nested group type. @since 1.8 */
#define EET_G_LAST 108 /**< Last group type */
#define EET_I_LIMIT 128 /**< Other type exist but are reserved for internal purpose. */
@ -3097,6 +3098,32 @@ eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
0, /* 0, */ NULL, subtype); \
} while (0)
/**
* Add a nested sub-element type to a data descriptor
* @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct.
* @param name The string name to use to encode/decode this member
* (must be a constant global and never change).
* @param member The struct member itself to be encoded.
* @param subtype The type of sub-type struct to add.
*
* This macro lets you easily add a sub-type: a struct that is nested into
* this one. If your data is pointed by this element instead of being nested,
* you should use EET_DATA_DESCRIPTOR_ADD_SUB().
* All the parameters are the same as for EET_DATA_DESCRIPTOR_ADD_SUB().
*
* @since 1.8.0
* @ingroup Eet_Data_Group
*/
#define EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(edd, struct_type, name, member, subtype) \
do { \
struct_type ___ett; \
eet_data_descriptor_element_add(edd, name, EET_T_UNKNOW, EET_G_UNKNOWN_NESTED, \
(char *)(& (___ett.member)) - \
(char *)(& (___ett)), \
0, /* 0, */ NULL, subtype); \
} while (0)
/**
* Add a linked list type to a data descriptor
* @param edd The data descriptor to add the type to.

View File

@ -548,7 +548,8 @@ static const Eet_Data_Group_Type_Codec eet_group_codec[] =
{ eet_data_get_list, eet_data_put_list },
{ eet_data_get_hash, eet_data_put_hash },
{ eet_data_get_union, eet_data_put_union },
{ eet_data_get_variant, eet_data_put_variant }
{ eet_data_get_variant, eet_data_put_variant },
{ eet_data_get_unknown, eet_data_put_unknown }
};
static int _eet_data_words_bigendian = -1;
@ -4570,8 +4571,16 @@ eet_data_get_unknown(Eet_Free_Context *context,
if (edd)
{
ptr = (void **)(((char *)data));
*ptr = (void *)data_ret;
if (subtype && ede->group_type == EET_G_UNKNOWN_NESTED)
{
memcpy(data, data_ret, subtype->size);
free(data_ret);
}
else
{
ptr = (void **)(((char *)data));
*ptr = (void *)data_ret;
}
}
else
{
@ -4680,11 +4689,18 @@ eet_data_put_unknown(Eet_Dictionary *ed,
if (IS_SIMPLE_TYPE(ede->type))
data = eet_data_put_type(ed, ede->type, data_in, &size);
else if (ede->subtype)
if (*((char **)data_in))
data = _eet_data_descriptor_encode(ed,
ede->subtype,
*((char **)((char *)(data_in))),
&size);
{
if (ede->group_type == EET_G_UNKNOWN_NESTED)
data = _eet_data_descriptor_encode(ed,
ede->subtype,
data_in,
&size);
else if (*((char **)data_in))
data = _eet_data_descriptor_encode(ed,
ede->subtype,
*((char **)((char *)(data_in))),
&size);
}
if (data)
eet_data_encode(ed,