summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-06-27 13:49:42 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-06-27 14:07:33 -0300
commit967e32d27a2a324a37f8f2b5cc5c07ff063f5f82 (patch)
tree3fd5508ae58db0edfd84cdb3ae671ea808d02793
parent920a1b4a52b96a84d724583f442e867c4f39168b (diff)
csharp: Update after iterator changes
Summary: Iterator and Accessors are views only, not owning the data they point to. Also updated the tests by handling some test data that were leaking. Fixes T8036 Reviewers: vitor.sousa, felipealmeida Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers, segfaultxavi, q66 Tags: #efl Maniphest Tasks: T8036 Differential Revision: https://phab.enlightenment.org/D9189
-rw-r--r--src/bin/eolian_mono/eolian/mono/parameter.hh78
-rw-r--r--src/bin/eolian_mono/eolian/mono/struct_definition.hh10
-rw-r--r--src/bindings/mono/eina_mono/eina_array.cs2
-rw-r--r--src/bindings/mono/eina_mono/eina_hash.cs4
-rw-r--r--src/bindings/mono/eina_mono/eina_inarray.cs4
-rw-r--r--src/bindings/mono/eina_mono/eina_inlist.cs2
-rw-r--r--src/bindings/mono/eina_mono/eina_iterator.cs31
-rw-r--r--src/bindings/mono/eina_mono/eina_list.cs4
-rw-r--r--src/tests/efl_mono/Eina.cs49
-rw-r--r--src/tests/efl_mono/dummy_test_object.c54
-rw-r--r--src/tests/efl_mono/dummy_test_object.eo16
11 files changed, 137 insertions, 117 deletions
diff --git a/src/bin/eolian_mono/eolian/mono/parameter.hh b/src/bin/eolian_mono/eolian/mono/parameter.hh
index ca3c573df7..f16c740f28 100644
--- a/src/bin/eolian_mono/eolian/mono/parameter.hh
+++ b/src/bin/eolian_mono/eolian/mono/parameter.hh
@@ -604,8 +604,6 @@ struct native_convert_in_variable_generator
604 } 604 }
605 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *" 605 else if (param.type.c_type == "Eina_Array *" || param.type.c_type == "const Eina_Array *"
606 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *" 606 || param.type.c_type == "Eina_List *" || param.type.c_type == "const Eina_List *"
607 || param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
608 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
609 ) 607 )
610 { 608 {
611 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type); 609 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@@ -618,6 +616,19 @@ struct native_convert_in_variable_generator
618 << ");\n" 616 << ");\n"
619 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context); 617 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
620 } 618 }
619 else if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
620 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
621 )
622 {
623 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
624 if (!complex)
625 return false;
626 return as_generator(
627 "var " << string << " = new " << type << "(" << escape_keyword(param.param_name)
628 << ", " << (param.type.has_own ? "true" : "false")
629 << ");\n"
630 ).generate(sink, std::make_tuple(in_variable_name(param.param_name), param.type), context);
631 }
621 else if (param.type.c_type == "Eina_Value") 632 else if (param.type.c_type == "Eina_Value")
622 { 633 {
623 return as_generator( 634 return as_generator(
@@ -706,6 +717,13 @@ struct convert_in_variable_generator
706 escape_keyword(param.param_name) << ".Own = false;\n" 717 escape_keyword(param.param_name) << ".Own = false;\n"
707 ).generate(sink, attributes::unused, context)) 718 ).generate(sink, attributes::unused, context))
708 return false; 719 return false;
720
721 // Iterators and Accessors can't own their content.
722 if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
723 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
724 )
725 return true;
726
709 if (complex->subtypes.front().has_own && !as_generator( 727 if (complex->subtypes.front().has_own && !as_generator(
710 escape_keyword(param.param_name) << ".OwnContent = false;\n" 728 escape_keyword(param.param_name) << ".OwnContent = false;\n"
711 ).generate(sink, attributes::unused, context)) 729 ).generate(sink, attributes::unused, context))
@@ -937,14 +955,26 @@ struct convert_out_assign_generator
937 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT) 955 || param_is_acceptable(param, "Eina_List *", !WANT_OWN, WANT_OUT)
938 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT) 956 || param_is_acceptable(param, "const Eina_List *", WANT_OWN, WANT_OUT)
939 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT) 957 || param_is_acceptable(param, "const Eina_List *", !WANT_OWN, WANT_OUT)
958 )
959 {
960 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
961 if (!complex)
962 return false;
963 return as_generator(
964 string << " = new " << type << "(" << string
965 << ", " << (param.type.has_own ? "true" : "false")
966 << ", " << (complex->subtypes.front().has_own ? "true" : "false")
967 << ");\n"
968 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
969 }
970 else if (param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
971 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
972 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
973 || param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
940 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT) 974 || param_is_acceptable(param, "Eina_Accessor *", WANT_OWN, WANT_OUT)
941 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT) 975 || param_is_acceptable(param, "Eina_Accessor *", !WANT_OWN, WANT_OUT)
942 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT) 976 || param_is_acceptable(param, "const Eina_Accessor *", WANT_OWN, WANT_OUT)
943 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT) 977 || param_is_acceptable(param, "const Eina_Accessor *", !WANT_OWN, WANT_OUT)
944 || param_is_acceptable(param, "Eina_Iterator *", WANT_OWN, WANT_OUT)
945 || param_is_acceptable(param, "Eina_Iterator *", !WANT_OWN, WANT_OUT)
946 || param_is_acceptable(param, "const Eina_Iterator *", WANT_OWN, WANT_OUT)
947 || param_is_acceptable(param, "const Eina_Iterator *", !WANT_OWN, WANT_OUT)
948 ) 978 )
949 { 979 {
950 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type); 980 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&param.type.original_type);
@@ -953,7 +983,6 @@ struct convert_out_assign_generator
953 return as_generator( 983 return as_generator(
954 string << " = new " << type << "(" << string 984 string << " = new " << type << "(" << string
955 << ", " << (param.type.has_own ? "true" : "false") 985 << ", " << (param.type.has_own ? "true" : "false")
956 << ", " << (complex->subtypes.front().has_own ? "true" : "false")
957 << ");\n" 986 << ");\n"
958 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context); 987 ).generate(sink, std::make_tuple(escape_keyword(param.param_name), param.type, out_variable_name(param.param_name)), context);
959 } 988 }
@@ -1057,9 +1086,7 @@ struct convert_return_generator
1057 } 1086 }
1058 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *" 1087 else if (ret_type.c_type == "Eina_Array *" || ret_type.c_type == "const Eina_Array *"
1059 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *" 1088 || ret_type.c_type == "Eina_List *" || ret_type.c_type == "const Eina_List *"
1060 || ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *" 1089 )
1061 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
1062 )
1063 { 1090 {
1064 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type); 1091 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
1065 if (!complex) 1092 if (!complex)
@@ -1070,6 +1097,17 @@ struct convert_return_generator
1070 .generate(sink, ret_type, context)) 1097 .generate(sink, ret_type, context))
1071 return false; 1098 return false;
1072 } 1099 }
1100 else if(ret_type.c_type == "Eina_Iterator *" || ret_type.c_type == "const Eina_Iterator *"
1101 || ret_type.c_type == "Eina_Accessor *" || ret_type.c_type == "const Eina_Accessor *"
1102 )
1103 {
1104 attributes::complex_type_def const* complex = efl::eina::get<attributes::complex_type_def>(&ret_type.original_type);
1105 if (!complex)
1106 return false;
1107 if (!as_generator("return new " << type << "(_ret_var, " << std::string{ret_type.has_own ? "true" : "false"} << ");\n")
1108 .generate(sink, ret_type, context))
1109 return false;
1110 }
1073 else if (ret_type.c_type != "void") 1111 else if (ret_type.c_type != "void")
1074 { 1112 {
1075 return as_generator("return _ret_var;\n").generate(sink, ret_type, context); 1113 return as_generator("return _ret_var;\n").generate(sink, ret_type, context);
@@ -1199,6 +1237,13 @@ struct native_convert_out_assign_generator
1199 string << ".Own = false;\n" 1237 string << ".Own = false;\n"
1200 ).generate(sink, outvar, context)) 1238 ).generate(sink, outvar, context))
1201 return false; 1239 return false;
1240
1241 // Iterators and Accessors can't own their content.
1242 if (param.type.c_type == "Eina_Iterator *" || param.type.c_type == "const Eina_Iterator *"
1243 || param.type.c_type == "Eina_Accessor *" || param.type.c_type == "const Eina_Accessor *"
1244 )
1245 return true;
1246
1202 if (complex->subtypes.front().has_own && !as_generator( 1247 if (complex->subtypes.front().has_own && !as_generator(
1203 string << ".OwnContent = false;\n" 1248 string << ".OwnContent = false;\n"
1204 ).generate(sink, outvar, context)) 1249 ).generate(sink, outvar, context))
@@ -1319,9 +1364,16 @@ struct native_convert_return_generator
1319 if (ret_type.has_own && !as_generator("_ret_var.Own = false; ") 1364 if (ret_type.has_own && !as_generator("_ret_var.Own = false; ")
1320 .generate(sink, attributes::unused, context)) 1365 .generate(sink, attributes::unused, context))
1321 return false; 1366 return false;
1322 if (complex->subtypes.front().has_own && !as_generator("_ret_var.OwnContent = false; ") 1367
1323 .generate(sink, attributes::unused, context)) 1368 // Iterators and Accessors can't own their content.
1324 return false; 1369 if (ret_type.c_type != "Eina_Iterator *" && ret_type.c_type != "const Eina_Iterator *"
1370 || ret_type.c_type != "Eina_Accessor *" && ret_type.c_type != "const Eina_Accessor *"
1371 )
1372 {
1373 if (complex->subtypes.front().has_own && !as_generator("_ret_var.OwnContent = false; ")
1374 .generate(sink, attributes::unused, context))
1375 return false;
1376 }
1325 1377
1326 return as_generator("return _ret_var.Handle;\n") 1378 return as_generator("return _ret_var.Handle;\n")
1327 .generate(sink, attributes::unused, context); 1379 .generate(sink, attributes::unused, context);
diff --git a/src/bin/eolian_mono/eolian/mono/struct_definition.hh b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
index ba50f2d2f9..204484c2b0 100644
--- a/src/bin/eolian_mono/eolian/mono/struct_definition.hh
+++ b/src/bin/eolian_mono/eolian/mono/struct_definition.hh
@@ -171,8 +171,7 @@ struct to_external_field_convert_generator
171 return false; 171 return false;
172 } 172 }
173 else if (complex && (complex->outer.base_type == "array" 173 else if (complex && (complex->outer.base_type == "array"
174 || complex->outer.base_type == "list" 174 || complex->outer.base_type == "list"))
175 || complex->outer.base_type == "iterator"))
176 { 175 {
177 // Always assumes pointer 176 // Always assumes pointer
178 if (!as_generator( 177 if (!as_generator(
@@ -187,6 +186,13 @@ struct to_external_field_convert_generator
187 .generate(sink, std::make_tuple(field_name, field.type, field_name), context)) 186 .generate(sink, std::make_tuple(field_name, field.type, field_name), context))
188 return false; 187 return false;
189 } 188 }
189 else if (complex && complex->outer.base_type == "iterator")
190 {
191 if (!as_generator(
192 indent << scope_tab << scope_tab << "_external_struct." << string << " = new " << type << "(_internal_struct." << string << ", false);\n")
193 .generate(sink, std::make_tuple(field_name, field.type, field_name), context))
194 return false;
195 }
190 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular)) 196 else if (field.type.is_ptr && helpers::need_pointer_conversion(regular) && !helpers::need_struct_conversion(regular))
191 { 197 {
192 if (!as_generator( 198 if (!as_generator(
diff --git a/src/bindings/mono/eina_mono/eina_array.cs b/src/bindings/mono/eina_mono/eina_array.cs
index e3bd852e2b..e75ca6ae7a 100644
--- a/src/bindings/mono/eina_mono/eina_array.cs
+++ b/src/bindings/mono/eina_mono/eina_array.cs
@@ -315,7 +315,7 @@ public class Array<T> : IEnumerable<T>, IDisposable
315 315
316 public Eina.Iterator<T> GetIterator() 316 public Eina.Iterator<T> GetIterator()
317 { 317 {
318 return new Eina.Iterator<T>(eina_array_iterator_new(Handle), true, false); 318 return new Eina.Iterator<T>(eina_array_iterator_new(Handle), true);
319 } 319 }
320 320
321 public IEnumerator<T> GetEnumerator() 321 public IEnumerator<T> GetEnumerator()
diff --git a/src/bindings/mono/eina_mono/eina_hash.cs b/src/bindings/mono/eina_mono/eina_hash.cs
index 8b3c1e7db5..1617eba961 100644
--- a/src/bindings/mono/eina_mono/eina_hash.cs
+++ b/src/bindings/mono/eina_mono/eina_hash.cs
@@ -485,12 +485,12 @@ public class Hash<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>>, IDi
485 485
486 public Eina.Iterator<TKey> Keys() 486 public Eina.Iterator<TKey> Keys()
487 { 487 {
488 return new Eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true, false); 488 return new Eina.Iterator<TKey>(EinaHashIteratorKeyNew<TKey>(Handle), true);
489 } 489 }
490 490
491 public Eina.Iterator<TValue> Values() 491 public Eina.Iterator<TValue> Values()
492 { 492 {
493 return new Eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true, false); 493 return new Eina.Iterator<TValue>(eina_hash_iterator_data_new(Handle), true);
494 } 494 }
495 495
496 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() 496 public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
diff --git a/src/bindings/mono/eina_mono/eina_inarray.cs b/src/bindings/mono/eina_mono/eina_inarray.cs
index c7f3151ac1..70f99cb8ca 100644
--- a/src/bindings/mono/eina_mono/eina_inarray.cs
+++ b/src/bindings/mono/eina_mono/eina_inarray.cs
@@ -358,12 +358,12 @@ public class Inarray<T> : IEnumerable<T>, IDisposable
358 358
359 public Eina.Iterator<T> GetIterator() 359 public Eina.Iterator<T> GetIterator()
360 { 360 {
361 return new Eina.Iterator<T>(eina_inarray_iterator_new(Handle), true, false); 361 return new Eina.Iterator<T>(eina_inarray_iterator_new(Handle), true);
362 } 362 }
363 363
364 public Eina.Iterator<T> GetReversedIterator() 364 public Eina.Iterator<T> GetReversedIterator()
365 { 365 {
366 return new Eina.Iterator<T>(eina_inarray_iterator_reversed_new(Handle), true, false); 366 return new Eina.Iterator<T>(eina_inarray_iterator_reversed_new(Handle), true);
367 } 367 }
368 368
369 public IEnumerator<T> GetEnumerator() 369 public IEnumerator<T> GetEnumerator()
diff --git a/src/bindings/mono/eina_mono/eina_inlist.cs b/src/bindings/mono/eina_mono/eina_inlist.cs
index 0cc9bae6a0..5f94f44f6a 100644
--- a/src/bindings/mono/eina_mono/eina_inlist.cs
+++ b/src/bindings/mono/eina_mono/eina_inlist.cs
@@ -314,7 +314,7 @@ public class Inlist<T> : IEnumerable<T>, IDisposable
314 314
315 public Eina.Iterator<T> GetIterator() 315 public Eina.Iterator<T> GetIterator()
316 { 316 {
317 return new Eina.Iterator<T>(eina_inlist_iterator_wrapper_new_custom_export_mono(Handle), true, false); 317 return new Eina.Iterator<T>(eina_inlist_iterator_wrapper_new_custom_export_mono(Handle), true);
318 } 318 }
319 319
320 public IEnumerator<T> GetEnumerator() 320 public IEnumerator<T> GetEnumerator()
diff --git a/src/bindings/mono/eina_mono/eina_iterator.cs b/src/bindings/mono/eina_mono/eina_iterator.cs
index 05b5408606..0ca4293c8f 100644
--- a/src/bindings/mono/eina_mono/eina_iterator.cs
+++ b/src/bindings/mono/eina_mono/eina_iterator.cs
@@ -33,20 +33,11 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
33{ 33{
34 public IntPtr Handle {get;set;} = IntPtr.Zero; 34 public IntPtr Handle {get;set;} = IntPtr.Zero;
35 public bool Own {get;set;} = true; 35 public bool Own {get;set;} = true;
36 public bool OwnContent {get;set;} = false;
37 36
38 public Iterator(IntPtr handle, bool own) 37 public Iterator(IntPtr handle, bool own)
39 { 38 {
40 Handle = handle; 39 Handle = handle;
41 Own = own; 40 Own = own;
42 OwnContent = own;
43 }
44
45 public Iterator(IntPtr handle, bool own, bool ownContent)
46 {
47 Handle = handle;
48 Own = own;
49 OwnContent = ownContent;
50 } 41 }
51 42
52 ~Iterator() 43 ~Iterator()
@@ -63,14 +54,6 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
63 return; 54 return;
64 } 55 }
65 56
66 if (OwnContent)
67 {
68 for (IntPtr data; eina_iterator_next(h, out data);)
69 {
70 NativeFree<T>(data);
71 }
72 }
73
74 if (Own) 57 if (Own)
75 { 58 {
76 if (disposing) 59 if (disposing)
@@ -102,16 +85,9 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
102 return h; 85 return h;
103 } 86 }
104 87
105 public void SetOwnership(bool ownAll) 88 public void SetOwnership(bool own)
106 {
107 Own = ownAll;
108 OwnContent = ownAll;
109 }
110
111 public void SetOwnership(bool own, bool ownContent)
112 { 89 {
113 Own = own; 90 Own = own;
114 OwnContent = ownContent;
115 } 91 }
116 92
117 public bool Next(out T res) 93 public bool Next(out T res)
@@ -125,11 +101,6 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
125 101
126 res = NativeToManaged<T>(data); 102 res = NativeToManaged<T>(data);
127 103
128 if (OwnContent)
129 {
130 NativeFree<T>(data);
131 }
132
133 return true; 104 return true;
134 } 105 }
135 106
diff --git a/src/bindings/mono/eina_mono/eina_list.cs b/src/bindings/mono/eina_mono/eina_list.cs
index 4b9e5f5856..4c25c25e62 100644
--- a/src/bindings/mono/eina_mono/eina_list.cs
+++ b/src/bindings/mono/eina_mono/eina_list.cs
@@ -353,12 +353,12 @@ public class List<T> : IEnumerable<T>, IDisposable
353 353
354 public Eina.Iterator<T> GetIterator() 354 public Eina.Iterator<T> GetIterator()
355 { 355 {
356 return new Eina.Iterator<T>(eina_list_iterator_new(Handle), true, false); 356 return new Eina.Iterator<T>(eina_list_iterator_new(Handle), true);
357 } 357 }
358 358
359 public Eina.Iterator<T> GetReversedIterator() 359 public Eina.Iterator<T> GetReversedIterator()
360 { 360 {
361 return new Eina.Iterator<T>(eina_list_iterator_reversed_new(Handle), true, false); 361 return new Eina.Iterator<T>(eina_list_iterator_reversed_new(Handle), true);
362 } 362 }
363 363
364 public IEnumerator<T> GetEnumerator() 364 public IEnumerator<T> GetEnumerator()
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 1705c7ab83..c15e062002 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -3129,14 +3129,12 @@ class TestEinaIterator
3129 var itr = arr.GetIterator(); 3129 var itr = arr.GetIterator();
3130 3130
3131 Test.Assert(itr.Own); 3131 Test.Assert(itr.Own);
3132 Test.Assert(!itr.OwnContent);
3133 Test.Assert(arr.Own); 3132 Test.Assert(arr.Own);
3134 Test.Assert(arr.OwnContent); 3133 Test.Assert(arr.OwnContent);
3135 3134
3136 Test.Assert(t.EinaIteratorIntIn(itr)); 3135 Test.Assert(t.EinaIteratorIntIn(itr));
3137 3136
3138 Test.Assert(itr.Own); 3137 Test.Assert(itr.Own);
3139 Test.Assert(!itr.OwnContent);
3140 Test.Assert(arr.Own); 3138 Test.Assert(arr.Own);
3141 Test.Assert(arr.OwnContent); 3139 Test.Assert(arr.OwnContent);
3142 3140
@@ -3150,20 +3148,18 @@ class TestEinaIterator
3150 var arr = new Eina.Array<int>(); 3148 var arr = new Eina.Array<int>();
3151 arr.Append(base_seq_int); 3149 arr.Append(base_seq_int);
3152 var itr = arr.GetIterator(); 3150 var itr = arr.GetIterator();
3153 arr.OwnContent = false;
3154 itr.OwnContent = true;
3155 3151
3156 Test.Assert(itr.Own); 3152 Test.Assert(itr.Own);
3157 Test.Assert(itr.OwnContent);
3158 Test.Assert(arr.Own); 3153 Test.Assert(arr.Own);
3159 Test.Assert(!arr.OwnContent); 3154 Test.Assert(arr.OwnContent);
3160 3155
3156 // Will take ownership of the Iterator
3161 Test.Assert(t.EinaIteratorIntInOwn(itr)); 3157 Test.Assert(t.EinaIteratorIntInOwn(itr));
3162 3158
3163 Test.Assert(!itr.Own); 3159 Test.Assert(!itr.Own);
3164 Test.Assert(!itr.OwnContent);
3165 Test.Assert(arr.Own); 3160 Test.Assert(arr.Own);
3166 Test.Assert(!arr.OwnContent); 3161 // Content must continue to be owned by the array
3162 Test.Assert(arr.OwnContent);
3167 3163
3168 itr.Dispose(); 3164 itr.Dispose();
3169 arr.Dispose(); 3165 arr.Dispose();
@@ -3178,9 +3174,7 @@ class TestEinaIterator
3178 3174
3179 Test.Assert(t.EinaIteratorIntOut(out itr)); 3175 Test.Assert(t.EinaIteratorIntOut(out itr));
3180 3176
3181
3182 Test.Assert(!itr.Own); 3177 Test.Assert(!itr.Own);
3183 Test.Assert(!itr.OwnContent);
3184 3178
3185 int idx = 0; 3179 int idx = 0;
3186 foreach (int e in itr) 3180 foreach (int e in itr)
@@ -3203,7 +3197,6 @@ class TestEinaIterator
3203 Test.Assert(t.EinaIteratorIntOutOwn(out itr)); 3197 Test.Assert(t.EinaIteratorIntOutOwn(out itr));
3204 3198
3205 Test.Assert(itr.Own); 3199 Test.Assert(itr.Own);
3206 Test.Assert(itr.OwnContent);
3207 3200
3208 int idx = 0; 3201 int idx = 0;
3209 foreach (int e in itr) 3202 foreach (int e in itr)
@@ -3223,7 +3216,6 @@ class TestEinaIterator
3223 var itr = t.EinaIteratorIntReturn(); 3216 var itr = t.EinaIteratorIntReturn();
3224 3217
3225 Test.Assert(!itr.Own); 3218 Test.Assert(!itr.Own);
3226 Test.Assert(!itr.OwnContent);
3227 3219
3228 int idx = 0; 3220 int idx = 0;
3229 foreach (int e in itr) 3221 foreach (int e in itr)
@@ -3245,7 +3237,6 @@ class TestEinaIterator
3245 var itr = t.EinaIteratorIntReturnOwn(); 3237 var itr = t.EinaIteratorIntReturnOwn();
3246 3238
3247 Test.Assert(itr.Own); 3239 Test.Assert(itr.Own);
3248 Test.Assert(itr.OwnContent);
3249 3240
3250 int idx = 0; 3241 int idx = 0;
3251 foreach (int e in itr) 3242 foreach (int e in itr)
@@ -3268,14 +3259,12 @@ class TestEinaIterator
3268 var itr = arr.GetIterator(); 3259 var itr = arr.GetIterator();
3269 3260
3270 Test.Assert(itr.Own); 3261 Test.Assert(itr.Own);
3271 Test.Assert(!itr.OwnContent);
3272 Test.Assert(arr.Own); 3262 Test.Assert(arr.Own);
3273 Test.Assert(arr.OwnContent); 3263 Test.Assert(arr.OwnContent);
3274 3264
3275 Test.Assert(t.EinaIteratorStrIn(itr)); 3265 Test.Assert(t.EinaIteratorStrIn(itr));
3276 3266
3277 Test.Assert(itr.Own); 3267 Test.Assert(itr.Own);
3278 Test.Assert(!itr.OwnContent);
3279 Test.Assert(arr.Own); 3268 Test.Assert(arr.Own);
3280 Test.Assert(arr.OwnContent); 3269 Test.Assert(arr.OwnContent);
3281 3270
@@ -3289,24 +3278,16 @@ class TestEinaIterator
3289 var arr = new Eina.Array<string>(); 3278 var arr = new Eina.Array<string>();
3290 arr.Append(base_seq_str); 3279 arr.Append(base_seq_str);
3291 var itr = arr.GetIterator(); 3280 var itr = arr.GetIterator();
3292 arr.OwnContent = false;
3293 itr.OwnContent = true;
3294 3281
3295 Test.Assert(itr.Own); 3282 Test.Assert(itr.Own);
3296 Test.Assert(itr.OwnContent);
3297 Test.Assert(arr.Own); 3283 Test.Assert(arr.Own);
3298 Test.Assert(!arr.OwnContent); 3284 Test.Assert(arr.OwnContent);
3299 3285
3300 Test.Assert(t.EinaIteratorStrInOwn(itr)); 3286 Test.Assert(t.EinaIteratorStrInOwn(itr));
3301 3287
3302 Test.Assert(!itr.Own); 3288 Test.Assert(!itr.Own);
3303 Test.Assert(!itr.OwnContent);
3304 Test.Assert(!itr.Own);
3305 Test.Assert(!itr.OwnContent);
3306 Test.Assert(arr.Own); 3289 Test.Assert(arr.Own);
3307 Test.Assert(!arr.OwnContent); 3290 Test.Assert(arr.OwnContent);
3308 Test.Assert(arr.Own);
3309 Test.Assert(!arr.OwnContent);
3310 3291
3311 itr.Dispose(); 3292 itr.Dispose();
3312 arr.Dispose(); 3293 arr.Dispose();
@@ -3322,7 +3303,6 @@ class TestEinaIterator
3322 Test.Assert(t.EinaIteratorStrOut(out itr)); 3303 Test.Assert(t.EinaIteratorStrOut(out itr));
3323 3304
3324 Test.Assert(!itr.Own); 3305 Test.Assert(!itr.Own);
3325 Test.Assert(!itr.OwnContent);
3326 3306
3327 int idx = 0; 3307 int idx = 0;
3328 foreach (string e in itr) 3308 foreach (string e in itr)
@@ -3345,7 +3325,6 @@ class TestEinaIterator
3345 Test.Assert(t.EinaIteratorStrOutOwn(out itr)); 3325 Test.Assert(t.EinaIteratorStrOutOwn(out itr));
3346 3326
3347 Test.Assert(itr.Own); 3327 Test.Assert(itr.Own);
3348 Test.Assert(itr.OwnContent);
3349 3328
3350 int idx = 0; 3329 int idx = 0;
3351 foreach (string e in itr) 3330 foreach (string e in itr)
@@ -3365,7 +3344,6 @@ class TestEinaIterator
3365 var itr = t.EinaIteratorStrReturn(); 3344 var itr = t.EinaIteratorStrReturn();
3366 3345
3367 Test.Assert(!itr.Own); 3346 Test.Assert(!itr.Own);
3368 Test.Assert(!itr.OwnContent);
3369 3347
3370 int idx = 0; 3348 int idx = 0;
3371 foreach (string e in itr) 3349 foreach (string e in itr)
@@ -3387,7 +3365,6 @@ class TestEinaIterator
3387 var itr = t.EinaIteratorStrReturnOwn(); 3365 var itr = t.EinaIteratorStrReturnOwn();
3388 3366
3389 Test.Assert(itr.Own); 3367 Test.Assert(itr.Own);
3390 Test.Assert(itr.OwnContent);
3391 3368
3392 int idx = 0; 3369 int idx = 0;
3393 foreach (string e in itr) 3370 foreach (string e in itr)
@@ -3410,14 +3387,12 @@ class TestEinaIterator
3410 var itr = arr.GetIterator(); 3387 var itr = arr.GetIterator();
3411 3388
3412 Test.Assert(itr.Own); 3389 Test.Assert(itr.Own);
3413 Test.Assert(!itr.OwnContent);
3414 Test.Assert(arr.Own); 3390 Test.Assert(arr.Own);
3415 Test.Assert(arr.OwnContent); 3391 Test.Assert(arr.OwnContent);
3416 3392
3417 Test.Assert(t.EinaIteratorObjIn(itr)); 3393 Test.Assert(t.EinaIteratorObjIn(itr));
3418 3394
3419 Test.Assert(itr.Own); 3395 Test.Assert(itr.Own);
3420 Test.Assert(!itr.OwnContent);
3421 Test.Assert(arr.Own); 3396 Test.Assert(arr.Own);
3422 Test.Assert(arr.OwnContent); 3397 Test.Assert(arr.OwnContent);
3423 3398
@@ -3431,20 +3406,16 @@ class TestEinaIterator
3431 var arr = new Eina.Array<Dummy.Numberwrapper>(); 3406 var arr = new Eina.Array<Dummy.Numberwrapper>();
3432 arr.Append(BaseSeqObj()); 3407 arr.Append(BaseSeqObj());
3433 var itr = arr.GetIterator(); 3408 var itr = arr.GetIterator();
3434 arr.OwnContent = false;
3435 itr.OwnContent = true;
3436 3409
3437 Test.Assert(itr.Own); 3410 Test.Assert(itr.Own);
3438 Test.Assert(itr.OwnContent);
3439 Test.Assert(arr.Own); 3411 Test.Assert(arr.Own);
3440 Test.Assert(!arr.OwnContent); 3412 Test.Assert(arr.OwnContent);
3441 3413
3442 Test.Assert(t.EinaIteratorObjInOwn(itr)); 3414 Test.Assert(t.EinaIteratorObjInOwn(itr));
3443 3415
3444 Test.Assert(!itr.Own); 3416 Test.Assert(!itr.Own);
3445 Test.Assert(!itr.OwnContent);
3446 Test.Assert(arr.Own); 3417 Test.Assert(arr.Own);
3447 Test.Assert(!arr.OwnContent); 3418 Test.Assert(arr.OwnContent);
3448 3419
3449 itr.Dispose(); 3420 itr.Dispose();
3450 arr.Dispose(); 3421 arr.Dispose();
@@ -3460,7 +3431,6 @@ class TestEinaIterator
3460 Test.Assert(t.EinaIteratorObjOut(out itr)); 3431 Test.Assert(t.EinaIteratorObjOut(out itr));
3461 3432
3462 Test.Assert(!itr.Own); 3433 Test.Assert(!itr.Own);
3463 Test.Assert(!itr.OwnContent);
3464 3434
3465 var base_seq_obj = BaseSeqObj(); 3435 var base_seq_obj = BaseSeqObj();
3466 3436
@@ -3485,7 +3455,6 @@ class TestEinaIterator
3485 Test.Assert(t.EinaIteratorObjOutOwn(out itr)); 3455 Test.Assert(t.EinaIteratorObjOutOwn(out itr));
3486 3456
3487 Test.Assert(itr.Own); 3457 Test.Assert(itr.Own);
3488 Test.Assert(itr.OwnContent);
3489 3458
3490 var base_seq_obj = BaseSeqObj(); 3459 var base_seq_obj = BaseSeqObj();
3491 3460
@@ -3507,7 +3476,6 @@ class TestEinaIterator
3507 var itr = t.EinaIteratorObjReturn(); 3476 var itr = t.EinaIteratorObjReturn();
3508 3477
3509 Test.Assert(!itr.Own); 3478 Test.Assert(!itr.Own);
3510 Test.Assert(!itr.OwnContent);
3511 3479
3512 var base_seq_obj = BaseSeqObj(); 3480 var base_seq_obj = BaseSeqObj();
3513 3481
@@ -3531,7 +3499,6 @@ class TestEinaIterator
3531 var itr = t.EinaIteratorObjReturnOwn(); 3499 var itr = t.EinaIteratorObjReturnOwn();
3532 3500
3533 Test.Assert(itr.Own); 3501 Test.Assert(itr.Own);
3534 Test.Assert(itr.OwnContent);
3535 3502
3536 var base_seq_obj = BaseSeqObj(); 3503 var base_seq_obj = BaseSeqObj();
3537 3504
diff --git a/src/tests/efl_mono/dummy_test_object.c b/src/tests/efl_mono/dummy_test_object.c
index fa5d01888a..4fdc69bbed 100644
--- a/src/tests/efl_mono/dummy_test_object.c
+++ b/src/tests/efl_mono/dummy_test_object.c
@@ -16,6 +16,9 @@ typedef struct Dummy_Test_Object_Data
16 int iface_prop; 16 int iface_prop;
17 Eo *provider; 17 Eo *provider;
18 Eo *iface_provider; 18 Eo *iface_provider;
19
20 // Containers passed to C# as iterator/accessors
21 Eina_Array *out_array;
19} Dummy_Test_Object_Data; 22} Dummy_Test_Object_Data;
20 23
21static 24static
@@ -97,6 +100,9 @@ _dummy_test_object_efl_object_destructor(Eo *obj, Dummy_Test_Object_Data *pd)
97 pd->list_for_accessor = NULL; 100 pd->list_for_accessor = NULL;
98 } 101 }
99 102
103 if (pd->out_array)
104 eina_array_free(pd->out_array);
105
100 efl_destructor(efl_super(obj, DUMMY_TEST_OBJECT_CLASS)); 106 efl_destructor(efl_super(obj, DUMMY_TEST_OBJECT_CLASS));
101} 107}
102 108
@@ -2695,7 +2701,7 @@ static Eina_Iterator *_iterator_int_in_own_to_check = NULL;
2695 2701
2696Eina_Bool _dummy_test_object_eina_iterator_int_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Iterator *itr) 2702Eina_Bool _dummy_test_object_eina_iterator_int_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Iterator *itr)
2697{ 2703{
2698 Eina_Bool r = _iterator_int_equal(itr, base_seq_int, base_seq_int_size, EINA_TRUE); 2704 Eina_Bool r = _iterator_int_equal(itr, base_seq_int, base_seq_int_size, EINA_FALSE);
2699 _iterator_int_in_own_to_check = itr; 2705 _iterator_int_in_own_to_check = itr;
2700 return r; 2706 return r;
2701} 2707}
@@ -2746,9 +2752,12 @@ Eina_Bool _dummy_test_object_eina_iterator_int_out_own(EINA_UNUSED Eo *obj, EINA
2746{ 2752{
2747 if (!itr) return EINA_FALSE; 2753 if (!itr) return EINA_FALSE;
2748 2754
2749 Eina_Array *arr = _iterator_int_eina_array_new(); 2755 if (pd->out_array)
2756 eina_array_free(pd->out_array);
2750 2757
2751 *itr = eina_array_iterator_new(arr); 2758 pd->out_array = _iterator_int_eina_array_new();
2759
2760 *itr = eina_array_iterator_new(pd->out_array);
2752 2761
2753 return EINA_TRUE; 2762 return EINA_TRUE;
2754} 2763}
@@ -2786,8 +2795,11 @@ Eina_Bool _dummy_test_object_check_eina_iterator_int_return(EINA_UNUSED Eo *obj,
2786 2795
2787Eina_Iterator *_dummy_test_object_eina_iterator_int_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) 2796Eina_Iterator *_dummy_test_object_eina_iterator_int_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
2788{ 2797{
2789 Eina_Array *arr = _iterator_int_eina_array_new(); 2798 if (pd->out_array)
2790 return eina_array_iterator_new(arr); 2799 eina_array_free(pd->out_array);
2800
2801 pd->out_array = _iterator_int_eina_array_new();
2802 return eina_array_iterator_new(pd->out_array);
2791} 2803}
2792 2804
2793// String // 2805// String //
@@ -2853,7 +2865,7 @@ static Eina_Iterator *_iterator_str_in_own_to_check = NULL;
2853 2865
2854Eina_Bool _dummy_test_object_eina_iterator_str_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Iterator *itr) 2866Eina_Bool _dummy_test_object_eina_iterator_str_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Iterator *itr)
2855{ 2867{
2856 Eina_Bool r = _iterator_str_equal(itr, base_seq_str, base_seq_str_size, EINA_TRUE); 2868 Eina_Bool r = _iterator_str_equal(itr, base_seq_str, base_seq_str_size, EINA_FALSE);
2857 _iterator_str_in_own_to_check = itr; 2869 _iterator_str_in_own_to_check = itr;
2858 return r; 2870 return r;
2859} 2871}
@@ -2904,9 +2916,12 @@ Eina_Bool _dummy_test_object_eina_iterator_str_out_own(EINA_UNUSED Eo *obj, EINA
2904{ 2916{
2905 if (!itr) return EINA_FALSE; 2917 if (!itr) return EINA_FALSE;
2906 2918
2907 Eina_Array *arr = _iterator_str_eina_array_new(); 2919 if (pd->out_array)
2920 eina_array_free(pd->out_array);
2908 2921
2909 *itr = eina_array_iterator_new(arr); 2922 pd->out_array = _iterator_str_eina_array_new();
2923
2924 *itr = eina_array_iterator_new(pd->out_array);
2910 2925
2911 return EINA_TRUE; 2926 return EINA_TRUE;
2912} 2927}
@@ -2944,8 +2959,11 @@ Eina_Bool _dummy_test_object_check_eina_iterator_str_return(EINA_UNUSED Eo *obj,
2944 2959
2945Eina_Iterator *_dummy_test_object_eina_iterator_str_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) 2960Eina_Iterator *_dummy_test_object_eina_iterator_str_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
2946{ 2961{
2947 Eina_Array *arr = _iterator_str_eina_array_new(); 2962 if (pd->out_array)
2948 return eina_array_iterator_new(arr); 2963 eina_array_free(pd->out_array);
2964
2965 pd->out_array = _iterator_str_eina_array_new();
2966 return eina_array_iterator_new(pd->out_array);
2949} 2967}
2950 2968
2951// Object // 2969// Object //
@@ -3015,7 +3033,7 @@ static Eina_Iterator *_iterator_obj_in_own_to_check = NULL;
3015 3033
3016Eina_Bool _dummy_test_object_eina_iterator_obj_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Iterator *itr) 3034Eina_Bool _dummy_test_object_eina_iterator_obj_in_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd, Eina_Iterator *itr)
3017{ 3035{
3018 Eina_Bool r = _iterator_obj_equal(itr, base_seq_obj, base_seq_obj_size, EINA_TRUE); 3036 Eina_Bool r = _iterator_obj_equal(itr, base_seq_obj, base_seq_obj_size, EINA_FALSE);
3019 _iterator_obj_in_own_to_check = itr; 3037 _iterator_obj_in_own_to_check = itr;
3020 return r; 3038 return r;
3021} 3039}
@@ -3066,9 +3084,12 @@ Eina_Bool _dummy_test_object_eina_iterator_obj_out_own(EINA_UNUSED Eo *obj, EINA
3066{ 3084{
3067 if (!itr) return EINA_FALSE; 3085 if (!itr) return EINA_FALSE;
3068 3086
3069 Eina_Array *arr = _iterator_obj_eina_array_new(); 3087 if (pd->out_array)
3088 eina_array_free(pd->out_array);
3070 3089
3071 *itr = eina_array_iterator_new(arr); 3090 pd->out_array = _iterator_obj_eina_array_new();
3091
3092 *itr = eina_array_iterator_new(pd->out_array);
3072 3093
3073 return EINA_TRUE; 3094 return EINA_TRUE;
3074} 3095}
@@ -3106,8 +3127,11 @@ Eina_Bool _dummy_test_object_check_eina_iterator_obj_return(EINA_UNUSED Eo *obj,
3106 3127
3107Eina_Iterator *_dummy_test_object_eina_iterator_obj_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd) 3128Eina_Iterator *_dummy_test_object_eina_iterator_obj_return_own(EINA_UNUSED Eo *obj, EINA_UNUSED Dummy_Test_Object_Data *pd)
3108{ 3129{
3109 Eina_Array *arr = _iterator_obj_eina_array_new(); 3130 if (pd->out_array)
3110 return eina_array_iterator_new(arr); 3131 eina_array_free(pd->out_array);
3132
3133 pd->out_array = _iterator_obj_eina_array_new();
3134 return eina_array_iterator_new(pd->out_array);
3111} 3135}
3112 3136
3113// // 3137// //
diff --git a/src/tests/efl_mono/dummy_test_object.eo b/src/tests/efl_mono/dummy_test_object.eo
index 56fa844b96..529b246418 100644
--- a/src/tests/efl_mono/dummy_test_object.eo
+++ b/src/tests/efl_mono/dummy_test_object.eo
@@ -869,14 +869,14 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
869 /* Integer */ 869 /* Integer */
870 eina_iterator_int_in { 870 eina_iterator_int_in {
871 params { 871 params {
872 @in itr: iterator<ptr(int)>; 872 @in itr: iterator<int>;
873 } 873 }
874 return: bool; 874 return: bool;
875 } 875 }
876 876
877 eina_iterator_int_in_own { 877 eina_iterator_int_in_own {
878 params { 878 params {
879 @in itr: iterator<free(ptr(int),free)> @owned; 879 @in itr: iterator<int> @owned;
880 } 880 }
881 return: bool; 881 return: bool;
882 } 882 }
@@ -886,7 +886,7 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
886 886
887 eina_iterator_int_out { 887 eina_iterator_int_out {
888 params { 888 params {
889 @out itr: iterator<ptr(int)>; 889 @out itr: iterator<int>;
890 } 890 }
891 return: bool; 891 return: bool;
892 } 892 }
@@ -896,20 +896,20 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
896 896
897 eina_iterator_int_out_own { 897 eina_iterator_int_out_own {
898 params { 898 params {
899 @out itr: iterator<free(ptr(int),free)> @owned; 899 @out itr: iterator<int> @owned;
900 } 900 }
901 return: bool; 901 return: bool;
902 } 902 }
903 903
904 eina_iterator_int_return { 904 eina_iterator_int_return {
905 return: iterator<ptr(int)>; 905 return: iterator<int>;
906 } 906 }
907 check_eina_iterator_int_return { 907 check_eina_iterator_int_return {
908 return: bool; 908 return: bool;
909 } 909 }
910 910
911 eina_iterator_int_return_own { 911 eina_iterator_int_return_own {
912 return: iterator<free(ptr(int),free)> @owned; 912 return: iterator<int> @owned;
913 } 913 }
914 914
915 /* String */ 915 /* String */
@@ -1393,9 +1393,9 @@ class Dummy.Test_Object extends Efl.Object implements Dummy.Test_Iface {
1393 /* Accessors */ 1393 /* Accessors */
1394 clone_accessor { 1394 clone_accessor {
1395 params { 1395 params {
1396 @in acc: accessor<ptr(int)>; 1396 @in acc: accessor<int>;
1397 } 1397 }
1398 return: accessor<ptr(int)> @owned; 1398 return: accessor<int> @owned;
1399 } 1399 }
1400 1400
1401 @property setter_only { 1401 @property setter_only {