diff options
author | Teravus Ovares | 2008-05-01 16:39:02 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-01 16:39:02 +0000 |
commit | c803e0cca1ef1e81bec4dcd615aea955f3756b19 (patch) | |
tree | 97c1ff9b468e930e8152a8d6e8df523353229d16 /OpenSim/Region/ScriptEngine/Common/Executor.cs | |
parent | * Spring cleaning on Region.Environment. (diff) | |
download | opensim-SC-c803e0cca1ef1e81bec4dcd615aea955f3756b19.zip opensim-SC-c803e0cca1ef1e81bec4dcd615aea955f3756b19.tar.gz opensim-SC-c803e0cca1ef1e81bec4dcd615aea955f3756b19.tar.bz2 opensim-SC-c803e0cca1ef1e81bec4dcd615aea955f3756b19.tar.xz |
* 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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/Executor.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/Executor.cs | 39 |
1 files changed, 39 insertions, 0 deletions
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 | |||
35 | { | 35 | { |
36 | // Cache functions by keeping a reference to them in a dictionary | 36 | // Cache functions by keeping a reference to them in a dictionary |
37 | private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); | 37 | private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); |
38 | private Dictionary<string, scriptEvents> m_stateEvents = new Dictionary<string, scriptEvents>(); | ||
38 | 39 | ||
39 | public Executor(IScript script) : base(script) | 40 | public Executor(IScript script) : base(script) |
40 | { | 41 | { |
42 | initEventFlags(); | ||
43 | } | ||
44 | |||
45 | |||
46 | protected override scriptEvents DoGetStateEventFlags() | ||
47 | { | ||
48 | // Console.WriteLine("Get event flags for " + m_Script.State); | ||
49 | |||
50 | // Check to see if we've already computed the flags for this state | ||
51 | scriptEvents eventFlags = scriptEvents.None; | ||
52 | if (m_stateEvents.ContainsKey(m_Script.State)) | ||
53 | { | ||
54 | m_stateEvents.TryGetValue(m_Script.State, out eventFlags); | ||
55 | return eventFlags; | ||
56 | } | ||
57 | |||
58 | // Fill in the events for this state, cache the results in the map | ||
59 | foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap) | ||
60 | { | ||
61 | string evname = m_Script.State + "_event_" + kvp.Key; | ||
62 | Type type = m_Script.GetType(); | ||
63 | try | ||
64 | { | ||
65 | MethodInfo mi = type.GetMethod(evname); | ||
66 | if (mi != null) | ||
67 | { | ||
68 | // Console.WriteLine("Found handler for " + kvp.Key); | ||
69 | eventFlags |= kvp.Value; | ||
70 | } | ||
71 | } | ||
72 | catch | ||
73 | { | ||
74 | } | ||
75 | } | ||
76 | |||
77 | // Save the flags we just computed and return the result | ||
78 | m_stateEvents.Add(m_Script.State, eventFlags); | ||
79 | return (eventFlags); | ||
41 | } | 80 | } |
42 | 81 | ||
43 | protected override void DoExecuteEvent(string FunctionName, object[] args) | 82 | protected override void DoExecuteEvent(string FunctionName, object[] args) |