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
0.7.4.1
Melanie 2012-03-25 19:52:38 +01:00
parent a07fa0395f
commit cb44808504
2 changed files with 20 additions and 3 deletions

View File

@ -46,7 +46,8 @@ namespace OpenSim.Region.Framework.Interfaces
/// </summary> /// </summary>
event ScriptCommand OnScriptCommand; event ScriptCommand OnScriptCommand;
void RegisterScriptInvocation(string name, ScriptInvocation fn, Type[] csig, Type rsig); void RegisterScriptInvocation(ScriptInvocation fn);
ScriptInvocation[] GetScriptInvocationList();
ScriptInvocation LookupScriptInvocation(string fname); ScriptInvocation LookupScriptInvocation(string fname);
string LookupModInvocation(string fname); string LookupModInvocation(string fname);

View File

@ -126,14 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
m_scriptModule.PostScriptEvent(script, "link_message", args); 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) 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<ScriptInvocation> ret = new List<ScriptInvocation>();
lock (m_scriptInvocation)
{
foreach (ScriptInvocationData d in m_scriptInvocation.Values)
ret.Add(d.ScriptInvocationFn);
}
return ret.ToArray();
}
public string LookupModInvocation(string fname) public string LookupModInvocation(string fname)
{ {
lock (m_scriptInvocation) lock (m_scriptInvocation)