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
This commit is contained in:
Lauro Moura 2019-12-17 14:34:01 -03:00
parent 518d9b2649
commit 5befca9a10
2 changed files with 7 additions and 15 deletions

View File

@ -150,29 +150,18 @@ public class Accessor<T> : IEnumerable<T>, IDisposable
/// <returns>An enumerator to walk through the acessor items.</returns>
public IEnumerator<T> GetEnumerator()
{
/*
if (Handle == IntPtr.Zero)
{
throw new ObjectDisposedException(base.GetType().Name);
}
IntPtr tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(IntPtr)));
IntPtr tmp;
uint position = 0;
try
while (eina_accessor_data_get(Handle, position, out tmp))
{
while (eina_accessor_data_get(Handle, position, tmp))
{
IntPtr data = (IntPtr)Marshal.PtrToStructure(tmp, typeof(IntPtr));
yield return Convert(data);
position += 1;
}
yield return Convert(tmp); // No need to free as it is still owned by the container.
position += 1;
}
finally
{
MemoryNative.Free(tmp);
}
*/
yield break;
}
IEnumerator IEnumerable.GetEnumerator()

View File

@ -4577,6 +4577,9 @@ class TestEinaAccessor
Test.AssertEquals(pair.Item1, pair.Item2);
}
IEnumerable<int> seq = accessor;
Test.AssertEquals(seq.Count(), 4);
lst.Dispose();
}