Browse Source

Declare callback delegates as using Cdecl calling convention, so it's consistent with the rest of the code and also consistent across all platforms.

console
Nico de Poel 5 years ago
parent
commit
d268e8794a
  1. 4
      Assets/Scripts/SysCalls.cs
  2. 8
      engine/projects/uniquake/uniquake.h

4
Assets/Scripts/SysCalls.cs

@ -35,6 +35,7 @@ public class SysCalls: CallbackHandler<SysCalls>
public IntPtr SysFloatTime;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SysPrintCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string message);
[AOT.MonoPInvokeCallback(typeof(SysPrintCallback))]
@ -48,6 +49,7 @@ public class SysCalls: CallbackHandler<SysCalls>
Debug.Log(message);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SysErrorCallback(IntPtr target, [MarshalAs(UnmanagedType.LPStr)] string message);
[AOT.MonoPInvokeCallback(typeof(SysErrorCallback))]
@ -63,6 +65,7 @@ public class SysCalls: CallbackHandler<SysCalls>
Application.Quit(1);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void SysQuitCallback(IntPtr target);
[AOT.MonoPInvokeCallback(typeof(SysQuitCallback))]
@ -77,6 +80,7 @@ public class SysCalls: CallbackHandler<SysCalls>
Application.Quit(0);
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate double SysFloatTimeCallback(IntPtr target);
[AOT.MonoPInvokeCallback(typeof(SysFloatTimeCallback))]

8
engine/projects/uniquake/uniquake.h

@ -13,10 +13,10 @@ typedef struct unity_syscalls_s
{
void *target;
void(__stdcall *SysPrint)(void *target, const char *msg);
void(__stdcall *SysError)(void *target, const char *msg);
void(__stdcall *SysQuit)(void *target);
double(__stdcall *SysFloatTime)(void *target);
void(*SysPrint)(void *target, const char *msg);
void(*SysError)(void *target, const char *msg);
void(*SysQuit)(void *target);
double(*SysFloatTime)(void *target);
} unity_syscalls_t;
extern const unity_syscalls_t *unity_syscalls;
Loading…
Cancel
Save