From 1dcac642dd03cd89ff14760d65a122d66cebc69d Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Tue, 25 Oct 2011 16:58:38 -0500 Subject: [PATCH] FS-2774 --resolve upgrade mono support - MichaelGG --- src/mod/languages/mod_managed/Makefile | 8 ++++---- src/mod/languages/mod_managed/freeswitch.i | 3 +-- .../languages/mod_managed/freeswitch_managed.h | 5 ++--- .../languages/mod_managed/freeswitch_wrap.cxx | 2 -- src/mod/languages/mod_managed/mod_managed.cpp | 18 +++++++----------- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/mod/languages/mod_managed/Makefile b/src/mod/languages/mod_managed/Makefile index 0ac49b44a8..83869ea9e8 100644 --- a/src/mod/languages/mod_managed/Makefile +++ b/src/mod/languages/mod_managed/Makefile @@ -1,6 +1,6 @@ -LOCAL_INSERT_CFLAGS= /usr/bin/pkg-config mono --cflags -LOCAL_INSERT_LDFLAGS= /usr/bin/pkg-config mono --libs -#MOD_CFLAGS=-D_REENTRANT -pthread -I/opt/mono-1.9/lib/pkgconfig/../../include/mono-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lmono +LOCAL_INSERT_CFLAGS= /usr/bin/pkg-config mono-2 --cflags +LOCAL_INSERT_LDFLAGS= /usr/bin/pkg-config mono-2 --libs +#MOD_CFLAGS=-D_REENTRANT -pthread -I/usr/lib/mono -lmono BASE=../../../.. VERBOSE=1 include $(BASE)/build/modmake.rules @@ -40,4 +40,4 @@ freeswitch_wrap.cxx: rm -f *.cs depend_install: - mkdir -p $(DESTDIR)$(modulesdir)/managed + mkdir -p $(DESTDIR)$(modulesdir)/managed \ No newline at end of file diff --git a/src/mod/languages/mod_managed/freeswitch.i b/src/mod/languages/mod_managed/freeswitch.i index 49e0e27977..c3a4416dd5 100644 --- a/src/mod/languages/mod_managed/freeswitch.i +++ b/src/mod/languages/mod_managed/freeswitch.i @@ -10,7 +10,6 @@ /* Callback for returning strings to C# without leaking memory */ #ifndef _MANAGED -#include #include #include #include @@ -216,4 +215,4 @@ char * SWIG_csharp_string_callback(const char * str) { %include switch_scheduler.h %include switch_config.h %include switch_cpp.h -%include freeswitch_managed.h +%include freeswitch_managed.h \ No newline at end of file diff --git a/src/mod/languages/mod_managed/freeswitch_managed.h b/src/mod/languages/mod_managed/freeswitch_managed.h index 1d0b6a72b1..cfe4c034e3 100644 --- a/src/mod/languages/mod_managed/freeswitch_managed.h +++ b/src/mod/languages/mod_managed/freeswitch_managed.h @@ -40,7 +40,6 @@ typedef void (*hangupFunction) (void); typedef char *(*inputFunction) (void *, switch_input_type_t); #ifndef _MANAGED -#include #include #include #include @@ -73,7 +72,7 @@ extern mod_managed_globals globals; #ifdef WIN32 #define RESULT_FREE(x) CoTaskMemFree(x) #else -#define RESULT_FREE(x) g_free(x) +#define RESULT_FREE(x) mono_free(x) #endif SWITCH_END_EXTERN_C @@ -191,4 +190,4 @@ class ManagedSession:public CoreSession { hangupFunction hangupDelegate; }; -#endif +#endif \ No newline at end of file diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index f24001c611..1093a2568f 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -259,7 +259,6 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_freeswitch( /* Callback for returning strings to C# without leaking memory */ #ifndef _MANAGED -#include #include #include #include @@ -36907,4 +36906,3 @@ SWIGEXPORT CoreSession * SWIGSTDCALL CSharp_ManagedSessionUpcast(ManagedSession #ifdef __cplusplus } #endif - diff --git a/src/mod/languages/mod_managed/mod_managed.cpp b/src/mod/languages/mod_managed/mod_managed.cpp index ec2d8663e3..dc1f8aa604 100644 --- a/src/mod/languages/mod_managed/mod_managed.cpp +++ b/src/mod/languages/mod_managed/mod_managed.cpp @@ -190,6 +190,7 @@ switch_status_t loadRuntime() // So linux can find the .so char xmlConfig[300]; switch_snprintf(xmlConfig, 300, "", SWITCH_GLOBAL_dirs.mod_dir, SWITCH_PATH_SEPARATOR); + mono_config_parse(NULL); mono_config_parse_memory(xmlConfig); #endif @@ -208,18 +209,13 @@ switch_status_t loadRuntime() } /* Already loaded? */ - MonoAssemblyName name; - name.name = MOD_MANAGED_ASM_NAME; - name.major = MOD_MANAGED_ASM_V1; - name.minor = MOD_MANAGED_ASM_V2; - name.revision = MOD_MANAGED_ASM_V3; - name.build = MOD_MANAGED_ASM_V4; - name.culture = ""; - name.hash_value = ""; - + MonoAssemblyName *name = mono_assembly_name_new (MOD_MANAGED_ASM_NAME); + //Note also that it can't be allocated on the stack anymore and you'll need to create and destroy it with the following API: + //mono_assembly_name_free (name); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_assembly_loaded.\n"); - if (!(globals.mod_mono_asm = mono_assembly_loaded(&name))) { + if (!(globals.mod_mono_asm = mono_assembly_loaded(name))) { /* Open the assembly */ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Calling mono_domain_assembly_open.\n"); globals.mod_mono_asm = mono_domain_assembly_open(globals.domain, filename); @@ -444,4 +440,4 @@ SWITCH_STANDARD_API(managedreload_api_function) return SWITCH_STATUS_SUCCESS; } -SWITCH_END_EXTERN_C +SWITCH_END_EXTERN_C \ No newline at end of file