Merge branch 'master' into careminster
commit
d739246030
|
@ -74,6 +74,14 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="methods"></param>
|
/// <param name="methods"></param>
|
||||||
void RegisterScriptInvocation(Type target, string[] methods);
|
void RegisterScriptInvocation(Type target, string[] methods);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Automatically register script invocations by checking for methods
|
||||||
|
/// with <see cref="ScriptInvocationAttribute"/>. Should only check
|
||||||
|
/// public methods.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target"></param>
|
||||||
|
void RegisterScriptInvocations(IRegionModuleBase target);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an array of all registered script calls
|
/// Returns an array of all registered script calls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -96,11 +104,43 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <param name="key"></param>
|
/// <param name="key"></param>
|
||||||
void DispatchReply(UUID scriptId, int code, string text, string key);
|
void DispatchReply(UUID scriptId, int code, string text, string key);
|
||||||
|
|
||||||
/// For constants
|
/// <summary>
|
||||||
|
/// Operation to for a region module to register a constant to be used
|
||||||
|
/// by the script engine
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cname">
|
||||||
|
/// The name of the constant. LSL convention is for constant names to
|
||||||
|
/// be uppercase.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="value">
|
||||||
|
/// The value of the constant. Should be of a type that can be
|
||||||
|
/// converted to one of <see cref="OpenSim.Region.ScriptEngine.Shared.LSL_Types"/>
|
||||||
|
/// </param>
|
||||||
void RegisterConstant(string cname, object value);
|
void RegisterConstant(string cname, object value);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Automatically register all constants on a region module by
|
||||||
|
/// checking for fields with <see cref="ScriptConstantAttribute"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target"></param>
|
||||||
|
void RegisterConstants(IRegionModuleBase target);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Operation to check for a registered constant
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cname">Name of constant</param>
|
||||||
|
/// <returns>Value of constant or null if none found.</returns>
|
||||||
object LookupModConstant(string cname);
|
object LookupModConstant(string cname);
|
||||||
|
|
||||||
// For use ONLY by the script API
|
// For use ONLY by the script API
|
||||||
void RaiseEvent(UUID script, string id, string module, string command, string key);
|
void RaiseEvent(UUID script, string id, string module, string command, string key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
|
public class ScriptInvocationAttribute : Attribute
|
||||||
|
{ }
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Field)]
|
||||||
|
public class ScriptConstantAttribute : Attribute
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterScriptInvocations(IRegionModuleBase target)
|
||||||
|
{
|
||||||
|
foreach(MethodInfo method in target.GetType().GetMethods(
|
||||||
|
BindingFlags.Public | BindingFlags.Instance |
|
||||||
|
BindingFlags.Static))
|
||||||
|
{
|
||||||
|
if(method.GetCustomAttributes(
|
||||||
|
typeof(ScriptInvocationAttribute), true).Any())
|
||||||
|
{
|
||||||
|
if(method.IsStatic)
|
||||||
|
RegisterScriptInvocation(target.GetType(), method);
|
||||||
|
else
|
||||||
|
RegisterScriptInvocation(target, method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Delegate[] GetScriptInvocationList()
|
public Delegate[] GetScriptInvocationList()
|
||||||
{
|
{
|
||||||
List<Delegate> ret = new List<Delegate>();
|
List<Delegate> ret = new List<Delegate>();
|
||||||
|
@ -313,6 +330,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterConstants(IRegionModuleBase target)
|
||||||
|
{
|
||||||
|
foreach (FieldInfo field in target.GetType().GetFields(
|
||||||
|
BindingFlags.Public | BindingFlags.Static |
|
||||||
|
BindingFlags.Instance))
|
||||||
|
{
|
||||||
|
if (field.GetCustomAttributes(
|
||||||
|
typeof(ScriptConstantAttribute), true).Any())
|
||||||
|
{
|
||||||
|
RegisterConstant(field.Name, field.GetValue(target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Operation to check for a registered constant
|
/// Operation to check for a registered constant
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue