Mercurial > pidgin.yaz
changeset 11952:565d2e437c04
[gaim-migrate @ 14243]
Another patch attached to sf #1285501, from Eoin Coffey
"the loader will now attempt to catch exceptions, so
hopefully this will resolve some of the issues we were having."
This looked fairly innocuous.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 02 Nov 2005 05:23:00 +0000 |
parents | b6fa01513d76 |
children | 4824e4f0c6f3 |
files | plugins/mono/loader/mono-helper.c plugins/mono/loader/mono-helper.h plugins/mono/loader/mono.c plugins/mono/loader/signal-glue.c |
diffstat | 4 files changed, 38 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mono/loader/mono-helper.c Wed Nov 02 05:14:35 2005 +0000 +++ b/plugins/mono/loader/mono-helper.c Wed Nov 02 05:23:00 2005 +0000 @@ -15,6 +15,31 @@ #include "mono-helper.h" #include "mono-glue.h" #include "value.h" +#include "debug.h" + +MonoObject* mono_loader_delegate_invoke(MonoObject *method, void **params) +{ + MonoObject *ret, *exception; + + ret = mono_runtime_delegate_invoke(method, params, &exception); + if (exception) { + gaim_debug(GAIM_DEBUG_ERROR, "mono", "caught exception: %s\n", mono_class_get_name(mono_object_get_class(exception))); + } + + return ret; +} + +MonoObject* mono_loader_invoke(MonoMethod *method, void *obj, void **params) +{ + MonoObject *ret, *exception; + + ret = mono_runtime_invoke(method, obj, params, &exception); + if (exception) { + gaim_debug(GAIM_DEBUG_ERROR, "mono", "caught exception: %s\n", mono_class_get_name(mono_object_get_class(exception))); + } + + return ret; +} MonoClass* mono_loader_find_plugin_class(MonoImage *image) {
--- a/plugins/mono/loader/mono-helper.h Wed Nov 02 05:14:35 2005 +0000 +++ b/plugins/mono/loader/mono-helper.h Wed Nov 02 05:23:00 2005 +0000 @@ -22,6 +22,10 @@ MonoMethod *destroy; } GaimMonoPlugin; +MonoObject* mono_loader_invoke(MonoMethod *method, void *obj, void **params); + +MonoObject* mono_loader_delegate_invoke(MonoObject *method, void **params); + MonoClass* mono_loader_find_plugin_class(MonoImage *image); gchar* mono_loader_get_prop_string(MonoObject *obj, char *field);
--- a/plugins/mono/loader/mono.c Wed Nov 02 05:14:35 2005 +0000 +++ b/plugins/mono/loader/mono.c Wed Nov 02 05:23:00 2005 +0000 @@ -18,9 +18,6 @@ #define MONO_PLUGIN_ID "core-mono" -/* This is where our code executes */ -static MonoDomain *domain = NULL; - /****************************************************************************** * Loader Stuff *****************************************************************************/ @@ -39,7 +36,7 @@ char *file = plugin->path; - assm = mono_domain_assembly_open(domain, file); + assm = mono_domain_assembly_open(mono_loader_get_domain(), file); if (!assm) { return FALSE; @@ -63,7 +60,7 @@ return FALSE; } - mplug->obj = mono_object_new(domain, mplug->klass); + mplug->obj = mono_object_new(mono_loader_get_domain(), mplug->klass); if (!mplug->obj) { gaim_debug(GAIM_DEBUG_ERROR, "mono", "obj not valid\n"); return FALSE; @@ -92,7 +89,7 @@ return FALSE; } - plugin_info = mono_runtime_invoke(info_method, mplug->obj, NULL, NULL); + plugin_info = mono_loader_invoke(info_method, mplug->obj, NULL); /* now that the methods are filled out we can populate the info struct with all the needed info */ @@ -130,7 +127,7 @@ mplug = (GaimMonoPlugin*)plugin->info->extra_info; - mono_runtime_invoke(mplug->load, mplug->obj, NULL, NULL); + mono_loader_invoke(mplug->load, mplug->obj, NULL); return TRUE; } @@ -146,13 +143,11 @@ gaim_signals_disconnect_by_handle((gpointer)mplug->klass); - mono_runtime_invoke(mplug->unload, mplug->obj, NULL, NULL); + mono_loader_invoke(mplug->unload, mplug->obj, NULL); return TRUE; } -/* Destroys a Mono Plugin by calling 'destroy' in the class, - and cleaning up all the malloced memory */ static void destroy_mono_plugin(GaimPlugin *plugin) { GaimMonoPlugin *mplug; @@ -161,7 +156,7 @@ mplug = (GaimMonoPlugin*)plugin->info->extra_info; - mono_runtime_invoke(mplug->destroy, mplug->obj, NULL, NULL); + mono_loader_invoke(mplug->destroy, mplug->obj, NULL); if (plugin->info) { g_free(plugin->info->name); @@ -187,7 +182,7 @@ *****************************************************************************/ static void plugin_destroy(GaimPlugin *plugin) { - mono_jit_cleanup(domain); + mono_jit_cleanup(mono_loader_get_domain()); } static GaimPluginLoaderInfo loader_info = @@ -225,13 +220,9 @@ NULL }; -/* Creates the domain to execute in, and setups our CS Gaim API (note: - in the future the 'mono_add_internal_call' will be spread through out - the source to whatever module is exposing the API; this function will - simply call helper functions to do so) */ static void init_plugin(GaimPlugin *plugin) { - domain = mono_jit_init("gaim"); + MonoDomain *domain = mono_jit_init("gaim"); mono_loader_set_domain(domain);
--- a/plugins/mono/loader/signal-glue.c Wed Nov 02 05:14:35 2005 +0000 +++ b/plugins/mono/loader/signal-glue.c Wed Nov 02 05:23:00 2005 +0000 @@ -45,7 +45,7 @@ meth_args[0] = array; - return mono_runtime_delegate_invoke(sig_data->func, meth_args, NULL); + return mono_loader_delegate_invoke(sig_data->func, meth_args); } static void cb_void__pointer(void *arg1, void *data)