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);
|
void RegisterScriptInvocation(object target, string method);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="target"></param>
|
/// <param name="target">If target is a Type object, will assume method is static.</param>
|
||||||
/// <param name="method"></param>
|
/// <param name="method"></param>
|
||||||
void RegisterScriptInvocation(object target, MethodInfo method);
|
void RegisterScriptInvocation(object target, MethodInfo method);
|
||||||
|
|
||||||
|
@ -67,6 +67,13 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="methods"></param>
|
/// <param name="methods"></param>
|
||||||
void RegisterScriptInvocation(object target, string[] methods);
|
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>
|
/// <summary>
|
||||||
/// Returns an array of all registered script calls
|
/// Returns an array of all registered script calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -181,7 +181,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
||||||
}
|
}
|
||||||
|
|
||||||
Delegate fcall;
|
Delegate fcall;
|
||||||
|
if (!(target is Type))
|
||||||
fcall = Delegate.CreateDelegate(delegateType, target, mi);
|
fcall = Delegate.CreateDelegate(delegateType, target, mi);
|
||||||
|
else
|
||||||
|
fcall = Delegate.CreateDelegate(delegateType, (Type)target, mi.Name);
|
||||||
|
|
||||||
lock (m_scriptInvocation)
|
lock (m_scriptInvocation)
|
||||||
{
|
{
|
||||||
|
@ -197,6 +200,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public Delegate[] GetScriptInvocationList()
|
||||||
{
|
{
|
||||||
List<Delegate> ret = new List<Delegate>();
|
List<Delegate> ret = new List<Delegate>();
|
||||||
|
|
Loading…
Reference in New Issue