diff --git a/src/bindings/mono/efl_sharp.csproj.in b/src/bindings/mono/efl_sharp.csproj.in index e03be33950..94e092e16a 100644 --- a/src/bindings/mono/efl_sharp.csproj.in +++ b/src/bindings/mono/efl_sharp.csproj.in @@ -22,7 +22,7 @@ - + diff --git a/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs b/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs index 636f83ebb1..604fbee111 100644 --- a/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs +++ b/src/bindings/mono/eo_mono/FunctionWrapper_Unix.cs @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if !WIN32 + using System; using System.Runtime.InteropServices; @@ -40,3 +42,5 @@ internal static partial class FunctionInterop } } + +#endif \ No newline at end of file diff --git a/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs b/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs index 1ff7627a2f..c0708d7b27 100644 --- a/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs +++ b/src/bindings/mono/eo_mono/FunctionWrapper_Windows.cs @@ -13,19 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#if WIN32 + using System; using System.Runtime.InteropServices; namespace Efl.Eo { -static partial class FunctionInterop +internal static partial class FunctionInterop { - [DllImport(efl.Libs.Libdl)] + [DllImport(efl.Libs.Kernel32, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)] internal static extern IntPtr GetProcAddress(IntPtr handle, string symbol); - private static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) - => FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName); + private static IntPtr dlsym(IntPtr handle, string symbol) => FunctionInterop.GetProcAddress(handle, symbol); + + internal static IntPtr LoadFunctionPointer(IntPtr nativeLibraryHandle, string functionName) => + FunctionInterop.GetProcAddress(nativeLibraryHandle, functionName); } } + +#endif \ No newline at end of file diff --git a/src/bindings/mono/eo_mono/NativeModule_Unix.cs b/src/bindings/mono/eo_mono/NativeModule_Unix.cs index b4dfeb8aea..7059715062 100644 --- a/src/bindings/mono/eo_mono/NativeModule_Unix.cs +++ b/src/bindings/mono/eo_mono/NativeModule_Unix.cs @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if !WIN32 + using System; using System.Runtime.InteropServices; @@ -98,3 +100,5 @@ internal partial class NativeModule } } + +#endif \ No newline at end of file diff --git a/src/bindings/mono/eo_mono/NativeModule_Windows.cs b/src/bindings/mono/eo_mono/NativeModule_Windows.cs index 513eb723e1..88d7d3d363 100644 --- a/src/bindings/mono/eo_mono/NativeModule_Windows.cs +++ b/src/bindings/mono/eo_mono/NativeModule_Windows.cs @@ -13,16 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if WIN32 + using System; using System.Runtime.InteropServices; namespace Efl.Eo { -internal class partial NativeModule +internal partial class NativeModule { - [DllImport(efl.Libs.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] - internal static extern IntPtr LoadLibrary(string libFilename); + [DllImport(efl.Libs.Kernel32, EntryPoint = "LoadLibrary", CharSet = CharSet.Unicode, SetLastError = true)] + private static extern IntPtr _LoadLibrary(string libFilename); + + internal static IntPtr LoadLibrary(string libFilename) + { + if (!libFilename.StartsWith("lib")) + { + libFilename = "lib" + libFilename + "-1"; + } + return NativeModule._LoadLibrary(libFilename); + } + + [DllImport(efl.Libs.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)] + internal static extern void UnloadLibrary(IntPtr handle); } } + +#endif \ No newline at end of file diff --git a/src/bindings/mono/eo_mono/meson.build b/src/bindings/mono/eo_mono/meson.build index 013b1cc97f..719d575486 100644 --- a/src/bindings/mono/eo_mono/meson.build +++ b/src/bindings/mono/eo_mono/meson.build @@ -4,11 +4,9 @@ mono_files += files( 'FunctionWrapper.cs', 'NativeModule.cs', 'EoWrapper.cs', - 'WrapperSupervisor.cs' + 'WrapperSupervisor.cs', + 'FunctionWrapper_Windows.cs', + 'NativeModule_Windows.cs', + 'FunctionWrapper_Unix.cs', + 'NativeModule_Unix.cs' ) - -if host_machine.system() == 'windows' - mono_files += files('FunctionWrapper_Windows.cs', 'NativeModule_Windows.cs') -else - mono_files += files('FunctionWrapper_Unix.cs', 'NativeModule_Unix.cs') -endif