summaryrefslogtreecommitdiff
path: root/src/bindings/mono/eo_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-28 19:04:33 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-28 19:04:59 -0300
commit1db12b5fb4c0160c0d486a0e6d2a8bd748820881 (patch)
tree29e78f7ca341e5f7af356094f7a1999973d35b4d /src/bindings/mono/eo_mono
parent72da16f6794a688424318c1e22a2b00482acc103 (diff)
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
Diffstat (limited to 'src/bindings/mono/eo_mono')
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper.cs26
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs4
-rw-r--r--src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs4
-rw-r--r--src/bindings/mono/eo_mono/iwrapper.cs4
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 a0c8bd8..04f1561 100644
--- a/src/bindings/mono/eo_mono/FunctionWrapper.cs
+++ b/src/bindings/mono/eo_mono/FunctionWrapper.cs
@@ -24,13 +24,13 @@ namespace Efl.Eo
24///This class has a platform-dependent implementation on whether it 24///This class has a platform-dependent implementation on whether it
25///is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix 25///is compiled for Windows (using LoadLibrary/GetProcAddress) or Unix
26///(dlopen/dlsym).</summary> 26///(dlopen/dlsym).</summary>
27public static partial class FunctionInterop 27internal static partial class FunctionInterop
28{ 28{
29 ///<summary>Loads a function pointer from the given module.</summary> 29 ///<summary>Loads a function pointer from the given module.</summary>
30 ///<param name="moduleName">The name of the module containing the function.</param> 30 ///<param name="moduleName">The name of the module containing the function.</param>
31 ///<param name="functionName">The name of the function to search for.</param> 31 ///<param name="functionName">The name of the function to search for.</param>
32 ///<returns>A function pointer that can be used with delegates.</returns> 32 ///<returns>A function pointer that can be used with delegates.</returns>
33 public static IntPtr LoadFunctionPointer(string moduleName, string functionName) 33 internal static IntPtr LoadFunctionPointer(string moduleName, string functionName)
34 { 34 {
35 IntPtr module = NativeModule.LoadLibrary(moduleName); 35 IntPtr module = NativeModule.LoadLibrary(moduleName);
36 Eina.Log.Debug($"searching {module} for {functionName}"); 36 Eina.Log.Debug($"searching {module} for {functionName}");
@@ -42,7 +42,7 @@ public static partial class FunctionInterop
42 ///<summary>Loads a function pointer from the default module.</summary> 42 ///<summary>Loads a function pointer from the default module.</summary>
43 ///<param name="functionName">The name of the function to search for.</param> 43 ///<param name="functionName">The name of the function to search for.</param>
44 ///<returns>A function pointer that can be used with delegates.</returns> 44 ///<returns>A function pointer that can be used with delegates.</returns>
45 public static IntPtr LoadFunctionPointer(string functionName) 45 internal static IntPtr LoadFunctionPointer(string functionName)
46 { 46 {
47 Eina.Log.Debug($"searching {null} for {functionName}"); 47 Eina.Log.Debug($"searching {null} for {functionName}");
48 var s = FunctionInterop.dlsym(IntPtr.Zero, functionName); 48 var s = FunctionInterop.dlsym(IntPtr.Zero, functionName);
@@ -57,7 +57,7 @@ public static partial class FunctionInterop
57/// 57///
58///The parameter T must be a delegate. 58///The parameter T must be a delegate.
59///</summary> 59///</summary>
60public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate? 60class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T: System.Delegate?
61{ 61{
62 private Lazy<FunctionLoadResult<T>> loadResult; 62 private Lazy<FunctionLoadResult<T>> loadResult;
63#pragma warning disable 0414 63#pragma warning disable 0414
@@ -87,7 +87,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
87 ///<summary>Creates a wrapper for the given function of the given module.</summary> 87 ///<summary>Creates a wrapper for the given function of the given module.</summary>
88 ///<param name="moduleName">The name of the module containing the function.</param> 88 ///<param name="moduleName">The name of the module containing the function.</param>
89 ///<param name="functionName">The name of the function to search for.</param> 89 ///<param name="functionName">The name of the function to search for.</param>
90 public FunctionWrapper(string moduleName, string functionName) 90 internal FunctionWrapper(string moduleName, string functionName)
91 : this(new NativeModule(moduleName), functionName) 91 : this(new NativeModule(moduleName), functionName)
92 { 92 {
93 } 93 }
@@ -95,7 +95,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
95 ///<summary>Creates a wrapper for the given function of the given module.</summary> 95 ///<summary>Creates a wrapper for the given function of the given module.</summary>
96 ///<param name="module">The module wrapper containing the function.</param> 96 ///<param name="module">The module wrapper containing the function.</param>
97 ///<param name="functionName">The name of the function to search for.</param> 97 ///<param name="functionName">The name of the function to search for.</param>
98 public FunctionWrapper(NativeModule module, string functionName) 98 internal FunctionWrapper(NativeModule module, string functionName)
99 { 99 {
100 this.module = module; 100 this.module = module;
101 loadResult = new Lazy<FunctionLoadResult<T>> 101 loadResult = new Lazy<FunctionLoadResult<T>>
@@ -107,7 +107,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
107 107
108 ///<summary>Retrieves the result of function load.</summary> 108 ///<summary>Retrieves the result of function load.</summary>
109 ///<returns>The load result.</returns> 109 ///<returns>The load result.</returns>
110 public FunctionLoadResult<T> Value 110 internal FunctionLoadResult<T> Value
111 { 111 {
112 get 112 get
113 { 113 {
@@ -117,7 +117,7 @@ public class FunctionWrapper<T> // NOTE: When supporting C# >=7.3, add a where T
117} 117}
118 118
119///<summary>The outcome of the function load process.</summary> 119///<summary>The outcome of the function load process.</summary>
120public enum FunctionLoadResultKind 120enum FunctionLoadResultKind
121{ 121{
122 ///<summary>Function was loaded successfully.</summary> 122 ///<summary>Function was loaded successfully.</summary>
123 Success, 123 Success,
@@ -128,16 +128,16 @@ public enum FunctionLoadResultKind
128} 128}
129 129
130///<summary>Represents the result of loading a function pointer.</summary> 130///<summary>Represents the result of loading a function pointer.</summary>
131public class FunctionLoadResult<T> 131class FunctionLoadResult<T>
132{ 132{
133 ///<summary>The status of the load.</summary> 133 ///<summary>The status of the load.</summary>
134 public FunctionLoadResultKind Kind; 134 FunctionLoadResultKind Kind;
135 private T _Delegate; 135 private T _Delegate;
136 136
137 ///<summary>The delegate wrapping the loaded function pointer. 137 ///<summary>The delegate wrapping the loaded function pointer.
138 /// 138 ///
139 ///Throws InvalidOperationException if trying to access while not loaded.</summary> 139 ///Throws InvalidOperationException if trying to access while not loaded.</summary>
140 public T Delegate 140 internal T Delegate
141 { 141 {
142 get 142 get
143 { 143 {
@@ -152,14 +152,14 @@ public class FunctionLoadResult<T>
152 152
153 ///<summary>Creates a new load result of the given kind.</summary> 153 ///<summary>Creates a new load result of the given kind.</summary>
154 ///<param name="kind">The outcome of the load process.</param> 154 ///<param name="kind">The outcome of the load process.</param>
155 public FunctionLoadResult(FunctionLoadResultKind kind) 155 internal FunctionLoadResult(FunctionLoadResultKind kind)
156 { 156 {
157 this.Kind = kind; 157 this.Kind = kind;
158 } 158 }
159 159
160 ///<summary>Creates a new load result with the given delegate.</summary> 160 ///<summary>Creates a new load result with the given delegate.</summary>
161 ///<param name="Delegate">The delegate wrapping the native function.</param> 161 ///<param name="Delegate">The delegate wrapping the native function.</param>
162 public FunctionLoadResult(T Delegate) 162 internal FunctionLoadResult(T Delegate)
163 { 163 {
164 this._Delegate = Delegate; 164 this._Delegate = Delegate;
165 this.Kind = FunctionLoadResultKind.Success; 165 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 09d8d3e..641f954 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;
19namespace Efl.Eo 19namespace Efl.Eo
20{ 20{
21 21
22public static partial class FunctionInterop 22internal static partial class FunctionInterop
23{ 23{
24 [DllImport(efl.Libs.Libdl)] 24 [DllImport(efl.Libs.Libdl)]
25 private static extern IntPtr dlsym(IntPtr handle, string symbol); 25 private static extern IntPtr dlsym(IntPtr handle, string symbol);
@@ -28,7 +28,7 @@ public static partial class FunctionInterop
28 ///<param name="nativeLibraryHandle">The module containing the function.</param> 28 ///<param name="nativeLibraryHandle">The module containing the function.</param>
29 ///<param name="functionName">The name of the function to search for.</param> 29 ///<param name="functionName">The name of the function to search for.</param>
30 ///<returns>A function pointer that can be used with delegates.</returns> 30 ///<returns>A function pointer that can be used with delegates.</returns>
31 public static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) 31 internal static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
32 { 32 {
33 Eina.Log.Debug($"searching {nativeLibraryHandle} for {functionName}"); 33 Eina.Log.Debug($"searching {nativeLibraryHandle} for {functionName}");
34 var s = FunctionInterop.dlsym(nativeLibraryHandle, functionName); 34 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 34d69bd..1ff7627 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;
19namespace Efl.Eo 19namespace Efl.Eo
20{ 20{
21 21
22public static partial class FunctionInterop 22static partial class FunctionInterop
23{ 23{
24 [DllImport(efl.Libs.Libdl)] 24 [DllImport(efl.Libs.Libdl)]
25 public static extern IntPtr GetProcAddress(IntPtr handle, string symbol); 25 internal static extern IntPtr GetProcAddress(IntPtr handle, string symbol);
26 26
27 private static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) 27 private static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName)
28 => FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName); 28 => FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName);
diff --git a/src/bindings/mono/eo_mono/iwrapper.cs b/src/bindings/mono/eo_mono/iwrapper.cs
index 32715fa..691a59f 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
52 52
53 [return: MarshalAs(UnmanagedType.U1)] 53 [return: MarshalAs(UnmanagedType.U1)]
54 public delegate bool efl_object_init_delegate(); 54 public delegate bool efl_object_init_delegate();
55 public static readonly FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr = 55 static readonly FunctionWrapper<efl_object_init_delegate> efl_object_init_ptr =
56 new FunctionWrapper<efl_object_init_delegate>(efl.Libs.EoModule, "efl_object_init"); 56 new FunctionWrapper<efl_object_init_delegate>(efl.Libs.EoModule, "efl_object_init");
57 public static bool efl_object_init() => efl_object_init_ptr.Value.Delegate(); 57 public static bool efl_object_init() => efl_object_init_ptr.Value.Delegate();
58 58
59 public delegate void efl_object_shutdown_delegate(); 59 public delegate void efl_object_shutdown_delegate();
60 public static readonly FunctionWrapper<efl_object_shutdown_delegate> efl_object_shutdown_ptr = new FunctionWrapper<efl_object_shutdown_delegate>(efl.Libs.EoModule, "efl_object_shutdown"); 60 static readonly FunctionWrapper<efl_object_shutdown_delegate> efl_object_shutdown_ptr = new FunctionWrapper<efl_object_shutdown_delegate>(efl.Libs.EoModule, "efl_object_shutdown");
61 public static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate(); 61 public static void efl_object_shutdown() => efl_object_shutdown_ptr.Value.Delegate();
62 // [DllImport(efl.Libs.Eo)] internal static extern void efl_object_shutdown(); 62 // [DllImport(efl.Libs.Eo)] internal static extern void efl_object_shutdown();
63 63