diff options
Diffstat (limited to '')
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/examples/eet/eet-data-file_descriptor_02.c | 98 | ||||
-rw-r--r-- | src/lib/eet/Eet.h | 19 | ||||
-rw-r--r-- | src/lib/eet/eet_data.c | 28 |
6 files changed, 144 insertions, 7 deletions
@@ -68,6 +68,7 @@ Mike Blumenkrantz <michael.blumenkrantz@gmail.com> | |||
68 | Lionel Orry <lionel.orry@gmail.com> | 68 | Lionel Orry <lionel.orry@gmail.com> |
69 | Jérôme Pinot <ngc891@gmail.com> | 69 | Jérôme Pinot <ngc891@gmail.com> |
70 | Leandro Santiago <leandrosansilva@gmail.com> | 70 | Leandro Santiago <leandrosansilva@gmail.com> |
71 | Christophe Sadoine <chris@indefini.org> | ||
71 | 72 | ||
72 | Eo | 73 | Eo |
73 | -- | 74 | -- |
@@ -1,3 +1,7 @@ | |||
1 | 2013-11-03 Christophe Sadoine | ||
2 | |||
3 | * Eet: Added EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC(). | ||
4 | |||
1 | 2013-10-24 Sung W. Park (sung_) | 5 | 2013-10-24 Sung W. Park (sung_) |
2 | 6 | ||
3 | * EvasGL: Fixed direct rendering mode not clipping to its clip region. | 7 | * EvasGL: Fixed direct rendering mode not clipping to its clip region. |
@@ -47,6 +47,7 @@ Additions: | |||
47 | - Add eet_data_descriptor_name_get() | 47 | - Add eet_data_descriptor_name_get() |
48 | - Add support EET_T_VALUE | 48 | - Add support EET_T_VALUE |
49 | - Add EET_DATA_DESCRIPTOR_ADD_SUB_NESTED() | 49 | - Add EET_DATA_DESCRIPTOR_ADD_SUB_NESTED() |
50 | - Add EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC() | ||
50 | * Eo: | 51 | * Eo: |
51 | - Add generic efl object infrastructure | 52 | - Add generic efl object infrastructure |
52 | - Add debugging facility | 53 | - Add debugging facility |
diff --git a/src/examples/eet/eet-data-file_descriptor_02.c b/src/examples/eet/eet-data-file_descriptor_02.c index bfd34d13e4..cba0377458 100644 --- a/src/examples/eet/eet-data-file_descriptor_02.c +++ b/src/examples/eet/eet-data-file_descriptor_02.c | |||
@@ -23,7 +23,9 @@ enum _Example_Data_Type | |||
23 | EET_UNKNOWN = 0, | 23 | EET_UNKNOWN = 0, |
24 | EET_STRUCT1, | 24 | EET_STRUCT1, |
25 | EET_STRUCT2, | 25 | EET_STRUCT2, |
26 | EET_STRUCT3 | 26 | EET_STRUCT3, |
27 | EET_BASIC_FLOAT, | ||
28 | EET_BASIC_STRING | ||
27 | }; | 29 | }; |
28 | 30 | ||
29 | struct | 31 | struct |
@@ -34,6 +36,8 @@ struct | |||
34 | { EET_STRUCT1, "ST1" }, | 36 | { EET_STRUCT1, "ST1" }, |
35 | { EET_STRUCT2, "ST2" }, | 37 | { EET_STRUCT2, "ST2" }, |
36 | { EET_STRUCT3, "ST3" }, | 38 | { EET_STRUCT3, "ST3" }, |
39 | { EET_BASIC_FLOAT, "float" }, | ||
40 | { EET_BASIC_STRING, "string" }, | ||
37 | { EET_UNKNOWN, NULL } | 41 | { EET_UNKNOWN, NULL } |
38 | }; | 42 | }; |
39 | 43 | ||
@@ -63,6 +67,8 @@ struct _Example_Union | |||
63 | Example_Struct1 st1; | 67 | Example_Struct1 st1; |
64 | Example_Struct2 st2; | 68 | Example_Struct2 st2; |
65 | Example_Struct3 st3; | 69 | Example_Struct3 st3; |
70 | float f; | ||
71 | const char* string; | ||
66 | } u; | 72 | } u; |
67 | }; | 73 | }; |
68 | 74 | ||
@@ -288,6 +294,10 @@ _data_descriptors_init(void) | |||
288 | _union_unified_descriptor, "ST2", _struct_2_descriptor); | 294 | _union_unified_descriptor, "ST2", _struct_2_descriptor); |
289 | EET_DATA_DESCRIPTOR_ADD_MAPPING( | 295 | EET_DATA_DESCRIPTOR_ADD_MAPPING( |
290 | _union_unified_descriptor, "ST3", _struct_3_descriptor); | 296 | _union_unified_descriptor, "ST3", _struct_3_descriptor); |
297 | EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC( | ||
298 | _union_unified_descriptor, "float", EET_T_FLOAT); | ||
299 | EET_DATA_DESCRIPTOR_ADD_MAPPING_BASIC( | ||
300 | _union_unified_descriptor, "string", EET_T_STRING); | ||
291 | 301 | ||
292 | EET_DATA_DESCRIPTOR_ADD_UNION( | 302 | EET_DATA_DESCRIPTOR_ADD_UNION( |
293 | _union_descriptor, Example_Union, "u", u, type, | 303 | _union_descriptor, Example_Union, "u", u, type, |
@@ -404,6 +414,40 @@ _union_3_new(const char *v1) | |||
404 | return un; | 414 | return un; |
405 | } | 415 | } |
406 | 416 | ||
417 | static Example_Union * | ||
418 | _union_float_new(const char *v1) | ||
419 | { | ||
420 | Example_Union *un = calloc(1, sizeof(Example_Union)); | ||
421 | if (!un) | ||
422 | { | ||
423 | fprintf( | ||
424 | stderr, "ERROR: could not allocate an Example_Union struct.\n"); | ||
425 | return NULL; | ||
426 | } | ||
427 | |||
428 | un->type = EET_BASIC_FLOAT; | ||
429 | un->u.f = atof(v1); | ||
430 | |||
431 | return un; | ||
432 | } | ||
433 | |||
434 | static Example_Union * | ||
435 | _union_string_new(const char *v1) | ||
436 | { | ||
437 | Example_Union *un = calloc(1, sizeof(Example_Union)); | ||
438 | if (!un) | ||
439 | { | ||
440 | fprintf( | ||
441 | stderr, "ERROR: could not allocate an Example_Union struct.\n"); | ||
442 | return NULL; | ||
443 | } | ||
444 | |||
445 | un->type = EET_BASIC_STRING; | ||
446 | un->u.string = v1; | ||
447 | |||
448 | return un; | ||
449 | } | ||
450 | |||
407 | static Example_Variant * | 451 | static Example_Variant * |
408 | _variant_1_new(const char *v1, | 452 | _variant_1_new(const char *v1, |
409 | const char *v2, | 453 | const char *v2, |
@@ -624,6 +668,14 @@ _print_union(const Example_Union *un) | |||
624 | printf("\t\t val1: %i\n", un->u.st3.body); | 668 | printf("\t\t val1: %i\n", un->u.st3.body); |
625 | break; | 669 | break; |
626 | 670 | ||
671 | case EET_BASIC_FLOAT: | ||
672 | printf("\t\t float: %f\n", un->u.f); | ||
673 | break; | ||
674 | |||
675 | case EET_BASIC_STRING: | ||
676 | printf("\t\t string: %s\n", un->u.string); | ||
677 | break; | ||
678 | |||
627 | default: | 679 | default: |
628 | return; | 680 | return; |
629 | } | 681 | } |
@@ -712,7 +764,7 @@ main(int argc, | |||
712 | int type = atoi(argv[4]); | 764 | int type = atoi(argv[4]); |
713 | Example_Union *un; | 765 | Example_Union *un; |
714 | 766 | ||
715 | if (type < EET_STRUCT1 || type > EET_STRUCT3) | 767 | if (type < EET_STRUCT1 || type > EET_BASIC_STRING) |
716 | { | 768 | { |
717 | fprintf(stderr, | 769 | fprintf(stderr, |
718 | "ERROR: invalid type parameter (%s).\n", | 770 | "ERROR: invalid type parameter (%s).\n", |
@@ -786,6 +838,48 @@ main(int argc, | |||
786 | eina_list_append(data_lists->union_list, un); | 838 | eina_list_append(data_lists->union_list, un); |
787 | break; | 839 | break; |
788 | 840 | ||
841 | case EET_BASIC_FLOAT: | ||
842 | if (argc != 6) | ||
843 | { | ||
844 | fprintf( | ||
845 | stderr, "ERROR: wrong number of parameters" | ||
846 | " (%d).\n", argc); | ||
847 | goto cont; | ||
848 | } | ||
849 | |||
850 | un = _union_float_new(argv[5]); | ||
851 | if (!un) | ||
852 | { | ||
853 | fprintf( | ||
854 | stderr, "ERROR: could not create the " | ||
855 | "requested union.\n"); | ||
856 | goto cont; | ||
857 | } | ||
858 | data_lists->union_list = | ||
859 | eina_list_append(data_lists->union_list, un); | ||
860 | break; | ||
861 | |||
862 | case EET_BASIC_STRING: | ||
863 | if (argc != 6) | ||
864 | { | ||
865 | fprintf( | ||
866 | stderr, "ERROR: wrong number of parameters" | ||
867 | " (%d).\n", argc); | ||
868 | goto cont; | ||
869 | } | ||
870 | |||
871 | un = _union_string_new(argv[5]); | ||
872 | if (!un) | ||
873 | { | ||
874 | fprintf( | ||
875 | stderr, "ERROR: could not create the " | ||
876 | "requested union.\n"); | ||
877 | goto cont; | ||
878 | } | ||
879 | data_lists->union_list = | ||
880 | eina_list_append(data_lists->union_list, un); | ||
881 | break; | ||
882 | |||
789 | default: | 883 | default: |
790 | fprintf( | 884 | fprintf( |
791 | stderr, "ERROR: bad type of of struct passed\n"); | 885 | stderr, "ERROR: bad type of of struct passed\n"); |
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)) |