cdecl'd calling conventions
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10125 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
2123b46d6d
commit
97157c42fc
|
@ -37,18 +37,9 @@ SWITCH_BEGIN_EXTERN_C
|
|||
|
||||
#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
|
||||
|
|
|
@ -94,16 +94,20 @@ namespace FreeSWITCH
|
|||
}
|
||||
}
|
||||
|
||||
[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
|
||||
|
|
|
@ -38,12 +38,15 @@ namespace FreeSWITCH.Native
|
|||
{
|
||||
// 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>
|
||||
|
|
|
@ -68,10 +68,10 @@ SWITCH_STANDARD_API(managed_loadassembly); /* Load assembly */
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue