Add a hust UUID to the script invocations

0.7.4.1
Melanie 2012-03-26 14:19:55 +01:00
parent 98a6c78943
commit 7e0936e4b6
5 changed files with 25 additions and 9 deletions

View File

@ -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);
/// <summary>
/// Send a link_message event to an in-world script

View File

@ -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<object> olist = new List<object>();
olist.Add(hostid);
olist.Add(scriptid);
foreach (object o in parms)
olist.Add(o);

View File

@ -122,6 +122,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// <param name="fname">The name of the function to invoke</param>
/// <param name="parms">List of parameters</param>
/// <returns>string result of the invocation</returns>
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;

View File

@ -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);

View File

@ -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);