diff options
Diffstat (limited to '')
3 files changed, 93 insertions, 29 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index bbb9f06..bac8bde 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | |||
@@ -13,15 +13,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
13 | 13 | ||
14 | public LSL2CSConverter() | 14 | public LSL2CSConverter() |
15 | { | 15 | { |
16 | |||
16 | DataTypes.Add("void", "void"); | 17 | DataTypes.Add("void", "void"); |
17 | DataTypes.Add("integer", "int"); | 18 | DataTypes.Add("integer", "System.Int32"); |
18 | DataTypes.Add("float", "double"); | 19 | DataTypes.Add("float", "System.Double"); |
19 | DataTypes.Add("string", "string"); | 20 | DataTypes.Add("string", "string"); |
20 | DataTypes.Add("key", "string"); | 21 | DataTypes.Add("key", "System.String"); |
21 | DataTypes.Add("vector", "LSL_Types.Vector3"); | 22 | DataTypes.Add("vector", "LSL_Types.Vector3"); |
22 | DataTypes.Add("rotation", "LSL_Types.Quaternion"); | 23 | DataTypes.Add("rotation", "LSL_Types.Quaternion"); |
23 | DataTypes.Add("list", "list"); | 24 | DataTypes.Add("list", "list"); |
24 | DataTypes.Add("null", "null"); | 25 | DataTypes.Add("null", "null"); |
26 | |||
25 | } | 27 | } |
26 | 28 | ||
27 | 29 | ||
@@ -227,11 +229,29 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
227 | 229 | ||
228 | 230 | ||
229 | // Add namespace, class name and inheritance | 231 | // Add namespace, class name and inheritance |
232 | |||
230 | Return = "" + | 233 | Return = "" + |
231 | "using System; " + | 234 | "using System; " + |
232 | "using System.Collections.Generic; " + | 235 | "using System.Collections.Generic; " + |
233 | "using System.Text; " + | 236 | "using System.Text; " + |
234 | "using OpenSim.Region.ScriptEngine.Common; " + | 237 | "using OpenSim.Region.ScriptEngine.Common; " + |
238 | "using integer = System.Int32; " + | ||
239 | "using key = System.String; "; | ||
240 | |||
241 | //// Make a Using out of DataTypes | ||
242 | //// Using integer = System.Int32; | ||
243 | //string _val; | ||
244 | //foreach (string key in DataTypes.Keys) | ||
245 | //{ | ||
246 | // DataTypes.TryGetValue(key, out _val); | ||
247 | // if (key != _val) | ||
248 | // { | ||
249 | // Return += "using " + key + " = " + _val + "; "; | ||
250 | // } | ||
251 | //} | ||
252 | |||
253 | |||
254 | Return += "" + | ||
235 | "namespace SecondLife { "; | 255 | "namespace SecondLife { "; |
236 | Return += "" + | 256 | Return += "" + |
237 | //"[Serializable] " + | 257 | //"[Serializable] " + |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs index 7018dfe..c724f01 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs | |||
@@ -177,6 +177,35 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
177 | { | 177 | { |
178 | myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param); | 178 | myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param); |
179 | } | 179 | } |
180 | catch (Exception e) | ||
181 | { | ||
182 | // DISPLAY ERROR INWORLD | ||
183 | string text = "Error executing script:\r\n"; | ||
184 | if (e.InnerException != null) | ||
185 | { // Send inner exception | ||
186 | text += e.InnerException.Message.ToString(); | ||
187 | } | ||
188 | else | ||
189 | { // Send normal | ||
190 | text += e.Message.ToString(); | ||
191 | } | ||
192 | try | ||
193 | { | ||
194 | if (text.Length > 1500) | ||
195 | text = text.Substring(0, 1500); | ||
196 | IScriptHost m_host = myScriptEngine.World.GetSceneObjectPart(QIS.localID); | ||
197 | //if (m_host != null) | ||
198 | //{ | ||
199 | myScriptEngine.World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID); | ||
200 | } catch { | ||
201 | //} | ||
202 | //else | ||
203 | //{ | ||
204 | // T oconsole | ||
205 | Console.WriteLine("Unable to send text in-world:\r\n" + text); | ||
206 | } | ||
207 | |||
208 | } | ||
180 | finally | 209 | finally |
181 | { | 210 | { |
182 | ReleaseLock(QIS.localID); | 211 | ReleaseLock(QIS.localID); |
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 | } |