Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
avinationmerge
Melanie 2012-03-26 14:22:49 +01:00
commit da9743d1d7
5 changed files with 35 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,10 +130,18 @@ 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)
{
m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
return;
}
Type delegateType;
var typeArgs = mi.GetParameters()
.Select(p => p.ParameterType)
.ToList();
@ -153,13 +161,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);
}
}
@ -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);
}
}
@ -239,9 +249,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);