[Freeswitch-svn] [commit] r10125 - in freeswitch/trunk/src/mod/languages/mod_managed: . managed

Freeswitch SVN michaelgg at freeswitch.org
Thu Oct 23 00:29:13 EDT 2008


Author: michaelgg
Date: Thu Oct 23 00:29:13 2008
New Revision: 10125

Modified:
   freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h
   freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs
   freeswitch/trunk/src/mod/languages/mod_managed/managed/ManagedSession.cs
   freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp

Log:
cdecl'd calling conventions

Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h	Thu Oct 23 00:29:13 2008
@@ -37,18 +37,9 @@
 
 #include <switch.h>
 #include <switch_cpp.h>
-
-/* calling conventions for Windows */
-#ifndef MANAGED_STDCALL
-#ifdef WIN32
-#   define MANAGED_STDCALL __stdcall
-# else
-#   define MANAGED_STDCALL
-# endif 
-#endif
-
-typedef void (MANAGED_STDCALL *hangupFunction)(void);
-typedef char* (MANAGED_STDCALL *inputFunction)(void*, switch_input_type_t);
+
+typedef void (*hangupFunction)(void);
+typedef char* (*inputFunction)(void*, switch_input_type_t);
 
 
 #ifndef _MANAGED

Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/Loader.cs	Thu Oct 23 00:29:13 2008
@@ -94,16 +94,20 @@
             }
         }
 
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         delegate bool ExecuteDelegate(string cmd, IntPtr streamH, IntPtr eventH);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         delegate bool ExecuteBackgroundDelegate(string cmd);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         delegate bool RunDelegate(string cmd, IntPtr session);
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         delegate bool LoadAssemblyDelegate(string filename);
         static readonly ExecuteDelegate _execute = Execute;
         static readonly ExecuteBackgroundDelegate _executeBackground = ExecuteBackground;
         static readonly RunDelegate _run = Run;
         static readonly LoadAssemblyDelegate _loadAssembly = LoadAssembly;
         //SWITCH_MOD_DECLARE(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, loadAssemblyFunction loadAssembly)  
-        [DllImport("mod_managed", CharSet = CharSet.Ansi)]
+        [DllImport("mod_managed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
         static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, LoadAssemblyDelegate loadAssembly);
 
         // Be rather lenient in finding the Load and Unload methods

Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/ManagedSession.cs
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/ManagedSession.cs	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/ManagedSession.cs	Thu Oct 23 00:29:13 2008
@@ -38,12 +38,15 @@
 {
     // switch_status_t ManagedSession::run_dtmf_callback(void *input, switch_input_type_t itype)
     // But, process_callback_result is used to turn a string into a switch_status_t
-    //using DtmfCallback = Func<IntPtr, Native.switch_input_type_t, string>;
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
     delegate string DtmfCallback(IntPtr input, Native.switch_input_type_t itype);
+    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+    delegate void CdeclAction();
+
     public partial class ManagedSession
     {
         // SWITCH_DECLARE(void) InitManagedSession(ManagedSession *session, MonoObject *dtmfDelegate, MonoObject *hangupDelegate)
-        [DllImport("mod_managed.dll", CharSet = CharSet.Ansi)]
+        [DllImport("mod_managed.dll", CharSet = CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
         static extern void InitManagedSession(IntPtr sessionPtr, DtmfCallback dtmfDelegate, Action hangupDelegate);
 
         /// <summary>Initializes the native ManagedSession. Must be called after Originate.</summary>

Modified: freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/mod_managed.cpp	Thu Oct 23 00:29:13 2008
@@ -68,10 +68,10 @@
 mod_managed_globals globals = { 0 };
 
 // Global delegates to call managed functions
-typedef int (MANAGED_STDCALL *runFunction)(const char *data, void *sessionPtr);
-typedef int (MANAGED_STDCALL *executeFunction)(const char *cmd, void *stream, void *Event);
-typedef int (MANAGED_STDCALL *executeBackgroundFunction)(const char* cmd);
-typedef int (MANAGED_STDCALL *loadAssemblyFunction)(const char* filename);
+typedef int (*runFunction)(const char *data, void *sessionPtr);
+typedef int (*executeFunction)(const char *cmd, void *stream, void *Event);
+typedef int (*executeBackgroundFunction)(const char* cmd);
+typedef int (*loadAssemblyFunction)(const char* filename);
 static runFunction runDelegate;
 static executeFunction executeDelegate;
 static executeBackgroundFunction executeBackgroundDelegate;



More information about the Freeswitch-svn mailing list