adding support for static method script invocations
parent
b625579780
commit
794c5f5a6d
|
@ -54,9 +54,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
void RegisterScriptInvocation(object target, string method);
|
||||
|
||||
/// <summary>
|
||||
/// Register an instance method as a script call by method info
|
||||
/// Register a static or instance method as a script call by method info
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="target">If target is a Type object, will assume method is static.</param>
|
||||
/// <param name="method"></param>
|
||||
void RegisterScriptInvocation(object target, MethodInfo method);
|
||||
|
||||
|
@ -67,6 +67,13 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <param name="methods"></param>
|
||||
void RegisterScriptInvocation(object target, string[] methods);
|
||||
|
||||
/// <summary>
|
||||
/// Register one or more static methods as script calls by method name
|
||||
/// </summary>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="methods"></param>
|
||||
void RegisterScriptInvocation(Type target, string[] methods);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an array of all registered script calls
|
||||
/// </summary>
|
||||
|
|
|
@ -181,7 +181,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
|||
}
|
||||
|
||||
Delegate fcall;
|
||||
if (!(target is Type))
|
||||
fcall = Delegate.CreateDelegate(delegateType, target, mi);
|
||||
else
|
||||
fcall = Delegate.CreateDelegate(delegateType, (Type)target, mi.Name);
|
||||
|
||||
lock (m_scriptInvocation)
|
||||
{
|
||||
|
@ -196,6 +199,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
|||
m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterScriptInvocation(Type target, string[] methods)
|
||||
{
|
||||
foreach (string method in methods)
|
||||
{
|
||||
MethodInfo mi = GetMethodInfoFromType(target, method, false);
|
||||
if (mi == null)
|
||||
m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}", method);
|
||||
else
|
||||
RegisterScriptInvocation(target, mi);
|
||||
}
|
||||
}
|
||||
|
||||
public Delegate[] GetScriptInvocationList()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue