aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorCharles Krinke2008-09-05 23:26:35 +0000
committerCharles Krinke2008-09-05 23:26:35 +0000
commit947242f4764b8d98fe860d3c18bcea709aea777f (patch)
tree2169a26250473aa887dac6f492b582e779d41639 /OpenSim/Region/ScriptEngine
parentThank you kindly, KrTaylor for a patch that adds: (diff)
downloadopensim-SC_OLD-947242f4764b8d98fe860d3c18bcea709aea777f.zip
opensim-SC_OLD-947242f4764b8d98fe860d3c18bcea709aea777f.tar.gz
opensim-SC_OLD-947242f4764b8d98fe860d3c18bcea709aea777f.tar.bz2
opensim-SC_OLD-947242f4764b8d98fe860d3c18bcea709aea777f.tar.xz
Mantis#2126. Thank you kindly, Ralphos for a patch that addresses:
Types extracted from a LSL_Types.list have to be down-cast initially to the exact type of value type object that the Object actually is. This would make for very cumbersome, ugly code when extracting list parameter items in ll functions where a few implicit conversions should be applied such as key -> LSLString and LSLInteger -> LSLFloat (but not LSLFloat -> LSLInteger). This patch adds a set of GetXXXItem member functions to the LLS_Type.list class, where XXX is the name of the LSL_Type to be extracted: LSLFLoat, LSLInteger etc. All take a single, int parameter that is the item number to be extracted.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs64
2 files changed, 70 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 74c2d89..93dfeea 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5726,13 +5726,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5726 if (remain < 7) 5726 if (remain < 7)
5727 return; 5727 return;
5728 5728
5729 bool flexi = (LSL_Types.LSLInteger)rules.Data[idx++]; 5729 bool flexi = rules.GetLSLIntegerItem(idx++);
5730 int softness = (LSL_Types.LSLInteger)rules.Data[idx++]; 5730 int softness = rules.GetLSLIntegerItem(idx++);
5731 float gravity = (float)(LSL_Types.LSLFloat)rules.Data[idx++]; 5731 float gravity = (float)rules.GetLSLFloatItem(idx++);
5732 float friction = (float)(LSL_Types.LSLFloat)rules.Data[idx++]; 5732 float friction = (float)rules.GetLSLFloatItem(idx++);
5733 float wind = (float)(LSL_Types.LSLFloat)rules.Data[idx++]; 5733 float wind = (float)rules.GetLSLFloatItem(idx++);
5734 float tension = (float)(LSL_Types.LSLFloat)rules.Data[idx++]; 5734 float tension = (float)rules.GetLSLFloatItem(idx++);
5735 LSL_Types.Vector3 force = (LSL_Types.Vector3)rules.Data[idx++]; 5735 LSL_Types.Vector3 force = rules.GetVector3Item(idx++);
5736 5736
5737 SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); 5737 SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force);
5738 5738
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 85abdb0..4713283 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -421,6 +421,58 @@ namespace OpenSim.Region.ScriptEngine.Shared
421 } 421 }
422 } 422 }
423 423
424 // Member functions to obtain item as specific types.
425 // For cases where implicit conversions would apply if items
426 // were not in a list (e.g. integer to float, but not float
427 // to integer) functions check for alternate types so as to
428 // down-cast from Object to the correct type.
429 // Note: no checks for item index being valid are performed
430
431 public LSL_Types.LSLFloat GetLSLFloatItem( int itemIndex )
432 {
433 if (m_data[itemIndex] is LSL_Types.LSLInteger)
434 {
435 return (LSL_Types.LSLInteger)m_data[itemIndex];
436 }
437 else
438 {
439 return (LSL_Types.LSLFloat)m_data[itemIndex];
440 }
441 }
442
443 public LSL_Types.LSLString GetLSLStringItem(int itemIndex)
444 {
445 if (m_data[itemIndex] is LSL_Types.key)
446 {
447 return (LSL_Types.key)m_data[itemIndex];
448 }
449 else
450 {
451 return (LSL_Types.LSLString)m_data[itemIndex];
452 }
453 }
454
455 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
456 {
457 return (LSL_Types.LSLInteger)m_data[itemIndex];
458 }
459
460 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
461 {
462 return (LSL_Types.Vector3)m_data[itemIndex];
463 }
464
465 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
466 {
467 return (LSL_Types.Quaternion)m_data[itemIndex];
468 }
469
470 public LSL_Types.key GetKeyItem(int itemIndex)
471 {
472 return (LSL_Types.key)m_data[itemIndex];
473 }
474
475
424 public static list operator +(list a, list b) 476 public static list operator +(list a, list b)
425 { 477 {
426 object[] tmp; 478 object[] tmp;
@@ -1164,7 +1216,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
1164 1216
1165 static public implicit operator String(key k) 1217 static public implicit operator String(key k)
1166 { 1218 {
1167 return k.value; 1219 return k.value;
1220 }
1221
1222 static public implicit operator LSLString(key k)
1223 {
1224 return k.value;
1168 } 1225 }
1169 1226
1170 public static bool operator ==(key k1, key k2) 1227 public static bool operator ==(key k1, key k2)
@@ -1190,6 +1247,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
1190 return value.GetHashCode(); 1247 return value.GetHashCode();
1191 } 1248 }
1192 1249
1250 public override string ToString()
1251 {
1252 return value;
1253 }
1254
1193 #endregion 1255 #endregion
1194 } 1256 }
1195 1257