aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-23 02:28:27 +0000
committerJustin Clark-Casey (justincc)2013-01-23 02:36:43 +0000
commitcf168194e5968c1fab33266bdbb57465f303860b (patch)
tree7fbf7f668bd48a9831df7eefdf47c09baa47a522 /OpenSim/Region/ScriptEngine/Shared
parentAdd co-op termination regression test for infinite recursive manual call on e... (diff)
downloadopensim-SC-cf168194e5968c1fab33266bdbb57465f303860b.zip
opensim-SC-cf168194e5968c1fab33266bdbb57465f303860b.tar.gz
opensim-SC-cf168194e5968c1fab33266bdbb57465f303860b.tar.bz2
opensim-SC-cf168194e5968c1fab33266bdbb57465f303860b.tar.xz
If ScriptStopStrategy hasn't been set to co-op in [XEngine] config, then continue to generate C# that is functionality identical to historical generation
This is to eliminate disruption until co-op termination has been well-tested. In non co-op mode, XEngine will continue to load DLLs of the existing Script class and the new XEngineScript class. Moving to co-op mode still requires existing script DLL deletion to force recompilation, either manually or by setting DeleteScriptsOnStartup = true for one run. This change also means that scripts which fail to initialize do not still show up as running scripts.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs30
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs48
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs2
3 files changed, 59 insertions, 21 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 7432202..002e852 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -416,16 +416,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
416 case enumCompileType.cs: 416 case enumCompileType.cs:
417 case enumCompileType.lsl: 417 case enumCompileType.lsl:
418 compileScript = CreateCSCompilerScript( 418 compileScript = CreateCSCompilerScript(
419 compileScript, m_scriptEngine.ScriptBaseClassName, m_scriptEngine.ScriptBaseClassParameters); 419 compileScript,
420 m_scriptEngine.ScriptClassName,
421 m_scriptEngine.ScriptBaseClassName,
422 m_scriptEngine.ScriptBaseClassParameters);
420 break; 423 break;
421 case enumCompileType.vb: 424 case enumCompileType.vb:
422 compileScript = CreateVBCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName); 425 compileScript = CreateVBCompilerScript(
426 compileScript, m_scriptEngine.ScriptClassName, m_scriptEngine.ScriptBaseClassName);
423 break; 427 break;
424// case enumCompileType.js: 428// case enumCompileType.js:
425// compileScript = CreateJSCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName); 429// compileScript = CreateJSCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName);
426// break; 430// break;
427 case enumCompileType.yp: 431 case enumCompileType.yp:
428 compileScript = CreateYPCompilerScript(compileScript, m_scriptEngine.ScriptBaseClassName); 432 compileScript = CreateYPCompilerScript(
433 compileScript, m_scriptEngine.ScriptClassName,m_scriptEngine.ScriptBaseClassName);
429 break; 434 break;
430 } 435 }
431 436
@@ -457,7 +462,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
457// } 462// }
458 463
459 private static string CreateCSCompilerScript( 464 private static string CreateCSCompilerScript(
460 string compileScript, string baseClassName, ParameterInfo[] constructorParameters) 465 string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters)
461 { 466 {
462 compileScript = string.Format( 467 compileScript = string.Format(
463@"using OpenSim.Region.ScriptEngine.Shared; 468@"using OpenSim.Region.ScriptEngine.Shared;
@@ -465,12 +470,13 @@ using System.Collections.Generic;
465 470
466namespace SecondLife 471namespace SecondLife
467{{ 472{{
468 public class Script : {0} 473 public class {0} : {1}
469 {{ 474 {{
470 public Script({1}) : base({2}) {{}} 475 public {0}({2}) : base({3}) {{}}
471{3} 476{4}
472 }} 477 }}
473}}", 478}}",
479 className,
474 baseClassName, 480 baseClassName,
475 constructorParameters != null 481 constructorParameters != null
476 ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString())) 482 ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString()))
@@ -483,28 +489,28 @@ namespace SecondLife
483 return compileScript; 489 return compileScript;
484 } 490 }
485 491
486 private static string CreateYPCompilerScript(string compileScript, string baseClassName) 492 private static string CreateYPCompilerScript(string compileScript, string className, string baseClassName)
487 { 493 {
488 compileScript = String.Empty + 494 compileScript = String.Empty +
489 "using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " + 495 "using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
490 "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" + 496 "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
491 String.Empty + "namespace SecondLife { " + 497 String.Empty + "namespace SecondLife { " +
492 String.Empty + "public class Script : " + baseClassName + " { \r\n" + 498 String.Empty + "public class " + className + " : " + baseClassName + " { \r\n" +
493 //@"public Script() { } " + 499 //@"public Script() { } " +
494 @"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " + 500 @"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
495 @"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " + 501 @"public " + className + "() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
496 compileScript + 502 compileScript +
497 "} }\r\n"; 503 "} }\r\n";
498 504
499 return compileScript; 505 return compileScript;
500 } 506 }
501 507
502 private static string CreateVBCompilerScript(string compileScript, string baseClassName) 508 private static string CreateVBCompilerScript(string compileScript, string className, string baseClassName)
503 { 509 {
504 compileScript = String.Empty + 510 compileScript = String.Empty +
505 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + 511 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
506 String.Empty + "NameSpace SecondLife:" + 512 String.Empty + "NameSpace SecondLife:" +
507 String.Empty + "Public Class Script: Inherits " + baseClassName + 513 String.Empty + "Public Class " + className + ": Inherits " + baseClassName +
508 "\r\nPublic Sub New()\r\nEnd Sub: " + 514 "\r\nPublic Sub New()\r\nEnd Sub: " +
509 compileScript + 515 compileScript +
510 ":End Class :End Namespace\r\n"; 516 ":End Class :End Namespace\r\n";
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index e6ec0e1..4cfcb75 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -251,7 +251,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
251 /// <param name='dom'></param> 251 /// <param name='dom'></param>
252 /// <param name='assembly'></param> 252 /// <param name='assembly'></param>
253 /// <param name='stateSource'></param> 253 /// <param name='stateSource'></param>
254 public void Load(AppDomain dom, string assembly, StateSource stateSource) 254 /// <returns>false if load failed, true if suceeded</returns>
255 public bool Load(AppDomain dom, string assembly, StateSource stateSource)
255 { 256 {
256 m_Assembly = assembly; 257 m_Assembly = assembly;
257 m_stateSource = stateSource; 258 m_stateSource = stateSource;
@@ -266,26 +267,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
266 267
267 try 268 try
268 { 269 {
270 object[] constructorParams;
271
272 Assembly scriptAssembly = dom.Load(Path.GetFileNameWithoutExtension(assembly));
273 Type scriptType = scriptAssembly.GetType("SecondLife.XEngineScript");
274
275 if (scriptType != null)
276 {
277 constructorParams = new object[] { m_coopSleepHandle };
278 }
279 else if (!m_coopTermination)
280 {
281 scriptType = scriptAssembly.GetType("SecondLife.Script");
282 constructorParams = null;
283 }
284 else
285 {
286 m_log.ErrorFormat(
287 "[SCRIPT INSTANCE]: You must remove all existing script DLLs before using enabling co-op termination"
288 + ", either by setting DeleteScriptsOnStartup = true in [XEngine] for one run"
289 + " or by deleting all *.dll* files in the relevant bin/ScriptEngines/<region-id>/ directory");
290
291 return false;
292 }
293
294// m_log.DebugFormat(
295// "[SCRIPT INSTANCE]: Looking to load {0} from assembly {1} in {2}",
296// scriptType.FullName, Path.GetFileNameWithoutExtension(assembly), Engine.World.Name);
297
269 if (dom != System.AppDomain.CurrentDomain) 298 if (dom != System.AppDomain.CurrentDomain)
270 m_Script 299 m_Script
271 = (IScript)dom.CreateInstanceAndUnwrap( 300 = (IScript)dom.CreateInstanceAndUnwrap(
272 Path.GetFileNameWithoutExtension(assembly), 301 Path.GetFileNameWithoutExtension(assembly),
273 "SecondLife.Script", 302 scriptType.FullName,
274 false, 303 false,
275 BindingFlags.Default, 304 BindingFlags.Default,
276 null, 305 null,
277 new object[] { m_coopSleepHandle }, 306 constructorParams,
278 null,
279 null, 307 null,
280 null); 308 null);
281 else 309 else
282 m_Script 310 m_Script
283 = (IScript)Assembly.Load(Path.GetFileNameWithoutExtension(assembly)).CreateInstance( 311 = (IScript)scriptAssembly.CreateInstance(
284 "SecondLife.Script", 312 scriptType.FullName,
285 false, 313 false,
286 BindingFlags.Default, 314 BindingFlags.Default,
287 null, 315 null,
288 new object[] { m_coopSleepHandle }, 316 constructorParams,
289 null, 317 null,
290 null); 318 null);
291 319
@@ -298,6 +326,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
298 m_log.ErrorFormat( 326 m_log.ErrorFormat(
299 "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}", 327 "[SCRIPT INSTANCE]: Error loading assembly {0}. Exception {1}{2}",
300 assembly, e.Message, e.StackTrace); 328 assembly, e.Message, e.StackTrace);
329
330 return false;
301 } 331 }
302 332
303 try 333 try
@@ -318,7 +348,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
318 "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}", 348 "[SCRIPT INSTANCE]: Error loading script instance from assembly {0}. Exception {1}{2}",
319 assembly, e.Message, e.StackTrace); 349 assembly, e.Message, e.StackTrace);
320 350
321 return; 351 return false;
322 } 352 }
323 353
324 m_SaveState = true; 354 m_SaveState = true;
@@ -390,6 +420,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
390// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); 420// presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
391 421
392// } 422// }
423
424 return true;
393 } 425 }
394 426
395 public void Init() 427 public void Init()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
index bd882f9..52d75a0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Tests/CoopTerminationTests.cs
@@ -245,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance.Tests
245 public void TestStopOnInfiniteJumpLoop() 245 public void TestStopOnInfiniteJumpLoop()
246 { 246 {
247 TestHelpers.InMethod(); 247 TestHelpers.InMethod();
248// TestHelpers.EnableLogging(); 248 TestHelpers.EnableLogging();
249 249
250 string script = 250 string script =
251@"default 251@"default