summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2017-06-08 21:36:54 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-07-13 18:25:44 -0300
commit2624e91cbaa2045117c91688974f973c1bdf2bf5 (patch)
tree0e9f2a3523d21c292d9b0b8ae9cd7cee9df5f07c
parent715f0fd87b203e67e355e1560c1fa6e43e1b8569 (diff)
eolian_mono eina_mono: WIP version of eina.Inarray binding and generation
Still need to address the eolian keyword problem.
-rw-r--r--src/Makefile_Efl_Mono.am1
-rw-r--r--src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh5
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh28
-rw-r--r--src/bin/eolian_mono/eolian/mono/type_impl.hh6
-rw-r--r--src/bindings/mono/eina_mono/eina_inarray.cs92
-rw-r--r--src/tests/efl_mono/Eina.cs513
-rw-r--r--src/tests/efl_mono/libefl_mono_native_test.c392
-rw-r--r--src/tests/efl_mono/test_testing.eo147
8 files changed, 1153 insertions, 31 deletions
diff --git a/src/Makefile_Efl_Mono.am b/src/Makefile_Efl_Mono.am
index 8b542a42d9..1a40dec739 100644
--- a/src/Makefile_Efl_Mono.am
+++ b/src/Makefile_Efl_Mono.am
@@ -132,6 +132,7 @@ efl_eina_mono_files = \
132 bindings/mono/eina_mono/eina_array.cs \ 132 bindings/mono/eina_mono/eina_array.cs \
133 bindings/mono/eina_mono/eina_hash.cs \ 133 bindings/mono/eina_mono/eina_hash.cs \
134 bindings/mono/eina_mono/eina_list.cs \ 134 bindings/mono/eina_mono/eina_list.cs \
135 bindings/mono/eina_mono/eina_inarray.cs \
135 bindings/mono/eina_mono/eina_container_common.cs \ 136 bindings/mono/eina_mono/eina_container_common.cs \
136 bindings/mono/eina_mono/eina_common.cs \ 137 bindings/mono/eina_mono/eina_common.cs \
137 bindings/mono/eina_mono/eina_log.cs \ 138 bindings/mono/eina_mono/eina_log.cs \
diff --git a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
index 7de790481e..94ce00dbd5 100644
--- a/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/marshall_type_impl.hh
@@ -132,6 +132,11 @@ struct marshall_type_visitor_generate
132 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}}; 132 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
133 } 133 }
134 } 134 }
135 ,{"inarray", nullptr, nullptr, [&]
136 {
137 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
138 }
139 }
135 ,{"list", nullptr, nullptr, [&] 140 ,{"list", nullptr, nullptr, [&]
136 { 141 {
137 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}}; 142 return regular_type_def{" System.IntPtr", complex.outer.base_qualifier, {}};
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index 50083802f1..1080f992d9 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -236,6 +236,10 @@ inline bool param_should_use_out_var(attributes::parameter_def const& param)
236 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, WANT_OUT) 236 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, WANT_OUT)
237 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 237 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
238 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 238 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
239 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
240 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
241 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
242 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
239 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 243 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
240 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 244 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
241 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 245 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
@@ -260,6 +264,10 @@ inline bool param_should_use_in_var(attributes::parameter_def const& param)
260 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, !WANT_OUT) 264 || param_is_acceptable(param, "Eina_Array *", WANT_OWN, !WANT_OUT)
261 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, !WANT_OUT) 265 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, !WANT_OUT)
262 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, !WANT_OUT) 266 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, !WANT_OUT)
267 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, !WANT_OUT)
268 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, !WANT_OUT)
269 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, !WANT_OUT)
270 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, !WANT_OUT)
263 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, !WANT_OUT) 271 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, !WANT_OUT)
264 || param_is_acceptable(param, "Eina_List *", WANT_OWN, !WANT_OUT) 272 || param_is_acceptable(param, "Eina_List *", WANT_OWN, !WANT_OUT)
265 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, !WANT_OUT) 273 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, !WANT_OUT)
@@ -442,6 +450,7 @@ struct native_convert_in_variable_generator
442 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context); 450 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
443 } 451 }
444 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *" 452 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *"
453 || param.type.c_type == "Eina_Inarray *" || param.type.c_type == "const Eina_Inarray *"
445 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 454 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
446 ) 455 )
447 { 456 {
@@ -507,6 +516,7 @@ struct convert_in_variable_generator
507 return false; 516 return false;
508 } 517 }
509 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *" 518 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *"
519 || param.type.c_type == "Eina_Inarray *" || param.type.c_type == "const Eina_Inarray *"
510 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 520 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
511 ) 521 )
512 { 522 {
@@ -563,6 +573,10 @@ struct convert_out_variable_generator
563 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 573 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
564 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 574 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
565 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 575 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
576 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
577 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
578 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
579 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
566 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 580 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
567 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 581 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
568 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 582 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
@@ -608,6 +622,10 @@ struct native_convert_out_variable_generator
608 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 622 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
609 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 623 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
610 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 624 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
625 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
626 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
627 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
628 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
611 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 629 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
612 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 630 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
613 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 631 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
@@ -695,6 +713,10 @@ struct convert_out_assign_generator
695 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 713 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
696 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 714 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
697 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 715 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
716 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
717 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
718 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
719 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT
698 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 720 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
699 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 721 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
700 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 722 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
@@ -774,6 +796,7 @@ struct convert_return_generator
774 return false; 796 return false;
775 } 797 }
776 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *" 798 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *"
799 || ret_type.c_type == "Eina_Inarray *" || ret_type.c_type == "const Eina_Inarray *"
777 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 800 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
778 ) 801 )
779 { 802 {
@@ -862,6 +885,10 @@ struct native_convert_out_assign_generator
862 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT) 885 || param_is_acceptable(param, "Eina_Array *", !WANT_OWN, WANT_OUT)
863 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT) 886 || param_is_acceptable(param, "const Eina_Array *", WANT_OWN, WANT_OUT)
864 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT) 887 || param_is_acceptable(param, "const Eina_Array *", !WANT_OWN, WANT_OUT)
888 || param_is_acceptable(param, "Eina_Inarray *", WANT_OWN, WANT_OUT)
889 || param_is_acceptable(param, "Eina_Inarray *", !WANT_OWN, WANT_OUT)
890 || param_is_acceptable(param, "const Eina_Inarray *", WANT_OWN, WANT_OUT)
891 || param_is_acceptable(param, "const Eina_Inarray *", !WANT_OWN, WANT_OUT)
865 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT) 892 || param_is_acceptable(param, "Eina_List *", WANT_OWN, WANT_OUT)
866 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 893 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
867 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 894 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
@@ -966,6 +993,7 @@ struct native_convert_return_generator
966 .generate(sink, attributes::unused, context); 993 .generate(sink, attributes::unused, context);
967 } 994 }
968 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *" 995 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *"
996 || ret_type.c_type == "Eina_Inarray *" || ret_type.c_type == "const Eina_Inarray *"
969 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 997 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
970 ) 998 )
971 { 999 {
diff --git a/src/bin/eolian_mono/eolian/mono/type_impl.hh b/src/bin/eolian_mono/eolian/mono/type_impl.hh
index 8f654c5598..562aac7b0e 100644
--- a/src/bin/eolian_mono/eolian/mono/type_impl.hh
+++ b/src/bin/eolian_mono/eolian/mono/type_impl.hh
@@ -272,6 +272,12 @@ struct visitor_generate
272 c.outer.base_type = "eina.Array"; 272 c.outer.base_type = "eina.Array";
273 return c; 273 return c;
274 }} 274 }}
275 , {"inarray", nullptr, nullptr, [&]
276 {
277 complex_type_def c = complex;
278 c.outer.base_type = "eina.Inarray";
279 return c;
280 }}
275 , {"hash", nullptr, nullptr 281 , {"hash", nullptr, nullptr
276 , [&] 282 , [&]
277 { 283 {
diff --git a/src/bindings/mono/eina_mono/eina_inarray.cs b/src/bindings/mono/eina_mono/eina_inarray.cs
index e92f4afbba..1daf7dd9f8 100644
--- a/src/bindings/mono/eina_mono/eina_inarray.cs
+++ b/src/bindings/mono/eina_mono/eina_inarray.cs
@@ -128,7 +128,7 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
128 uint len = eina_inarray_count(h); 128 uint len = eina_inarray_count(h);
129 for(uint i = 0; i < len; ++i) 129 for(uint i = 0; i < len; ++i)
130 { 130 {
131 NativeFreeInplace<T>(eina_inarray_nth(h, i)); 131 InarrayNativeFree<T>(eina_inarray_nth(h, i));
132 } 132 }
133 } 133 }
134 134
@@ -161,17 +161,11 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
161 int len = Length; 161 int len = Length;
162 for (int i = 0; i < len; ++i) 162 for (int i = 0; i < len; ++i)
163 { 163 {
164 NativeFreeInplace<T>(eina_inarray_nth(h, i)); 164 InarrayNativeFree<T>(eina_inarray_nth(Handle, i));
165 } 165 }
166 } 166 }
167 } 167 }
168 168
169 public void Clean()
170 {
171 FreeElementsIfOwned();
172 eina_inarray_clean_custom_export_mono(Handle);
173 }
174
175 public void Flush() 169 public void Flush()
176 { 170 {
177 FreeElementsIfOwned(); 171 FreeElementsIfOwned();
@@ -180,7 +174,7 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
180 174
181 public int Count() 175 public int Count()
182 { 176 {
183 return (int) eina_inarray_count_custom_export_mono(Handle); 177 return (int) eina_inarray_count(Handle);
184 } 178 }
185 179
186 public void SetOwnership(bool ownAll) 180 public void SetOwnership(bool ownAll)
@@ -195,12 +189,14 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
195 OwnContent = ownContent; 189 OwnContent = ownContent;
196 } 190 }
197 191
198 public bool Push(T val) 192 public int Push(T val)
199 { 193 {
200 IntPtr ele = ManagedToNativeAlloc(val); 194 IntPtr ele = InarrayManagedToNativeAlloc(val);
201 var r = InternalPush(ele); 195 var r = eina_inarray_push(Handle, ele);
202 if (!r) 196 if (r == -1)
203 NativeFree<T>(ele); 197 InarrayNativeFree<T>(ele);
198 else
199 InarrayTempFree<T>(ele);
204 return r; 200 return r;
205 } 201 }
206 202
@@ -213,45 +209,79 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
213 209
214 public T Pop() 210 public T Pop()
215 { 211 {
216 IntPtr ele = InternalPop(); 212 IntPtr ele = eina_inarray_pop(Handle);
217 var r = NativeToManaged<T>(ele); 213 var r = InarrayNativeToManaged<T>(ele);
218 if (OwnContent && ele != IntPtr.Zero) 214 if (OwnContent && ele != IntPtr.Zero)
219 NativeFree<T>(ele); 215 InarrayNativeFree<T>(ele);
220 return r; 216 return r;
221 } 217 }
222 218
223 public T DataGet(int idx) 219 public T Nth(uint idx)
224 { 220 {
225 IntPtr ele = InternalDataGet(idx); 221 IntPtr ele = eina_inarray_nth(Handle, idx);
226 return NativeToManaged<T>(ele); 222 return InarrayNativeToManaged<T>(ele);
227 } 223 }
228 224
229 public T At(int idx) 225 public T At(int idx)
230 { 226 {
231 return DataGet(idx); 227 return Nth((uint)idx);
232 } 228 }
233 229
234 public void DataSet(int idx, T val) 230 public bool InsertAt(uint idx, T val)
235 { 231 {
236 IntPtr ele = InternalDataGet(idx); // TODO: check bondaries ?? 232 IntPtr ele = InarrayManagedToNativeAlloc(val);
237 if (OwnContent && ele != IntPtr.Zero) 233 var r = eina_inarray_insert_at(Handle, idx, ele);
238 NativeFree<T>(ele); 234 if (r)
239 ele = ManagedToNativeAlloc(val); 235 InarrayTempFree<T>(ele);
240 InternalDataSet(idx, ele); 236 else
237 InarrayNativeFree<T>(ele);
238 return r;
239 }
240
241 public bool ReplaceAt(uint idx, T val)
242 {
243 IntPtr ele = eina_inarray_nth(Handle, idx);
244 if (ele == IntPtr.Zero)
245 return false;
246 if (OwnContent)
247 InarrayNativeFree<T>(ele);
248 ele = InarrayManagedToNativeAlloc(val);
249 var r = eina_inarray_insert_at(Handle, idx, ele);
250 if (r)
251 InarrayTempFree<T>(ele);
252 else
253 InarrayNativeFree<T>(ele);
254 return r;
241 } 255 }
242 256
243 public T this[int idx] 257 public T this[int idx]
244 { 258 {
245 get 259 get
246 { 260 {
247 return DataGet(idx); 261 return At(idx);
248 } 262 }
249 set 263 set
250 { 264 {
251 DataSet(idx, value); 265 ReplaceAt(idx, value);
252 } 266 }
253 } 267 }
254 268
269 public bool RemoveAt(uint idx)
270 {
271 IntPtr ele = eina_inarray_nth(Handle, idx);
272 if (ele == IntPtr.Zero)
273 return false;
274 if (OwnContent)
275 InarrayNativeFree<T>(ele);
276
277 return eina_inarray_remove_at(Handle, idx);
278 }
279
280 public bool Reverse()
281 {
282 eina_inarray_reverse(Handle);
283 }
284
255 public T[] ToArray() 285 public T[] ToArray()
256 { 286 {
257 int len = Length; 287 int len = Length;
@@ -266,7 +296,7 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
266 public bool Append(T[] values) 296 public bool Append(T[] values)
267 { 297 {
268 foreach(T v in values) 298 foreach(T v in values)
269 if (!Push(v)) 299 if (Push(v) == -1)
270 return false; 300 return false;
271 return true; 301 return true;
272 } 302 }
@@ -276,7 +306,7 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
276 int len = Length; 306 int len = Length;
277 for(int i = 0; i < len; ++i) 307 for(int i = 0; i < len; ++i)
278 { 308 {
279 yield return DataGet(i); 309 yield return At(i);
280 } 310 }
281 } 311 }
282 312
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 20b1433a8d..5f0c3643da 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -1242,6 +1242,519 @@ class TestEinaArray
1242 // 1242 //
1243} 1243}
1244 1244
1245class TestEinaInarray
1246{
1247 public static void eina_inarray_default()
1248 {
1249 var a = new eina.Inarray<int>();
1250 Test.Assert(a.Handle != IntPtr.Zero);
1251 }
1252
1253 public static void push_int()
1254 {
1255 var a = new eina.Inarray<int>();
1256 Test.Assert(a.Handle != IntPtr.Zero);
1257 Test.Assert(a.Push(88) == 0);
1258 Test.Assert(a[0] == 88);
1259 }
1260
1261 public static void push_string()
1262 {
1263 var a = new eina.Inarray<string>();
1264 Test.Assert(a.Handle != IntPtr.Zero);
1265 Test.Assert(a.Push("test string") == 0);
1266 Test.Assert(a[0] == "test string");
1267 }
1268
1269 public static void push_obj()
1270 {
1271 var a = new eina.Inarray<test.NumberwrapperConcrete>();
1272 Test.Assert(a.Handle != IntPtr.Zero);
1273 var o = new test.NumberwrapperConcrete();
1274 o.number_set(88);
1275 Test.Assert(a.Push(o) == 0);
1276 Test.Assert(a[0].raw_handle == o.raw_handle);
1277 Test.Assert(a[0].number_get() == 88);
1278 }
1279
1280 public static void pop_int()
1281 {
1282 var a = new eina.Inarray<int>();
1283 Test.Assert(a.Handle != IntPtr.Zero);
1284 Test.Assert(a.Push(88) >= 0);
1285 Test.Assert(a.Pop() == 88);
1286 Test.Assert(a.Count() == 0);
1287 }
1288
1289 public static void pop_string()
1290 {
1291 var a = new eina.Inarray<string>();
1292 Test.Assert(a.Handle != IntPtr.Zero);
1293 Test.Assert(a.Push("test string") >= 0);
1294 Test.Assert(a.Pop() == "test string");
1295 Test.Assert(a.Count() == 0);
1296 }
1297
1298 public static void pop_obj()
1299 {
1300 var a = new eina.Inarray<test.NumberwrapperConcrete>();
1301 Test.Assert(a.Handle != IntPtr.Zero);
1302 var o = new test.NumberwrapperConcrete();
1303 o.number_set(88);
1304 Test.Assert(a.Push(o) >= 0);
1305 var p = a.Pop();
1306 Test.Assert(p.raw_handle == o.raw_handle);
1307 Test.Assert(p.number_get() == 88);
1308 Test.Assert(a.Count() == 0);
1309 }
1310
1311 public static void replace_at_int()
1312 {
1313 var a = new eina.Inarray<int>();
1314 Test.Assert(a.Handle != IntPtr.Zero);
1315 Test.Assert(a.Push(88) >= 0);
1316 Test.Assert(a[0] == 88);
1317 a.ReplaceAt(0, 44);
1318 Test.Assert(a[0] == 44);
1319 a[0] = 22;
1320 Test.Assert(a[0] == 22);
1321 }
1322
1323 public static void replace_at_string()
1324 {
1325 var a = new eina.Inarray<string>();
1326 Test.Assert(a.Handle != IntPtr.Zero);
1327 Test.Assert(a.Push("test string") >= 0);
1328 Test.Assert(a[0] == "test string");
1329 a.ReplaceAt(0, "other string");
1330 Test.Assert(a[0] == "other string");
1331 a[0] = "abc";
1332 Test.Assert(a[0] == "abc");
1333 }
1334
1335 public static void replace_at_obj()
1336 {
1337 var a = new eina.Inarray<test.NumberwrapperConcrete>();
1338 Test.Assert(a.Handle != IntPtr.Zero);
1339
1340 var o1 = new test.NumberwrapperConcrete();
1341 o1.number_set(88);
1342
1343 Test.Assert(a.Push(o1) >= 0);
1344 Test.Assert(a[0].raw_handle == o1.raw_handle);
1345 Test.Assert(a[0].number_get() == 88);
1346
1347 var o2 = new test.NumberwrapperConcrete();
1348 o2.number_set(44);
1349
1350 a.ReplaceAt(0, o2);
1351 Test.Assert(a[0].raw_handle == o2.raw_handle);
1352 Test.Assert(a[0].number_get() == 44);
1353
1354 var o3 = new test.NumberwrapperConcrete();
1355 o3.number_set(22);
1356
1357 a[0] = o3;
1358 Test.Assert(a[0].raw_handle == o3.raw_handle);
1359 Test.Assert(a[0].number_get() == 22);
1360 }
1361
1362 public static void count_int()
1363 {
1364 var a = new eina.Inarray<int>();
1365 Test.Assert(a.Handle != IntPtr.Zero);
1366 Test.Assert(a.Count() == 0);
1367 Test.Assert(a.Push(88) == 0);
1368 Test.Assert(a[0] == 88);
1369 Test.Assert(a.Count() == 1);
1370 Test.Assert(a.Push(44) == 1);
1371 Test.Assert(a[1] == 44);
1372 Test.Assert(a.Count() == 2);
1373 Test.Assert(a.Push(22) == 2);
1374 Test.Assert(a[2] == 22);
1375 Test.Assert(a.Count() == 3);
1376 }
1377
1378 public static void count_string()
1379 {
1380 var a = new eina.Inarray<string>();
1381 Test.Assert(a.Handle != IntPtr.Zero);
1382 Test.Assert(a.Count() == 0);
1383 Test.Assert(a.Push("a") == 0);
1384 Test.Assert(a[0] == "a");
1385 Test.Assert(a.Count() == 1);
1386 Test.Assert(a.Push("b") == 1);
1387 Test.Assert(a[1] == "b");
1388 Test.Assert(a.Count() == 2);
1389 Test.Assert(a.Push("c") == 2);
1390 Test.Assert(a[2] == "c");
1391 Test.Assert(a.Count() == 3);
1392 }
1393
1394 public static void count_obj()
1395 {
1396 var a = new eina.Inarray<test.NumberwrapperConcrete>();
1397 Test.Assert(a.Handle != IntPtr.Zero);
1398
1399 Test.Assert(a.Count() == 0);
1400
1401 var o1 = new test.NumberwrapperConcrete();
1402 o1.number_set(88);
1403 Test.Assert(a.Push(o1) == 0);
1404 Test.Assert(a[0].raw_handle == o1.raw_handle);
1405 Test.Assert(a[0].number_get() == 88);
1406 Test.Assert(a.Count() == 1);
1407
1408 var o2 = new test.NumberwrapperConcrete();
1409 o2.number_set(44);
1410 Test.Assert(a.Push(o2) == 1);
1411 Test.Assert(a[1].raw_handle == o2.raw_handle);
1412 Test.Assert(a[1].number_get() == 44);
1413 Test.Assert(a.Count() == 2);
1414
1415 var o3 = new test.NumberwrapperConcrete();
1416 o3.number_set(22);
1417 Test.Assert(a.Push(o3) == 2);
1418 Test.Assert(a[2].raw_handle == o3.raw_handle);
1419 Test.Assert(a[2].number_get() == 22);
1420 Test.Assert(a.Count() == 3);
1421 }
1422
1423 public static void length_int()
1424 {
1425 var a = new eina.Inarray<int>();
1426 Test.Assert(a.Handle != IntPtr.Zero);
1427 Test.Assert(a.Length == 0);
1428 Test.Assert(a.Push(88) >= 0);
1429 Test.Assert(a[0] == 88);
1430 Test.Assert(a.Length == 1);
1431 Test.Assert(a.Push(44) >= 0);
1432 Test.Assert(a[1] == 44);
1433 Test.Assert(a.Length == 2);
1434 Test.Assert(a.Push(22) >= 0);
1435 Test.Assert(a[2] == 22);
1436 Test.Assert(a.Length == 3);
1437 }
1438
1439 public static void length_string()
1440 {
1441 var a = new eina.Inarray<string>();
1442 Test.Assert(a.Handle != IntPtr.Zero);
1443 Test.Assert(a.Length == 0);
1444 Test.Assert(a.Push("a") >= 0);
1445 Test.Assert(a[0] == "a");
1446 Test.Assert(a.Length == 1);
1447 Test.Assert(a.Push("b") >= 0);
1448 Test.Assert(a[1] == "b");
1449 Test.Assert(a.Length == 2);
1450 Test.Assert(a.Push("c") >= 0);
1451 Test.Assert(a[2] == "c");
1452 Test.Assert(a.Length == 3);
1453 }
1454
1455 public static void eina_inarray_as_ienumerable_int()
1456 {
1457 var a = new eina.Inarray<int>();
1458 Test.Assert(a.Handle != IntPtr.Zero);
1459 Test.Assert(a.Push(88) == 0);
1460 Test.Assert(a.Push(44) == 1);
1461 Test.Assert(a.Push(22) == 2);
1462
1463 int cmp = 88;
1464 foreach (int e in a)
1465 {
1466 Test.AssertEquals(cmp, e);
1467 cmp /= 2;
1468 }
1469 }
1470
1471 public static void eina_inarray_as_ienumerable_string()
1472 {
1473 var a = new eina.Inarray<string>();
1474 Test.Assert(a.Handle != IntPtr.Zero);
1475 Test.Assert(a.Push("X") == 0);
1476 Test.Assert(a.Push("XX") == 1);
1477 Test.Assert(a.Push("XXX") == 2);
1478
1479 string cmp = "X";
1480 foreach (string e in a)
1481 {
1482 Test.AssertEquals(cmp, e);
1483 cmp = cmp + "X";
1484 }
1485 }
1486
1487 public static void eina_inarray_as_ienumerable_obj()
1488 {
1489 var a = new test.NumberwrapperConcrete();
1490 var b = new test.NumberwrapperConcrete();
1491 var c = new test.NumberwrapperConcrete();
1492 a.number_set(88);
1493 b.number_set(44);
1494 c.number_set(22);
1495 var cmp = new test.NumberwrapperConcrete[]{a,b,c};
1496
1497 var arr = new eina.Inarray<test.NumberwrapperConcrete>();
1498 Test.Assert(arr.Handle != IntPtr.Zero);
1499 Test.Assert(arr.Push(a) == 0);
1500 Test.Assert(arr.Push(b) == 1);
1501 Test.Assert(arr.Push(c) == 2);
1502
1503 int i = 0;
1504 foreach (test.NumberwrapperConcrete e in arr)
1505 {
1506 Test.AssertEquals(cmp[i].number_get(), e.number_get());
1507 Test.Assert(cmp[i].raw_handle == e.raw_handle);
1508 ++i;
1509 }
1510 }
1511
1512 // //
1513 // Code Generation
1514 //
1515
1516 // Integer //
1517
1518 public static void test_eina_inarray_int_in()
1519 {
1520 test.Testing t = new test.TestingConcrete();
1521 var arr = new eina.Inarray<int>();
1522 arr.Append(base_arr_int);
1523 Test.Assert(t.eina_inarray_int_in(arr));
1524 Test.Assert(arr.Own);
1525 Test.Assert(arr.ToArray().SequenceEqual(modified_arr_int));
1526 arr.Dispose();
1527 Test.Assert(arr.Handle == IntPtr.Zero);
1528 }
1529
1530 public static void test_eina_inarray_int_in_own()
1531 {
1532 test.Testing t = new test.TestingConcrete();
1533 var arr = new eina.Inarray<int>();
1534 arr.Append(base_arr_int);
1535 Test.Assert(t.eina_inarray_int_in_own(arr));
1536 Test.Assert(!arr.Own);
1537 Test.Assert(arr.ToArray().SequenceEqual(modified_arr_int));
1538 arr.Dispose();
1539 Test.Assert(arr.Handle == IntPtr.Zero);
1540 Test.Assert(t.check_eina_inarray_int_in_own());
1541 }
1542
1543 public static void test_eina_inarray_int_out()
1544 {
1545 test.Testing t = new test.TestingConcrete();
1546 eina.Inarray<int> arr;
1547 Test.Assert(t.eina_inarray_int_out(out arr));
1548 Test.Assert(!arr.Own);
1549 Test.Assert(arr.ToArray().SequenceEqual(base_arr_int));
1550 Test.Assert(arr.Append(append_arr_int));
1551 arr.Dispose();
1552 Test.Assert(arr.Handle == IntPtr.Zero);
1553 Test.Assert(t.check_eina_inarray_int_out());
1554 }
1555
1556 public static void test_eina_inarray_int_out_own()
1557 {
1558 test.Testing t = new test.TestingConcrete();
1559 eina.Inarray<int> arr;
1560 Test.Assert(t.eina_inarray_int_out_own(out arr));
1561 Test.Assert(arr.Own);
1562 Test.Assert(arr.ToArray().SequenceEqual(base_arr_int));
1563 Test.Assert(arr.Append(append_arr_int));
1564 arr.Dispose();
1565 Test.Assert(arr.Handle == IntPtr.Zero);
1566 }
1567
1568 public static void test_eina_inarray_int_return()
1569 {
1570 test.Testing t = new test.TestingConcrete();
1571 var arr = t.eina_inarray_int_return();
1572 Test.Assert(!arr.Own);
1573 Test.Assert(arr.ToArray().SequenceEqual(base_arr_int));
1574 Test.Assert(arr.Append(append_arr_int));
1575 arr.Dispose();
1576 Test.Assert(arr.Handle == IntPtr.Zero);
1577 Test.Assert(t.check_eina_inarray_int_return());
1578 }
1579
1580 public static void test_eina_inarray_int_return_own()
1581 {
1582 test.Testing t = new test.TestingConcrete();
1583 var arr = t.eina_inarray_int_return_own();
1584 Test.Assert(arr.Own);
1585 Test.Assert(arr.ToArray().SequenceEqual(base_arr_int));
1586 Test.Assert(arr.Append(append_arr_int));
1587 arr.Dispose();
1588 Test.Assert(arr.Handle == IntPtr.Zero);
1589 }
1590
1591 // String //
1592 public static void test_eina_inarray_str_in()
1593 {
1594 test.Testing t = new test.TestingConcrete();
1595 var arr = new eina.Inarray<string>();
1596 arr.Append(base_arr_str);
1597 Test.Assert(t.eina_inarray_str_in(arr));
1598 Test.Assert(arr.Own);
1599 Test.Assert(arr.ToArray().SequenceEqual(modified_arr_str));
1600 arr.Dispose();
1601 Test.Assert(arr.Handle == IntPtr.Zero);
1602 }
1603
1604 public static void test_eina_inarray_str_in_own()
1605 {
1606 test.Testing t = new test.TestingConcrete();
1607 var arr = new eina.Inarray<string>();
1608 arr.Append(base_arr_str);
1609 Test.Assert(t.eina_inarray_str_in_own(arr));
1610 Test.Assert(!arr.Own);
1611 Test.Assert(arr.ToArray().SequenceEqual(modified_arr_str));
1612 arr.Dispose();
1613 Test.Assert(arr.Handle == IntPtr.Zero);
1614 Test.Assert(t.check_eina_inarray_str_in_own());
1615 }
1616
1617 public static void test_eina_inarray_str_out()
1618 {
1619 test.Testing t = new test.TestingConcrete();
1620 eina.Inarray<string> arr;
1621 Test.Assert(t.eina_inarray_str_out(out arr));
1622 Test.Assert(!arr.Own);
1623 Test.Assert(arr.ToArray().SequenceEqual(base_arr_str));
1624 Test.Assert(arr.Append(append_arr_str));
1625 arr.Dispose();
1626 Test.Assert(arr.Handle == IntPtr.Zero);
1627 Test.Assert(t.check_eina_inarray_str_out());
1628 }
1629
1630 public static void test_eina_inarray_str_out_own()
1631 {
1632 test.Testing t = new test.TestingConcrete();
1633 eina.Inarray<string> arr;
1634 Test.Assert(t.eina_inarray_str_out_own(out arr));
1635 Test.Assert(arr.Own);
1636 Test.Assert(arr.ToArray().SequenceEqual(base_arr_str));
1637 Test.Assert(arr.Append(append_arr_str));
1638 arr.Dispose();
1639 Test.Assert(arr.Handle == IntPtr.Zero);
1640 }
1641
1642 public static void test_eina_inarray_str_return()
1643 {
1644 test.Testing t = new test.TestingConcrete();
1645 var arr = t.eina_inarray_str_return();
1646 Test.Assert(!arr.Own);
1647 Test.Assert(arr.ToArray().SequenceEqual(base_arr_str));
1648 Test.Assert(arr.Append(append_arr_str));
1649 arr.Dispose();
1650 Test.Assert(arr.Handle == IntPtr.Zero);
1651 Test.Assert(t.check_eina_inarray_str_return());
1652 }
1653
1654 public static void test_eina_inarray_str_return_own()
1655 {
1656 test.Testing t = new test.TestingConcrete();
1657 var arr = t.eina_inarray_str_return_own();
1658 Test.Assert(arr.Own);
1659 Test.Assert(arr.ToArray().SequenceEqual(base_arr_str));
1660 Test.Assert(arr.Append(append_arr_str));
1661 arr.Dispose();
1662 Test.Assert(arr.Handle == IntPtr.Zero);
1663 }
1664
1665 // Object //
1666
1667 public static void test_eina_inarray_obj_in()
1668 {
1669 test.Testing t = new test.TestingConcrete();
1670 var arr = new eina.Inarray<test.Numberwrapper>();
1671 arr.Append(BaseArrObj());
1672 Test.Assert(t.eina_inarray_obj_in(arr));
1673 Test.Assert(arr.Own);
1674 NumberwrapperInarrayAssertEqual(arr.ToArray(), ModifiedArrObj());
1675 arr.Dispose();
1676 Test.Assert(arr.Handle == IntPtr.Zero);
1677 }
1678
1679 public static void test_eina_inarray_obj_in_own()
1680 {
1681 test.Testing t = new test.TestingConcrete();
1682 var arr = new eina.Inarray<test.Numberwrapper>();
1683 arr.Append(BaseArrObj());
1684 Test.Assert(t.eina_inarray_obj_in_own(arr));
1685 Test.Assert(!arr.Own);
1686 NumberwrapperInarrayAssertEqual(arr.ToArray(), ModifiedArrObj());
1687 arr.Dispose();
1688 Test.Assert(arr.Handle == IntPtr.Zero);
1689 Test.Assert(t.check_eina_inarray_obj_in_own());
1690 }
1691
1692 public static void test_eina_inarray_obj_out()
1693 {
1694 test.Testing t = new test.TestingConcrete();
1695 eina.Inarray<test.Numberwrapper> arr;
1696 Test.Assert(t.eina_inarray_obj_out(out arr));
1697 Test.Assert(!arr.Own);
1698 NumberwrapperInarrayAssertEqual(arr.ToArray(), BaseArrObj());
1699 Test.Assert(arr.Append(AppendArrObj()));
1700 arr.Dispose();
1701 Test.Assert(arr.Handle == IntPtr.Zero);
1702 Test.Assert(t.check_eina_inarray_obj_out());
1703 }
1704
1705 public static void test_eina_inarray_obj_out_own()
1706 {
1707 test.Testing t = new test.TestingConcrete();
1708 eina.Inarray<test.Numberwrapper> arr;
1709 Test.Assert(t.eina_inarray_obj_out_own(out arr));
1710 Test.Assert(arr.Own);
1711 NumberwrapperInarrayAssertEqual(arr.ToArray(), BaseArrObj());
1712 Test.Assert(arr.Append(AppendArrObj()));
1713 arr.Dispose();
1714 Test.Assert(arr.Handle == IntPtr.Zero);
1715 }
1716
1717 public static void test_eina_inarray_obj_return()
1718 {
1719 test.Testing t = new test.TestingConcrete();
1720 var arr = t.eina_inarray_obj_return();
1721 Test.Assert(!arr.Own);
1722 NumberwrapperInarrayAssertEqual(arr.ToArray(), BaseArrObj());
1723 Test.Assert(arr.Append(AppendArrObj()));
1724 arr.Dispose();
1725 Test.Assert(arr.Handle == IntPtr.Zero);
1726 Test.Assert(t.check_eina_inarray_obj_return());
1727 }
1728
1729 public static void test_eina_inarray_obj_return_own()
1730 {
1731 test.Testing t = new test.TestingConcrete();
1732 var arr = t.eina_inarray_obj_return_own();
1733 Test.Assert(arr.Own);
1734 NumberwrapperInarrayAssertEqual(arr.ToArray(), BaseArrObj());
1735 Test.Assert(arr.Append(AppendArrObj()));
1736 arr.Dispose();
1737 Test.Assert(arr.Handle == IntPtr.Zero);
1738 }
1739
1740 public static void test_eina_inarray_obj_return_in_same_id()
1741 {
1742 test.Testing t = new test.TestingConcrete();
1743 var cmp = BaseArrObj();
1744 var a = new eina.Inarray<test.Numberwrapper>();
1745 a.Append(cmp);
1746 var b = t.eina_inarray_obj_return_in(a);
1747 NumberwrapperInarrayAssertEqual(a.ToArray(), b.ToArray());
1748 NumberwrapperInarrayAssertEqual(a.ToArray(), BaseArrObj());
1749 int len = a.Length;
1750 for (int i=0; i < len; ++i)
1751 {
1752 Test.Assert(a[i].raw_handle == b[i].raw_handle);
1753 Test.Assert(a[i].raw_handle == cmp[i].raw_handle);
1754 }
1755 }
1756}
1757
1245class TestEinaList 1758class TestEinaList
1246{ 1759{
1247 public static void data_set_int() 1760 public static void data_set_int()
diff --git a/src/tests/efl_mono/libefl_mono_native_test.c b/src/tests/efl_mono/libefl_mono_native_test.c
index 8f024df0dd..4a71d024b9 100644
--- a/src/tests/efl_mono/libefl_mono_native_test.c
+++ b/src/tests/efl_mono/libefl_mono_native_test.c
@@ -58,11 +58,35 @@ void *_new_int(int v)
58} 58}
59 59
60static 60static
61int **_int_ref(int n)
62{
63 static int r;
64 r = n;
65 return &r;
66}
67
68static
69char **_new_str_ref(const char* str)
70{
71 static char *r;
72 r = strdup(str);
73 return &r;
74}
75
76static
61Test_Numberwrapper *_new_obj(int n) 77Test_Numberwrapper *_new_obj(int n)
62{ 78{
63 return efl_add(TEST_NUMBERWRAPPER_CLASS, NULL, test_numberwrapper_number_set(efl_added, n)); 79 return efl_add(TEST_NUMBERWRAPPER_CLASS, NULL, test_numberwrapper_number_set(efl_added, n));
64} 80}
65 81
82static
83Test_Numberwrapper **_new_obj_ref(int n)
84{
85 static Test_Numberwrapper *r;
86 r = _new_obj(n);
87 return &r;
88}
89
66// ############ // 90// ############ //
67// Test.Testing // 91// Test.Testing //
68// ############ // 92// ############ //
@@ -766,6 +790,374 @@ Eina_Array *_test_testing_eina_array_obj_return_in(EINA_UNUSED Eo *obj, EINA_UNU
766 return arr; 790 return arr;
767} 791}
768 792
793// //
794// Inarray
795//
796
797// Integer
798
799Eina_Bool _inarray_int_equal(const Eina_Inarray *arr, const int base[], unsigned int len)
800{
801 if (eina_inarray_count(arr) != len)
802 return EINA_FALSE;
803 for (unsigned int i = 0; i < len; ++i)
804 {
805 if (*((int*)eina_inarray_nth(arr, i)) != base[i])
806 return EINA_FALSE;
807 }
808 return EINA_TRUE;
809}
810
811Eina_Bool _test_testing_eina_inarray_int_in(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
812{
813 Eina_Bool r = _inarray_int_equal(arr, base_arr_int, base_arr_int_size);
814 eina_inarray_push(arr, _int_ref(42));
815 eina_inarray_push(arr, _int_ref(43));
816 eina_inarray_push(arr, _int_ref(33));
817 return r;
818}
819
820static Eina_Inarray *_inarray_int_in_own_to_check = NULL;
821
822Eina_Bool _test_testing_eina_inarray_int_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
823{
824 Eina_Bool r = _inarray_int_equal(arr, base_arr_int, base_arr_int_size);
825 eina_inarray_push(arr, _int_ref(42));
826 eina_inarray_push(arr, _int_ref(43));
827 eina_inarray_push(arr, _int_ref(33));
828 _inarray_int_in_own_to_check = arr;
829 return r;
830}
831Eina_Bool _test_testing_check_eina_inarray_int_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
832{
833 if (!_inarray_int_in_own_to_check) return EINA_FALSE;
834
835 Eina_Bool r = _inarray_int_equal(_inarray_int_in_own_to_check, modified_arr_int, modified_arr_int_size);
836
837 eina_inarray_free(_inarray_int_in_own_to_check);
838 _inarray_int_in_own_to_check = NULL;
839 return r;
840}
841
842Eina_Inarray *_inarray_int_out_to_check = NULL;
843
844Eina_Bool _test_testing_eina_inarray_int_out(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray **arr)
845{
846 if (!arr) return EINA_FALSE;
847 *arr = eina_inarray_new(sizeof(int), 0);
848 eina_inarray_push(*arr, _int_ref(0x0));
849 eina_inarray_push(*arr, _int_ref(0x2A));
850 eina_inarray_push(*arr, _int_ref(0x42));
851 _inarray_int_out_to_check = *arr;
852 return EINA_TRUE;
853}
854Eina_Bool _test_testing_check_eina_inarray_int_out(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
855{
856 if (!_inarray_int_out_to_check) return EINA_FALSE;
857
858 Eina_Bool r = _inarray_int_equal(_inarray_int_out_to_check, modified_arr_int, modified_arr_int_size);
859
860 eina_inarray_free(_inarray_int_out_to_check);
861 _inarray_int_out_to_check = NULL;
862 return r;
863}
864
865Eina_Bool _test_testing_eina_inarray_int_out_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray **arr)
866{
867 if (!arr) return EINA_FALSE;
868 *arr = eina_inarray_new(sizeof(int), 0);
869 eina_inarray_push(*arr, _int_ref(0x0));
870 eina_inarray_push(*arr, _int_ref(0x2A));
871 eina_inarray_push(*arr, _int_ref(0x42));
872 return EINA_TRUE;
873}
874
875Eina_Inarray *_inarray_int_return_to_check = NULL;
876
877Eina_Inarray *_test_testing_eina_inarray_int_return(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
878{
879 Eina_Inarray *arr = eina_inarray_new(sizeof(int), 0);
880 eina_inarray_push(arr, _int_ref(0x0));
881 eina_inarray_push(arr, _int_ref(0x2A));
882 eina_inarray_push(arr, _int_ref(0x42));
883 _inarray_int_return_to_check = arr;
884 return arr;
885}
886Eina_Bool _test_testing_check_eina_inarray_int_return(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
887{
888 if (!_inarray_int_return_to_check) return EINA_FALSE;
889
890 Eina_Bool r = _inarray_int_equal(_inarray_int_return_to_check, modified_arr_int, modified_arr_int_size);
891
892 eina_inarray_free(_inarray_int_return_to_check);
893 _inarray_int_return_to_check = NULL;
894 return r;
895}
896
897Eina_Inarray *_test_testing_eina_inarray_int_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
898{
899 Eina_Inarray *arr = eina_inarray_new(sizeof(int), 0);
900 eina_inarray_push(arr, _int_ref(0x0));
901 eina_inarray_push(arr, _int_ref(0x2A));
902 eina_inarray_push(arr, _int_ref(0x42));
903 return arr;
904}
905
906// String
907
908Eina_Bool _inarray_str_equal(const Eina_Inarray *arr, const char * const base[], unsigned int len)
909{
910 if (eina_inarray_count(arr) != len)
911 return EINA_FALSE;
912 for (unsigned int i = 0; i < len; ++i)
913 {
914 if (0 != strcmp(*((char**)eina_inarray_nth(arr, i), base[i]))
915 return EINA_FALSE;
916 }
917 return EINA_TRUE;
918}
919
920Eina_Bool _test_testing_eina_inarray_str_in(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
921{
922 Eina_Bool r = _inarray_str_equal(arr, base_arr_str, base_arr_str_size);
923 eina_inarray_push(arr, _new_str_ref("42"));
924 eina_inarray_push(arr, _new_str_ref("43"));
925 eina_inarray_push(arr, _new_str_ref("33"));
926 return r;
927}
928
929static Eina_Inarray *_inarray_str_in_own_to_check = NULL;
930
931Eina_Bool _test_testing_eina_inarray_str_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
932{
933 Eina_Bool r = _inarray_str_equal(arr, base_arr_str, base_arr_str_size);
934 eina_inarray_push(arr, _new_str_ref("42"));
935 eina_inarray_push(arr, _new_str_ref("43"));
936 eina_inarray_push(arr, _new_str_ref("33"));
937 _inarray_str_in_own_to_check = arr;
938 return r;
939}
940
941Eina_Bool _test_testing_check_eina_inarray_str_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
942{
943 if (!_inarray_str_in_own_to_check) return EINA_FALSE;
944
945 Eina_Bool r = _inarray_str_equal(_inarray_str_in_own_to_check, modified_arr_str, modified_arr_str_size);
946
947 char **ele;
948 EINA_INARRAY_FOREACH(_inarray_str_in_own_to_check, ele)
949 free(*ele);
950
951 eina_inarray_free(_inarray_str_in_own_to_check);
952 _inarray_str_in_own_to_check = NULL;
953 return r;
954}
955
956Eina_Inarray *_inarray_str_out_to_check = NULL;
957
958Eina_Bool _test_testing_eina_inarray_str_out(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray **arr)
959{
960 if (!arr) return EINA_FALSE;
961 *arr = eina_inarray_new(sizeof(char*), 0);
962 eina_inarray_push(*arr, _new_str_ref("0x0"));
963 eina_inarray_push(*arr, _new_str_ref("0x2A"));
964 eina_inarray_push(*arr, _new_str_ref("0x42"));
965 _inarray_str_out_to_check = *arr;
966 return EINA_TRUE;
967}
968Eina_Bool _test_testing_check_eina_inarray_str_out(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
969{
970 if (!_inarray_str_out_to_check) return EINA_FALSE;
971
972 Eina_Bool r = _inarray_str_equal(_inarray_str_out_to_check, modified_arr_str, modified_arr_str_size);
973
974 char **ele;
975 EINA_INARRAY_FOREACH(_inarray_str_in_own_to_check, ele)
976 free(*ele);
977
978 eina_inarray_free(_inarray_str_out_to_check);
979 _inarray_str_out_to_check = NULL;
980 return r;
981}
982
983Eina_Bool _test_testing_eina_inarray_str_out_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray **arr)
984{
985 if (!arr) return EINA_FALSE;
986 *arr = eina_inarray_new(sizeof(char*), 0);
987 eina_inarray_push(*arr, _new_str_ref("0x0"));
988 eina_inarray_push(*arr, _new_str_ref("0x2A"));
989 eina_inarray_push(*arr, _new_str_ref("0x42"));
990 return EINA_TRUE;
991}
992
993Eina_Inarray *_inarray_str_return_to_check = NULL;
994
995Eina_Inarray *_test_testing_eina_inarray_str_return(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
996{
997 Eina_Inarray *arr = eina_inarray_new(sizeof(char*), 0);
998 eina_inarray_push(arr, _new_str_ref("0x0"));
999 eina_inarray_push(arr, _new_str_ref("0x2A"));
1000 eina_inarray_push(arr, _new_str_ref("0x42"));
1001 _inarray_str_return_to_check = arr;
1002 return arr;
1003}
1004Eina_Bool _test_testing_check_eina_inarray_str_return(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1005{
1006 if (!_inarray_str_return_to_check) return EINA_FALSE;
1007
1008 Eina_Bool r = _inarray_str_equal(_inarray_str_return_to_check, modified_arr_str, modified_arr_str_size);
1009
1010 char **ele;
1011 EINA_INARRAY_FOREACH(_inarray_str_in_own_to_check, ele)
1012 free(*ele);
1013
1014 eina_inarray_free(_inarray_str_return_to_check);
1015 _inarray_str_return_to_check = NULL;
1016 return r;
1017}
1018
1019Eina_Inarray *_test_testing_eina_inarray_str_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1020{
1021 Eina_Inarray *arr = eina_inarray_new(sizeof(char*), 0);
1022 eina_inarray_push(arr, _new_str_ref("0x0"));
1023 eina_inarray_push(arr, _new_str_ref("0x2A"));
1024 eina_inarray_push(arr, _new_str_ref("0x42"));
1025 return arr;
1026}
1027
1028// Object
1029
1030Eina_Bool _inarray_obj_equal(const Eina_Inarray *arr, const Test_Numberwrapper * const base[], unsigned int len)
1031{
1032 if (eina_inarray_count(arr) != len)
1033 return EINA_FALSE;
1034 for (unsigned int i = 0; i < len; ++i)
1035 {
1036 const Test_Numberwrapper **eo = eina_inarray_nth(arr, i);
1037 int a = test_numberwrapper_number_get(*eo);
1038 int b = test_numberwrapper_number_get(base[i]);
1039 if (a != b)
1040 return EINA_FALSE;
1041 }
1042 return EINA_TRUE;
1043}
1044
1045Eina_Bool _test_testing_eina_inarray_obj_in(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
1046{
1047 Eina_Bool r = _inarray_obj_equal(arr, base_arr_obj, base_arr_obj_size);
1048 if (!r) return r;
1049 eina_inarray_push(arr, _new_obj_ref(42));
1050 eina_inarray_push(arr, _new_obj_ref(43));
1051 eina_inarray_push(arr, _new_obj_ref(33));
1052 return r;
1053}
1054
1055static Eina_Inarray *_inarray_obj_in_own_to_check = NULL;
1056
1057Eina_Bool _test_testing_eina_inarray_obj_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
1058{
1059 Eina_Bool r = _inarray_obj_equal(arr, base_arr_obj, base_arr_obj_size);
1060 if (!r) return r;
1061 eina_inarray_push(arr, _new_obj_ref(42));
1062 eina_inarray_push(arr, _new_obj_ref(43));
1063 eina_inarray_push(arr, _new_obj_ref(33));
1064 _inarray_obj_in_own_to_check = arr;
1065 return r;
1066}
1067Eina_Bool _test_testing_check_eina_inarray_obj_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1068{
1069 if (!_inarray_obj_in_own_to_check) return EINA_FALSE;
1070
1071 Eina_Bool r = _inarray_obj_equal(_inarray_obj_in_own_to_check, modified_arr_obj, modified_arr_obj_size);
1072 if (!r) return r;
1073
1074 Test_Numberwrapper **ele;
1075 EINA_INARRAY_FOREACH(_inarray_obj_in_own_to_check, ele)
1076 efl_unref(*ele);
1077
1078 eina_inarray_free(_inarray_obj_in_own_to_check);
1079 _inarray_obj_in_own_to_check = NULL;
1080 return r;
1081}
1082
1083Eina_Inarray *_inarray_obj_out_to_check = NULL;
1084
1085Eina_Bool _test_testing_eina_inarray_obj_out(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray **arr)
1086{
1087 if (!arr) return EINA_FALSE;
1088 *arr = eina_inarray_new(sizeof(Eo*), 0);
1089 eina_inarray_push(*arr, _new_obj_ref(0x0));
1090 eina_inarray_push(*arr, _new_obj_ref(0x2A));
1091 eina_inarray_push(*arr, _new_obj_ref(0x42));
1092 _inarray_obj_out_to_check = *arr;
1093 return EINA_TRUE;
1094}
1095Eina_Bool _test_testing_check_eina_inarray_obj_out(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1096{
1097 if (!_inarray_obj_out_to_check) return EINA_FALSE;
1098
1099 Eina_Bool r = _inarray_obj_equal(_inarray_obj_out_to_check, modified_arr_obj, modified_arr_obj_size);
1100 if (!r) return r;
1101
1102 Test_Numberwrapper **ele;
1103 EINA_INARRAY_FOREACH(_inarray_obj_in_own_to_check, ele)
1104 efl_unref(*ele);
1105
1106 eina_inarray_free(_inarray_obj_out_to_check);
1107 _inarray_obj_out_to_check = NULL;
1108 return r;
1109}
1110
1111Eina_Bool _test_testing_eina_inarray_obj_out_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray **arr)
1112{
1113 if (!arr) return EINA_FALSE;
1114 *arr = eina_inarray_new(sizeof(Eo*), 0);
1115 eina_inarray_push(*arr, _new_obj_ref(0x0));
1116 eina_inarray_push(*arr, _new_obj_ref(0x2A));
1117 eina_inarray_push(*arr, _new_obj_ref(0x42));
1118 return EINA_TRUE;
1119}
1120
1121Eina_Inarray *_inarray_obj_return_to_check = NULL;
1122
1123Eina_Inarray *_test_testing_eina_inarray_obj_return(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1124{
1125 Eina_Inarray *arr = eina_inarray_new(sizeof(Eo*), 0);
1126 eina_inarray_push(arr, _new_obj_ref(0x0));
1127 eina_inarray_push(arr, _new_obj_ref(0x2A));
1128 eina_inarray_push(arr, _new_obj_ref(0x42));
1129 _inarray_obj_return_to_check = arr;
1130 return arr;
1131}
1132Eina_Bool _test_testing_check_eina_inarray_obj_return(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1133{
1134 if (!_inarray_obj_return_to_check) return EINA_FALSE;
1135
1136 Eina_Bool r = _inarray_obj_equal(_inarray_obj_return_to_check, modified_arr_obj, modified_arr_obj_size);
1137 if (!r) return r;
1138
1139 Test_Numberwrapper **ele;
1140 EINA_INARRAY_FOREACH(_inarray_obj_in_own_to_check, ele)
1141 efl_unref(*ele);
1142
1143 eina_inarray_free(_inarray_obj_return_to_check);
1144 _inarray_obj_return_to_check = NULL;
1145 return r;
1146}
1147
1148Eina_Inarray *_test_testing_eina_inarray_obj_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd)
1149{
1150 Eina_Inarray *arr = eina_inarray_new(sizeof(Eo*), 0);
1151 eina_inarray_push(arr, _new_obj_ref(0x0));
1152 eina_inarray_push(arr, _new_obj_ref(0x2A));
1153 eina_inarray_push(arr, _new_obj_ref(0x42));
1154 return arr;
1155}
1156
1157Eina_Inarray *_test_testing_eina_inarray_obj_return_in(EINA_UNUSED Eo *obj, EINA_UNUSED Test_Testing_Data *pd, Eina_Inarray *arr)
1158{
1159 return arr;
1160}
769 1161
770// // 1162// //
771// List 1163// List
diff --git a/src/tests/efl_mono/test_testing.eo b/src/tests/efl_mono/test_testing.eo
index 612aef4851..7bbf84d616 100644
--- a/src/tests/efl_mono/test_testing.eo
+++ b/src/tests/efl_mono/test_testing.eo
@@ -365,6 +365,153 @@ class Test.Testing (Efl.Object) {
365 return: array<Test.Numberwrapper>; 365 return: array<Test.Numberwrapper>;
366 } 366 }
367 367
368 /* Eina Inarray */
369
370 /* Integer */
371 eina_inarray_int_in {
372 params {
373 @in arr: inarray<int>;
374 }
375 return: bool;
376 }
377
378 eina_inarray_int_in_own {
379 params {
380 @in arr: own(inarray<own(ref(int))>);
381 }
382 return: bool;
383 }
384 check_eina_inarray_int_in_own {
385 return: bool;
386 }
387
388 eina_inarray_int_out {
389 params {
390 @out arr: inarray<int>;
391 }
392 return: bool;
393 }
394 check_eina_inarray_int_out {
395 return: bool;
396 }
397
398 eina_inarray_int_out_own {
399 params {
400 @out arr: own(inarray<own(ref(int))>);
401 }
402 return: bool;
403 }
404
405 eina_inarray_int_return {
406 return: inarray<int>;
407 }
408 check_eina_inarray_int_return {
409 return: bool;
410 }
411
412 eina_inarray_int_return_own {
413 return: own(inarray<own(ref(int))>);
414 }
415
416 /* String */
417 eina_inarray_str_in {
418 params {
419 @in arr: inarray<string>;
420 }
421 return: bool;
422 }
423
424 eina_inarray_str_in_own {
425 params {
426 @in arr: own(inarray<own(string)>);
427 }
428 return: bool;
429 }
430 check_eina_inarray_str_in_own {
431 return: bool;
432 }
433
434 eina_inarray_str_out {
435 params {
436 @out arr: inarray<string>;
437 }
438 return: bool;
439 }
440 check_eina_inarray_str_out {
441 return: bool;
442 }
443
444 eina_inarray_str_out_own {
445 params {
446 @out arr: own(inarray<own(string)>);
447 }
448 return: bool;
449 }
450
451 eina_inarray_str_return {
452 return: inarray<string>;
453 }
454 check_eina_inarray_str_return {
455 return: bool;
456 }
457
458 eina_inarray_str_return_own {
459 return: own(inarray<own(string)>);
460 }
461
462 /* Object */
463 eina_inarray_obj_in {
464 params {
465 @in arr: inarray<Test.Numberwrapper>;
466 }
467 return: bool;
468 }
469
470 eina_inarray_obj_in_own {
471 params {
472 @in arr: own(inarray<own(Test.Numberwrapper)>);
473 }
474 return: bool;
475 }
476 check_eina_inarray_obj_in_own {
477 return: bool;
478 }
479
480 eina_inarray_obj_out {
481 params {
482 @out arr: inarray<Test.Numberwrapper>;
483 }
484 return: bool;
485 }
486 check_eina_inarray_obj_out {
487 return: bool;
488 }
489
490 eina_inarray_obj_out_own {
491 params {
492 @out arr: own(inarray<own(Test.Numberwrapper)>);
493 }
494 return: bool;
495 }
496
497 eina_inarray_obj_return {
498 return: inarray<Test.Numberwrapper>;
499 }
500 check_eina_inarray_obj_return {
501 return: bool;
502 }
503
504 eina_inarray_obj_return_own {
505 return: own(inarray<own(Test.Numberwrapper)>);
506 }
507
508 eina_inarray_obj_return_in {
509 params {
510 @in arr: inarray<Test.Numberwrapper>;
511 }
512 return: inarray<Test.Numberwrapper>;
513 }
514
368 /* Eina List */ 515 /* Eina List */
369 516
370 /* Integer */ 517 /* Integer */