Fix up windows build of mono bindings

This commit is contained in:
Ryan Gammon 2023-06-21 06:47:33 -07:00 committed by Christopher Michael
parent 7cb584861f
commit 1517fcd575
6 changed files with 44 additions and 15 deletions

View File

@ -22,7 +22,7 @@
<ItemGroup>
<Compile Include="@BINDING_SRC@/efl_mono/*.cs" />
<!-- FIXME Windows support -->
<Compile Include="@BINDING_SRC@/eo_mono/*.cs" Exclude="@BINDING_SRC@/eo_mono/*Windows.cs" />
<Compile Include="@BINDING_SRC@/eo_mono/*.cs" />
<Compile Include="@BINDING_SRC@/eina_mono/*.cs" />
<Compile Include="@BINDING_SRC@/eolian_mono/*.cs" />
<Compile Include="@BINDING_SRC@/eldbus_mono/*.cs" />

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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