csharp: updating eina_config docs and hide api.

Reviewers: felipealmeida, lauromoura, woohyun, segfaultxavi

Reviewed By: lauromoura

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10312
This commit is contained in:
Bruno da Silva Belo 2019-10-14 12:23:56 -03:00 committed by Lauro Moura
parent 37e6430e46
commit 8ba2638f0e
1 changed files with 29 additions and 5 deletions

View File

@ -2,20 +2,24 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.ComponentModel;
namespace Eina namespace Eina
{ {
/// <summary> /// <summary>
/// Manage the initialization and cleanup for eina. /// Manage the initialization and cleanup for eina.
/// /// <para>Since EFL 1.23.</para>
/// Since EFL 1.23.
/// </summary> /// </summary>
public class Config public class Config
{ {
[DllImport(efl.Libs.Eina)] private static extern int eina_init(); [DllImport(efl.Libs.Eina)] private static extern int eina_init();
[DllImport(efl.Libs.Eina)] private static extern int eina_shutdown(); [DllImport(efl.Libs.Eina)] private static extern int eina_shutdown();
/// <summary>
/// Initialize the Eina library.
/// <para>Since EFL 1.23.</para>
/// </summary>
public static void Init() public static void Init()
{ {
if (eina_init() == 0) if (eina_init() == 0)
@ -24,6 +28,10 @@ public class Config
} }
} }
/// <summary>
/// Finalize the Eina library.
/// <para>Since EFL 1.23.</para>
/// </summary>
public static int Shutdown() public static int Shutdown()
{ {
return eina_shutdown(); return eina_shutdown();
@ -33,29 +41,41 @@ public class Config
/// <summary> /// <summary>
/// Wrapper class for pointers that need some cleanup afterwards like strings /// Wrapper class for pointers that need some cleanup afterwards like strings
/// /// <para>Since EFL 1.23.</para>
/// Since EFL 1.23.
/// </summary> /// </summary>
public class DisposableIntPtr : IDisposable public class DisposableIntPtr : IDisposable
{ {
[EditorBrowsable(EditorBrowsableState.Never)]
public IntPtr Handle { get; set; } public IntPtr Handle { get; set; }
private bool ShouldFree; private bool ShouldFree;
private bool Disposed; private bool Disposed;
/// <summary>Wraps a new ptr what will be freed based on the /// <summary>Wraps a new ptr what will be freed based on the
/// value of shouldFree</summary> /// value of shouldFree
/// <para>Since EFL 1.23.</para>
/// </summary>
public DisposableIntPtr(IntPtr ptr, bool shouldFree = false) public DisposableIntPtr(IntPtr ptr, bool shouldFree = false)
{ {
Handle = ptr; Handle = ptr;
ShouldFree = shouldFree; ShouldFree = shouldFree;
} }
/// <summary>Release 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>Disposes of this wrapper, releasing the native handle 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)
{ {
if (!Disposed && ShouldFree) if (!Disposed && ShouldFree)
@ -66,6 +86,10 @@ public class DisposableIntPtr : IDisposable
Disposed = true; Disposed = true;
} }
/// <summary>Release the native resources held by this instance.
/// <para>Since EFL 1.23.</para>
/// </summary>
~DisposableIntPtr() ~DisposableIntPtr()
{ {
Dispose(false); Dispose(false);