aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMike Mazur2008-07-25 07:50:31 +0000
committerMike Mazur2008-07-25 07:50:31 +0000
commit19ad7db5e1ebcce8fc13995270b2ebe94f8a9a52 (patch)
tree3de434cccd390c7068726e874756e44a9e82c322 /OpenSim
parentThanks, lulurun, for a patch that adds an authenticated session cache to reduce (diff)
downloadopensim-SC_OLD-19ad7db5e1ebcce8fc13995270b2ebe94f8a9a52.zip
opensim-SC_OLD-19ad7db5e1ebcce8fc13995270b2ebe94f8a9a52.tar.gz
opensim-SC_OLD-19ad7db5e1ebcce8fc13995270b2ebe94f8a9a52.tar.bz2
opensim-SC_OLD-19ad7db5e1ebcce8fc13995270b2ebe94f8a9a52.tar.xz
Add casts from integer to float. Fix issue 1822.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs5
-rw-r--r--OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs32
3 files changed, 41 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index 0b28af0..7ac7a65 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -1454,6 +1454,11 @@ namespace OpenSim.Region.ScriptEngine.Common
1454 return new LSLFloat(i); 1454 return new LSLFloat(i);
1455 } 1455 }
1456 1456
1457 static public implicit operator LSLFloat(LSLInteger i)
1458 {
1459 return new LSLFloat(i.value);
1460 }
1461
1457 static public implicit operator LSLFloat(string s) 1462 static public implicit operator LSLFloat(string s)
1458 { 1463 {
1459 return new LSLFloat(double.Parse(s)); 1464 return new LSLFloat(double.Parse(s));
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index f49d453..7eb5e77 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -1509,6 +1509,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
1509 return new LSLFloat(i); 1509 return new LSLFloat(i);
1510 } 1510 }
1511 1511
1512 static public implicit operator LSLFloat(LSLInteger i)
1513 {
1514 return new LSLFloat(i.value);
1515 }
1516
1512 static public implicit operator LSLFloat(string s) 1517 static public implicit operator LSLFloat(string s)
1513 { 1518 {
1514 return new LSLFloat(double.Parse(s)); 1519 return new LSLFloat(double.Parse(s));
diff --git a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs
index aba87ac..2d553a7 100644
--- a/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs
+++ b/OpenSim/Tests/OpenSim/Region/ScriptEngine/Common/LSL_TypesTestLSLFloat.cs
@@ -304,6 +304,36 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
304 } 304 }
305 305
306 /// <summary> 306 /// <summary>
307 /// Tests LSLInteger is correctly cast implicitly to LSLFloat.
308 /// </summary>
309 [Test]
310 public void TestImplicitCastLSLIntegerToLSLFloat()
311 {
312 LSL_Types.LSLFloat testFloat;
313
314 foreach (int number in m_intList)
315 {
316 testFloat = new LSL_Types.LSLInteger(number);
317 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
318 }
319 }
320
321 /// <summary>
322 /// Tests LSLInteger is correctly cast explicitly to LSLFloat.
323 /// </summary>
324 [Test]
325 public void TestExplicitCastLSLIntegerToLSLFloat()
326 {
327 LSL_Types.LSLFloat testFloat;
328
329 foreach (int number in m_intList)
330 {
331 testFloat = (LSL_Types.LSLFloat) new LSL_Types.LSLInteger(number);
332 Assert.That(testFloat.value, new DoubleToleranceConstraint(number, _lowPrecisionTolerance));
333 }
334 }
335
336 /// <summary>
307 /// Tests string is correctly cast implicitly to LSLFloat. 337 /// Tests string is correctly cast implicitly to LSLFloat.
308 /// </summary> 338 /// </summary>
309 [Test] 339 [Test]
@@ -319,7 +349,7 @@ namespace OpenSim.Region.ScriptEngine.Common.Tests
319 } 349 }
320 350
321 /// <summary> 351 /// <summary>
322 /// Tests string is correctly cast implicitly to LSLFloat. 352 /// Tests LSLString is correctly cast implicitly to LSLFloat.
323 /// </summary> 353 /// </summary>
324 [Test] 354 [Test]
325 public void TestExplicitCastLSLStringToLSLFloat() 355 public void TestExplicitCastLSLStringToLSLFloat()