diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 5dc928a..1944025 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; | |||
39 | using OpenSim.Region.ScriptEngine.Common; | 39 | using OpenSim.Region.ScriptEngine.Common; |
40 | using libsecondlife; | 40 | using libsecondlife; |
41 | 41 | ||
42 | |||
42 | namespace OpenSim.Region.ScriptEngine.DotNetEngine | 43 | namespace OpenSim.Region.ScriptEngine.DotNetEngine |
43 | { | 44 | { |
44 | /// <summary> | 45 | /// <summary> |
@@ -49,7 +50,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
49 | [Serializable] | 50 | [Serializable] |
50 | public class ScriptManager | 51 | public class ScriptManager |
51 | { | 52 | { |
52 | 53 | #region Declares | |
53 | private Thread ScriptLoadUnloadThread; | 54 | private Thread ScriptLoadUnloadThread; |
54 | private int ScriptLoadUnloadThread_IdleSleepms = 100; | 55 | private int ScriptLoadUnloadThread_IdleSleepms = 100; |
55 | private Queue<LoadStruct> LoadQueue = new Queue<LoadStruct>(); | 56 | private Queue<LoadStruct> LoadQueue = new Queue<LoadStruct>(); |
@@ -66,6 +67,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
66 | public LLUUID itemID; | 67 | public LLUUID itemID; |
67 | } | 68 | } |
68 | 69 | ||
70 | // Object<string, Script<string, script>> | ||
71 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | ||
72 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! | ||
73 | internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>(); | ||
74 | public Scene World | ||
75 | { | ||
76 | get | ||
77 | { | ||
78 | return m_scriptEngine.World; | ||
79 | } | ||
80 | } | ||
81 | #endregion | ||
82 | #region Object init/shutdown | ||
69 | private ScriptEngine m_scriptEngine; | 83 | private ScriptEngine m_scriptEngine; |
70 | public ScriptManager(ScriptEngine scriptEngine) | 84 | public ScriptManager(ScriptEngine scriptEngine) |
71 | { | 85 | { |
@@ -96,6 +110,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
96 | { | 110 | { |
97 | } | 111 | } |
98 | } | 112 | } |
113 | #endregion | ||
114 | #region Load / Unload scripts (Thread loop) | ||
99 | private void ScriptLoadUnloadThreadLoop() | 115 | private void ScriptLoadUnloadThreadLoop() |
100 | { | 116 | { |
101 | try | 117 | try |
@@ -129,7 +145,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
129 | } | 145 | } |
130 | 146 | ||
131 | } | 147 | } |
132 | 148 | #endregion | |
149 | #region Helper functions | ||
133 | private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) | 150 | private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) |
134 | { | 151 | { |
135 | 152 | ||
@@ -139,19 +156,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
139 | } | 156 | } |
140 | 157 | ||
141 | 158 | ||
142 | // Object<string, Script<string, script>> | 159 | #endregion |
143 | // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. | 160 | #region Internal functions to keep track of script |
144 | // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! | ||
145 | internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>(); | ||
146 | public Scene World | ||
147 | { | ||
148 | get | ||
149 | { | ||
150 | return m_scriptEngine.World; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | |||
155 | internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID) | 161 | internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID) |
156 | { | 162 | { |
157 | if (Scripts.ContainsKey(localID) == false) | 163 | if (Scripts.ContainsKey(localID) == false) |
@@ -212,6 +218,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
212 | Obj.Remove(itemID); | 218 | Obj.Remove(itemID); |
213 | 219 | ||
214 | } | 220 | } |
221 | #endregion | ||
222 | #region Start/Stop script | ||
215 | /// <summary> | 223 | /// <summary> |
216 | /// Fetches, loads and hooks up a script to an objects events | 224 | /// Fetches, loads and hooks up a script to an objects events |
217 | /// </summary> | 225 | /// </summary> |
@@ -346,9 +354,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
346 | //return TempDotNetMicroThreadingCodeInjector.TestFix(FileName); | 354 | //return TempDotNetMicroThreadingCodeInjector.TestFix(FileName); |
347 | return FileName; | 355 | return FileName; |
348 | } | 356 | } |
349 | 357 | #endregion | |
350 | 358 | #region Perform event execution in script | |
351 | |||
352 | /// <summary> | 359 | /// <summary> |
353 | /// Execute a LL-event-function in Script | 360 | /// Execute a LL-event-function in Script |
354 | /// </summary> | 361 | /// </summary> |
@@ -366,16 +373,24 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
366 | return; | 373 | return; |
367 | 374 | ||
368 | // Must be done in correct AppDomain, so leaving it up to the script itself | 375 | // Must be done in correct AppDomain, so leaving it up to the script itself |
369 | try | 376 | Script.Exec.ExecuteEvent(FunctionName, args); |
370 | { | 377 | |
371 | Script.Exec.ExecuteEvent(FunctionName, args); | 378 | } |
372 | } | 379 | #endregion |
373 | catch (Exception e) | 380 | |
374 | { | 381 | #region Script serialization/deserialization |
375 | Console.WriteLine("Exception executing script funcion: " + e.ToString()); | 382 | public void GetSerializedScript(uint localID, LLUUID itemID) |
376 | } | 383 | { |
384 | // Serialize the script and return it | ||
377 | 385 | ||
386 | // Should not be a problem | ||
378 | } | 387 | } |
388 | public void PutSerializedScript(uint localID, LLUUID itemID) | ||
389 | { | ||
390 | // Deserialize the script and inject it into an AppDomain | ||
379 | 391 | ||
392 | // How to inject into an AppDomain? | ||
393 | } | ||
394 | #endregion | ||
380 | } | 395 | } |
381 | } | 396 | } |