diff --git a/src/bindings/mono/eina_mono/eina_array.cs b/src/bindings/mono/eina_mono/eina_array.cs index 8c09557098..90cc4b4cf1 100644 --- a/src/bindings/mono/eina_mono/eina_array.cs +++ b/src/bindings/mono/eina_mono/eina_array.cs @@ -45,20 +45,23 @@ public static class ArrayNativeFunctions eina_array_foreach_custom_export_mono(IntPtr array, IntPtr cb, IntPtr fdata); } +/// A container of contiguous allocated elements (SINCE EFL 1.23). public class Array : IEnumerable, IDisposable { public static uint DefaultStep = 32; + /// Pointer to the native buffer. public IntPtr Handle {get;set;} = IntPtr.Zero; + ///Whether this wrapper owns the native buffer. public bool Own {get;set;} + /// Who is in charge of releasing the resources wrapped by this instance. public bool OwnContent {get;set;} - + /// Length of the array. public int Length { get { return Count(); } } - private void InitNew(uint step) { Handle = eina_array_new(step); @@ -90,16 +93,28 @@ public class Array : IEnumerable, IDisposable eina_array_data_set_custom_export_mono(Handle, (uint)idx, ele); // TODO: Check bounds ??? } + /// + /// Create a new array. + /// public Array() { InitNew(DefaultStep); } + /// + /// Create a new array. + /// + ///// Step size of the array. public Array(uint step) { InitNew(step); } + /// + /// Create a new array. + /// + ///// The native handle to be wrapped. + ///// Whether this wrapper owns the native handle. public Array(IntPtr handle, bool own) { if (handle == IntPtr.Zero) @@ -112,6 +127,12 @@ public class Array : IEnumerable, IDisposable OwnContent = own; } + /// + /// Create a new array + /// + ///// The native array to be wrapped. + ///// Whether this wrapper owns the native array. + ///// For compatibility with other EFL# containers. public Array(IntPtr handle, bool own, bool ownContent) { if (handle == IntPtr.Zero) @@ -124,11 +145,16 @@ public class Array : IEnumerable, IDisposable OwnContent = ownContent; } + /// + /// Finalizer to be called from the Garbage Collector. + /// ~Array() { Dispose(false); } - + /// Disposes of this wrapper, releasing the native array if owned. + /// True if this was called from public method. False if + /// called from the C# finalizer. protected virtual void Dispose(bool disposing) { IntPtr h = Handle; @@ -160,17 +186,23 @@ public class Array : IEnumerable, IDisposable } } + /// Releases the native resources held by this instance. public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + /// Releases the native resources held by this instance. public void Free() { Dispose(); } + /// + /// Releases the native array. + /// + /// The native array. public IntPtr Release() { IntPtr h = Handle; @@ -190,18 +222,28 @@ public class Array : IEnumerable, IDisposable } } + /// + /// Clears an array's elements and deallocates the memory. + /// public void Clean() { FreeElementsIfOwned(); eina_array_clean_custom_export_mono(Handle); } + /// + /// Clears an array's elements and deallocates the memory. + /// public void Flush() { FreeElementsIfOwned(); eina_array_flush(Handle); } + /// + /// Returns the number of elements in an array. + /// + /// The number of elements. public int Count() { return (int)eina_array_count_custom_export_mono(Handle); @@ -219,6 +261,10 @@ public class Array : IEnumerable, IDisposable OwnContent = ownContent; } + /// + /// Inserts the element of the array at the end. + /// + ///// The value of the element to be inserted. public bool Push(T val) { IntPtr ele = ManagedToNativeAlloc(val); @@ -240,6 +286,10 @@ public class Array : IEnumerable, IDisposable // } // } + /// + /// Returns the element of the array at the end. + /// + /// The element at the end position. public T Pop() { IntPtr ele = InternalPop(); @@ -252,17 +302,32 @@ public class Array : IEnumerable, IDisposable return r; } + /// + /// Returns the element of the array at the specified position. + /// + ///// The position of the desired element. + /// The element at the specified position public T DataGet(int idx) { IntPtr ele = InternalDataGet(idx); return NativeToManaged(ele); } + /// + /// Returns the element of the array at the specified position. + /// + ///// The position of the desired element. + /// The element at the specified position public T At(int idx) { return DataGet(idx); } + /// + /// Replaces the element at the specified position. + /// + ///// The position of the desired element. + ///// The value of the element to be inserted. public void DataSet(int idx, T val) { IntPtr ele = InternalDataGet(idx); // TODO: check bondaries ?? @@ -287,6 +352,10 @@ public class Array : IEnumerable, IDisposable } } + /// + /// Returns a array containing all of the elements in proper sequence. + /// + /// A array public T[] ToArray() { int len = Length; @@ -299,6 +368,9 @@ public class Array : IEnumerable, IDisposable return managed; } + /// + /// Appends all elements at the end of array. + /// public bool Append(T[] values) { foreach (T v in values) @@ -313,11 +385,13 @@ public class Array : IEnumerable, IDisposable } + /// Gets an Iterator for this Array. public Eina.Iterator GetIterator() { return new Eina.Iterator(eina_array_iterator_new(Handle), true); } + /// Gets an Enumerator for this Array. public IEnumerator GetEnumerator() { int len = Length; @@ -327,6 +401,7 @@ public class Array : IEnumerable, IDisposable } } + /// Gets an Enumerator for this Array. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.GetEnumerator();