From 402ff75d781d6f4e38eee8884d7b4411bb756c9b Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Thu, 15 Mar 2012 13:16:02 -0700 Subject: Adds a new script command 'modInvoke' to invoke registered functions from region modules. The LSL translator is extended to generate the modInvoke format of commands for directly inlined function calls. A region module can register a function Test() with the name "Test". LSL code can call that function as "Test()". The compiler will translate that invocation into modInvoke("Test", ...) --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 99 +++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 44c9ada..a90362e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -27,6 +27,7 @@ using System; using System.Reflection; +using System.Collections.Generic; using Nini.Config; using log4net; using OpenSim.Framework; @@ -35,7 +36,7 @@ using OpenSim.Region.Framework.Scenes; using Mono.Addins; using OpenMetaverse; -namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms +namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms @@ -43,10 +44,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private IScriptModule m_scriptModule = null; +#region ScriptInvocation + protected class ScriptInvocationData + { + public ScriptInvocation ScriptInvocationFn { get; private set; } + public string FunctionName { get; private set; } + public Type[] TypeSignature { get; private set; } + public Type ReturnType { get; private set; } + + public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig) + { + FunctionName = fname; + ScriptInvocationFn = fn; + TypeSignature = callsig; + ReturnType = returnsig; + } + } + private Dictionary m_scriptInvocation = new Dictionary(); +#endregion + + private IScriptModule m_scriptModule = null; public event ScriptCommand OnScriptCommand; +#region RegionModuleInterface public void Initialise(IConfigSource config) { } @@ -81,6 +102,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms public void Close() { } +#endregion + +#region ScriptModuleComms public void RaiseEvent(UUID script, string id, string module, string command, string k) { @@ -101,5 +125,76 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } + + public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig) + { + lock (m_scriptInvocation) + { + m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig); + } + } + + public string LookupModInvocation(string fname) + { + lock (m_scriptInvocation) + { + ScriptInvocationData sid; + if (m_scriptInvocation.TryGetValue(fname,out sid)) + { + if (sid.ReturnType == typeof(string)) + return "modInvokeS"; + else if (sid.ReturnType == typeof(int)) + return "modInvokeI"; + else if (sid.ReturnType == typeof(float)) + return "modInvokeF"; + } + } + + return null; + } + + public ScriptInvocation LookupScriptInvocation(string fname) + { + lock (m_scriptInvocation) + { + ScriptInvocationData sid; + if (m_scriptInvocation.TryGetValue(fname,out sid)) + return sid.ScriptInvocationFn; + } + + return null; + } + + public Type[] LookupTypeSignature(string fname) + { + lock (m_scriptInvocation) + { + ScriptInvocationData sid; + if (m_scriptInvocation.TryGetValue(fname,out sid)) + return sid.TypeSignature; + } + + return null; + } + + public Type LookupReturnType(string fname) + { + lock (m_scriptInvocation) + { + ScriptInvocationData sid; + if (m_scriptInvocation.TryGetValue(fname,out sid)) + return sid.ReturnType; + } + + return null; + } + + public object InvokeOperation(UUID scriptid, string fname, params object[] parms) + { + ScriptInvocation fn = LookupScriptInvocation(fname); + return fn(scriptid,parms); + } +#endregion + } } -- cgit v1.1 From c903813e00e894475aff75c1b7eec3f8d4b3986c Mon Sep 17 00:00:00 2001 From: BlueWall Date: Thu, 22 Mar 2012 20:49:45 -0400 Subject: RegionReady logging Some maintenance to clean up logging messages --- .../Scripting/RegionReadyModule/RegionReadyModule.cs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index d0142a4..0b9f875 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs @@ -70,8 +70,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady public void Initialise(IConfigSource config) { - //m_log.Info("[RegionReady] Initialising"); - m_config = config.Configs["RegionReady"]; if (m_config != null) { @@ -84,9 +82,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady m_uri = m_config.GetString("alert_uri",string.Empty); } } - -// if (!m_enabled) -// m_log.Info("[RegionReady] disabled."); } public void AddRegion(Scene scene) @@ -113,7 +108,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { scene.LoginLock = true; scene.LoginsDisabled = true; - m_log.InfoFormat("[RegionReady]: Logins disabled for {0}",m_scene.RegionInfo.RegionName); + m_log.InfoFormat("[RegionReady]: Region {0} - logins disabled during initialization.",m_scene.RegionInfo.RegionName); if(m_uri != string.Empty) { @@ -167,7 +162,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady void OnEmptyScriptCompileQueue(int numScriptsFailed, string message) { - m_log.InfoFormat("[RegionReady]: Script compile queue empty!"); + m_log.DebugFormat("[RegionReady]: Script compile queue empty!"); if (m_firstEmptyCompileQueue || m_oarFileLoading) { @@ -194,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady c.SenderUUID = UUID.Zero; c.Scene = m_scene; - m_log.InfoFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}", + m_log.DebugFormat("[RegionReady]: Region \"{0}\" is ready: \"{1}\" on channel {2}", m_scene.RegionInfo.RegionName, c.Message, m_channelNotify); m_scene.EventManager.TriggerOnChatBroadcast(this, c); @@ -210,7 +205,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady { m_lastOarLoadedOk = true; } else { - m_log.InfoFormat("[RegionReady]: Oar file load errors: {0}", message); + m_log.WarnFormat("[RegionReady]: Oar file load errors: {0}", message); m_lastOarLoadedOk = false; } } @@ -233,7 +228,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady // m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}", // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); - m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName); + m_log.InfoFormat("[RegionReady]: Initialization complete - logins enabled for {0}", m_scene.RegionInfo.RegionName); if ( m_uri != string.Empty ) { -- cgit v1.1 From a14437ad5abf4d4dc95897216224548515a599e7 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sat, 24 Mar 2012 22:43:42 -0700 Subject: Add support for key, vector, rotation and list types for both arguments and return values to the modInvoke family of functions. See http://opensimulator.org/wiki/OSSL_Script_Library/ModInvoke --- .../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index a90362e..0661c65 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -147,6 +147,14 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return "modInvokeI"; else if (sid.ReturnType == typeof(float)) return "modInvokeF"; + else if (sid.ReturnType == typeof(UUID)) + return "modInvokeK"; + else if (sid.ReturnType == typeof(OpenMetaverse.Vector3)) + return "modInvokeV"; + else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion)) + return "modInvokeR"; + else if (sid.ReturnType == typeof(object[])) + return "modInvokeL"; } } -- cgit v1.1 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 --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') 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 From d7cc194e83ade3453649ab897a4f40b0fa856d0d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 00:30:52 +0100 Subject: Correct the design error I introduced into ScriptComms. Untested but about to be. --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 8e8a0b6..e37e42e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -47,15 +47,15 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms #region ScriptInvocation protected class ScriptInvocationData { - public ScriptInvocation ScriptInvocationFn { get; private set; } + public Delegate ScriptInvocationDelegate { get; private set; } public string FunctionName { get; private set; } public Type[] TypeSignature { get; private set; } public Type ReturnType { get; private set; } - public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig) + public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig) { FunctionName = fname; - ScriptInvocationFn = fn; + ScriptInvocationDelegate = fn; TypeSignature = callsig; ReturnType = returnsig; } @@ -126,26 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(ScriptInvocation fcall) + public void RegisterScriptInvocation(Delegate fcall) { lock (m_scriptInvocation) { ParameterInfo[] parameters = fcall.Method.GetParameters (); - Type[] parmTypes = new Type[parameters.Length]; - for (int i = 0 ; i < parameters.Length ; i++) - parmTypes[i] = parameters[i].ParameterType; + if (parameters.Length == 0) // Must have one UUID param + return; + + // Hide the first parameter + Type[] parmTypes = new Type[parameters.Length - 1]; + for (int i = 1 ; i < parameters.Length ; i++) + parmTypes[i - 1] = parameters[i].ParameterType; m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); } } - public ScriptInvocation[] GetScriptInvocationList() + public Delegate[] GetScriptInvocationList() { - List ret = new List(); + List ret = new List(); lock (m_scriptInvocation) { foreach (ScriptInvocationData d in m_scriptInvocation.Values) - ret.Add(d.ScriptInvocationFn); + ret.Add(d.ScriptInvocationDelegate); } return ret.ToArray(); } @@ -177,13 +181,13 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return null; } - public ScriptInvocation LookupScriptInvocation(string fname) + public Delegate LookupScriptInvocation(string fname) { lock (m_scriptInvocation) { ScriptInvocationData sid; if (m_scriptInvocation.TryGetValue(fname,out sid)) - return sid.ScriptInvocationFn; + return sid.ScriptInvocationDelegate; } return null; @@ -215,8 +219,12 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public object InvokeOperation(UUID scriptid, string fname, params object[] parms) { - ScriptInvocation fn = LookupScriptInvocation(fname); - return fn(scriptid,parms); + List olist = new List(); + olist.Add(scriptid); + foreach (object o in parms) + olist.Add(o); + Delegate fn = LookupScriptInvocation(fname); + return fn.DynamicInvoke(olist.ToArray()); } #endregion -- cgit v1.1 From ac0f1ff0a66e361e7ca24ce4660bf58c5662283c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 01:21:44 +0100 Subject: Dynamically create the delegate type to reduce complexity in the caller --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index e37e42e..e0683a0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -35,6 +35,8 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Mono.Addins; using OpenMetaverse; +using System.Linq; +using System.Linq.Expressions; namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms { @@ -126,8 +128,26 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(Delegate fcall) + public void RegisterScriptInvocation(object target, MethodInfo mi) { + Type delegateType; + + var typeArgs = mi.GetParameters() + .Select(p => p.ParameterType) + .ToList(); + + if (mi.ReturnType == typeof(void)) + { + delegateType = Expression.GetActionType(typeArgs.ToArray()); + } + else + { + typeArgs.Add(mi.ReturnType); + delegateType = Expression.GetFuncType(typeArgs.ToArray()); + } + + Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi); + lock (m_scriptInvocation) { ParameterInfo[] parameters = fcall.Method.GetParameters (); -- cgit v1.1 From c9c01d52265dde85aa8b8813fb00af8375240ebd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 03:20:40 +0100 Subject: Further simplify ScriptComms --- .../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index e0683a0..7fc8759 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -128,8 +128,10 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(object target, MethodInfo mi) + public void RegisterScriptInvocation(object target, string meth) { + MethodInfo mi = target.GetType()..GetMethod(meth, + BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Type delegateType; var typeArgs = mi.GetParameters() -- cgit v1.1 From 055269805d88c5f3d347d3ba7d03db2182a78277 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sun, 25 Mar 2012 22:59:06 -0700 Subject: Fix compile error in ScriptModuelComms and add some debugging into the modInvoke routines to simplify finding method registration issues. --- .../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 7fc8759..c2ec5b4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -130,10 +130,18 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public void RegisterScriptInvocation(object target, string meth) { - MethodInfo mi = target.GetType()..GetMethod(meth, + m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}",meth,target.GetType().Name); + + + MethodInfo mi = target.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (mi == null) + { + m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth); + return; + } + Type delegateType; - var typeArgs = mi.GetParameters() .Select(p => p.ParameterType) .ToList(); @@ -197,6 +205,8 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return "modInvokeR"; else if (sid.ReturnType == typeof(object[])) return "modInvokeL"; + + m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); } } -- cgit v1.1 From 7e0936e4b6ec0596390266a8435dea9c3f19f09c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 14:19:55 +0100 Subject: Add a hust UUID to the script invocations --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 7fc8759..1e755ba 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public void RegisterScriptInvocation(object target, string meth) { - MethodInfo mi = target.GetType()..GetMethod(meth, + MethodInfo mi = target.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Type delegateType; @@ -153,13 +153,13 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms lock (m_scriptInvocation) { ParameterInfo[] parameters = fcall.Method.GetParameters (); - if (parameters.Length == 0) // Must have one UUID param + if (parameters.Length < 2) // Must have two UUID params return; - // Hide the first parameter - Type[] parmTypes = new Type[parameters.Length - 1]; - for (int i = 1 ; i < parameters.Length ; i++) - parmTypes[i - 1] = parameters[i].ParameterType; + // Hide the first two parameters + Type[] parmTypes = new Type[parameters.Length - 2]; + for (int i = 2 ; i < parameters.Length ; i++) + parmTypes[i - 2] = parameters[i].ParameterType; m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); } } @@ -239,9 +239,10 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return null; } - public object InvokeOperation(UUID scriptid, string fname, params object[] parms) + public object InvokeOperation(UUID hostid, UUID scriptid, string fname, params object[] parms) { List olist = new List(); + olist.Add(hostid); olist.Add(scriptid); foreach (object o in parms) olist.Add(o); -- cgit v1.1 From ad865ab4fc6703610d15336fa22fa2a62f628979 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 16:46:07 +0100 Subject: Add some more overloads to allow registering overloaded methods and lists of methods. --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/Scripting') diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 0605590..cab30de 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -130,9 +130,6 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public void RegisterScriptInvocation(object target, string meth) { - m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}",meth,target.GetType().Name); - - MethodInfo mi = target.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (mi == null) @@ -140,7 +137,20 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth); return; } - + + RegisterScriptInvocation(target, mi); + } + + public void RegisterScriptInvocation(object target, string[] meth) + { + foreach (string m in meth) + RegisterScriptInvocation(target, m); + } + + public void RegisterScriptInvocation(object target, MethodInfo mi) + { + m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name); + Type delegateType; var typeArgs = mi.GetParameters() .Select(p => p.ParameterType) -- cgit v1.1