lauromoura pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=1db12b5fb4c0160c0d486a0e6d2a8bd748820881
commit 1db12b5fb4c0160c0d486a0e6d2a8bd748820881 Author: Lauro Moura <[email protected]> Date: Mon Oct 28 19:04:33 2019 -0300 mono: encapsulate internal FunctionWrapper Summary: Depends on D10340 Test Plan: meson setup -Dbindings=mono,cxx -Dmono-beta=true Reviewers: lauromoura, segfaultxavi, Jaehyun_Cho Reviewed By: lauromoura Subscribers: cedric, #reviewers, woohyun, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10342 --- src/bindings/mono/eo_mono/FunctionWrapper.cs | 26 +++++++++++----------- src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs | 4 ++-- .../mono/eo_mono/FunctionWrapper_Windows.cs | 4 ++-- src/bindings/mono/eo_mono/iwrapper.cs | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/bindings/mono/eo_mono/FunctionWrapper.cs b/src/bindings/mono/eo_mono/FunctionWrapper.cs index a0c8bd8a08..04f1561507 100644 --- a/src/bindings/mono/eo_mono/FunctionWrapper.cs +++ b/src/bindings/mono/eo_mono/FunctionWrapper.cs @@ -24,13 +24,13 @@ namespace Efl.Eo ///This class has a platform-dependent implementation on whether it ///is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix ///(dlopen/dlsym).</summary> -public static partial class FunctionInterop +internal static 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) + internal static IntPtr LoadFunctionPointer(string moduleName, string functionName) { IntPtr module = NativeModule.LoadLibrary(moduleName); Eina.Log.Debug($"searching {module} for {functionName}"); @@ -42,7 +42,7 @@ public static partial class FunctionInterop ///<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) + internal static IntPtr LoadFunctionPointer(string functionName) { Eina.Log.Debug($"searching {null} for {functionName}"); var s = FunctionInterop.dlsym(IntPtr.Zero, functionName); @@ -57,7 +57,7 @@ public static partial class FunctionInterop /// ///The parameter T must be a delegate. ///</summary> -public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate? +class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate? { private Lazy<FunctionLoadResult<T>> loadResult; #pragma warning disable 0414 @@ -87,7 +87,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T ///<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) + internal FunctionWrapper(string moduleName, string functionName) : this(new NativeModule(moduleName), functionName) { } @@ -95,7 +95,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T ///<summary>Creates a wrapper for the given function of the given module.</summary> ///<param name="module">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) + internal FunctionWrapper(NativeModule module, string functionName) { this.module = module; loadResult = new Lazy<FunctionLoadResult<T>> @@ -107,7 +107,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T ///<summary>Retrieves the result of function load.</summary> ///<returns>The load result.</returns> - public FunctionLoadResult<T> Value + internal FunctionLoadResult<T> Value { get { @@ -117,7 +117,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T } ///<summary>The outcome of the function load process.</summary> -public enum FunctionLoadResultKind +enum FunctionLoadResultKind { ///<summary>Function was loaded successfully.</summary> Success, @@ -128,16 +128,16 @@ public enum FunctionLoadResultKind } ///<summary>Represents the result of loading a function pointer.</summary> -public class FunctionLoadResult<T> +class FunctionLoadResult<T> { ///<summary>The status of the load.</summary> - public FunctionLoadResultKind Kind; + FunctionLoadResultKind Kind; private T _Delegate; ///<summary>The delegate wrapping the loaded function pointer. /// ///Throws InvalidOperationException if trying to access while not loaded.</summary> - public T Delegate + internal T Delegate { get { @@ -152,14 +152,14 @@ public class FunctionLoadResult<T> ///<summary>Creates a new load result of the given kind.</summary> ///<param name="kind">The outcome of the load process.</param> - public FunctionLoadResult(FunctionLoadResultKind kind) + internal FunctionLoadResult(FunctionLoadResultKind kind) { this.Kind = kind; } ///<summary>Creates a new load result with the given delegate.</summary> ///<param name="Delegate">The delegate wrapping the native function.</param> - public FunctionLoadResult(T Delegate) + internal FunctionLoadResult(T Delegate) { this._Delegate = Delegate; this.Kind = FunctionLoadResultKind.Success; diff --git a/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs b/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs index 09d8d3e0b9..641f954cb1 100644 --- a/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs +++ b/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs @@ -19,7 +19,7 @@ using System.Runtime.InteropServices; namespace Efl.Eo { -public static partial class FunctionInterop +internal static partial class FunctionInterop { [DllImport(efl.Libs.Libdl)] private static extern IntPtr dlsym(IntPtr handle, string symbol); @@ -28,7 +28,7 @@ public static partial class FunctionInterop ///<param name="nativeLibraryHandle">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(IntPtr nativeLibraryHandle, string functionName) + internal static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) { Eina.Log.Debug($"searching {nativeLibraryHandle} for {functionName}"); var s = FunctionInterop.dlsym(nativeLibraryHandle, functionName); diff --git a/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs b/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs index 34d69bd268..1ff7627a2f 100644 --- a/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs +++ b/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs @@ -19,10 +19,10 @@ using System.Runtime.InteropServices; namespace Efl.Eo { -public static partial class FunctionInterop +static partial class FunctionInterop { [DllImport(efl.Libs.Libdl)] - public static extern IntPtr GetProcAddress(IntPtr handle, string symbol); + internal static extern IntPtr GetProcAddress(IntPtr handle, string symbol); private static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) => FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName); diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs index 32715fa854..691a59fb12 100644 --- a/src/bindings/mono/eo_mono/iwrapper.cs +++ b/src/bindings/mono/eo_mono/iwrapper.cs @@ -52,12 +52,12 @@ public static class Globals [return: MarshalAs(UnmanagedType.U1)] public delegate bool efl_object_init_delegate(); - public static readonly FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr = + static readonly FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr = new FunctionWrapper<efl_object_init_delegate>(efl.Libs.EoModule, "efl_object_init"); public static bool efl_object_init() => efl_object_init_ptr.Value.Delegate(); public delegate void efl_object_shutdown_delegate(); - public static readonly FunctionWrapper<efl_object_shutdown_delegate> efl_object_shutdown_ptr = new FunctionWrapper<efl_object_shutdown_delegate>(efl.Libs.EoModule, "efl_object_shutdown"); + static readonly FunctionWrapper<efl_object_shutdown_delegate> efl_object_shutdown_ptr = new FunctionWrapper<efl_object_shutdown_delegate>(efl.Libs.EoModule, "efl_object_shutdown"); public static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate(); // [DllImport(efl.Libs.Eo)] internal static extern void efl_object_shutdown(); --
