summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristophe Sadoine <chris@indefini.org>2013-11-04 15:33:12 +0900
committerCedric Bail <cedric.bail@samsung.com>2013-11-04 15:35:41 +0900
commit6853dbcf23f71038a14fb4e44c0011dbb475821c (patch)
treefa4a7a79e55d4c88b79975d3394e3010db7b365d /src/lib
parentcff3ec04b4d234c8ef59f9d6235e85b725e0bcf3 (diff)
eet: Adding EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC to add a basic type to a union.
I added EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC because I need basic types in unions, and EET_DATA_DESCRIPTOR_ADD_MAPPING is only for structs. I also modified the example with a float and a string. Reviewers: cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D313 Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eet/Eet.h19
-rw-r--r--src/lib/eet/eet_data.c28
2 files changed, 42 insertions, 5 deletions
diff --git a/src/lib/eet/Eet.h b/src/lib/eet/Eet.h
index 12e8c98a89..de57e4a3d7 100644
--- a/src/lib/eet/Eet.h
+++ b/src/lib/eet/Eet.h
@@ -3463,6 +3463,25 @@ eet_data_descriptor_encode(Eet_Data_Descriptor *edd,
3463 subtype) 3463 subtype)
3464 3464
3465/** 3465/**
3466 * Add a mapping of a basic type to a data descriptor that will be used by a union type.
3467 * @param unified_type The data descriptor to add the mapping to.
3468 * @param name The string name to get/set type.
3469 * @param basic_type The matching basic type.
3470 *
3471 * @since 1.8
3472 * @ingroup Eet_Data_Group
3473 * @see Eet_Data_Descriptor_Class
3474 */
3475#define EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC(unified_type, name, basic_type) \
3476 eet_data_descriptor_element_add(unified_type, \
3477 name, \
3478 basic_type, \
3479 EET_G_UNKNOWN, \
3480 0, \
3481 0, \
3482 NULL, \
3483 NULL)
3484/**
3466 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers 3485 * @defgroup Eet_Data_Cipher_Group Eet Data Serialization using A Ciphers
3467 * 3486 *
3468 * Most of the @ref Eet_Data_Group have alternative versions that 3487 * Most of the @ref Eet_Data_Group have alternative versions that
diff --git a/src/lib/eet/eet_data.c b/src/lib/eet/eet_data.c
index e4a0d26d68..33134b29a0 100644
--- a/src/lib/eet/eet_data.c
+++ b/src/lib/eet/eet_data.c
@@ -4060,7 +4060,11 @@ eet_data_put_union(Eet_Dictionary *ed,
4060 ede->group_type); 4060 ede->group_type);
4061 4061
4062 sede = &(ede->subtype->elements.set[i]); 4062 sede = &(ede->subtype->elements.set[i]);
4063 data = _eet_data_descriptor_encode(ed, 4063
4064 if (IS_SIMPLE_TYPE(sede->type))
4065 data = eet_data_put_type(ed, sede->type, data_in, &size);
4066 else
4067 data = _eet_data_descriptor_encode(ed,
4064 sede->subtype, 4068 sede->subtype,
4065 data_in, 4069 data_in,
4066 &size); 4070 &size);
@@ -4126,17 +4130,31 @@ eet_data_get_union(Eet_Free_Context *context,
4126 4130
4127 /* Yeah we found it ! */ 4131 /* Yeah we found it ! */
4128 sede = &(ede->subtype->elements.set[i]); 4132 sede = &(ede->subtype->elements.set[i]);
4129 EET_ASSERT(sede->subtype, goto on_error);
4130 4133
4131 data_ret = _eet_data_descriptor_decode(context, 4134 if (IS_SIMPLE_TYPE(sede->type))
4135 {
4136 ret = eet_data_get_type(ed,
4137 sede->type,
4138 echnk->data,
4139 ((char *)echnk->data) + echnk->size,
4140 (char *)data);
4141
4142 if (ret <= 0)
4143 return ret;
4144 }
4145 else
4146 {
4147 EET_ASSERT(sede->subtype, goto on_error);
4148 data_ret = _eet_data_descriptor_decode(context,
4132 ed, 4149 ed,
4133 sede->subtype, 4150 sede->subtype,
4134 echnk->data, 4151 echnk->data,
4135 echnk->size, 4152 echnk->size,
4136 data, 4153 data,
4137 sede->subtype->size); 4154 sede->subtype->size);
4138 if (!data_ret) 4155 if (!data_ret)
4139 goto on_error; 4156 goto on_error;
4157 }
4140 4158
4141 /* Set union type. */ 4159 /* Set union type. */
4142 if ((!ed) || (!ede->subtype->func.str_direct_alloc)) 4160 if ((!ed) || (!ede->subtype->func.str_direct_alloc))