summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@atoker.com>2006-08-26 19:11:50 +0100
committerAlp Toker <alp@atoker.com>2006-08-26 19:11:50 +0100
commitdf1f7fddb830558696973cbf3bdda26da48b7cdc (patch)
tree8cfea4a0a5d3c13107b026441f2056bb45d64f17
parentbf05aba7b960e7995ed0881459c967fbcaa39dac (diff)
downloadcompiz-cil-df1f7fddb830558696973cbf3bdda26da48b7cdc.tar.gz
compiz-cil-df1f7fddb830558696973cbf3bdda26da48b7cdc.tar.bz2
Start work on managed plugin unloading
-rw-r--r--glue/compiz-mono.c10
-rw-r--r--src/PluginLoader.cs48
2 files changed, 40 insertions, 18 deletions
diff --git a/glue/compiz-mono.c b/glue/compiz-mono.c
index 70e6cb0..f2ae108 100644
--- a/glue/compiz-mono.c
+++ b/glue/compiz-mono.c
@@ -63,6 +63,16 @@ monoloaderLoadPlugin (CompPlugin *p, char *path, char *name)
static void
monoloaderUnloadPlugin (CompPlugin *p)
{
+ fprintf (stderr, "monoloaderUnloadPlugin\n");
+
+ MonoMethodDesc *method_desc = mono_method_desc_new (":Unload(intptr)", FALSE);
+ MonoMethod *method = mono_method_desc_search_in_class (method_desc, data->loader_class);
+
+ gpointer params[1];
+ params[0] = &p;
+
+ MonoObject *mret = mono_runtime_invoke (method, data->loader_instance, params, NULL);
+
(*baseloaderUnloadPlugin) (p);
}
diff --git a/src/PluginLoader.cs b/src/PluginLoader.cs
index 0302370..1d08bb7 100644
--- a/src/PluginLoader.cs
+++ b/src/PluginLoader.cs
@@ -17,7 +17,7 @@ namespace Compiz
public PluginLoader ()
{
- Console.WriteLine ("new managed plugin loader");
+ Console.Error.WriteLine ("new managed plugin loader");
//keep references around, cheap hack for now
loaders.Add (this);
@@ -30,12 +30,6 @@ namespace Compiz
}
*/
- /*
- public unsafe bool Unload (IntPtr plugin)
- {
- }
- */
-
protected Plugin LoadAssembly (string name)
{
//temporary hack
@@ -64,11 +58,11 @@ namespace Compiz
}
List<Delegate> delegates = new List<Delegate> ();
- List<Plugin> plugins = new List<Plugin> ();
+ Dictionary<IntPtr,Plugin> plugins = new Dictionary<IntPtr,Plugin> ();
public unsafe bool Load (IntPtr plugin, string path, string name)
{
- Console.WriteLine ("managed load " + path + " " + name);
+ Console.Error.WriteLine ("managed load " + path + " " + name);
Plugin plug = LoadAssembly (name);
if (plug == null)
@@ -76,6 +70,13 @@ namespace Compiz
CompPlugin* p = (CompPlugin*)plugin;
+ InitPluginProc my_initPlugin;
+ InitPluginProc<IntPtr> my_initDisplay;
+ InitPluginProc<IntPtr> my_initScreen;
+ InitPluginProc<IntPtr> my_initWindow;
+ FiniPluginProc<IntPtr> my_finiWindow;
+ //InitPluginProc<CompWindow> my_initWindow;
+
my_initPlugin = initPlugin;
my_initDisplay = initDisplay;
my_initScreen = plug.InitScreen;
@@ -116,27 +117,38 @@ namespace Compiz
p->vTable->deps = null;
p->vTable->nDeps = 0;
- plugins.Add (plug);
+ plugins[plugin] = plug;
return true;
}
- InitPluginProc my_initPlugin;
- InitPluginProc<IntPtr> my_initDisplay;
- InitPluginProc<IntPtr> my_initScreen;
- InitPluginProc<IntPtr> my_initWindow;
- FiniPluginProc<IntPtr> my_finiWindow;
- //InitPluginProc<CompWindow> my_initWindow;
+ public unsafe void Unload (IntPtr plugin)
+ {
+ Console.Error.WriteLine ("managed unload");
+
+ //this is not a managed plugin, we can't unload it
+ if (!plugins.ContainsKey (plugin))
+ return;
+
+ CompPlugin* p = (CompPlugin*)plugin;
+
+ Marshal.FreeCoTaskMem ((IntPtr)p->vTable);
+
+ plugins[plugin] = null;
+
+ //TODO: complete unloading, including delegates
+ //this is maybe best done in the Plugin base class
+ }
bool initPlugin (IntPtr plugin)
{
- Console.WriteLine ("init");
+ Console.Error.WriteLine ("init");
return true;
}
bool initDisplay (IntPtr plugin, IntPtr display)
{
- Console.WriteLine ("initDisplay");
+ Console.Error.WriteLine ("initDisplay");
return true;
}
}