Discussion:
[sword-devel] cross platform c# binding patch
Daniel Hughes
2014-09-25 10:09:08 UTC
Permalink
This patch fixes two of the issues found by Jon Behrens when trying to
use the c# bingings on windows:

That is 8.1 and 8.2 from his makingSwordForWindows.txt

8.1 is fixed by using Cdecl calling convention on every call
8.2 is fixed by removing the .so extension on the DLLNAME, mono/dot
net is smart enough to find the lib with the correct extension if you
do this.

With this patch no change should be necessary in the c# code to run on windows.

God bless,
Daniel Hughes
Daniel Hughes
2014-09-25 10:09:46 UTC
Permalink
Forgot to attach the patch...
Post by Daniel Hughes
This patch fixes two of the issues found by Jon Behrens when trying to
That is 8.1 and 8.2 from his makingSwordForWindows.txt
8.1 is fixed by using Cdecl calling convention on every call
8.2 is fixed by removing the .so extension on the DLLNAME, mono/dot
net is smart enough to find the lib with the correct extension if you
do this.
With this patch no change should be necessary in the c# code to run on windows.
God bless,
Daniel Hughes
-------------- next part --------------
Index: bindings/csharp/NativeMethods.cs
===================================================================
--- bindings/csharp/NativeMethods.cs (revision 3257)
+++ bindings/csharp/NativeMethods.cs (working copy)
@@ -73,53 +73,51 @@

public static class NativeMethods
{
+ public const string DLLNAME = "libsword";

-
- public const string DLLNAME = "libsword.so";
-
- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWMgr_new();

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWMgr_newWithPath(string path);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWMgr_getModuleByName(IntPtr hSWMgr, string moduleName);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern void org_crosswire_sword_SWModule_setKeyText(IntPtr hSWModule, string key);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWModule_renderText(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWModule_getRawEntry(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWModule_getKeyText(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern void org_crosswire_sword_SWMgr_delete(IntPtr hSWMgr);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWMgr_getModInfoList(IntPtr hSWMgr);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWModule_stripText(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern void org_crosswire_sword_SWModule_setRawEntry(IntPtr hSWModule, string entryBuffer);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern void org_crosswire_sword_SWModule_terminateSearch(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern char org_crosswire_sword_SWModule_popError(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern long org_crosswire_sword_SWModule_getEntrySize(IntPtr hSWModule);

- [DllImport(DLLNAME)]
+ [DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr org_crosswire_sword_SWModule_getEntryAttribute(IntPtr hSWModule, string level1, string level2, string level3, char filteredBool);

[DllImport(DLLNAME, CallingConvention = CallingConvention.Cdecl)]
Loading...