summaryrefslogtreecommitdiff
path: root/src/bindings
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 /src/bindings
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
Diffstat (limited to 'src/bindings')
-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
6 files changed, 9 insertions, 38 deletions
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()