From cb44808504e48125d630823880ee8e710afcd9ea Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 25 Mar 2012 19:52:38 +0100 Subject: Simplify the module invocation registration. The types and method name can be pulled fromt he delegate so we don't need to pass them explicitly --- .../Framework/Interfaces/IScriptModuleComms.cs | 3 ++- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index bb4c788..8bfbbf8 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -46,7 +46,8 @@ namespace OpenSim.Region.Framework.Interfaces /// event ScriptCommand OnScriptCommand; - void RegisterScriptInvocation(string name, ScriptInvocation fn, Type[] csig, Type rsig); + void RegisterScriptInvocation(ScriptInvocation fn); + ScriptInvocation[] GetScriptInvocationList(); ScriptInvocation LookupScriptInvocation(string fname); string LookupModInvocation(string fname); diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 0661c65..8e8a0b6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -126,14 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig) + public void RegisterScriptInvocation(ScriptInvocation fcall) { lock (m_scriptInvocation) { - m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig); + ParameterInfo[] parameters = fcall.Method.GetParameters (); + Type[] parmTypes = new Type[parameters.Length]; + for (int i = 0 ; i < parameters.Length ; i++) + parmTypes[i] = parameters[i].ParameterType; + m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); } } + public ScriptInvocation[] GetScriptInvocationList() + { + List ret = new List(); + + lock (m_scriptInvocation) + { + foreach (ScriptInvocationData d in m_scriptInvocation.Values) + ret.Add(d.ScriptInvocationFn); + } + return ret.ToArray(); + } + public string LookupModInvocation(string fname) { lock (m_scriptInvocation) -- cgit v1.1