From 37446b0392ba423894952f81aa0f938d2bd2de22 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 18 Aug 2007 23:24:38 +0000 Subject: Moved in-AppDomain event execution from Script to OpenSim.Region.ScriptEngine.Executor. Script no longer responsible for handling event calls to itself (and we can create reference cache in Executor). --- OpenSim/Region/ScriptEngine/Common/Executor.cs | 48 +++++++++++++++++++++- .../Common/LSL_BuiltIn_Commands_Interface.cs | 1 + 2 files changed, 48 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 2ae6a60..ca6459b 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -1,10 +1,56 @@ using System; using System.Collections.Generic; using System.Text; +using System.Reflection; namespace OpenSim.Region.ScriptEngine.Common { - class Executor + public class Executor: MarshalByRefObject { + /* TODO: + * + * Needs to be common for all AppDomains - share memory too? + * Needs to have an instance in each AppDomain, and some way of referring it. + * Need to know what AppDomain a script is in so we know where to find our instance. + * + */ + + private IScript m_Script; + + public Executor(IScript Script) + { + m_Script = Script; + } + public void ExecuteEvent(string FunctionName, object[] args) + { + // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. + // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! + + //foreach (MemberInfo mi in this.GetType().GetMembers()) + //{ + //if (mi.ToString().ToLower().Contains("default")) + //{ + // Console.WriteLine("Member found: " + mi.ToString()); + //} + //} + + Type type = m_Script.GetType(); + + Console.WriteLine("ScriptEngine Executor.ExecuteEvent: \"" + m_Script.State() + "_event_" + FunctionName + "\""); + + try + { + type.InvokeMember(m_Script.State() + "_event_" + FunctionName, BindingFlags.InvokeMethod, null, m_Script, args); + } + catch (Exception e) + { + // TODO: Send to correct place + Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString()); + } + + + } + + } } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs index beddbc5..f80898b 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands_Interface.cs @@ -34,6 +34,7 @@ namespace OpenSim.Region.ScriptEngine.Common { public interface LSL_BuiltIn_Commands_Interface { + string State(); double llSin(double f); -- cgit v1.1