aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs73
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs2
2 files changed, 65 insertions, 10 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index c8c51f8..f8650a0 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -1088,6 +1088,12 @@ namespace OpenSim.Region.ScriptEngine.Common
1088 m_string=s; 1088 m_string=s;
1089 } 1089 }
1090 1090
1091 public LSLString(LSLFloat f)
1092 {
1093 string s=String.Format("{0:0.000000}", f.value);
1094 m_string=s;
1095 }
1096
1091 #endregion 1097 #endregion
1092 1098
1093 #region Operators 1099 #region Operators
@@ -1150,6 +1156,11 @@ namespace OpenSim.Region.ScriptEngine.Common
1150 return new LSLString(d); 1156 return new LSLString(d);
1151 } 1157 }
1152 1158
1159 public static explicit operator LSLString(LSLFloat f)
1160 {
1161 return new LSLString(f);
1162 }
1163
1153 public static implicit operator Vector3(LSLString s) 1164 public static implicit operator Vector3(LSLString s)
1154 { 1165 {
1155 return new Vector3(s.m_string); 1166 return new Vector3(s.m_string);
@@ -1202,6 +1213,8 @@ namespace OpenSim.Region.ScriptEngine.Common
1202 1213
1203 #endregion 1214 #endregion
1204 1215
1216 #region Operators
1217
1205 static public implicit operator int(LSLInteger i) 1218 static public implicit operator int(LSLInteger i)
1206 { 1219 {
1207 return i.value; 1220 return i.value;
@@ -1290,6 +1303,8 @@ namespace OpenSim.Region.ScriptEngine.Common
1290 return i.value == 0; 1303 return i.value == 0;
1291 } 1304 }
1292 1305
1306 #endregion
1307
1293 #region Overriders 1308 #region Overriders
1294 1309
1295 public override string ToString() 1310 public override string ToString()
@@ -1306,6 +1321,7 @@ namespace OpenSim.Region.ScriptEngine.Common
1306 public double value; 1321 public double value;
1307 1322
1308 #region Constructors 1323 #region Constructors
1324
1309 public LSLFloat(int i) 1325 public LSLFloat(int i)
1310 { 1326 {
1311 this.value = (double)i; 1327 this.value = (double)i;
@@ -1320,20 +1336,19 @@ namespace OpenSim.Region.ScriptEngine.Common
1320 1336
1321 #region Operators 1337 #region Operators
1322 1338
1323 static public implicit operator Double(LSLFloat f) 1339 static public implicit operator int(LSLFloat f)
1324 { 1340 {
1325 return f.value; 1341 return (int)f.value;
1326 } 1342 }
1327 1343
1328 //static public implicit operator System.Int32(LSLFloat f) 1344 static public implicit operator uint(LSLFloat f)
1329 //{ 1345 {
1330 // return (int)f.value; 1346 return (uint) Math.Abs(f.value);
1331 //} 1347 }
1332
1333 1348
1334 static public implicit operator Boolean(LSLFloat f) 1349 static public implicit operator Boolean(LSLFloat f)
1335 { 1350 {
1336 if (f.value == 0) 1351 if (f.value == 0.0)
1337 { 1352 {
1338 return false; 1353 return false;
1339 } 1354 }
@@ -1348,17 +1363,57 @@ namespace OpenSim.Region.ScriptEngine.Common
1348 return new LSLFloat(i); 1363 return new LSLFloat(i);
1349 } 1364 }
1350 1365
1366 static public implicit operator LSLFloat(string s)
1367 {
1368 return new LSLFloat(double.Parse(s));
1369 }
1370
1351 static public implicit operator LSLFloat(double d) 1371 static public implicit operator LSLFloat(double d)
1352 { 1372 {
1353 return new LSLFloat(d); 1373 return new LSLFloat(d);
1354 } 1374 }
1375
1376 static public bool operator ==(LSLFloat f1, LSLFloat f2)
1377 {
1378 return f1.value == f2.value;
1379 }
1380
1381 static public bool operator !=(LSLFloat f1, LSLFloat f2)
1382 {
1383 return f1.value != f2.value;
1384 }
1385
1386 static public LSLFloat operator ++(LSLFloat f)
1387 {
1388 f.value++;
1389 return f;
1390 }
1391
1392 static public LSLFloat operator --(LSLFloat f)
1393 {
1394 f.value--;
1395 return f;
1396 }
1397
1398 static public implicit operator System.Double(LSLFloat f)
1399 {
1400 return f.value;
1401 }
1402
1403 //static public implicit operator System.Int32(LSLFloat f)
1404 //{
1405 // return (int)f.value;
1406 //}
1407
1355 #endregion 1408 #endregion
1356 1409
1357 #region Overriders 1410 #region Overriders
1411
1358 public override string ToString() 1412 public override string ToString()
1359 { 1413 {
1360 return this.value.ToString(); 1414 return String.Format("{0:0.000000}", this.value);
1361 } 1415 }
1416
1362 #endregion 1417 #endregion
1363 } 1418 }
1364 } 1419 }
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index 583bb93..db73f6b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
52 // Only the types we need to convert 52 // Only the types we need to convert
53 dataTypes.Add("void", "void"); 53 dataTypes.Add("void", "void");
54 dataTypes.Add("integer", "LSL_Types.LSLInteger"); 54 dataTypes.Add("integer", "LSL_Types.LSLInteger");
55 dataTypes.Add("float", "double"); 55 dataTypes.Add("float", "LSL_Types.LSLFloat");
56 dataTypes.Add("string", "LSL_Types.LSLString"); 56 dataTypes.Add("string", "LSL_Types.LSLString");
57 dataTypes.Add("key", "LSL_Types.LSLString"); 57 dataTypes.Add("key", "LSL_Types.LSLString");
58 dataTypes.Add("vector", "LSL_Types.Vector3"); 58 dataTypes.Add("vector", "LSL_Types.Vector3");