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)
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 \
126lib/ecore/efl_model_composite.c \ 126lib/ecore/efl_model_composite.c \
127lib/ecore/efl_model_composite_boolean.c \ 127lib/ecore/efl_model_composite_boolean.c \
128lib/ecore/efl_model_composite_selection.c \ 128lib/ecore/efl_model_composite_selection.c \
129lib/ecore/efl_model_composite_private.h \
129lib/ecore/efl_model_accessor_view.c \ 130lib/ecore/efl_model_accessor_view.c \
130lib/ecore/efl_model_accessor_view_private.h \ 131lib/ecore/efl_model_accessor_view_private.h \
131lib/ecore/efl_linear_interpolator.c \ 132lib/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 @@
5#include <Efl_Core.h> 5#include <Efl_Core.h>
6 6
7#include "efl_model_composite_boolean_children.eo.h" 7#include "efl_model_composite_boolean_children.eo.h"
8#include "efl_model_composite_private.h"
8 9
9typedef struct _Efl_Model_Composite_Boolean_Data Efl_Model_Composite_Boolean_Data; 10typedef struct _Efl_Model_Composite_Boolean_Data Efl_Model_Composite_Boolean_Data;
10typedef struct _Efl_Model_Composite_Boolean_Children_Data Efl_Model_Composite_Boolean_Children_Data; 11typedef struct _Efl_Model_Composite_Boolean_Children_Data Efl_Model_Composite_Boolean_Children_Data;
@@ -71,16 +72,11 @@ static Eina_Iterator *
71_efl_model_composite_boolean_children_efl_model_properties_get(const Eo *obj, 72_efl_model_composite_boolean_children_efl_model_properties_get(const Eo *obj,
72 Efl_Model_Composite_Boolean_Children_Data *pd) 73 Efl_Model_Composite_Boolean_Children_Data *pd)
73{ 74{
74 Eina_Iterator *its; 75 EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(props,
75 Eina_Iterator *itr; 76 obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS,
76 77 eina_hash_iterator_key_new(pd->parent->values),
77 its = efl_model_properties_get(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS)); 78 "child.index");
78 itr = eina_hash_iterator_key_new(pd->parent->values); 79 return props;
79
80 if (!its) return itr;
81 if (!itr) return its;
82
83 return eina_multi_iterator_new(its, itr);
84} 80}
85 81
86static Eina_Value * 82static Eina_Value *
@@ -109,9 +105,9 @@ _efl_model_composite_boolean_children_efl_model_property_get(const Eo *obj,
109 if ((pd->index >> 3) >= v->buffer_count) 105 if ((pd->index >> 3) >= v->buffer_count)
110 flag = v->default_value; 106 flag = v->default_value;
111 else 107 else
112 flag = v->buffer[pd->index >> 3] & (1 << pd->index & 0x7); 108 flag = v->buffer[pd->index >> 3] & (((unsigned char)1) << (pd->index & 0x7));
113 109
114 return eina_value_uchar_new(!!flag); 110 return eina_value_bool_new(!!flag);
115} 111}
116 112
117static Eina_Future * 113static Eina_Future *
@@ -139,7 +135,7 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
139 return efl_model_property_set(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS), 135 return efl_model_property_set(efl_super(obj, EFL_MODEL_COMPOSITE_BOOLEAN_CHILDREN_CLASS),
140 property, value); 136 property, value);
141 137
142 eina_value_setup(&b, EINA_VALUE_TYPE_UCHAR); 138 eina_value_setup(&b, EINA_VALUE_TYPE_BOOL);
143 if (!eina_value_convert(value, &b)) 139 if (!eina_value_convert(value, &b))
144 return eina_future_rejected(efl_loop_future_scheduler_get(obj), 140 return eina_future_rejected(efl_loop_future_scheduler_get(obj),
145 EFL_MODEL_ERROR_UNKNOWN); 141 EFL_MODEL_ERROR_UNKNOWN);
@@ -165,12 +161,16 @@ _efl_model_composite_boolean_children_efl_model_property_set(Eo *obj,
165 161
166 // It is assumed that during slice get the buffer is properly sized 162 // It is assumed that during slice get the buffer is properly sized
167 if (flag) 163 if (flag)
168 v->buffer[pd->index >> 3] |= 1 << (pd->index & 0x7); 164 v->buffer[pd->index >> 3] |= ((unsigned char)1) << (pd->index & 0x7);
169 else 165 else
170 v->buffer[pd->index >> 3] &= ~(1 << (pd->index & 0x7)); 166 v->buffer[pd->index >> 3] &= ~(((unsigned char)1) << (pd->index & 0x7));
171 167
168 // Calling "properties,changed" event
169 efl_model_properties_changed(obj, property);
170
171 // Return fulfilled future
172 return eina_future_resolved(efl_loop_future_scheduler_get(obj), 172 return eina_future_resolved(efl_loop_future_scheduler_get(obj),
173 eina_value_uchar_init(!!flag)); 173 eina_value_bool_init(!!flag));
174} 174}
175 175
176/**************** efl_model_composite_boolean **************/ 176/**************** efl_model_composite_boolean **************/
@@ -225,6 +225,8 @@ _boolean_value_free(void *data)
225 free(value->buffer); 225 free(value->buffer);
226 value->buffer = NULL; 226 value->buffer = NULL;
227 value->buffer_count = 0; 227 value->buffer_count = 0;
228
229 free(value);
228} 230}
229 231
230static Eo * 232static 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 @@
1
2#define EFL_MODEL_COMPOSITE_PROPERTIES(name, dyn, sta, ...) \
3 EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(name, NULL, NULL, (dyn), sta, ##__VA_ARGS__)
4
5#define EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(name, obj, klass, dyn, sta, ...) \
6 Eina_Iterator *name; \
7 do \
8 { \
9 static const char *static_props__[] = { \
10 sta, \
11 ##__VA_ARGS__ \
12 }; \
13 name = _efl_model_composite_properties_mix( \
14 ((obj) ? efl_model_properties_get(efl_super((obj), (klass))) : NULL), \
15 (dyn), \
16 EINA_C_ARRAY_ITERATOR_NEW(static_props__)); \
17 } \
18 while (0)
19
20
21static inline Eina_Iterator *
22_efl_model_composite_properties_mix(Eina_Iterator *super, Eina_Iterator *dyn, Eina_Iterator *sta)
23{
24 Eina_Iterator *its[3];
25 int i = 0;
26
27 if (sta) its[i++] = sta;
28 if (dyn) its[i++] = dyn;
29 if (super) its[i++] = super;
30
31 switch (i)
32 {
33 case 1: return its[0];
34 case 2: return eina_multi_iterator_new(its[0], its[1]);
35 case 3: return eina_multi_iterator_new(its[0], its[1], its[2]);
36 default: return NULL;
37 };
38}
39
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 @@
9 9
10#include "efl_model_composite_selection.eo.h" 10#include "efl_model_composite_selection.eo.h"
11#include "efl_model_accessor_view_private.h" 11#include "efl_model_accessor_view_private.h"
12#include "efl_model_composite_private.h"
12 13
13typedef struct _Efl_Model_Composite_Selection_Data Efl_Model_Composite_Selection_Data; 14typedef struct _Efl_Model_Composite_Selection_Data Efl_Model_Composite_Selection_Data;
14typedef struct _Efl_Model_Composite_Selection_Children_Data Efl_Model_Composite_Selection_Children_Data; 15typedef struct _Efl_Model_Composite_Selection_Children_Data Efl_Model_Composite_Selection_Children_Data;
@@ -186,6 +187,17 @@ _unselect_slice_then(void *data EINA_UNUSED,
186 return v; 187 return v;
187} 188}
188 189
190static Eina_Iterator *
191_efl_model_composite_selection_efl_model_properties_get(const Eo *obj,
192 Efl_Model_Composite_Selection_Data *pd EINA_UNUSED)
193{
194 EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(props,
195 obj, EFL_MODEL_COMPOSITE_SELECTION_CLASS,
196 NULL,
197 "selected", "exclusive");
198 return props;
199}
200
189static Eina_Future * 201static Eina_Future *
190_efl_model_composite_selection_efl_model_property_set(Eo *obj, 202_efl_model_composite_selection_efl_model_property_set(Eo *obj,
191 Efl_Model_Composite_Selection_Data *pd, 203 Efl_Model_Composite_Selection_Data *pd,
@@ -196,13 +208,18 @@ _efl_model_composite_selection_efl_model_property_set(Eo *obj,
196 if (!strcmp("exclusive", property)) 208 if (!strcmp("exclusive", property))
197 { 209 {
198 Eina_Bool exclusive = pd->exclusive; 210 Eina_Bool exclusive = pd->exclusive;
211 Eina_Bool changed;
199 212
200 vf = eina_value_bool_init(exclusive); 213 vf = eina_value_bool_init(exclusive);
201 eina_value_convert(value, &vf); 214 eina_value_convert(value, &vf);
202 eina_value_bool_get(&vf, &exclusive); 215 eina_value_bool_get(&vf, &exclusive);
203 216
217 changed = (!pd->exclusive != !exclusive);
204 pd->exclusive = !!exclusive; 218 pd->exclusive = !!exclusive;
205 219
220 if (changed)
221 efl_model_properties_changed(obj, "exclusive");
222
206 return eina_future_resolved(efl_loop_future_scheduler_get(obj), vf); 223 return eina_future_resolved(efl_loop_future_scheduler_get(obj), vf);
207 } 224 }
208 225
@@ -291,6 +308,17 @@ _untangle_array(void *data,
291 return va; 308 return va;
292} 309}
293 310
311static Eina_Iterator *
312_efl_model_composite_selection_children_efl_model_properties_get(const Eo *obj,
313 Efl_Model_Composite_Selection_Children_Data *pd EINA_UNUSED)
314{
315 EFL_MODEL_COMPOSITE_PROPERTIES_SUPER(props,
316 obj, EFL_MODEL_COMPOSITE_SELECTION_CHILDREN_CLASS,
317 NULL,
318 "selected");
319 return props;
320}
321
294static Eina_Future * 322static Eina_Future *
295_efl_model_composite_selection_children_efl_model_property_set(Eo *obj, 323_efl_model_composite_selection_children_efl_model_property_set(Eo *obj,
296 Efl_Model_Composite_Selection_Children_Data *pd EINA_UNUSED, 324 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)
5 Efl.Object.constructor; 5 Efl.Object.constructor;
6 Efl.Model.children_slice_get; 6 Efl.Model.children_slice_get;
7 Efl.Model.property { get; set; } 7 Efl.Model.property { get; set; }
8 Efl.Model.properties { get; }
8 } 9 }
9 events { 10 events {
10 /* FIXME: The object is emitted in the event_info. This is redundant. */ 11 /* 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
3 [[Efl model composite selection children class]] 3 [[Efl model composite selection children class]]
4 implements { 4 implements {
5 Efl.Model.property { set; } 5 Efl.Model.property { set; }
6 Efl.Model.properties { get; }
6 } 7 }
8 /* FIXME: emitting Efl.Model_Composite_Selection.Selected. Use a default selection event! */
7} 9}
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 = [
153 'efl_model_composite.c', 153 'efl_model_composite.c',
154 'efl_model_composite_boolean.c', 154 'efl_model_composite_boolean.c',
155 'efl_model_composite_selection.c', 155 'efl_model_composite_selection.c',
156 'efl_model_composite_private.h',
156 'efl_model_accessor_view.c', 157 'efl_model_accessor_view.c',
157 'efl_model_accessor_view_private.h', 158 'efl_model_accessor_view_private.h',
158 'efl_linear_interpolator.c', 159 'efl_linear_interpolator.c',