summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-11-06 10:42:36 -0200
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-11-29 20:44:20 -0200
commit759db1711c7095d34942617f076f9e010e46889f (patch)
tree3e00000eaefd38df83722d7e116e4e4c6fbc3edb
parent4ad2206d920862c98c8f344d2ec891c4a6df8c06 (diff)
downloadefl-devs/vitorsousa/model_composite.tar.gz
ecore: fix bugs from composite modelsdevs/vitorsousa/model_composite
Fix type error while getting boolean property from Efl.Model_Composite_Boolean. Fix properties_get methods for all composite models. Now properly call property.changed events when it is needed. Use EINA_VALUE_TYPE_BOOL instead of EINA_VALUE_TYPE_UCHAR. Remove some memory leaks.
-rw-r--r--src/Makefile_Ecore.am1
-rw-r--r--src/lib/ecore/efl_model_composite_boolean.c34
-rw-r--r--src/lib/ecore/efl_model_composite_private.h39
-rw-r--r--src/lib/ecore/efl_model_composite_selection.c28
-rw-r--r--src/lib/ecore/efl_model_composite_selection.eo1
-rw-r--r--src/lib/ecore/efl_model_composite_selection_children.eo2
-rw-r--r--src/lib/ecore/meson.build1
7 files changed, 90 insertions, 16 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index 5b7c664687..ff23d05680 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -126,6 +126,7 @@ lib/ecore/efl_model_container_private.h \
lib/ecore/efl_model_composite.c \
lib/ecore/efl_model_composite_boolean.c \
lib/ecore/efl_model_composite_selection.c \
+lib/ecore/efl_model_composite_private.h \
lib/ecore/efl_model_accessor_view.c \
lib/ecore/efl_model_accessor_view_private.h \
lib/ecore/efl_linear_interpolator.c \
diff --git a/src/lib/ecore/efl_model_composite_boolean.c b/src/lib/ecore/efl_model_composite_boolean.c
index cb52e85328..e710091288 100644
--- a/src/lib/ecore/efl_model_composite_boolean.c
+++ b/src/lib/ecore/efl_model_composite_boolean.c
@@ -5,6 +5,7 @@
#include <Efl_Core.h>
#include "efl_model_composite_boolean_children.eo.h"
+#include "efl_model_composite_private.h"
typedef struct _Efl_Model_Composite_Boolean_Data Efl_Model_Composite_Boolean_Data;
typedef struct _Efl_Model_Composite_Boolean_Children_Data Efl_Model_Composite_Boolean_Children_Data;
@@ -71,16 +72,11 @@ static Eina_Iterator *
_efl_model_composite_boolean_children_efl_model_properties_get(const Eo *obj,
Efl_Model_Composite_Boolean_Children_Data *pd)
{
- Eina_Iterator *its;
- Eina_Iterator *itr;
-
- its = efl_model_properties_get(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS));
- itr = eina_hash_iterator_key_new(pd->parent->values);
-
- if (!its) return itr;
- if (!itr) return its;
-
- return eina_multi_iterator_new(its, itr);
+ EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(props,
+ obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS,
+ eina_hash_iterator_key_new(pd->parent->values),
+ "child.index");
+ return props;
}
static Eina_Value *
@@ -109,9 +105,9 @@ _efl_model_composite_boolean_children_efl_model_property_get(const Eo *obj,
if ((pd->index >> 3) >= v->buffer_count)
flag = v->default_value;
else
- flag = v->buffer[pd->index >> 3] & (1 << pd->index & 0x7);
+ flag = v->buffer[pd->index >> 3] & (((unsigned char)1) << (pd->index & 0x7));
- return eina_value_uchar_new(!!flag);
+ return eina_value_bool_new(!!flag);
}
static Eina_Future *
@@ -139,7 +135,7 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
return efl_model_property_set(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS),
property, value);
- eina_value_setup(&b, EINA_VALUE_TYPE_UCHAR);
+ eina_value_setup(&b, EINA_VALUE_TYPE_BOOL);
if (!eina_value_convert(value, &b))
return eina_future_rejected(efl_loop_future_scheduler_get(obj),
EFL_MODEL_ERROR_UNKNOWN);
@@ -165,12 +161,16 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
// It is assumed that during slice get the buffer is properly sized
if (flag)
- v->buffer[pd->index >> 3] |= 1 << (pd->index & 0x7);
+ v->buffer[pd->index >> 3] |= ((unsigned char)1) << (pd->index & 0x7);
else
- v->buffer[pd->index >> 3] &= ~(1 << (pd->index & 0x7));
+ v->buffer[pd->index >> 3] &= ~(((unsigned char)1) << (pd->index & 0x7));
+ // Calling "properties,changed" event
+ efl_model_properties_changed(obj, property);
+
+ // Return fulfilled future
return eina_future_resolved(efl_loop_future_scheduler_get(obj),
- eina_value_uchar_init(!!flag));
+ eina_value_bool_init(!!flag));
}
/**************** efl_model_composite_boolean **************/
@@ -225,6 +225,8 @@ _boolean_value_free(void *data)
free(value->buffer);
value->buffer = NULL;
value->buffer_count = 0;
+
+ free(value);
}
static Eo *
diff --git a/src/lib/ecore/efl_model_composite_private.h b/src/lib/ecore/efl_model_composite_private.h
new file mode 100644
index 0000000000..eb9b07b47c
--- /dev/null
+++ b/src/lib/ecore/efl_model_composite_private.h
@@ -0,0 +1,39 @@
+
+#define EFL_MODEL_COMPOSITE_PROPERTIES(name, dyn, sta, ...) \
+ EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(name, NULL, NULL, (dyn), sta, ##__VA_ARGS__)
+
+#define EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(name, obj, klass, dyn, sta, ...) \
+ Eina_Iterator *name; \
+ do \
+ { \
+ static const char *static_props__[] = { \
+ sta, \
+ ##__VA_ARGS__ \
+ }; \
+ name = _efl_model_composite_properties_mix( \
+ ((obj) ? efl_model_properties_get(efl_super((obj), (klass))) : NULL), \
+ (dyn), \
+ EINA_C_ARRAY_ITERATOR_NEW(static_props__)); \
+ } \
+ while (0)
+
+
+static inline Eina_Iterator *
+_efl_model_composite_properties_mix(Eina_Iterator *super, Eina_Iterator *dyn, Eina_Iterator *sta)
+{
+ Eina_Iterator *its[3];
+ int i = 0;
+
+ if (sta) its[i++] = sta;
+ if (dyn) its[i++] = dyn;
+ if (super) its[i++] = super;
+
+ switch (i)
+ {
+ case 1: return its[0];
+ case 2: return eina_multi_iterator_new(its[0], its[1]);
+ case 3: return eina_multi_iterator_new(its[0], its[1], its[2]);
+ default: return NULL;
+ };
+}
+
diff --git a/src/lib/ecore/efl_model_composite_selection.c b/src/lib/ecore/efl_model_composite_selection.c
index 622d183b60..cb35c0f0ce 100644
--- a/src/lib/ecore/efl_model_composite_selection.c
+++ b/src/lib/ecore/efl_model_composite_selection.c
@@ -9,6 +9,7 @@
#include "efl_model_composite_selection.eo.h"
#include "efl_model_accessor_view_private.h"
+#include "efl_model_composite_private.h"
typedef struct _Efl_Model_Composite_Selection_Data Efl_Model_Composite_Selection_Data;
typedef struct _Efl_Model_Composite_Selection_Children_Data Efl_Model_Composite_Selection_Children_Data;
@@ -186,6 +187,17 @@ _unselect_slice_then(void *data EINA_UNUSED,
return v;
}
+static Eina_Iterator *
+_efl_model_composite_selection_efl_model_properties_get(const Eo *obj,
+ Efl_Model_Composite_Selection_Data *pd EINA_UNUSED)
+{
+ EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(props,
+ obj, EFL_MODEL_COMPOSITE_SELECTION_CLASS,
+ NULL,
+ "selected", "exclusive");
+ return props;
+}
+
static Eina_Future *
_efl_model_composite_selection_efl_model_property_set(Eo *obj,
Efl_Model_Composite_Selection_Data *pd,
@@ -196,13 +208,18 @@ _efl_model_composite_selection_efl_model_property_set(Eo *obj,
if (!strcmp("exclusive", property))
{
Eina_Bool exclusive = pd->exclusive;
+ Eina_Bool changed;
vf = eina_value_bool_init(exclusive);
eina_value_convert(value, &vf);
eina_value_bool_get(&vf, &exclusive);
+ changed = (!pd->exclusive != !exclusive);
pd->exclusive = !!exclusive;
+ if (changed)
+ efl_model_properties_changed(obj, "exclusive");
+
return eina_future_resolved(efl_loop_future_scheduler_get(obj), vf);
}
@@ -291,6 +308,17 @@ _untangle_array(void *data,
return va;
}
+static Eina_Iterator *
+_efl_model_composite_selection_children_efl_model_properties_get(const Eo *obj,
+ Efl_Model_Composite_Selection_Children_Data *pd EINA_UNUSED)
+{
+ EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(props,
+ obj, EFL_MODEL_COMPOSITE_SELECTION_CHILDREN_CLASS,
+ NULL,
+ "selected");
+ return props;
+}
+
static Eina_Future *
_efl_model_composite_selection_children_efl_model_property_set(Eo *obj,
Efl_Model_Composite_Selection_Children_Data *pd EINA_UNUSED,
diff --git a/src/lib/ecore/efl_model_composite_selection.eo b/src/lib/ecore/efl_model_composite_selection.eo
index 782a928a64..fca9b9c2ba 100644
--- a/src/lib/ecore/efl_model_composite_selection.eo
+++ b/src/lib/ecore/efl_model_composite_selection.eo
@@ -5,6 +5,7 @@ class Efl.Model_Composite_Selection (Efl.Model_Composite_Boolean)
Efl.Object.constructor;
Efl.Model.children_slice_get;
Efl.Model.property { get; set; }
+ Efl.Model.properties { get; }
}
events {
/* FIXME: The object is emitted in the event_info. This is redundant. */
diff --git a/src/lib/ecore/efl_model_composite_selection_children.eo b/src/lib/ecore/efl_model_composite_selection_children.eo
index f3a9bd826e..ef2af4d465 100644
--- a/src/lib/ecore/efl_model_composite_selection_children.eo
+++ b/src/lib/ecore/efl_model_composite_selection_children.eo
@@ -3,5 +3,7 @@ class Efl.Model_Composite_Selection_Children (Efl.Model_Composite_Boolean_Childr
[[Efl model composite selection children class]]
implements {
Efl.Model.property { set; }
+ Efl.Model.properties { get; }
}
+ /* FIXME: emitting Efl.Model_Composite_Selection.Selected. Use a default selection event! */
}
diff --git a/src/lib/ecore/meson.build b/src/lib/ecore/meson.build
index 96ad59b98c..cfa6609666 100644
--- a/src/lib/ecore/meson.build
+++ b/src/lib/ecore/meson.build
@@ -153,6 +153,7 @@ ecore_src = [
'efl_model_composite.c',
'efl_model_composite_boolean.c',
'efl_model_composite_selection.c',
+ 'efl_model_composite_private.h',
'efl_model_accessor_view.c',
'efl_model_accessor_view_private.h',
'efl_linear_interpolator.c',