summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-03-11 15:48:29 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2019-03-11 15:48:29 -0300
commit44772c9c2da80b411cda95828e6a2e4b827a121d (patch)
tree5f9c8af978601660677aa68af4d662196436ce3a
parentbbb208abb30c24b490dfe5e3d69cd81934a6ae11 (diff)
efl-mono: More modeldevs/felipealmeida/mono_model
-rw-r--r--src/bindings/mono/efl_mono/GenericModel.cs30
-rw-r--r--src/bindings/mono/efl_mono/UserModel.cs83
-rw-r--r--src/bindings/mono/eina_mono/eina_promises.cs10
-rw-r--r--src/bindings/mono/eina_mono/eina_value.cs4
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs11
-rw-r--r--src/lib/ecore/efl_loop.c6
-rw-r--r--src/lib/ecore/efl_loop_consumer.c1
-rw-r--r--src/lib/ecore/efl_mono_model_internal.c80
-rw-r--r--src/lib/ecore/efl_mono_model_internal.eo2
-rw-r--r--src/lib/ecore/efl_mono_model_internal_child.eo2
-rw-r--r--src/lib/efl/interfaces/efl_model.eo2
-rw-r--r--src/lib/eina/eina_log.c2
-rw-r--r--src/lib/eina/eina_promise.c2
-rw-r--r--src/lib/eina/eina_value.c5
-rw-r--r--src/tests/efl_mono/Model.cs31
15 files changed, 210 insertions, 61 deletions
diff --git a/src/bindings/mono/efl_mono/GenericModel.cs b/src/bindings/mono/efl_mono/GenericModel.cs
index 214755cefb..773c61a5d0 100644
--- a/src/bindings/mono/efl_mono/GenericModel.cs
+++ b/src/bindings/mono/efl_mono/GenericModel.cs
@@ -3,6 +3,7 @@ using System.Runtime.InteropServices;
3using System.Collections.Generic; 3using System.Collections.Generic;
4using System.Linq; 4using System.Linq;
5using System.ComponentModel; 5using System.ComponentModel;
6using Eina;
6 7
7namespace Efl { 8namespace Efl {
8 9
@@ -52,6 +53,12 @@ public class GenericModel<T> : Efl.Object, Efl.Model, IDisposable
52 { 53 {
53 return model.GetChildrenSlice(start, count); 54 return model.GetChildrenSlice(start, count);
54 } 55 }
56 public void Add(T o)
57 {
58 Efl.Object obj = this.AddChild();
59 Efl.Model child = Efl.ModelConcrete.static_cast(obj);
60 ModelHelper.SetProperties(o, child);
61 }
55 public Efl.Object AddChild() 62 public Efl.Object AddChild()
56 { 63 {
57 return model.AddChild(); 64 return model.AddChild();
@@ -60,6 +67,29 @@ public class GenericModel<T> : Efl.Object, Efl.Model, IDisposable
60 { 67 {
61 model.DelChild(child); 68 model.DelChild(child);
62 } 69 }
70 async public System.Threading.Tasks.Task<T> GetAtAsync(uint index)
71 {
72 Console.WriteLine("awaiting getchildren");
73 using (Eina.Value v = await GetChildrenSliceAsync(index, 1))
74 {
75 Console.WriteLine("awaited getchildren");
76 if (v.GetValueType().IsContainer())
77 {
78 Console.WriteLine("awaited getchildren is container");
79 var o = (Efl.Object)v[0];
80 var child = Efl.ModelConcrete.static_cast(o);
81 T obj = (T)Activator.CreateInstance(typeof(T), new System.Object[] {});
82 ModelHelper.GetProperties(obj, child);
83 return obj;
84 }
85 else
86 {
87 Console.WriteLine("awaited getchildren NOT container");
88 // error
89 throw new System.Exception("");
90 }
91 }
92 }
63 public System.Threading.Tasks.Task<Eina.Value> SetPropertyAsync( System.String property, Eina.Value value, System.Threading.CancellationToken token=default(System.Threading.CancellationToken)) 93 public System.Threading.Tasks.Task<Eina.Value> SetPropertyAsync( System.String property, Eina.Value value, System.Threading.CancellationToken token=default(System.Threading.CancellationToken))
64 { 94 {
65 return model.SetPropertyAsync(property, value, token); 95 return model.SetPropertyAsync(property, value, token);
diff --git a/src/bindings/mono/efl_mono/UserModel.cs b/src/bindings/mono/efl_mono/UserModel.cs
index 4555607470..c7584d7b28 100644
--- a/src/bindings/mono/efl_mono/UserModel.cs
+++ b/src/bindings/mono/efl_mono/UserModel.cs
@@ -6,6 +6,65 @@ using System.ComponentModel;
6 6
7namespace Efl { 7namespace Efl {
8 8
9internal class ModelHelper
10{
11 static internal void SetProperties<T>(T o, Efl.Model child)
12 {
13 var properties = typeof(T).GetProperties();
14 foreach(var prop in properties)
15 {
16 Eina.Value v;
17 if (prop.PropertyType == typeof(int))
18 {
19 v = new Eina.Value(Eina.ValueType.Int32);
20 v.Set((int)prop.GetValue(o));
21 }
22 else if (prop.PropertyType == typeof(string))
23 {
24 v = new Eina.Value(Eina.ValueType.String);
25 v.Set((string)prop.GetValue(o));
26 }
27 else
28 throw new Exception("Type unknown " + prop.PropertyType.Name);
29 Console.WriteLine ("Setting property with value {0}", v.ToString());
30 child.SetProperty(prop.Name, v);
31 //v.Dispose();
32 }
33 }
34
35 static internal void GetProperties<T>(T o, Efl.Model child)
36 {
37 var properties = typeof(T).GetProperties();
38 foreach(var prop in properties)
39 {
40 Console.WriteLine("Reading property of name {0}", prop.Name);
41 using (var v = child.GetProperty(prop.Name))
42 {
43 Console.WriteLine("Read property");
44 if (prop.PropertyType == typeof(int))
45 {
46 int x;
47 v.Get(out x);
48 Console.WriteLine("Type is int, value is {0}", x);
49 prop.SetValue(o, x);
50 }
51 else if (prop.PropertyType == typeof(string))
52 {
53 string x;
54 v.Get(out x);
55 Console.WriteLine("Type is string, value is {0}", x);
56 prop.SetValue(o, x);
57 }
58 else
59 {
60 Console.WriteLine("Type is unknown");
61 throw new Exception("Type unknown " + prop.PropertyType.Name);
62 }
63 }
64 }
65 }
66}
67
9public class UserModel<T> : Efl.MonoModelInternal, IDisposable 68public class UserModel<T> : Efl.MonoModelInternal, IDisposable
10{ 69{
11 ///<summary>Pointer to the native class description.</summary> 70 ///<summary>Pointer to the native class description.</summary>
@@ -36,30 +95,14 @@ public class UserModel<T> : Efl.MonoModelInternal, IDisposable
36 public void Add (T o) 95 public void Add (T o)
37 { 96 {
38 Efl.Object obj = this.AddChild(); 97 Efl.Object obj = this.AddChild();
39 if (obj == null) 98 // if (obj == null)
40 Console.WriteLine("Object from AddChild is null"); 99 // Console.WriteLine("Object from AddChild is null");
41 //Debug.Assert(obj != null); 100 //Debug.Assert(obj != null);
101 Console.WriteLine ("static casting"); Console.Out.Flush();
42 Efl.Model child = Efl.ModelConcrete.static_cast(obj); 102 Efl.Model child = Efl.ModelConcrete.static_cast(obj);
43 //Debug.Assert(child != null); 103 //Debug.Assert(child != null);
44 104
45 var properties = typeof(T).GetProperties(); 105 ModelHelper.SetProperties(o, child);
46 foreach(var prop in properties)
47 {
48 Eina.Value v;
49 if (prop.PropertyType == typeof(int))
50 {
51 v = new Eina.Value(Eina.ValueType.Int32);
52 v.Set((int)prop.GetValue(o));
53 }
54 else if (prop.PropertyType == typeof(string))
55 {
56 v = new Eina.Value(Eina.ValueType.String);
57 v.Set((string)prop.GetValue(o));
58 }
59 else
60 throw new Exception("Type unknown " + prop.PropertyType.Name);
61 child.SetProperty(prop.Name, v);
62 }
63 } 106 }
64} 107}
65 108
diff --git a/src/bindings/mono/eina_mono/eina_promises.cs b/src/bindings/mono/eina_mono/eina_promises.cs
index 8be5f9d6cb..0ef12dffa8 100644
--- a/src/bindings/mono/eina_mono/eina_promises.cs
+++ b/src/bindings/mono/eina_mono/eina_promises.cs
@@ -197,10 +197,11 @@ public class Future
197 /// </summary> 197 /// </summary>
198 public Future(IntPtr handle) 198 public Future(IntPtr handle)
199 { 199 {
200 Handle = ThenRaw(handle, (Eina.Value value) => { 200 Handle = handle;
201 Handle = IntPtr.Zero; 201 // Handle = ThenRaw(handle, (Eina.Value value) => {
202 return value; 202 // Handle = IntPtr.Zero;
203 }); 203 // return value;
204 // });
204 } 205 }
205 206
206 /// <summary> 207 /// <summary>
@@ -265,6 +266,7 @@ public class Future
265 } 266 }
266 private static Eina.ValueNative NativeResolvedCb(IntPtr data, Eina.ValueNative value, IntPtr dead_future) 267 private static Eina.ValueNative NativeResolvedCb(IntPtr data, Eina.ValueNative value, IntPtr dead_future)
267 { 268 {
269 Console.WriteLine("Type is addr 0x{0:X}", value.Type.ToInt64());
268 GCHandle handle = GCHandle.FromIntPtr(data); 270 GCHandle handle = GCHandle.FromIntPtr(data);
269 ResolvedCb cb = handle.Target as ResolvedCb; 271 ResolvedCb cb = handle.Target as ResolvedCb;
270 if (cb != null) 272 if (cb != null)
diff --git a/src/bindings/mono/eina_mono/eina_value.cs b/src/bindings/mono/eina_mono/eina_value.cs
index ce92140c37..ab5334d301 100644
--- a/src/bindings/mono/eina_mono/eina_value.cs
+++ b/src/bindings/mono/eina_mono/eina_value.cs
@@ -776,6 +776,10 @@ public class Value : IDisposable, IComparable<Value>, IEquatable<Value>
776 /// <summary>Constructor to build value from Values_Natives passed by value from C.</summary> 776 /// <summary>Constructor to build value from Values_Natives passed by value from C.</summary>
777 public Value(ValueNative value) 777 public Value(ValueNative value)
778 { 778 {
779 Console.WriteLine("Type is addr 0x{0:X}", value.Type.ToInt64());
780 var t = ValueTypeBridge.GetManaged(value.Type);
781 Console.WriteLine("Type is {0}", t);
782
779 IntPtr tmp = IntPtr.Zero; 783 IntPtr tmp = IntPtr.Zero;
780 try { 784 try {
781 this.Handle = Alloc(); 785 this.Handle = Alloc();
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 7243fad592..ac9ab222a4 100644
--- a/src/bindings/mono/eo_mono/iwrapper.cs
+++ b/src/bindings/mono/eo_mono/iwrapper.cs
@@ -416,7 +416,7 @@ public class Globals {
416 Eina.Log.Debug($"Calling data_scope_get with obj {obj.NativeHandle.ToInt64():x} and klass {obj.NativeClass.ToInt64():x}"); 416 Eina.Log.Debug($"Calling data_scope_get with obj {obj.NativeHandle.ToInt64():x} and klass {obj.NativeClass.ToInt64():x}");
417 Console.WriteLine($"Calling data_scope_get with obj {obj.NativeHandle.ToInt64():x} and klass {obj.NativeClass.ToInt64():x}"); 417 Console.WriteLine($"Calling data_scope_get with obj {obj.NativeHandle.ToInt64():x} and klass {obj.NativeClass.ToInt64():x}");
418 IntPtr pd = Efl.Eo.Globals.efl_data_scope_get(obj.NativeHandle, obj.NativeClass); 418 IntPtr pd = Efl.Eo.Globals.efl_data_scope_get(obj.NativeHandle, obj.NativeClass);
419 if (pd != null) 419 if (pd != IntPtr.Zero)
420 { 420 {
421 GCHandle gch = GCHandle.Alloc(obj); 421 GCHandle gch = GCHandle.Alloc(obj);
422 EolianPD epd; 422 EolianPD epd;
@@ -467,12 +467,17 @@ public class Globals {
467 // Flag to be passed to the cancell callback 467 // Flag to be passed to the cancell callback
468 bool fulfilled = false; 468 bool fulfilled = false;
469 469
470 Console.WriteLine("1"); Console.Out.Flush();
471
470 future.Then((Eina.Value received) => { 472 future.Then((Eina.Value received) => {
473 Console.WriteLine("2"); Console.Out.Flush();
471 lock (future) 474 lock (future)
472 { 475 {
476 Console.WriteLine("2"); Console.Out.Flush();
473 // Convert an failed Future to a failed Task. 477 // Convert an failed Future to a failed Task.
474 if (received.GetValueType() == Eina.ValueType.Error) 478 if (received.GetValueType() == Eina.ValueType.Error)
475 { 479 {
480 Console.WriteLine("Error"); Console.Out.Flush();
476 Eina.Error err; 481 Eina.Error err;
477 received.Get(out err); 482 received.Get(out err);
478 if (err == Eina.Error.ECANCELED) 483 if (err == Eina.Error.ECANCELED)
@@ -482,6 +487,7 @@ public class Globals {
482 } 487 }
483 else 488 else
484 { 489 {
490 Console.WriteLine("Succeeded"); Console.Out.Flush();
485 // Will mark the returned task below as completed. 491 // Will mark the returned task below as completed.
486 tcs.SetResult(received); 492 tcs.SetResult(received);
487 } 493 }
@@ -489,8 +495,10 @@ public class Globals {
489 return received; 495 return received;
490 } 496 }
491 }); 497 });
498 Console.WriteLine("11"); Console.Out.Flush();
492 // Callback to be called when the token is cancelled. 499 // Callback to be called when the token is cancelled.
493 token.Register(() => { 500 token.Register(() => {
501 Console.WriteLine("4"); Console.Out.Flush();
494 lock (future) 502 lock (future)
495 { 503 {
496 // Will trigger the Then callback above with an Eina.Error 504 // Will trigger the Then callback above with an Eina.Error
@@ -498,6 +506,7 @@ public class Globals {
498 future.Cancel(); 506 future.Cancel();
499 } 507 }
500 }); 508 });
509 Console.WriteLine("3"); Console.Out.Flush();
501 510
502 return tcs.Task; 511 return tcs.Task;
503 } 512 }
diff --git a/src/lib/ecore/efl_loop.c b/src/lib/ecore/efl_loop.c
index 1096c62bdb..7c37d49ba0 100644
--- a/src/lib/ecore/efl_loop.c
+++ b/src/lib/ecore/efl_loop.c
@@ -690,7 +690,10 @@ efl_loop_future_scheduler_get(const Eo *obj)
690{ 690{
691 Efl_Loop *loop; 691 Efl_Loop *loop;
692 692
693 printf ("efl_loop_future_scheduler_get\n"); fflush(stdout);
694
693 if (!obj) return NULL; 695 if (!obj) return NULL;
696 printf ("efl_loop_future_scheduler_get\n"); fflush(stdout);
694 697
695 if (efl_isa(obj, EFL_LOOP_CLASS)) 698 if (efl_isa(obj, EFL_LOOP_CLASS))
696 { 699 {
@@ -711,9 +714,12 @@ efl_loop_future_scheduler_get(const Eo *obj)
711 return efl_loop_future_scheduler_get(efl_loop_get(obj)); 714 return efl_loop_future_scheduler_get(efl_loop_get(obj));
712 715
713 loop = efl_provider_find(obj, EFL_LOOP_CLASS); 716 loop = efl_provider_find(obj, EFL_LOOP_CLASS);
717 printf ("scheduler found %p\n", loop); fflush(stdout);
714 if (loop) 718 if (loop)
715 return efl_loop_future_scheduler_get(loop); 719 return efl_loop_future_scheduler_get(loop);
716 720
721 printf ("no scheduler found\n"); fflush(stdout);
722
717 return NULL; 723 return NULL;
718} 724}
719 725
diff --git a/src/lib/ecore/efl_loop_consumer.c b/src/lib/ecore/efl_loop_consumer.c
index 2b5182e6d8..d2f5de88d3 100644
--- a/src/lib/ecore/efl_loop_consumer.c
+++ b/src/lib/ecore/efl_loop_consumer.c
@@ -40,6 +40,7 @@ static Eina_Future *
40_efl_loop_consumer_future_resolved(const Eo *obj, Efl_Loop_Consumer_Data *pd EINA_UNUSED, 40_efl_loop_consumer_future_resolved(const Eo *obj, Efl_Loop_Consumer_Data *pd EINA_UNUSED,
41 Eina_Value result) 41 Eina_Value result)
42{ 42{
43 printf("_efl_loop_consumer_future_resolved\n"); fflush(stdout);
43 return eina_future_resolved(efl_loop_future_scheduler_get(obj), result); 44 return eina_future_resolved(efl_loop_future_scheduler_get(obj), result);
44} 45}
45 46
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
35 Efl_Mono_Model_Internal_Data* model_pd; 35 Efl_Mono_Model_Internal_Data* model_pd;
36 size_t index; 36 size_t index;
37 Eina_Array *values; 37 Eina_Array *values;
38 Eo* child;
38 //Eina_Array *items; 39 //Eina_Array *items;
39} Efl_Mono_Model_Internal_Child_Data; 40} Efl_Mono_Model_Internal_Child_Data;
40 41
41static int _find_property_index (const char* name, Eina_Array* properties_info) 42static int _find_property_index (const char* name, Eina_Array* properties_name)
42{ 43{
43 int i, size = eina_array_count_get(properties_info); 44 int i, size = eina_array_count_get(properties_name);
44 fprintf(stdout, "count %d\n", size); fflush(stdout); 45 fprintf(stdout, "count %d\n", size); fflush(stdout);
45 for (i = 0; i != size; ++i) 46 for (i = 0; i != size; ++i)
46 { 47 {
47 if (!strcmp(properties_info->data[i], name)) 48 printf ("Testing %s with %s\n", (char*)properties_name->data[i], name); fflush(stdout);
49 if (!strcmp(properties_name->data[i], name))
48 { 50 {
49 return i; 51 return i;
50 } 52 }
@@ -59,6 +61,7 @@ _efl_mono_model_internal_efl_object_constructor(Eo *obj, Efl_Mono_Model_Internal
59 obj = efl_constructor(efl_super(obj, MY_CLASS)); 61 obj = efl_constructor(efl_super(obj, MY_CLASS));
60 62
61 pd->properties_info = eina_array_new(5); 63 pd->properties_info = eina_array_new(5);
64 pd->properties_names = eina_array_new(5);
62 pd->items = eina_array_new(5); 65 pd->items = eina_array_new(5);
63 66
64 if (!obj) return NULL; 67 if (!obj) return NULL;
@@ -81,6 +84,7 @@ _efl_mono_model_internal_add_property(Eo *obj EINA_UNUSED, Efl_Mono_Model_Intern
81 info->name = eina_stringshare_add(name); 84 info->name = eina_stringshare_add(name);
82 info->type = type; 85 info->type = type;
83 eina_array_push (pd->properties_info, info); 86 eina_array_push (pd->properties_info, info);
87 eina_array_push (pd->properties_names, eina_stringshare_add(info->name));
84} 88}
85 89
86 90
@@ -100,6 +104,8 @@ _efl_mono_model_internal_efl_model_child_add(Eo *obj, Efl_Mono_Model_Internal_Da
100 Efl_Mono_Model_Internal_Child_Data* pcd = efl_data_xref (child, EFL_MONO_MODEL_INTERNAL_CHILD_CLASS, obj); 104 Efl_Mono_Model_Internal_Child_Data* pcd = efl_data_xref (child, EFL_MONO_MODEL_INTERNAL_CHILD_CLASS, obj);
101 pcd->model_pd = pd; 105 pcd->model_pd = pd;
102 pcd->index = eina_array_count_get(pd->items); 106 pcd->index = eina_array_count_get(pd->items);
107 pcd->child = child;
108 pcd->values = eina_array_new(5);
103 eina_array_push (pd->items, pcd); 109 eina_array_push (pd->items, pcd);
104 110
105 return child; 111 return child;
@@ -115,47 +121,65 @@ static Eina_Future *
115_efl_mono_model_internal_child_efl_model_property_set(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd, const char *property, Eina_Value *value) 121_efl_mono_model_internal_child_efl_model_property_set(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd, const char *property, Eina_Value *value)
116{ 122{
117 fprintf (stdout, "property_set\n"); fflush(stdout); 123 fprintf (stdout, "property_set\n"); fflush(stdout);
118 int i = _find_property_index (property, pd->model_pd->properties_info); 124 int i = _find_property_index (property, pd->model_pd->properties_names);
119 int j; 125 int j;
120 Eina_Value* old_value; 126 Eina_Value* old_value;
127 Eina_Value* new_value;
128 Eina_Value tmp_value;
121 129
122 fprintf (stdout, "property_set\n"); fflush(stdout); 130 printf ("value type %p\n", value->type); fflush(stdout);
131 fprintf (stdout, "property_set %d\n", i); fflush(stdout);
123 132
124 if (i >= 0) 133 if (i >= 0)
125 //if (0)
126 { 134 {
127 for (j = i - eina_array_count_get (pd->values); j; --j) 135 fprintf(stdout, __FILE__ ":%d %d %d\n", __LINE__, i, eina_array_count_get (pd->values)); fflush(stdout);
128 eina_array_push (pd->values, NULL); 136 for (j = i - eina_array_count_get (pd->values); j >= 0; --j)
129 137 {
138 fprintf(stdout, __FILE__ ":%d\n", __LINE__); fflush(stdout);
139 eina_array_push (pd->values, (void*)1);
140 pd->values->data[pd->values->count-1] = NULL;
141 }
142
143 fprintf(stdout, __FILE__ ":%d %d %d\n", __LINE__, i, eina_array_count_get (pd->values)); fflush(stdout);
130 old_value = eina_array_data_get (pd->values, i); 144 old_value = eina_array_data_get (pd->values, i);
145 fprintf(stdout, __FILE__ ":%d %p\n", __LINE__, old_value); fflush(stdout);
131 if (old_value) 146 if (old_value)
132 eina_value_free (old_value); 147 eina_value_free (old_value);
133 eina_array_data_set (pd->values, i, value); 148 new_value = malloc (sizeof(Eina_Value));
149 eina_value_copy (value, new_value);
150 printf ("new_value type %p\n", new_value->type); fflush(stdout);
151 eina_value_copy (value, &tmp_value);
152 printf ("tmp_value type %p\n", tmp_value.type); fflush(stdout);
153 eina_array_data_set (pd->values, i, new_value);
134 154
135 /* promise = eian_promise_new (efl_loop_future_scheduler_get(obj), NULL, NULL); */ 155 fprintf(stdout, __FILE__ ":%d\n", __LINE__); fflush(stdout);
136 /* future = eina_future_new (promise); */
137 156
138 157 return efl_loop_future_resolved(obj, tmp_value);
139 Eina_Future* f = efl_loop_future_resolved(obj, *value);
140 fprintf(stdout, "com resolved %p\n", f); fflush(stdout);
141 assert(!!f);
142 return f;
143 } 158 }
144 else 159 else
145 { 160 {
161 printf ("Index not found!\n"); fflush(stdout);
146 // not found property 162 // not found property
147 //return efl_loop_future_rejected(obj, EAGAIN); 163 return efl_loop_future_rejected(obj, EAGAIN);
148
149 Eina_Promise* promise = eina_promise_new (efl_loop_future_scheduler_get(obj), NULL, NULL);
150 Eina_Future* future = eina_future_new (promise);
151 return future;
152 } 164 }
153} 165}
154 166
155static Eina_Value * 167static Eina_Value *
156_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) 168_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)
157{ 169{
158 return eina_value_error_new(EAGAIN); 170 printf ("trying to property get prop name %s\n", property); fflush(stdout);
171 int i = _find_property_index (property, pd->model_pd->properties_names);
172 printf ("trying to property get index %d\n", i); fflush(stdout);
173 if(eina_array_count_get (pd->values) <= i
174 || eina_array_data_get (pd->values, i) == NULL)
175 return eina_value_error_new(EAGAIN);
176 else
177 {
178 Eina_Value* src = eina_array_data_get(pd->values, i);
179 Eina_Value* clone = malloc (sizeof(Eina_Value));
180 eina_value_copy (src, clone);
181 return clone;
182 }
159} 183}
160 184
161static Eina_Future * 185static Eina_Future *
@@ -163,11 +187,18 @@ _efl_mono_model_internal_efl_model_children_slice_get(Eo *obj, Efl_Mono_Model_In
163{ 187{
164 unsigned int i; 188 unsigned int i;
165 Eina_Value array = EINA_VALUE_EMPTY; 189 Eina_Value array = EINA_VALUE_EMPTY;
190 Efl_Mono_Model_Internal_Child_Data* pcd;
166 191
167 eina_value_array_setup(&array, EINA_VALUE_TYPE_OBJECT, count % 8); 192 eina_value_array_setup(&array, EINA_VALUE_TYPE_OBJECT, count % 8);
168 193
169 for (i = start; i != start + count; ++i) 194 for (i = start; i != start + count; ++i)
170 eina_value_array_append (&array, eina_array_data_get(pd->items, i)); 195 {
196 pcd = eina_array_data_get(pd->items, i);
197 eina_value_array_append (&array, pcd->child);
198 }
199
200 printf("returning future resolved of type %p and subtype %p type %p\n", EINA_VALUE_TYPE_ARRAY, EINA_VALUE_TYPE_OBJECT,
201 array.type); fflush(stdout);
171 202
172 return efl_loop_future_resolved(obj, array); 203 return efl_loop_future_resolved(obj, array);
173} 204}
@@ -183,6 +214,7 @@ _efl_mono_model_internal_child_efl_object_constructor(Eo *obj, Efl_Mono_Model_In
183static void 214static void
184_efl_mono_model_internal_child_efl_object_destructor(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd EINA_UNUSED) 215_efl_mono_model_internal_child_efl_object_destructor(Eo *obj, Efl_Mono_Model_Internal_Child_Data *pd EINA_UNUSED)
185{ 216{
217 printf("_efl_mono_model_internal_child_efl_object_destructor\n"); fflush(stdout);
186 efl_destructor(efl_super(obj, EFL_MONO_MODEL_INTERNAL_CHILD_CLASS)); 218 efl_destructor(efl_super(obj, EFL_MONO_MODEL_INTERNAL_CHILD_CLASS));
187} 219}
188 220
diff --git a/src/lib/ecore/efl_mono_model_internal.eo b/src/lib/ecore/efl_mono_model_internal.eo
index 341f066480..ee7642baca 100644
--- a/src/lib/ecore/efl_mono_model_internal.eo
+++ b/src/lib/ecore/efl_mono_model_internal.eo
@@ -1,4 +1,4 @@
1class Efl.Mono_Model_Internal extends Efl.Object implements Efl.Model 1class Efl.Mono_Model_Internal extends Efl.Loop_Consumer implements Efl.Model
2{ 2{
3 methods { 3 methods {
4 add_property { 4 add_property {
diff --git a/src/lib/ecore/efl_mono_model_internal_child.eo b/src/lib/ecore/efl_mono_model_internal_child.eo
index 5802e69e4f..ec8d657ca4 100644
--- a/src/lib/ecore/efl_mono_model_internal_child.eo
+++ b/src/lib/ecore/efl_mono_model_internal_child.eo
@@ -1,4 +1,4 @@
1class Efl.Mono_Model_Internal_Child extends Efl.Object implements Efl.Model 1class Efl.Mono_Model_Internal_Child extends Efl.Loop_Consumer implements Efl.Model
2{ 2{
3 implements { 3 implements {
4 Efl.Object.constructor; 4 Efl.Object.constructor;
diff --git a/src/lib/efl/interfaces/efl_model.eo b/src/lib/efl/interfaces/efl_model.eo
index 48c4809aa8..07c91c03e0 100644
--- a/src/lib/efl/interfaces/efl_model.eo
+++ b/src/lib/efl/interfaces/efl_model.eo
@@ -125,7 +125,7 @@ interface @beta Efl.Model
125 ignored.]] 125 ignored.]]
126 } 126 }
127 /* XXX: is this right? */ 127 /* XXX: is this right? */
128 return: future<accessor<Efl.Object>>; [[Array of children]] 128 return: future<array<Efl.Object>>; [[Array of children]]
129 } 129 }
130 @property children_count { 130 @property children_count {
131 get { 131 get {
diff --git a/src/lib/eina/eina_log.c b/src/lib/eina/eina_log.c
index 52cf8f98ac..bb487af3f4 100644
--- a/src/lib/eina/eina_log.c
+++ b/src/lib/eina/eina_log.c
@@ -163,7 +163,7 @@ static unsigned int _log_domains_count = 0;
163static size_t _log_domains_allocated = 0; 163static size_t _log_domains_allocated = 0;
164 164
165// Default function for printing on domains 165// Default function for printing on domains
166static Eina_Log_Print_Cb _print_cb = eina_log_print_cb_stderr; 166static Eina_Log_Print_Cb _print_cb = eina_log_print_cb_stdout;
167static void *_print_cb_data = NULL; 167static void *_print_cb_data = NULL;
168 168
169#ifdef DEBUG 169#ifdef DEBUG
diff --git a/src/lib/eina/eina_promise.c b/src/lib/eina/eina_promise.c
index f2dc9cccac..c91ec27f74 100644
--- a/src/lib/eina/eina_promise.c
+++ b/src/lib/eina/eina_promise.c
@@ -887,6 +887,8 @@ eina_future_resolved(Eina_Future_Scheduler *scheduler, Eina_Value value)
887 Eina_Promise *p; 887 Eina_Promise *p;
888 Eina_Future *f; 888 Eina_Future *f;
889 889
890 printf ("eina_promise.c value with type %p\n", value.type); fflush(stdout);
891
890 EINA_SAFETY_ON_NULL_GOTO(scheduler, error); 892 EINA_SAFETY_ON_NULL_GOTO(scheduler, error);
891 893
892 p = eina_promise_new(scheduler, _dummy_cancel, NULL); 894 p = eina_promise_new(scheduler, _dummy_cancel, NULL);
diff --git a/src/lib/eina/eina_value.c b/src/lib/eina/eina_value.c
index dbf6f48d9c..018fcd43d8 100644
--- a/src/lib/eina/eina_value.c
+++ b/src/lib/eina/eina_value.c
@@ -2348,6 +2348,7 @@ _eina_value_type_array_flush(const Eina_Value_Type *type EINA_UNUSED, void *mem)
2348 Eina_Value_Array *tmem = mem; 2348 Eina_Value_Array *tmem = mem;
2349 Eina_Bool ret =_eina_value_type_array_flush_elements(tmem); 2349 Eina_Bool ret =_eina_value_type_array_flush_elements(tmem);
2350 2350
2351 printf (__FILE__ ":%d\n", __LINE__); fflush(stdout);
2351 if (tmem->array) eina_inarray_free(tmem->array); 2352 if (tmem->array) eina_inarray_free(tmem->array);
2352 tmem->array = NULL; 2353 tmem->array = NULL;
2353 tmem->subtype = NULL; 2354 tmem->subtype = NULL;
@@ -2363,6 +2364,7 @@ _eina_value_type_array_copy(const Eina_Value_Type *type EINA_UNUSED, const void
2363 unsigned int i, count, sz; 2364 unsigned int i, count, sz;
2364 char *ptr, *ptr_end; 2365 char *ptr, *ptr_end;
2365 2366
2367 printf (__FILE__ ":%d\n", __LINE__); fflush(stdout);
2366 d->subtype = subtype = s->subtype; 2368 d->subtype = subtype = s->subtype;
2367 d->step = s->step; 2369 d->step = s->step;
2368 2370
@@ -2371,11 +2373,13 @@ _eina_value_type_array_copy(const Eina_Value_Type *type EINA_UNUSED, const void
2371 d->array = NULL; 2373 d->array = NULL;
2372 return EINA_TRUE; 2374 return EINA_TRUE;
2373 } 2375 }
2376 printf (__FILE__ ":%d\n", __LINE__); fflush(stdout);
2374 2377
2375 if (!subtype->copy) 2378 if (!subtype->copy)
2376 { 2379 {
2377 return EINA_FALSE; 2380 return EINA_FALSE;
2378 } 2381 }
2382 printf (__FILE__ ":%d\n", __LINE__); fflush(stdout);
2379 2383
2380 d->array = eina_inarray_new(subtype->value_size, s->step); 2384 d->array = eina_inarray_new(subtype->value_size, s->step);
2381 if (!d->array) 2385 if (!d->array)
@@ -2401,6 +2405,7 @@ _eina_value_type_array_copy(const Eina_Value_Type *type EINA_UNUSED, const void
2401 return EINA_TRUE; 2405 return EINA_TRUE;
2402 2406
2403 error: 2407 error:
2408 printf (__FILE__ ":%d error\n", __LINE__); fflush(stdout);
2404 _eina_value_type_array_flush_elements(d); 2409 _eina_value_type_array_flush_elements(d);
2405 eina_inarray_free(d->array); 2410 eina_inarray_free(d->array);
2406 return EINA_FALSE; 2411 return EINA_FALSE;
diff --git a/src/tests/efl_mono/Model.cs b/src/tests/efl_mono/Model.cs
index 5a5f0536a4..f7541c316f 100644
--- a/src/tests/efl_mono/Model.cs
+++ b/src/tests/efl_mono/Model.cs
@@ -1,6 +1,7 @@
1#define CODE_ANALYSIS 1#define CODE_ANALYSIS
2 2
3using System; 3using System;
4using System.Threading.Tasks;
4using System.Diagnostics.CodeAnalysis; 5using System.Diagnostics.CodeAnalysis;
5 6
6namespace TestSuite { 7namespace TestSuite {
@@ -17,36 +18,50 @@ public static class TestModel {
17 18
18 public static void reflection_test () 19 public static void reflection_test ()
19 { 20 {
20 Efl.UserModel<VeggieViewModel> veggies = new Efl.UserModel<VeggieViewModel>(); 21 Efl.Loop loop = Efl.App.AppMain;
22
23 Efl.UserModel<VeggieViewModel> veggies = new Efl.UserModel<VeggieViewModel>(loop);
21 veggies.Add (new VeggieViewModel{ Name="Tomato", Type="Fruit", Image="tomato.png"}); 24 veggies.Add (new VeggieViewModel{ Name="Tomato", Type="Fruit", Image="tomato.png"});
22 veggies.Add (new VeggieViewModel{ Name="Romaine Lettuce", Type="Vegetable", Image="lettuce.png"}); 25 veggies.Add (new VeggieViewModel{ Name="Romaine Lettuce", Type="Vegetable", Image="lettuce.png"});
23 veggies.Add (new VeggieViewModel{ Name="Zucchini", Type="Vegetable", Image="zucchini.png"}); 26 veggies.Add (new VeggieViewModel{ Name="Zucchini", Type="Vegetable", Image="zucchini.png"});
24 27
25
26
27 Console.WriteLine ("end of test"); 28 Console.WriteLine ("end of test");
28 } 29 }
29 30
30 public static void easy_model_extraction () 31 internal static async Task EasyModelExtractionAsync (Efl.Loop loop)
31 { 32 {
32 Efl.UserModel<VeggieViewModel> veggies = new Efl.UserModel<VeggieViewModel>(); 33 Efl.UserModel<VeggieViewModel> veggies = new Efl.UserModel<VeggieViewModel>(loop);
33 veggies.Add (new VeggieViewModel{ Name="Tomato", Type="Fruit", Image="tomato.png"}); 34 veggies.Add (new VeggieViewModel{ Name="Tomato", Type="Fruit", Image="tomato.png"});
34 veggies.Add (new VeggieViewModel{ Name="Romaine Lettuce", Type="Vegetable", Image="lettuce.png"}); 35 veggies.Add (new VeggieViewModel{ Name="Romaine Lettuce", Type="Vegetable", Image="lettuce.png"});
35 veggies.Add (new VeggieViewModel{ Name="Zucchini", Type="Vegetable", Image="zucchini.png"}); 36 veggies.Add (new VeggieViewModel{ Name="Zucchini", Type="Vegetable", Image="zucchini.png"});
36 37
37 var model = new Efl.GenericModel<VeggieViewModel>(veggies); 38 var model = new Efl.GenericModel<VeggieViewModel>(veggies, loop);
38 Console.WriteLine ("size model {0}", model.GetChildrenCount()); 39 Console.WriteLine ("size model {0}", model.GetChildrenCount());
39 40
41 VeggieViewModel r = await model.GetAtAsync(0);
42
43 Test.AssertEquals(r.Name, "Tomato");
44 VeggieViewModel r2 = await model.GetAtAsync(1);
45 Test.AssertEquals(r2.Name, "Romaine Lettuce");
46
47 Console.WriteLine ("end of test, Name of result is {0}", r.Name);
48 loop.End();
49 }
50
51 public static void easy_model_extraction ()
52 {
53 Efl.Loop loop = Efl.App.AppMain;
40 54
55 Task task = EasyModelExtractionAsync(loop);
41 56
42 Console.WriteLine ("end of test"); 57 loop.Begin();
43 } 58 }
44 59
45 public static void factory_test () 60 public static void factory_test ()
46 { 61 {
47 var factory = new Efl.Ui.ItemFactory<Efl.Object>(); 62 var factory = new Efl.Ui.ItemFactory<Efl.Object>();
48 //factory.Foo(); 63 //factory.Foo();
49 factory.Name().Bind("name"); 64 factory.Name().Bind("first name");
50 } 65 }
51} 66}
52 67