From 7e0936e4b6ec0596390266a8435dea9c3f19f09c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 14:19:55 +0100 Subject: [PATCH] Add a hust UUID to the script invocations --- .../Framework/Interfaces/IScriptModuleComms.cs | 2 +- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 15 ++++++++------- .../Shared/Api/Implementation/MOD_Api.cs | 11 ++++++++++- .../ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | 5 +++++ 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 2183c1c4a7..34a4bfc1d7 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.Framework.Interfaces Type[] LookupTypeSignature(string fname); Type LookupReturnType(string fname); - object InvokeOperation(UUID scriptId, string fname, params object[] parms); + object InvokeOperation(UUID hostId, UUID scriptId, string fname, params object[] parms); /// /// Send a link_message event to an in-world script diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 7fc875919b..1e755baac2 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); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 1bcbcd3e1e..7c07e15fa3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -122,6 +122,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The name of the function to invoke /// List of parameters /// string result of the invocation + public void modInvokeN(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(string)) + MODError(String.Format("return type mismatch for {0}",fname)); + + modInvoke(fname,parms); + } + public LSL_String modInvokeS(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); @@ -243,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // non-null but don't trust it completely try { - object result = m_comms.InvokeOperation(m_itemID,fname,convertedParms); + object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); if (result != null) return result; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs index d258f76841..aa78aaa6bb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs @@ -41,6 +41,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces public interface IMOD_Api { // Invocation functions + void modInvokeN(string fname, params object[] parms); LSL_String modInvokeS(string fname, params object[] parms); LSL_Integer modInvokeI(string fname, params object[] parms); LSL_Float modInvokeF(string fname, params object[] parms); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs index e7a4b2b524..1c47138922 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs @@ -62,6 +62,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_MOD_Functions = (IMOD_Api)api; } + public void modInvokeN(string fname, params object[] parms) + { + m_MOD_Functions.modInvokeN(fname, parms); + } + public LSL_String modInvokeS(string fname, params object[] parms) { return m_MOD_Functions.modInvokeS(fname, parms);