aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs22
1 files changed, 21 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index e37e42e..e0683a0 100644
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -35,6 +35,8 @@ using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes; 35using OpenSim.Region.Framework.Scenes;
36using Mono.Addins; 36using Mono.Addins;
37using OpenMetaverse; 37using OpenMetaverse;
38using System.Linq;
39using System.Linq.Expressions;
38 40
39namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms 41namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
40{ 42{
@@ -126,8 +128,26 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
126 m_scriptModule.PostScriptEvent(script, "link_message", args); 128 m_scriptModule.PostScriptEvent(script, "link_message", args);
127 } 129 }
128 130
129 public void RegisterScriptInvocation(Delegate fcall) 131 public void RegisterScriptInvocation(object target, MethodInfo mi)
130 { 132 {
133 Type delegateType;
134
135 var typeArgs = mi.GetParameters()
136 .Select(p => p.ParameterType)
137 .ToList();
138
139 if (mi.ReturnType == typeof(void))
140 {
141 delegateType = Expression.GetActionType(typeArgs.ToArray());
142 }
143 else
144 {
145 typeArgs.Add(mi.ReturnType);
146 delegateType = Expression.GetFuncType(typeArgs.ToArray());
147 }
148
149 Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi);
150
131 lock (m_scriptInvocation) 151 lock (m_scriptInvocation)
132 { 152 {
133 ParameterInfo[] parameters = fcall.Method.GetParameters (); 153 ParameterInfo[] parameters = fcall.Method.GetParameters ();