aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs55
4 files changed, 46 insertions, 21 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 5590cd5..7d8821c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6846,12 +6846,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6846 { 6846 {
6847 m_host.AddScriptLPS(1); 6847 m_host.AddScriptLPS(1);
6848 m_host.SetCameraEyeOffset(offset); 6848 m_host.SetCameraEyeOffset(offset);
6849
6850 if (m_host.ParentGroup.RootPart.GetCameraEyeOffset() == Vector3.Zero)
6851 m_host.ParentGroup.RootPart.SetCameraEyeOffset(offset);
6849 } 6852 }
6850 6853
6851 public void llSetCameraAtOffset(LSL_Vector offset) 6854 public void llSetCameraAtOffset(LSL_Vector offset)
6852 { 6855 {
6853 m_host.AddScriptLPS(1); 6856 m_host.AddScriptLPS(1);
6854 m_host.SetCameraAtOffset(offset); 6857 m_host.SetCameraAtOffset(offset);
6858
6859 if (m_host.ParentGroup.RootPart.GetCameraAtOffset() == Vector3.Zero)
6860 m_host.ParentGroup.RootPart.SetCameraAtOffset(offset);
6855 } 6861 }
6856 6862
6857 public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) 6863 public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at)
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index 6aa717d..8b8e038 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -162,7 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
162 m_braceCount++; 162 m_braceCount++;
163 163
164 // line number 164 // line number
165 m_CSharpLine += 3; 165 m_CSharpLine += 9;
166 166
167 // here's the payload 167 // here's the payload
168 retstr += GenerateLine(); 168 retstr += GenerateLine();
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index b4640ef..1efe798 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -444,7 +444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
444// return compileScript; 444// return compileScript;
445// } 445// }
446 446
447 private static string CreateCSCompilerScript( 447 public static string CreateCSCompilerScript(
448 string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) 448 string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters)
449 { 449 {
450 compileScript = string.Format( 450 compileScript = string.Format(
@@ -472,7 +472,7 @@ namespace SecondLife
472 return compileScript; 472 return compileScript;
473 } 473 }
474 474
475 private static string CreateVBCompilerScript(string compileScript, string className, string baseClassName) 475 public static string CreateVBCompilerScript(string compileScript, string className, string baseClassName)
476 { 476 {
477 compileScript = String.Empty + 477 compileScript = String.Empty +
478 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " + 478 "Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
index 05a8756..badf82a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using Microsoft.CSharp; 31using Microsoft.CSharp;
32using NUnit.Framework; 32using NUnit.Framework;
33using OpenSim.Region.ScriptEngine.Shared.CodeTools; 33using OpenSim.Region.ScriptEngine.Shared.CodeTools;
34using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
34using OpenSim.Tests.Common; 35using OpenSim.Tests.Common;
35 36
36namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests 37namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
@@ -66,9 +67,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
66 m_CSCodeProvider = new CSharpCodeProvider(); 67 m_CSCodeProvider = new CSharpCodeProvider();
67 m_compilerParameters = new CompilerParameters(); 68 m_compilerParameters = new CompilerParameters();
68 69
69 string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory), "bin"); 70 string rootPath = Path.Combine(Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory));
70 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); 71 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll"));
71 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); 72 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll"));
73 m_compilerParameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenMetaverseTypes.dll"));
72 m_compilerParameters.GenerateExecutable = false; 74 m_compilerParameters.GenerateExecutable = false;
73 } 75 }
74 76
@@ -90,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
90 /// Test the C# compiler error message can be mapped to the correct 92 /// Test the C# compiler error message can be mapped to the correct
91 /// line/column in the LSL source when an undeclared variable is used. 93 /// line/column in the LSL source when an undeclared variable is used.
92 /// </summary> 94 /// </summary>
93 //[Test] 95 [Test]
94 public void TestUseUndeclaredVariable() 96 public void TestUseUndeclaredVariable()
95 { 97 {
96 TestHelpers.InMethod(); 98 TestHelpers.InMethod();
@@ -106,25 +108,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
106}"; 108}";
107 109
108 CSCodeGenerator cg = new CSCodeGenerator(); 110 CSCodeGenerator cg = new CSCodeGenerator();
109 string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + 111 string output = cg.Convert(input);
110 "namespace SecondLife { " + 112
111 "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + 113 output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null);
112 "public Script() { } " + 114// System.Console.WriteLine(output);
113 cg.Convert(input) + 115
114 "} }\n";
115 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> positionMap = cg.PositionMap; 116 Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> positionMap = cg.PositionMap;
116 117
117 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); 118 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output);
118 119//
119 Assert.AreEqual(new KeyValuePair<int, int>(5, 21), 120// foreach (KeyValuePair<int, int> key in positionMap.Keys)
120 positionMap[new KeyValuePair<int, int>(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]); 121// {
122// KeyValuePair<int, int> val = positionMap[key];
123//
124// System.Console.WriteLine("{0},{1} => {2},{3}", key.Key, key.Value, val.Key, val.Value);
125// }
126//
127// foreach (CompilerError compErr in m_compilerResults.Errors)
128// {
129// System.Console.WriteLine("Error: {0},{1} => {2}", compErr.Line, compErr.Column, compErr);
130// }
131
132 Assert.AreEqual(
133 new KeyValuePair<int, int>(5, 21),
134 positionMap[new KeyValuePair<int, int>(m_compilerResults.Errors[0].Line, m_compilerResults.Errors[0].Column)]);
121 } 135 }
122 136
123 /// <summary> 137 /// <summary>
124 /// Test that a string can be cast to string and another string 138 /// Test that a string can be cast to string and another string
125 /// concatenated. 139 /// concatenated.
126 /// </summary> 140 /// </summary>
127 //[Test] 141 [Test]
128 public void TestCastAndConcatString() 142 public void TestCastAndConcatString()
129 { 143 {
130 TestHelpers.InMethod(); 144 TestHelpers.InMethod();
@@ -143,15 +157,20 @@ default
143 } 157 }
144}"; 158}";
145 159
160// System.Console.WriteLine(input);
146 CSCodeGenerator cg = new CSCodeGenerator(); 161 CSCodeGenerator cg = new CSCodeGenerator();
147 string output = "using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\n" + 162 string output = cg.Convert(input);
148 "namespace SecondLife { " + 163
149 "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass {\n" + 164 output = Compiler.CreateCSCompilerScript(output, "script1", typeof(ScriptBaseClass).FullName, null);
150 "public Script() { } " + 165// System.Console.WriteLine(output);
151 cg.Convert(input) + 166
152 "} }\n";
153 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output); 167 m_compilerResults = m_CSCodeProvider.CompileAssemblyFromSource(m_compilerParameters, output);
154 168
169// foreach (CompilerError compErr in m_compilerResults.Errors)
170// {
171// System.Console.WriteLine("Error: {0}", compErr);
172// }
173
155 Assert.AreEqual(0, m_compilerResults.Errors.Count); 174 Assert.AreEqual(0, m_compilerResults.Errors.Count);
156 } 175 }
157 } 176 }