summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-06-05 13:23:45 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-06-05 13:40:26 -0700
commit1f8d3671380d645085f398032e6199ee8fd9c2ef (patch)
tree5be296bf74a31c021d3fa9f5f0ef1e3186d8d7ec /src/lib/eio
parent7ecc1815baa413f577faa3b92e50134491d9ef48 (diff)
eio: fix Efl.Io.Model properties iterator.
It kind of worked by luck for 6 months, but really shouldn't. This is now a custom iterator that will walk the string part of the properties only. It could become a generic iterator if necessary one day, but for now, it is fine just here. T7771 Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9075
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_model.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/lib/eio/efl_io_model.c b/src/lib/eio/efl_io_model.c
index b4ae262cae..3513852145 100644
--- a/src/lib/eio/efl_io_model.c
+++ b/src/lib/eio/efl_io_model.c
@@ -623,6 +623,62 @@ static struct {
623 PP(mime_type) 623 PP(mime_type)
624}; 624};
625 625
626typedef struct _Efl_Io_Model_Iterator Efl_Io_Model_Iterator;
627struct _Efl_Io_Model_Iterator
628{
629 Eina_Iterator iterator;
630 unsigned int i;
631 unsigned int end;
632};
633
634static Eina_Bool
635_efl_io_model_iterator_next(Efl_Io_Model_Iterator *it, void **data)
636{
637 const char **name = (const char **)data;
638
639 if (it->i >= it->end)
640 return EINA_FALSE;
641
642 *name = properties[it->i].name;
643 it->i++;
644
645 return EINA_TRUE;
646}
647
648static void*
649_efl_io_model_iterator_get_container(Efl_Io_Model_Iterator *it EINA_UNUSED)
650{
651 return &properties;
652}
653
654static void
655_efl_io_model_iterator_free(Efl_Io_Model_Iterator *it)
656{
657 free(it);
658}
659
660Eina_Iterator *
661_efl_io_model_properties_iterator_new(void)
662{
663 Efl_Io_Model_Iterator *it;
664
665 it = calloc(1, sizeof (Efl_Io_Model_Iterator));
666 if (!it) return NULL;
667
668 EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
669
670 it->i = 0;
671 it->end = EINA_C_ARRAY_LENGTH(properties);
672
673 it->iterator.version = EINA_ITERATOR_VERSION;
674 it->iterator.next = FUNC_ITERATOR_NEXT(_efl_io_model_iterator_next);
675 it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(
676 _efl_io_model_iterator_get_container);
677 it->iterator.free = FUNC_ITERATOR_FREE(_efl_io_model_iterator_free);
678
679 return &it->iterator;
680}
681
626/** 682/**
627 * Interfaces impl. 683 * Interfaces impl.
628 */ 684 */
@@ -630,7 +686,7 @@ static Eina_Iterator *
630_efl_io_model_efl_model_properties_get(const Eo *obj EINA_UNUSED, 686_efl_io_model_efl_model_properties_get(const Eo *obj EINA_UNUSED,
631 Efl_Io_Model_Data *pd EINA_UNUSED) 687 Efl_Io_Model_Data *pd EINA_UNUSED)
632{ 688{
633 return EINA_C_ARRAY_ITERATOR_NEW(properties); 689 return _efl_io_model_properties_iterator_new();
634} 690}
635 691
636static Eina_Value * 692static Eina_Value *