eina_value: list now adopts given Eina_List.
This should allow users to setup the array manually, in an efficient way, then make it an Eina_Value. SVN revision: 67146
This commit is contained in:
parent
d5de2617e0
commit
47b08d1a16
|
@ -227,6 +227,16 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY;
|
|||
* @li eina_value_list_vget() and eina_value_list_vset()
|
||||
* @li eina_value_list_pget() and eina_value_list_pset()
|
||||
*
|
||||
* eina_value_set() takes an #Eina_Value_List where just @c subtype is
|
||||
* used. If there is an @c list, it will be adopted and its contents
|
||||
* must be properly configurable as @c subtype
|
||||
* expects. eina_value_pset() takes a pointer to an #Eina_Value_List.
|
||||
* For your convenience, use eina_value_list_setup().
|
||||
*
|
||||
* eina_value_get() and eina_value_pget() takes a pointer to
|
||||
* #Eina_Value_List, it's an exact copy of the current structure in
|
||||
* use by value, no copies are done.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST;
|
||||
|
|
|
@ -2944,6 +2944,7 @@ _eina_value_type_list_pset(const Eina_Value_Type *type __UNUSED__, void *mem, co
|
|||
|
||||
_eina_value_type_list_flush_elements(tmem);
|
||||
tmem->subtype = desc->subtype;
|
||||
tmem->list = desc->list;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -1157,9 +1157,11 @@ END_TEST
|
|||
START_TEST(eina_value_test_list)
|
||||
{
|
||||
Eina_Value *value, other;
|
||||
Eina_Value_List desc;
|
||||
char c;
|
||||
char buf[1024];
|
||||
char *str;
|
||||
const char *s;
|
||||
|
||||
eina_init();
|
||||
|
||||
|
@ -1238,6 +1240,23 @@ START_TEST(eina_value_test_list)
|
|||
fail_unless(eina_value_get(&other, &c));
|
||||
fail_unless(c == 33);
|
||||
|
||||
desc.subtype = EINA_VALUE_TYPE_STRING;
|
||||
desc.list = NULL;
|
||||
desc.list = eina_list_append(desc.list, strdup("hello"));
|
||||
desc.list = eina_list_append(desc.list, strdup("world"));
|
||||
desc.list = eina_list_append(desc.list, strdup("eina"));
|
||||
fail_unless(eina_list_count(desc.list) == 3);
|
||||
fail_unless(eina_value_set(value, desc));
|
||||
fail_unless(eina_value_list_get(value, 0, &s));
|
||||
fail_unless(s != NULL);
|
||||
fail_unless(strcmp(s, "hello") == 0);
|
||||
fail_unless(eina_value_list_get(value, 1, &s));
|
||||
fail_unless(s != NULL);
|
||||
fail_unless(strcmp(s, "world") == 0);
|
||||
fail_unless(eina_value_list_get(value, 2, &s));
|
||||
fail_unless(s != NULL);
|
||||
fail_unless(strcmp(s, "eina") == 0);
|
||||
|
||||
eina_value_free(value);
|
||||
eina_shutdown();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue