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.
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 \
#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;
_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 *
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 *
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);
// 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 **************/
free(value->buffer);
value->buffer = NULL;
value->buffer_count = 0;
+
+ free(value);
}
static Eo *
--- /dev/null
+
+#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;
+ };
+}
+
#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;
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,
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);
}
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,
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. */
[[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! */
}
'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',