From c803e0cca1ef1e81bec4dcd615aea955f3756b19 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 1 May 2008 16:39:02 +0000 Subject: * Deletes my EventReader ScriptRewriter. It isn't required to rewrite the script to publish the events anymore. * Introduces a language(regex) independent event recognizer and publishes the events the script listens. --- OpenSim/Region/ScriptEngine/Common/Executor.cs | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Common/Executor.cs') diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs index 8e0d6f1..56baa66 100644 --- a/OpenSim/Region/ScriptEngine/Common/Executor.cs +++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs @@ -35,9 +35,48 @@ namespace OpenSim.Region.ScriptEngine.Common { // Cache functions by keeping a reference to them in a dictionary private Dictionary Events = new Dictionary(); + private Dictionary m_stateEvents = new Dictionary(); public Executor(IScript script) : base(script) { + initEventFlags(); + } + + + protected override scriptEvents DoGetStateEventFlags() + { + // Console.WriteLine("Get event flags for " + m_Script.State); + + // Check to see if we've already computed the flags for this state + scriptEvents eventFlags = scriptEvents.None; + if (m_stateEvents.ContainsKey(m_Script.State)) + { + m_stateEvents.TryGetValue(m_Script.State, out eventFlags); + return eventFlags; + } + + // Fill in the events for this state, cache the results in the map + foreach (KeyValuePair kvp in m_eventFlagsMap) + { + string evname = m_Script.State + "_event_" + kvp.Key; + Type type = m_Script.GetType(); + try + { + MethodInfo mi = type.GetMethod(evname); + if (mi != null) + { + // Console.WriteLine("Found handler for " + kvp.Key); + eventFlags |= kvp.Value; + } + } + catch + { + } + } + + // Save the flags we just computed and return the result + m_stateEvents.Add(m_Script.State, eventFlags); + return (eventFlags); } protected override void DoExecuteEvent(string FunctionName, object[] args) -- cgit v1.1