\r
#include <switch.h>\r
#include <switch_cpp.h>\r
-\r
-/* calling conventions for Windows */
-#ifndef MANAGED_STDCALL
-#ifdef WIN32
-# define MANAGED_STDCALL __stdcall
-# else
-# define MANAGED_STDCALL
-# endif
-#endif
-\r
-typedef void (MANAGED_STDCALL *hangupFunction)(void);\r
-typedef char* (MANAGED_STDCALL *inputFunction)(void*, switch_input_type_t);\r
+
+typedef void (*hangupFunction)(void);\r
+typedef char* (*inputFunction)(void*, switch_input_type_t);\r
\r
\r
#ifndef _MANAGED\r
}\r
}\r
\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
delegate bool ExecuteDelegate(string cmd, IntPtr streamH, IntPtr eventH);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
delegate bool ExecuteBackgroundDelegate(string cmd);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
delegate bool RunDelegate(string cmd, IntPtr session);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
delegate bool LoadAssemblyDelegate(string filename);\r
static readonly ExecuteDelegate _execute = Execute;\r
static readonly ExecuteBackgroundDelegate _executeBackground = ExecuteBackground;\r
static readonly RunDelegate _run = Run;\r
static readonly LoadAssemblyDelegate _loadAssembly = LoadAssembly;\r
//SWITCH_MOD_DECLARE(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, loadAssemblyFunction loadAssembly) \r
- [DllImport("mod_managed", CharSet = CharSet.Ansi)]\r
+ [DllImport("mod_managed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\r
static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, LoadAssemblyDelegate loadAssembly);\r
\r
// Be rather lenient in finding the Load and Unload methods\r
{\r
// switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)\r
// But, process_callback_result is used to turn a string into a switch_status_t\r
- //using DtmfCallback = Func<IntPtr, Native.switch_input_type_t, string>;\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
delegate string DtmfCallback(IntPtr input, Native.switch_input_type_t itype);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ delegate void CdeclAction();\r
+\r
public partial class ManagedSession\r
{\r
// SWITCH_DECLARE(void) InitManagedSession(ManagedSession *session, MonoObject *dtmfDelegate, MonoObject *hangupDelegate)\r
- [DllImport("mod_managed.dll", CharSet = CharSet.Ansi)]\r
+ [DllImport("mod_managed.dll", CharSet = CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]\r
static extern void InitManagedSession(IntPtr sessionPtr, DtmfCallback dtmfDelegate, Action hangupDelegate);\r
\r
/// <summary>Initializes the native ManagedSession. Must be called after Originate.</summary>\r
mod_managed_globals globals = { 0 };\r
\r
// Global delegates to call managed functions\r
-typedef int (MANAGED_STDCALL *runFunction)(const char *data, void *sessionPtr);\r
-typedef int (MANAGED_STDCALL *executeFunction)(const char *cmd, void *stream, void *Event);\r
-typedef int (MANAGED_STDCALL *executeBackgroundFunction)(const char* cmd);\r
-typedef int (MANAGED_STDCALL *loadAssemblyFunction)(const char* filename);\r
+typedef int (*runFunction)(const char *data, void *sessionPtr);\r
+typedef int (*executeFunction)(const char *cmd, void *stream, void *Event);\r
+typedef int (*executeBackgroundFunction)(const char* cmd);\r
+typedef int (*loadAssemblyFunction)(const char* filename);\r
static runFunction runDelegate;\r
static executeFunction executeDelegate;\r
static executeBackgroundFunction executeBackgroundDelegate;\r