From fe93c519ab2833aa997d53318777e357021224f4 Mon Sep 17 00:00:00 2001 From: Bruno da Silva Belo Date: Thu, 10 Oct 2019 00:52:26 -0300 Subject: [PATCH] csharp: updating eina_inarray docs and hide api. Reviewers: lauromoura, felipealmeida, segfaultxavi, woohyun Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8293 Differential Revision: https://phab.enlightenment.org/D10328 --- src/bindings/mono/eina_mono/eina_inarray.cs | 139 +++++++++++++++++++- 1 file changed, 134 insertions(+), 5 deletions(-) diff --git a/src/bindings/mono/eina_mono/eina_inarray.cs b/src/bindings/mono/eina_mono/eina_inarray.cs index a9c8d5fc92..a8c52374eb 100644 --- a/src/bindings/mono/eina_mono/eina_inarray.cs +++ b/src/bindings/mono/eina_mono/eina_inarray.cs @@ -3,6 +3,7 @@ using System; using System.Runtime.InteropServices; using System.Collections.Generic; +using System.ComponentModel; using static Eina.TraitFunctions; using static Eina.InarrayNativeFunctions; @@ -10,6 +11,7 @@ using static Eina.InarrayNativeFunctions; namespace Eina { +[EditorBrowsable(EditorBrowsableState.Never)] public static class InarrayNativeFunctions { [DllImport(efl.Libs.Eina)] public static extern IntPtr @@ -68,17 +70,25 @@ public static class InarrayNativeFunctions } /// Wrapper around an inplace array. -/// -/// Since EFL 1.23. +/// Since EFL 1.23. /// public class Inarray : IEnumerable, IDisposable { public static uint DefaultStep = 0; - + [EditorBrowsable(EditorBrowsableState.Never)] public IntPtr Handle {get;set;} = IntPtr.Zero; + /// Whether this wrapper owns the native buffer. + /// Since EFL 1.23. + /// public bool Own {get;set;} + /// Who is in charge of releasing the resources wrapped by + /// this instance. + /// Since EFL 1.23. + /// public bool OwnContent {get;set;} - + /// Length of the array. + /// Since EFL 1.23. + /// public int Length { get { return Count(); } @@ -96,16 +106,26 @@ public class Inarray : IEnumerable, IDisposable } } + /// + /// Default constructor + /// Since EFL 1.23. + /// public Inarray() { InitNew(DefaultStep); } + /// + /// Constructor with step. + /// Since EFL 1.23. + /// + /// Step size of the array. public Inarray(uint step) { InitNew(step); } + [EditorBrowsable(EditorBrowsableState.Never)] public Inarray(IntPtr handle, bool own) { Handle = handle; @@ -113,6 +133,7 @@ public class Inarray : IEnumerable, IDisposable OwnContent = own; } + [EditorBrowsable(EditorBrowsableState.Never)] public Inarray(IntPtr handle, bool own, bool ownContent) { Handle = handle; @@ -120,11 +141,20 @@ public class Inarray : IEnumerable, IDisposable OwnContent = ownContent; } + /// + /// Finalizer to be called from the Garbage Collector. + /// Since EFL 1.23. + /// ~Inarray() { Dispose(false); } + /// Disposes of this wrapper, releasing the native array if owned. + /// Since EFL 1.23. + /// + /// True if this was called from public method. False if + /// called from the C# finalizer. protected virtual void Dispose(bool disposing) { IntPtr h = Handle; @@ -156,17 +186,28 @@ public class Inarray : IEnumerable, IDisposable } } + /// Releases the native resources held by this instance. + /// Since EFL 1.23. + /// public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } + /// Releases the native resources held by this instance. + /// Since EFL 1.23. + /// public void Free() { Dispose(); } + /// + /// Releases the native array. + /// Since EFL 1.23. + /// + /// The native array. public IntPtr Release() { IntPtr h = Handle; @@ -186,29 +227,54 @@ public class Inarray : IEnumerable, IDisposable } } + /// + /// Removes every member from the array. + /// Since EFL 1.23. + /// public void Flush() { FreeElementsIfOwned(); eina_inarray_flush(Handle); } + /// + /// Counts the number of members in an array. + /// Since EFL 1.23. + /// + /// THe number of members in the array. public int Count() { return (int)eina_inarray_count(Handle); } + /// Sets all ownership. + /// Since EFL 1.23. + /// + /// If the hash own for all ownerships. public void SetOwnership(bool ownAll) { Own = ownAll; OwnContent = ownAll; } + /// Sets own individually. + /// Since EFL 1.23. + /// + /// If own the object. + /// If own the content's object. public void SetOwnership(bool own, bool ownContent) { Own = own; OwnContent = ownContent; } + + /// + /// Puts the value as the last member of the array. + /// Since EFL 1.23. + /// + /// The value to be pushed. + /// The index of the new member, otherwise -1 on errors. public int Push(T val) { IntPtr ele = IntPtr.Zero; @@ -237,6 +303,11 @@ public class Inarray : IEnumerable, IDisposable // } // } + /// + /// Removes the last member of the array. + /// Since EFL 1.23. + /// + /// The data poppep out of the array. public T Pop() { IntPtr ele = eina_inarray_pop(Handle); @@ -249,17 +320,36 @@ public class Inarray : IEnumerable, IDisposable return r; } + /// + /// Gets the member at the given position. + /// Since EFL 1.23. + /// + /// The member position. + /// The element of the given position. public T Nth(uint idx) { IntPtr ele = eina_inarray_nth(Handle, idx); return NativeToManagedInplace(ele); } + /// + /// Gets the member at the given position. + /// Since EFL 1.23. + /// + /// The member position. + /// The element of the given position. public T At(int idx) { return Nth((uint)idx); } + /// + /// Inserts the value at the given position in the array. + /// Since EFL 1.23. + /// + /// The position to insert the member at. + /// The value to be inserted. + /// true on success, false on failure. public bool InsertAt(uint idx, T val) { IntPtr ele = IntPtr.Zero; @@ -278,6 +368,12 @@ public class Inarray : IEnumerable, IDisposable return r; } + /// + /// Replaces the value at the given position. + /// Since EFL 1.23. + /// + /// The position to replace the member at. + /// The value to replace. public bool ReplaceAt(uint idx, T val) { var old = eina_inarray_nth(Handle, idx); @@ -302,6 +398,9 @@ public class Inarray : IEnumerable, IDisposable return r; } + /// Accessor by index to the elements of this list. + /// Since EFL 1.23. + /// public T this[int idx] { get @@ -314,6 +413,12 @@ public class Inarray : IEnumerable, IDisposable } } + /// + /// Removes a member from the given position. + /// Since EFL 1.23. + /// + /// The position to remove the member at. + /// true on success, false on failure. public bool RemoveAt(uint idx) { IntPtr ele = eina_inarray_nth(Handle, idx); @@ -330,11 +435,20 @@ public class Inarray : IEnumerable, IDisposable return eina_inarray_remove_at(Handle, idx); } + /// + /// Reverses members in the array. + /// Since EFL 1.23. + /// public void Reverse() { eina_inarray_reverse(Handle); } + /// + /// Returns a array containing all of the elements in proper sequence. + /// Since EFL 1.23. + /// + /// A array public T[] ToArray() { int len = Length; @@ -347,6 +461,10 @@ public class Inarray : IEnumerable, IDisposable return managed; } + /// Appends all elements at the end of array. + /// Since EFL 1.23. + /// + /// true on success, false otherwise. public bool Append(T[] values) { foreach (T v in values) @@ -360,16 +478,25 @@ public class Inarray : IEnumerable, IDisposable return true; } + /// Gets an Iterator for this Array. + /// Since EFL 1.23. + /// public Eina.Iterator GetIterator() { return new Eina.Iterator(eina_inarray_iterator_new(Handle), true); } + /// Gets an Iterator for this Array with reversed order. + /// Since EFL 1.23. + /// public Eina.Iterator GetReversedIterator() { return new Eina.Iterator(eina_inarray_iterator_reversed_new(Handle), true); } + /// Gets an Enumerator for this Array. + /// Since EFL 1.23. + /// public IEnumerator GetEnumerator() { int len = Length; @@ -384,7 +511,9 @@ public class Inarray : IEnumerable, IDisposable return this.GetEnumerator(); } - /// Gets an Accessor for this Array. + /// Gets an Accessor for this Array. + /// Since EFL 1.23. + /// public Eina.Accessor GetAccessor() { return new Eina.AccessorInArray(eina_inarray_accessor_new(Handle), Ownership.Managed);