aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs8
-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
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs26
-rw-r--r--prebuild.xml1
6 files changed, 88 insertions, 27 deletions
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index 20dcac9..b8fdd01 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -79,6 +79,14 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
79 string ScriptEnginePath { get; } 79 string ScriptEnginePath { get; }
80 80
81 /// <summary> 81 /// <summary>
82 /// Return the name of the class that will be used for all running scripts.
83 /// </summary>
84 /// <remarks>
85 /// Each class goes in its own assembly so we don't need to otherwise distinguish the class name.
86 /// </remarks>
87 string ScriptClassName { get; }
88
89 /// <summary>
82 /// Return the name of the base class that will be used for all running scripts. 90 /// Return the name of the base class that will be used for all running scripts.
83 /// </summary> 91 /// </summary>
84 string ScriptBaseClassName { get; } 92 string ScriptBaseClassName { get; }
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
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index c1f9271..604924b 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -46,13 +46,14 @@ using OpenSim.Framework;
46using OpenSim.Framework.Console; 46using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Scenes; 47using OpenSim.Region.Framework.Scenes;
48using OpenSim.Region.Framework.Interfaces; 48using OpenSim.Region.Framework.Interfaces;
49using OpenSim.Region.ScriptEngine.Interfaces;
49using OpenSim.Region.ScriptEngine.Shared; 50using OpenSim.Region.ScriptEngine.Shared;
50using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 51using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
51using OpenSim.Region.ScriptEngine.Shared.CodeTools; 52using OpenSim.Region.ScriptEngine.Shared.CodeTools;
52using OpenSim.Region.ScriptEngine.Shared.Instance; 53using OpenSim.Region.ScriptEngine.Shared.Instance;
53using OpenSim.Region.ScriptEngine.Shared.Api; 54using OpenSim.Region.ScriptEngine.Shared.Api;
54using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 55using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
55using OpenSim.Region.ScriptEngine.Interfaces; 56using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
56using OpenSim.Region.ScriptEngine.XEngine.ScriptBase; 57using OpenSim.Region.ScriptEngine.XEngine.ScriptBase;
57using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer; 58using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
58 59
@@ -177,6 +178,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
177 get { return "XEngine"; } 178 get { return "XEngine"; }
178 } 179 }
179 180
181 public string ScriptClassName { get; private set; }
182
180 public string ScriptBaseClassName { get; private set; } 183 public string ScriptBaseClassName { get; private set; }
181 184
182 public ParameterInfo[] ScriptBaseClassParameters { get; private set; } 185 public ParameterInfo[] ScriptBaseClassParameters { get; private set; }
@@ -238,9 +241,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
238 m_ScriptConfig = configSource.Configs["XEngine"]; 241 m_ScriptConfig = configSource.Configs["XEngine"];
239 m_ConfigSource = configSource; 242 m_ConfigSource = configSource;
240 243
241 ScriptBaseClassName = typeof(XEngineScriptBase).FullName; 244 if (m_ScriptConfig.GetString("ScriptStopStrategy", "abort") == "co-op")
242 ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters(); 245 {
243 ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) }; 246 ScriptClassName = "XEngineScript";
247 ScriptBaseClassName = typeof(XEngineScriptBase).FullName;
248 ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters();
249 ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) };
250 }
251 else
252 {
253 ScriptClassName = "Script";
254 ScriptBaseClassName = typeof(ScriptBaseClass).FullName;
255 }
244 256
245// Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]); 257// Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]);
246 } 258 }
@@ -1122,7 +1134,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1122 } 1134 }
1123 1135
1124 m_log.DebugFormat( 1136 m_log.DebugFormat(
1125 "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", 1137 "[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
1126 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, 1138 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
1127 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); 1139 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
1128 1140
@@ -1143,6 +1155,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1143 lock (m_AddingAssemblies) 1155 lock (m_AddingAssemblies)
1144 { 1156 {
1145 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap); 1157 m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
1158
1146 if (!m_AddingAssemblies.ContainsKey(assembly)) { 1159 if (!m_AddingAssemblies.ContainsKey(assembly)) {
1147 m_AddingAssemblies[assembly] = 1; 1160 m_AddingAssemblies[assembly] = 1;
1148 } else { 1161 } else {
@@ -1303,7 +1316,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1303 startParam, postOnRez, 1316 startParam, postOnRez,
1304 m_MaxScriptQueue); 1317 m_MaxScriptQueue);
1305 1318
1306 instance.Load(m_AppDomains[appDomain], assembly, stateSource); 1319 if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
1320 return false;
1307 1321
1308// if (DebugLevel >= 1) 1322// if (DebugLevel >= 1)
1309// m_log.DebugFormat( 1323// m_log.DebugFormat(
diff --git a/prebuild.xml b/prebuild.xml
index 4019e0b..e891433 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -2487,6 +2487,7 @@
2487 <Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/> 2487 <Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
2488 <Reference name="OpenSim.Region.ScriptEngine.Shared.Instance"/> 2488 <Reference name="OpenSim.Region.ScriptEngine.Shared.Instance"/>
2489 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/> 2489 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
2490 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/>
2490 <Reference name="OpenSim.Region.ScriptEngine.XEngine.Api.Runtime"/> 2491 <Reference name="OpenSim.Region.ScriptEngine.XEngine.Api.Runtime"/>
2491 <Reference name="SmartThreadPool"/> 2492 <Reference name="SmartThreadPool"/>
2492 <Reference name="Nini" path="../../../../bin/"/> 2493 <Reference name="Nini" path="../../../../bin/"/>