summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-17 14:34:01 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-12-18 10:40:53 -0300
commit5befca9a1066716433641bf7d480c6776f4c9ba6 (patch)
tree47e812f833d8f87da3c9468491414bacbcefca4c
parent518d9b264999d9a4a5c65d2593e449271b097974 (diff)
csharp: Fix accessor IEnumerable implementation.
Summary: Fixed after `data_get` marshalling changed (correctly) the data parameter to `out IntPtr` instead of manually marshalling the double pointer. The existing test (`basic_accessor_list`) passed due to the empty enumerable behavior, which made the `foreach` running no iterations. Reviewers: brunobelo, jptiz, felipealmeida, YOhoho Reviewed By: jptiz, YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10900
-rw-r--r--src/bindings/mono/eina_mono/eina_accessor.cs19
-rw-r--r--src/tests/efl_mono/Eina.cs3
2 files changed, 7 insertions, 15 deletions
diff --git a/src/bindings/mono/eina_mono/eina_accessor.cs b/src/bindings/mono/eina_mono/eina_accessor.cs
index 2fb8437efd..0bb3b788f3 100644
--- a/src/bindings/mono/eina_mono/eina_accessor.cs
+++ b/src/bindings/mono/eina_mono/eina_accessor.cs
@@ -150,29 +150,18 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
150 /// <returns>An enumerator to walk through the acessor items.</returns> 150 /// <returns>An enumerator to walk through the acessor items.</returns>
151 public IEnumerator<T> GetEnumerator() 151 public IEnumerator<T> GetEnumerator()
152 { 152 {
153/*
154 if (Handle == IntPtr.Zero) 153 if (Handle == IntPtr.Zero)
155 { 154 {
156 throw new ObjectDisposedException(base.GetType().Name); 155 throw new ObjectDisposedException(base.GetType().Name);
157 } 156 }
158 157
159 IntPtr tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(IntPtr))); 158 IntPtr tmp;
160 uint position = 0; 159 uint position = 0;
161 try 160 while (eina_accessor_data_get(Handle, position, out tmp))
162 {
163 while (eina_accessor_data_get(Handle, position, tmp))
164 {
165 IntPtr data = (IntPtr)Marshal.PtrToStructure(tmp, typeof(IntPtr));
166 yield return Convert(data);
167 position += 1;
168 }
169 }
170 finally
171 { 161 {
172 MemoryNative.Free(tmp); 162 yield return Convert(tmp); // No need to free as it is still owned by the container.
163 position += 1;
173 } 164 }
174*/
175 yield break;
176 } 165 }
177 166
178 IEnumerator IEnumerable.GetEnumerator() 167 IEnumerator IEnumerable.GetEnumerator()
diff --git a/src/tests/efl_mono/Eina.cs b/src/tests/efl_mono/Eina.cs
index 46d89e4c55..638a65ce58 100644
--- a/src/tests/efl_mono/Eina.cs
+++ b/src/tests/efl_mono/Eina.cs
@@ -4577,6 +4577,9 @@ class TestEinaAccessor
4577 Test.AssertEquals(pair.Item1, pair.Item2); 4577 Test.AssertEquals(pair.Item1, pair.Item2);
4578 } 4578 }
4579 4579
4580 IEnumerable<int> seq = accessor;
4581 Test.AssertEquals(seq.Count(), 4);
4582
4580 lst.Dispose(); 4583 lst.Dispose();
4581 } 4584 }
4582 4585