aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-03-13 21:17:15 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-03-13 21:17:15 -0300
commit53fedb7a7756c9560784bad270bc44cf6b4b7489 (patch)
tree56dee9fa3f6aedd023e63a692eaccc21ad7f3939
parentmeson: Enable generation of C# docs. (diff)
downloadefl-devs/lauromoura/csharp_docs.tar.gz
csharp: Start adding docs again.devs/lauromoura/csharp_docs
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper.cs38
1 files changed, 33 insertions, 5 deletions
diff --git a/src/bindings/mono/eo_mono/FunctionWrapper.cs b/src/bindings/mono/eo_mono/FunctionWrapper.cs
index 03e81383bb..2712915224 100644
--- a/src/bindings/mono/eo_mono/FunctionWrapper.cs
+++ b/src/bindings/mono/eo_mono/FunctionWrapper.cs
@@ -3,8 +3,17 @@ using System.Runtime.InteropServices;
namespace Efl { namespace Eo {
+///<summary>Class to load functions pointers from a native module.
+///
+///This class has a platform-dependent implementation on whether it
+///is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix
+///(dlopen/dlsym).</summary>
public partial class FunctionInterop
{
+ ///<summary>Loads a function pointer from the given module.</summary>
+ ///<param name="moduleName">The name of the module containing the function.</param>
+ ///<param name="functionName">The name of the function to search for.</param>
+ ///<returns>A function pointer that can be used with delegates.</returns>
public static IntPtr LoadFunctionPointer(string moduleName, string functionName)
{
NativeModule module = new NativeModule(moduleName);
@@ -13,6 +22,10 @@ public partial class FunctionInterop
Eina.Log.Debug($"searching {module.Module} for{functionName}, result {s}");
return s;
}
+
+ ///<summary>Loads a function pointer from the default module.</summary>
+ ///<param name="functionName">The name of the function to search for.</param>
+ ///<returns>A function pointer that can be used with delegates.</returns>
public static IntPtr LoadFunctionPointer(string functionName)
{
Eina.Log.Debug($"searching {null} for {functionName}");
@@ -21,8 +34,14 @@ public partial class FunctionInterop
return s;
}
}
-
-public class FunctionWrapper<T>
+
+///<summary>Wraps a native function in a portable manner.
+///
+///This is intended as a workaround DllImport limitations when switching between mono and dotnet.
+///
+///The parameter T must be a delegate.
+///</summary>
+public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate?
{
private Lazy<FunctionLoadResult<T>> loadResult;
#pragma warning disable 0414
@@ -42,12 +61,18 @@ public class FunctionWrapper<T>
return new FunctionLoadResult<T>(Marshal.GetDelegateForFunctionPointer<T>(funcptr));
}
}
-
+
+ ///<summary>Creates a wrapper for the given function of the given module.</summary>
+ ///<param name="moduleName">The name of the module containing the function.</param>
+ ///<param name="functionName">The name of the function to search for.</param>
public FunctionWrapper(string moduleName, string functionName)
: this (new NativeModule(moduleName), functionName)
{
}
-
+
+ ///<summary>Creates a wrapper for the given function of the given module.</summary>
+ ///<param name="moduleName">The module wrapper containing the function.</param>
+ ///<param name="functionName">The name of the function to search for.</param>
public FunctionWrapper(NativeModule module, string functionName)
{
this.module = module;
@@ -58,6 +83,8 @@ public class FunctionWrapper<T>
});
}
+ ///<summary>Retrieves the result of function load.</summary>
+ ///<returns>The load result.</returns>
public FunctionLoadResult<T> Value
{
get
@@ -67,8 +94,9 @@ public class FunctionWrapper<T>
}
}
+///<summary>The outcome of the function load process.</summary>
public enum FunctionLoadResultKind { Success, LibraryNotFound, FunctionNotFound }
-
+
public class FunctionLoadResult<T>
{
public FunctionLoadResultKind Kind;