forked from enlightenment/efl
csharp: updating eina_iterator docs and hide api.
Summary: ref T8293 Reviewers: felipealmeida, lauromoura, segfaultxavi, woohyun Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8293 Differential Revision: https://phab.enlightenment.org/D10330
This commit is contained in:
parent
5e6a965a79
commit
d9595d840d
|
@ -3,6 +3,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
using static Eina.TraitFunctions;
|
using static Eina.TraitFunctions;
|
||||||
using static Eina.IteratorNativeFunctions;
|
using static Eina.IteratorNativeFunctions;
|
||||||
|
@ -10,6 +11,7 @@ using static Eina.IteratorNativeFunctions;
|
||||||
namespace Eina
|
namespace Eina
|
||||||
{
|
{
|
||||||
|
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public static class IteratorNativeFunctions
|
public static class IteratorNativeFunctions
|
||||||
{
|
{
|
||||||
[DllImport(efl.Libs.Eina)] public static extern void
|
[DllImport(efl.Libs.Eina)] public static extern void
|
||||||
|
@ -30,25 +32,38 @@ public static class IteratorNativeFunctions
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Wrapper around a native Eina iterator.
|
/// <summary>Wrapper around a native Eina iterator.
|
||||||
///
|
/// <para>Since EFL 1.23.</para>
|
||||||
/// Since EFL 1.23.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Iterator<T> : IEnumerable<T>, IDisposable
|
public class Iterator<T> : IEnumerable<T>, IDisposable
|
||||||
{
|
{
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public IntPtr Handle {get;set;} = IntPtr.Zero;
|
public IntPtr Handle {get;set;} = IntPtr.Zero;
|
||||||
|
/// <summary>Whether this wrapper owns the native iterator.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
public bool Own {get;set;} = true;
|
public bool Own {get;set;} = true;
|
||||||
|
|
||||||
|
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||||
public Iterator(IntPtr handle, bool own)
|
public Iterator(IntPtr handle, bool own)
|
||||||
{
|
{
|
||||||
Handle = handle;
|
Handle = handle;
|
||||||
Own = own;
|
Own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finalizer to be called from the Garbage Collector.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
~Iterator()
|
~Iterator()
|
||||||
{
|
{
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Disposes of this wrapper, releasing the native array if owned.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">True if this was called from <see cref="Dispose()"/> public method. False if
|
||||||
|
/// called from the C# finalizer.</param>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
var h = Handle;
|
var h = Handle;
|
||||||
|
@ -71,17 +86,28 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Releases the native resources held by this instance.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Releases the native resources held by this instance.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
public void Free()
|
public void Free()
|
||||||
{
|
{
|
||||||
Dispose();
|
Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases the native iterator.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The native array.</returns>
|
||||||
public IntPtr Release()
|
public IntPtr Release()
|
||||||
{
|
{
|
||||||
IntPtr h = Handle;
|
IntPtr h = Handle;
|
||||||
|
@ -89,11 +115,20 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Sets own.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="own">If own the object.</param>
|
||||||
public void SetOwnership(bool own)
|
public void SetOwnership(bool own)
|
||||||
{
|
{
|
||||||
Own = own;
|
Own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Go to the next one.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
public bool Next(out T res)
|
public bool Next(out T res)
|
||||||
{
|
{
|
||||||
IntPtr data;
|
IntPtr data;
|
||||||
|
@ -108,16 +143,29 @@ public class Iterator<T> : IEnumerable<T>, IDisposable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Locks the container of the iterator.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true on success, false otherwise.</returns>
|
||||||
public bool Lock()
|
public bool Lock()
|
||||||
{
|
{
|
||||||
return eina_iterator_lock(Handle);
|
return eina_iterator_lock(Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unlocks the container of the iterator.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true on success, false otherwise.</returns>
|
||||||
public bool Unlock()
|
public bool Unlock()
|
||||||
{
|
{
|
||||||
return eina_iterator_unlock(Handle);
|
return eina_iterator_unlock(Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Gets an Enumerator for this iterator.
|
||||||
|
/// <para>Since EFL 1.23.</para>
|
||||||
|
/// </summary>
|
||||||
public IEnumerator<T> GetEnumerator()
|
public IEnumerator<T> GetEnumerator()
|
||||||
{
|
{
|
||||||
for (T curr; Next(out curr);)
|
for (T curr; Next(out curr);)
|
||||||
|
|
Loading…
Reference in New Issue