summaryrefslogtreecommitdiff
path: root/src/lib/ecore/efl_mono_model_internal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ecore/efl_mono_model_internal.c')
-rw-r--r--src/lib/ecore/efl_mono_model_internal.c80
1 files changed, 56 insertions, 24 deletions
diff --git a/src/lib/ecore/efl_mono_model_internal.c b/src/lib/ecore/efl_mono_model_internal.c
index bdd6ce6045..f613422ce4 100644
--- a/src/lib/ecore/efl_mono_model_internal.c
+++ b/src/lib/ecore/efl_mono_model_internal.c
@@ -35,16 +35,18 @@ typedef struct _Efl_Mono_Model_Internal_Child_Data
Efl_Mono_Model_Internal_Data* model_pd;
size_t index;
Eina_Array *values;
+ Eo* child;
//Eina_Array *items;
} Efl_Mono_Model_Internal_Child_Data;
-static int _find_property_index (const char* name, Eina_Array* properties_info)
+static int _find_property_index (const char* name, Eina_Array* properties_name)
{
- int i, size = eina_array_count_get(properties_info);
+ int i, size = eina_array_count_get(properties_name);
fprintf(stdout, "count %d\n", size); fflush(stdout);
for (i = 0; i != size; ++i)
{
- if (!strcmp(properties_info->data[i], name))
+ printf ("Testing %s with %s\n", (char*)properties_name->data[i], name); fflush(stdout);
+ if (!strcmp(properties_name->data[i], name))
{
return i;
}
@@ -59,6 +61,7 @@ _efl_mono_model_internal_efl_object_constructor(Eo *obj, Efl_Mono_Model_Internal
obj = efl_constructor(efl_super(obj, MY_CLASS));
pd->properties_info = eina_array_new(5);
+ pd->properties_names = eina_array_new(5);
pd->items = eina_array_new(5);
if (!obj) return NULL;
@@ -81,6 +84,7 @@ _efl_mono_model_internal_add_property(Eo *obj EINA_UNUSED, Efl_Mono_Model_Intern
info->name = eina_stringshare_add(name);
info->type = type;
eina_array_push (pd->properties_info, info);
+ eina_array_push (pd->properties_names, eina_stringshare_add(info->name));
}
@@ -100,6 +104,8 @@ _efl_mono_model_internal_efl_model_child_add(Eo *obj, Efl_Mono_Model_Internal_Da
Efl_Mono_Model_Internal_Child_Data* pcd = efl_data_xref (child, EFL_MONO_MODEL_INTERNAL_CHILD_CLASS, obj);
pcd->model_pd = pd;
pcd->index = eina_array_count_get(pd->items);
+ pcd->child = child;
+ pcd->values = eina_array_new(5);
eina_array_push (pd->items, pcd);
return child;
@@ -115,47 +121,65 @@ static Eina_Future *
_efl_mono_model_internal_child_efl_model_property_set(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd, const char *property, Eina_Value *value)
{
fprintf (stdout, "property_set\n"); fflush(stdout);
- int i = _find_property_index (property, pd->model_pd->properties_info);
+ int i = _find_property_index (property, pd->model_pd->properties_names);
int j;
Eina_Value* old_value;
+ Eina_Value* new_value;
+ Eina_Value tmp_value;
- fprintf (stdout, "property_set\n"); fflush(stdout);
+ printf ("value type %p\n", value->type); fflush(stdout);
+ fprintf (stdout, "property_set %d\n", i); fflush(stdout);
if (i >= 0)
- //if (0)
{
- for (j = i - eina_array_count_get (pd->values); j; --j)
- eina_array_push (pd->values, NULL);
-
+ fprintf(stdout, __FILE__ ":%d %d %d\n", __LINE__, i, eina_array_count_get (pd->values)); fflush(stdout);
+ for (j = i - eina_array_count_get (pd->values); j >= 0; --j)
+ {
+ fprintf(stdout, __FILE__ ":%d\n", __LINE__); fflush(stdout);
+ eina_array_push (pd->values, (void*)1);
+ pd->values->data[pd->values->count-1] = NULL;
+ }
+
+ fprintf(stdout, __FILE__ ":%d %d %d\n", __LINE__, i, eina_array_count_get (pd->values)); fflush(stdout);
old_value = eina_array_data_get (pd->values, i);
+ fprintf(stdout, __FILE__ ":%d %p\n", __LINE__, old_value); fflush(stdout);
if (old_value)
eina_value_free (old_value);
- eina_array_data_set (pd->values, i, value);
+ new_value = malloc (sizeof(Eina_Value));
+ eina_value_copy (value, new_value);
+ printf ("new_value type %p\n", new_value->type); fflush(stdout);
+ eina_value_copy (value, &tmp_value);
+ printf ("tmp_value type %p\n", tmp_value.type); fflush(stdout);
+ eina_array_data_set (pd->values, i, new_value);
- /* promise = eian_promise_new (efl_loop_future_scheduler_get(obj), NULL, NULL); */
- /* future = eina_future_new (promise); */
+ fprintf(stdout, __FILE__ ":%d\n", __LINE__); fflush(stdout);
-
- Eina_Future* f = efl_loop_future_resolved(obj, *value);
- fprintf(stdout, "com resolved %p\n", f); fflush(stdout);
- assert(!!f);
- return f;
+ return efl_loop_future_resolved(obj, tmp_value);
}
else
{
+ printf ("Index not found!\n"); fflush(stdout);
// not found property
- //return efl_loop_future_rejected(obj, EAGAIN);
-
- Eina_Promise* promise = eina_promise_new (efl_loop_future_scheduler_get(obj), NULL, NULL);
- Eina_Future* future = eina_future_new (promise);
- return future;
+ return efl_loop_future_rejected(obj, EAGAIN);
}
}
static Eina_Value *
_efl_mono_model_internal_child_efl_model_property_get(const Eo *obj EINA_UNUSED, Efl_Mono_Model_Internal_Child_Data *pd EINA_UNUSED, const char *property EINA_UNUSED)
{
- return eina_value_error_new(EAGAIN);
+ printf ("trying to property get prop name %s\n", property); fflush(stdout);
+ int i = _find_property_index (property, pd->model_pd->properties_names);
+ printf ("trying to property get index %d\n", i); fflush(stdout);
+ if(eina_array_count_get (pd->values) <= i
+ || eina_array_data_get (pd->values, i) == NULL)
+ return eina_value_error_new(EAGAIN);
+ else
+ {
+ Eina_Value* src = eina_array_data_get(pd->values, i);
+ Eina_Value* clone = malloc (sizeof(Eina_Value));
+ eina_value_copy (src, clone);
+ return clone;
+ }
}
static Eina_Future *
@@ -163,11 +187,18 @@ _efl_mono_model_internal_efl_model_children_slice_get(Eo *obj, Efl_Mono_Model_In
{
unsigned int i;
Eina_Value array = EINA_VALUE_EMPTY;
+ Efl_Mono_Model_Internal_Child_Data* pcd;
eina_value_array_setup(&array, EINA_VALUE_TYPE_OBJECT, count % 8);
for (i = start; i != start + count; ++i)
- eina_value_array_append (&array, eina_array_data_get(pd->items, i));
+ {
+ pcd = eina_array_data_get(pd->items, i);
+ eina_value_array_append (&array, pcd->child);
+ }
+
+ printf("returning future resolved of type %p and subtype %p type %p\n", EINA_VALUE_TYPE_ARRAY, EINA_VALUE_TYPE_OBJECT,
+ array.type); fflush(stdout);
return efl_loop_future_resolved(obj, array);
}
@@ -183,6 +214,7 @@ _efl_mono_model_internal_child_efl_object_constructor(Eo *obj, Efl_Mono_Model_In
static void
_efl_mono_model_internal_child_efl_object_destructor(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd EINA_UNUSED)
{
+ printf("_efl_mono_model_internal_child_efl_object_destructor\n"); fflush(stdout);
efl_destructor(efl_super(obj, EFL_MONO_MODEL_INTERNAL_CHILD_CLASS));
}