]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
cdecl'd calling conventions
authorMichael Giagnocavo <mgg@giagnocavo.net>
Thu, 23 Oct 2008 04:29:13 +0000 (04:29 +0000)
committerMichael Giagnocavo <mgg@giagnocavo.net>
Thu, 23 Oct 2008 04:29:13 +0000 (04:29 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10125 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_managed/freeswitch_managed.h
src/mod/languages/mod_managed/managed/Loader.cs
src/mod/languages/mod_managed/managed/ManagedSession.cs
src/mod/languages/mod_managed/mod_managed.cpp

index 31d36ef721818c6e45f06af1b03d8f0ffad27ad5..c69b662f92079bb6594b6057d2813d6bd260bb0e 100644 (file)
@@ -37,18 +37,9 @@ SWITCH_BEGIN_EXTERN_C
 \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
index af21f398d3833726ad6ebf659c6e7d0f8b0b9a1c..1670fd4439cfd973e65dfa8fd43fc74e813ae703 100644 (file)
@@ -94,16 +94,20 @@ namespace FreeSWITCH
             }\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
index 57064f9ce47250d3646d6a5659059e836328666c..fadbd6bd3fea177a8caf7c724512ef267a34aa17 100644 (file)
@@ -38,12 +38,15 @@ namespace FreeSWITCH.Native
 {\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
index 7f2d366e532bbe3ab0270ae11b714d4c24e1da15..b2ad33c0169fecf33d69dfe7b71cabd1f79e8d26 100644 (file)
@@ -68,10 +68,10 @@ SWITCH_STANDARD_API(managed_loadassembly); /* Load assembly */
 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