aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-30 03:36:13 +0000
committerTeravus Ovares2008-04-30 03:36:13 +0000
commit36bf16d35e928a338c932feeec42c0c8f35d8846 (patch)
tree06f11a4c546fce85fe1504fce08a09dd4bdebb06 /OpenSim/Region/ScriptEngine
parent* Disabled IntergridModule until a Mono bug can be isolated. (diff)
downloadopensim-SC_OLD-36bf16d35e928a338c932feeec42c0c8f35d8846.zip
opensim-SC_OLD-36bf16d35e928a338c932feeec42c0c8f35d8846.tar.gz
opensim-SC_OLD-36bf16d35e928a338c932feeec42c0c8f35d8846.tar.bz2
opensim-SC_OLD-36bf16d35e928a338c932feeec42c0c8f35d8846.tar.xz
Patch from Melanie: 0001077: [PATCH] LSL types cannot be cast implicitly or explicitly in many cases Thanks Melanie!
* Also, I moved the event parser and re-writer to a separate static object. More work will be done here shortly.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs64
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs176
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs12
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs23
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs488
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs250
11 files changed, 684 insertions, 339 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index e29ee5a..66d2700 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -80,6 +80,15 @@ namespace OpenSim.Region.ScriptEngine.Common
80 // Set it if it changed 80 // Set it if it changed
81 if (m_state != value) 81 if (m_state != value)
82 { 82 {
83 try
84 {
85 m_ScriptEngine.m_EventManager.state_exit(m_localID);
86
87 }
88 catch (AppDomainUnloadedException)
89 {
90 Console.WriteLine("[SCRIPT]: state change called when script was unloaded. Nothing to worry about, but noting the occurance");
91 }
83 m_state = value; 92 m_state = value;
84 try 93 try
85 { 94 {
@@ -2136,7 +2145,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2136 m_host.TaskInventory[invItemID].PermsMask=0; 2145 m_host.TaskInventory[invItemID].PermsMask=0;
2137 2146
2138 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2147 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2139 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)0}); 2148 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(0)});
2140 2149
2141 return; 2150 return;
2142 } 2151 }
@@ -2158,7 +2167,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2158 m_host.TaskInventory[invItemID].PermsMask=perm; 2167 m_host.TaskInventory[invItemID].PermsMask=perm;
2159 2168
2160 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2169 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2161 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)perm}); 2170 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(perm)});
2162 2171
2163 return; 2172 return;
2164 } 2173 }
@@ -2175,7 +2184,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2175 m_host.TaskInventory[invItemID].PermsMask=perm; 2184 m_host.TaskInventory[invItemID].PermsMask=perm;
2176 2185
2177 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2186 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2178 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)perm}); 2187 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(perm)});
2179 2188
2180 return; 2189 return;
2181 } 2190 }
@@ -2202,7 +2211,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2202 2211
2203 // Requested agent is not in range, refuse perms 2212 // Requested agent is not in range, refuse perms
2204 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2213 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2205 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)0}); 2214 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(0)});
2206 } 2215 }
2207 2216
2208 void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer) 2217 void handleScriptAnswer(IClientAPI client, LLUUID taskID, LLUUID itemID, int answer)
@@ -2220,7 +2229,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2220 2229
2221 m_host.TaskInventory[invItemID].PermsMask=answer; 2230 m_host.TaskInventory[invItemID].PermsMask=answer;
2222 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2231 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
2223 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {(int)answer}); 2232 m_localID, m_itemID, "run_time_permissions", EventQueueManager.llDetectNull, new Object[] {new LSL_Types.LSLInteger(answer)});
2224 } 2233 }
2225 2234
2226 public string llGetPermissionsKey() 2235 public string llGetPermissionsKey()
@@ -2600,7 +2609,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2600 2609
2601 object[] resobj = new object[] 2610 object[] resobj = new object[]
2602 { 2611 {
2603 m_host.LinkNum + 1, num, msg, id 2612 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2604 }; 2613 };
2605 2614
2606 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2615 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
@@ -2627,7 +2636,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2627 partItemID = item.ItemID; 2636 partItemID = item.ItemID;
2628 Object[] resobj = new object[] 2637 Object[] resobj = new object[]
2629 { 2638 {
2630 m_host.LinkNum + 1, num, msg, id 2639 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2631 }; 2640 };
2632 2641
2633 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2642 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
@@ -2655,7 +2664,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2655 partItemID = item.ItemID; 2664 partItemID = item.ItemID;
2656 Object[] resobj = new object[] 2665 Object[] resobj = new object[]
2657 { 2666 {
2658 m_host.LinkNum + 1, num, msg, id 2667 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2659 }; 2668 };
2660 2669
2661 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2670 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
@@ -2685,7 +2694,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2685 partItemID = item.ItemID; 2694 partItemID = item.ItemID;
2686 Object[] resobj = new object[] 2695 Object[] resobj = new object[]
2687 { 2696 {
2688 m_host.LinkNum + 1, num, msg, id 2697 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2689 }; 2698 };
2690 2699
2691 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2700 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
@@ -2709,7 +2718,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2709 2718
2710 object[] resobj = new object[] 2719 object[] resobj = new object[]
2711 { 2720 {
2712 m_host.LinkNum + 1, num, msg, id 2721 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2713 }; 2722 };
2714 2723
2715 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2724 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
@@ -2737,7 +2746,7 @@ namespace OpenSim.Region.ScriptEngine.Common
2737 partItemID = item.ItemID; 2746 partItemID = item.ItemID;
2738 Object[] resObjDef = new object[] 2747 Object[] resObjDef = new object[]
2739 { 2748 {
2740 m_host.LinkNum + 1, num, msg, id 2749 new LSL_Types.LSLInteger(m_host.LinkNum + 1), new LSL_Types.LSLInteger(num), new LSL_Types.LSLString(msg), new LSL_Types.LSLString(id)
2741 }; 2750 };
2742 2751
2743 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 2752 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
@@ -3058,7 +3067,14 @@ namespace OpenSim.Region.ScriptEngine.Common
3058 { 3067 {
3059 return 0; 3068 return 0;
3060 } 3069 }
3061 return Convert.ToInt32(src.Data[index]); 3070 try
3071 {
3072 return Convert.ToInt32(src.Data[index]);
3073 }
3074 catch (System.FormatException e)
3075 {
3076 return 0;
3077 }
3062 } 3078 }
3063 3079
3064 public double osList2Double(LSL_Types.list src, int index) 3080 public double osList2Double(LSL_Types.list src, int index)
@@ -3086,7 +3102,14 @@ namespace OpenSim.Region.ScriptEngine.Common
3086 { 3102 {
3087 return 0.0; 3103 return 0.0;
3088 } 3104 }
3089 return Convert.ToDouble(src.Data[index]); 3105 try
3106 {
3107 return Convert.ToDouble(src.Data[index]);
3108 }
3109 catch (System.FormatException e)
3110 {
3111 return 0.0;
3112 }
3090 } 3113 }
3091 3114
3092 public string llList2String(LSL_Types.list src, int index) 3115 public string llList2String(LSL_Types.list src, int index)
@@ -3112,18 +3135,9 @@ namespace OpenSim.Region.ScriptEngine.Common
3112 } 3135 }
3113 if (index >= src.Length) 3136 if (index >= src.Length)
3114 { 3137 {
3115 return "00000000-0000-0000-0000-000000000000"; 3138 return "";
3116 }
3117 //return OpenSim.Framework.ToString(src[index]);
3118 LLUUID tmpkey;
3119 if (LLUUID.TryParse(src.Data[index].ToString(), out tmpkey))
3120 {
3121 return tmpkey.ToString();
3122 }
3123 else
3124 {
3125 return "00000000-0000-0000-0000-000000000000";
3126 } 3139 }
3140 return src.Data[index].ToString();
3127 } 3141 }
3128 3142
3129 public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index) 3143 public LSL_Types.Vector3 llList2Vector(LSL_Types.list src, int index)
@@ -4317,7 +4331,7 @@ namespace OpenSim.Region.ScriptEngine.Common
4317 if (xmlrpcMod.IsEnabled()) 4331 if (xmlrpcMod.IsEnabled())
4318 { 4332 {
4319 LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID); 4333 LLUUID channelID = xmlrpcMod.OpenXMLRPCChannel(m_localID, m_itemID);
4320 object[] resobj = new object[] { 1, channelID.ToString(), LLUUID.Zero.ToString(), String.Empty, 0, String.Empty }; 4334 object[] resobj = new object[] { new LSL_Types.LSLInteger(1), new LSL_Types.LSLString(channelID.ToString()), new LSL_Types.LSLString(LLUUID.Zero.ToString()), new LSL_Types.LSLString(String.Empty), new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(String.Empty) };
4321 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj); 4335 m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(m_localID, m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj);
4322 } 4336 }
4323 } 4337 }
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index 65047fb..5337d7f 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -64,6 +64,11 @@ namespace OpenSim.Region.ScriptEngine.Common
64 str = str.Replace('<', ' '); 64 str = str.Replace('<', ' ');
65 str = str.Replace('>', ' '); 65 str = str.Replace('>', ' ');
66 string[] tmps = str.Split(new Char[] { ',', '<', '>' }); 66 string[] tmps = str.Split(new Char[] { ',', '<', '>' });
67 if(tmps.Length < 3)
68 {
69 x=y=z=0;
70 return;
71 }
67 bool res; 72 bool res;
68 res = Double.TryParse(tmps[0], out x); 73 res = Double.TryParse(tmps[0], out x);
69 res = res & Double.TryParse(tmps[1], out y); 74 res = res & Double.TryParse(tmps[1], out y);
@@ -76,14 +81,27 @@ namespace OpenSim.Region.ScriptEngine.Common
76 81
77 public override string ToString() 82 public override string ToString()
78 { 83 {
79 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ">"; 84 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", x, y, z);
85 return s;
86 }
87
88 public static explicit operator LSLString(Vector3 vec)
89 {
90 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z);
91 return new LSLString(s);
80 } 92 }
81 93
82 public static explicit operator string(Vector3 vec) 94 public static explicit operator string(Vector3 vec)
83 { 95 {
84 return "<" + vec.x.ToString() + ", " + vec.y.ToString() + ", " + vec.z.ToString() + ">"; 96 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000}>", vec.x, vec.y, vec.z);
97 return s;
85 } 98 }
86 99
100 public static explicit operator Vector3(string s)
101 {
102 return new Vector3(s);
103 }
104
87 public static bool operator ==(Vector3 lhs, Vector3 rhs) 105 public static bool operator ==(Vector3 lhs, Vector3 rhs)
88 { 106 {
89 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); 107 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
@@ -278,6 +296,11 @@ namespace OpenSim.Region.ScriptEngine.Common
278 str = str.Replace('<', ' '); 296 str = str.Replace('<', ' ');
279 str = str.Replace('>', ' '); 297 str = str.Replace('>', ' ');
280 string[] tmps = str.Split(new Char[] { ',', '<', '>' }); 298 string[] tmps = str.Split(new Char[] { ',', '<', '>' });
299 if(tmps.Length < 4)
300 {
301 x=y=z=s=0;
302 return;
303 }
281 bool res; 304 bool res;
282 res = Double.TryParse(tmps[0], out x); 305 res = Double.TryParse(tmps[0], out x);
283 res = res & Double.TryParse(tmps[1], out y); 306 res = res & Double.TryParse(tmps[1], out y);
@@ -307,14 +330,27 @@ namespace OpenSim.Region.ScriptEngine.Common
307 330
308 public override string ToString() 331 public override string ToString()
309 { 332 {
310 return "<" + x.ToString() + ", " + y.ToString() + ", " + z.ToString() + ", " + s.ToString() + ">"; 333 string st=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", x, y, z, s);
334 return st;
311 } 335 }
312 336
313 public static explicit operator string(Quaternion r) 337 public static explicit operator string(Quaternion r)
314 { 338 {
315 return "<" + r.x.ToString() + ", " + r.y.ToString() + ", " + r.z.ToString() + ", " + r.s.ToString() + ">"; 339 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s);
340 return s;
341 }
342
343 public static explicit operator LSLString(Quaternion r)
344 {
345 string s=String.Format("<{0:0.000000},{1:0.000000},{2:0.000000},{3:0.000000}>", r.x, r.y, r.z, r.s);
346 return new LSLString(s);
316 } 347 }
317 348
349 public static explicit operator Quaternion(string s)
350 {
351 return new Quaternion(s);
352 }
353
318 public static bool operator ==(Quaternion lhs, Quaternion rhs) 354 public static bool operator ==(Quaternion lhs, Quaternion rhs)
319 { 355 {
320 // Return true if the fields match: 356 // Return true if the fields match:
@@ -369,12 +405,20 @@ namespace OpenSim.Region.ScriptEngine.Common
369 405
370 public int Length 406 public int Length
371 { 407 {
372 get { return m_data.Length; } 408 get {
409 if(m_data == null)
410 m_data=new Object[0];
411 return m_data.Length;
412 }
373 } 413 }
374 414
375 public object[] Data 415 public object[] Data
376 { 416 {
377 get { return m_data; } 417 get {
418 if(m_data == null)
419 m_data=new Object[0];
420 return m_data;
421 }
378 } 422 }
379 423
380 public static list operator +(list a, list b) 424 public static list operator +(list a, list b)
@@ -571,13 +615,20 @@ namespace OpenSim.Region.ScriptEngine.Common
571 if(Data.Length == 0) 615 if(Data.Length == 0)
572 return new list(); // Don't even bother 616 return new list(); // Don't even bother
573 617
618 string[] keys;
619
574 if(stride == 1) // The simple case 620 if(stride == 1) // The simple case
575 { 621 {
576 Object[] ret=new Object[Data.Length]; 622 Object[] ret=new Object[Data.Length];
577 623
578 Array.Copy(Data, 0, ret, 0, Data.Length); 624 Array.Copy(Data, 0, ret, 0, Data.Length);
579 625
580 Array.Sort(ret); 626 keys=new string[Data.Length];
627 int k;
628 for(k=0;k<Data.Length;k++)
629 keys[k]=Data[k].ToString();
630
631 Array.Sort(keys, ret);
581 632
582 if(ascending == 0) 633 if(ascending == 0)
583 Array.Reverse(ret); 634 Array.Reverse(ret);
@@ -588,7 +639,7 @@ namespace OpenSim.Region.ScriptEngine.Common
588 639
589 int len=(Data.Length+stride-1)/stride; 640 int len=(Data.Length+stride-1)/stride;
590 641
591 string[] keys=new string[len]; 642 keys=new string[len];
592 Object[][] vals=new Object[len][]; 643 Object[][] vals=new Object[len][];
593 644
594 int i; 645 int i;
@@ -1016,17 +1067,7 @@ namespace OpenSim.Region.ScriptEngine.Common
1016 1067
1017 public override bool Equals(object o) 1068 public override bool Equals(object o)
1018 { 1069 {
1019 if (o is String) 1070 return o.ToString() == value;
1020 {
1021 string s = (string)o;
1022 return s == this.value;
1023 }
1024 if (o is key)
1025 {
1026 key k = (key)o;
1027 return this.value == k.value;
1028 }
1029 return false;
1030 } 1071 }
1031 1072
1032 public override int GetHashCode() 1073 public override int GetHashCode()
@@ -1046,6 +1087,13 @@ namespace OpenSim.Region.ScriptEngine.Common
1046 { 1087 {
1047 m_string = s; 1088 m_string = s;
1048 } 1089 }
1090
1091 public LSLString(double d)
1092 {
1093 string s=String.Format("{0:0.000000}", d);
1094 m_string=s;
1095 }
1096
1049 #endregion 1097 #endregion
1050 1098
1051 #region Operators 1099 #region Operators
@@ -1071,44 +1119,47 @@ namespace OpenSim.Region.ScriptEngine.Common
1071 return new LSLString(s); 1119 return new LSLString(s);
1072 } 1120 }
1073 1121
1074 // Commented out: 1122 public static string ToString(LSLString s)
1075 /* 1123 {
1076 [echo] Build Directory is /home/tedd/opensim/trunk/OpenSim/Region/ScriptEngine/Common/bin/Debug 1124 return s.m_string;
1077 [csc] Compiling 5 files to '/home/tedd/opensim/trunk/OpenSim/Region/ScriptEngine/Common/bin/Debug/OpenSim.Region.ScriptEngine.Common.dll'. 1125 }
1078 [csc] error CS0121: The call is ambiguous between the following methods or properties: `OpenSim.Region.ScriptEngine.Common.LSL_Types.LSLString.operator /(OpenSim.Region.ScriptEngine.Common.LSL_Types.LSLString, OpenSim.Region.ScriptEngine.Common.LSL_Types.LSLString)' and `string.operator /(string, string)' 1126
1079 [csc] /home/tedd/opensim/trunk/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs(602,32): (Location of the symbol related to previous error) 1127 public override string ToString()
1080 [csc] /usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error) 1128 {
1081 [csc] Compilation failed: 1 error(s), 0 warnings 1129 return m_string;
1082 */ 1130 }
1083 //public static bool operator ==(LSLString s1, LSLString s2) 1131
1084 //{ 1132 public static bool operator ==(LSLString s1, string s2)
1085 // return s1.m_string == s2.m_string; 1133 {
1086 //} 1134 return s1.m_string == s2;
1087 //public static bool operator !=(LSLString s1, LSLString s2) 1135 }
1088 //{ 1136
1089 // return s1.m_string != s2.m_string; 1137 public static bool operator !=(LSLString s1, string s2)
1090 //} 1138 {
1139 return s1.m_string != s2;
1140 }
1141
1142 public static explicit operator double(LSLString s)
1143 {
1144 return Convert.ToDouble(s.m_string);
1145 }
1146
1147 public static explicit operator LSLInteger(LSLString s)
1148 {
1149 return new LSLInteger(Convert.ToInt32(s.m_string));
1150 }
1151
1152 public static explicit operator LSLString(double d)
1153 {
1154 return new LSLString(d);
1155 }
1156
1091 #endregion 1157 #endregion
1092 1158
1093 #region Overriders 1159 #region Overriders
1094 public override bool Equals(object o) 1160 public override bool Equals(object o)
1095 { 1161 {
1096 if (o is String) 1162 return m_string == o.ToString();
1097 {
1098 string s = (string)o;
1099 return s == this.m_string;
1100 }
1101 if (o is key)
1102 {
1103 key k = (key)o;
1104 return this.m_string == k.value;
1105 }
1106 if (o is LSLString)
1107 {
1108 LSLString s = (string)o;
1109 return this.m_string == s;
1110 }
1111 return false;
1112 } 1163 }
1113 1164
1114 public override int GetHashCode() 1165 public override int GetHashCode()
@@ -1154,6 +1205,11 @@ namespace OpenSim.Region.ScriptEngine.Common
1154 return i.value; 1205 return i.value;
1155 } 1206 }
1156 1207
1208 static public explicit operator LSLString(LSLInteger i)
1209 {
1210 return new LSLString(i.ToString());
1211 }
1212
1157 static public implicit operator Boolean(LSLInteger i) 1213 static public implicit operator Boolean(LSLInteger i)
1158 { 1214 {
1159 if (i.value == 0) 1215 if (i.value == 0)
@@ -1171,6 +1227,11 @@ namespace OpenSim.Region.ScriptEngine.Common
1171 return new LSLInteger(i); 1227 return new LSLInteger(i);
1172 } 1228 }
1173 1229
1230 static public explicit operator LSLInteger(string s)
1231 {
1232 return new LSLInteger(int.Parse(s));
1233 }
1234
1174 static public implicit operator LSLInteger(double d) 1235 static public implicit operator LSLInteger(double d)
1175 { 1236 {
1176 return new LSLInteger(d); 1237 return new LSLInteger(d);
@@ -1182,6 +1243,17 @@ namespace OpenSim.Region.ScriptEngine.Common
1182 return ret; 1243 return ret;
1183 } 1244 }
1184 1245
1246 public static LSLInteger operator ++(LSLInteger i)
1247 {
1248 i.value++;
1249 return i;
1250 }
1251
1252 public static LSLInteger operator --(LSLInteger i)
1253 {
1254 i.value--;
1255 return i;
1256 }
1185 1257
1186 //static public implicit operator System.Double(LSLInteger i) 1258 //static public implicit operator System.Double(LSLInteger i)
1187 //{ 1259 //{
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
index 521402e..4b7ee84 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
72 { 72 {
73 object[] resobj = new object[] 73 object[] resobj = new object[]
74 { 74 {
75 httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body 75 new LSL_Types.LSLString(httpInfo.reqID.ToString()), new LSL_Types.LSLInteger(httpInfo.status), null, new LSL_Types.LSLString(httpInfo.response_body)
76 }; 76 };
77 77
78 sman.m_EventQueueManager.AddToScriptQueue( 78 sman.m_EventQueueManager.AddToScriptQueue(
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
index 874a905..2b68360 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/Listener.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
58 object[] resobj = new object[] 58 object[] resobj = new object[]
59 { 59 {
60 //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage() 60 //lInfo.GetChannel(), lInfo.GetName(), lInfo.GetID().ToString(), lInfo.GetMessage()
61 lInfo.GetChannel(), lInfo.GetName(), lInfo.GetSourceItemID().ToString(), lInfo.GetMessage() 61 new LSL_Types.LSLInteger(lInfo.GetChannel()), new LSL_Types.LSLString(lInfo.GetName()), new LSL_Types.LSLString(lInfo.GetSourceItemID().ToString()), new LSL_Types.LSLString(lInfo.GetMessage())
62 }; 62 };
63 63
64 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 64 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
index 71ae80c..1210b77 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/SensorRepeat.cs
@@ -314,7 +314,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
314 else 314 else
315 { 315 {
316 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull, 316 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "sensor", EventQueueManager.llDetectNull,
317 new object[] { SensedObjects.Length }); 317 new object[] { new LSL_Types.LSLInteger(SensedObjects.Length) });
318 } 318 }
319 } 319 }
320 } 320 }
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
index c3e1804..63c529a 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/XmlRequest.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
60 //Deliver data to prim's remote_data handler 60 //Deliver data to prim's remote_data handler
61 object[] resobj = new object[] 61 object[] resobj = new object[]
62 { 62 {
63 2, rInfo.GetChannelKey().ToString(), rInfo.GetMessageID().ToString(), String.Empty, 63 new LSL_Types.LSLInteger(2), new LSL_Types.LSLString(rInfo.GetChannelKey().ToString()), new LSL_Types.LSLString(rInfo.GetMessageID().ToString()), new LSL_Types.LSLString(String.Empty),
64 rInfo.GetIntValue(), 64 new LSL_Types.LSLInteger(rInfo.GetIntValue()),
65 rInfo.GetStrVal() 65 new LSL_Types.LSLString(rInfo.GetStrVal())
66 }; 66 };
67 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 67 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
68 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj 68 rInfo.GetLocalID(), rInfo.GetItemID(), "remote_data", EventQueueManager.llDetectNull, resobj
@@ -83,9 +83,9 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugin
83 //Deliver data to prim's remote_data handler 83 //Deliver data to prim's remote_data handler
84 object[] resobj = new object[] 84 object[] resobj = new object[]
85 { 85 {
86 3, srdInfo.channel.ToString(), srdInfo.GetReqID().ToString(), String.Empty, 86 new LSL_Types.LSLInteger(3), new LSL_Types.LSLString(srdInfo.channel.ToString()), new LSL_Types.LSLString(srdInfo.GetReqID().ToString()), new LSL_Types.LSLString(String.Empty),
87 srdInfo.idata, 87 new LSL_Types.LSLInteger(srdInfo.idata),
88 srdInfo.sdata 88 new LSL_Types.LSLString(srdInfo.sdata)
89 }; 89 };
90 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( 90 m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(
91 srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj 91 srdInfo.m_localID, srdInfo.m_itemID, "remote_data", EventQueueManager.llDetectNull, resobj
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
index cbc94e2..3bc01a9 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
100 public void changed(uint localID, uint change) 100 public void changed(uint localID, uint change)
101 { 101 {
102 // Add to queue for all scripts in localID, Object pass change. 102 // Add to queue for all scripts in localID, Object pass change.
103 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "changed", EventQueueManager.llDetectNull, new object[] { (int)change }); 103 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "changed", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(change) });
104 } 104 }
105 105
106 public void state_entry(uint localID) 106 public void state_entry(uint localID)
@@ -115,7 +115,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
115 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 115 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
116 detstruct._key = new LSL_Types.key[1]; 116 detstruct._key = new LSL_Types.key[1];
117 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 117 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
118 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { (int)1 }); 118 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
119 } 119 }
120 120
121 public void touch_end(uint localID, IClientAPI remoteClient) 121 public void touch_end(uint localID, IClientAPI remoteClient)
@@ -124,7 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
124 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct(); 124 EventQueueManager.Queue_llDetectParams_Struct detstruct = new EventQueueManager.Queue_llDetectParams_Struct();
125 detstruct._key = new LSL_Types.key[1]; 125 detstruct._key = new LSL_Types.key[1];
126 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString()); 126 detstruct._key[0] = new LSL_Types.key(remoteClient.AgentId.ToString());
127 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { (int)1 }); 127 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_end", detstruct, new object[] { new LSL_Types.LSLInteger(1) });
128 } 128 }
129 129
130 public void OnRezScript(uint localID, LLUUID itemID, string script) 130 public void OnRezScript(uint localID, LLUUID itemID, string script)
@@ -145,7 +145,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
145 145
146 public void money(uint localID, LLUUID agentID, int amount) 146 public void money(uint localID, LLUUID agentID, int amount)
147 { 147 {
148 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "money", EventQueueManager.llDetectNull, new object[] { agentID.ToString(), (int)amount }); 148 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "money", EventQueueManager.llDetectNull, new object[] { agentID.ToString(), new LSL_Types.LSLInteger(amount) });
149 } 149 }
150 150
151 // TODO: Replace placeholders below 151 // TODO: Replace placeholders below
@@ -154,9 +154,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
154 // then queued in EventQueueManager. 154 // then queued in EventQueueManager.
155 // When queued in EventQueueManager they need to be LSL compatible (name and params) 155 // When queued in EventQueueManager they need to be LSL compatible (name and params)
156 156
157 public void state_exit(uint localID, LLUUID itemID) 157 public void state_exit(uint localID)
158 { 158 {
159 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit", EventQueueManager.llDetectNull); 159 // Add to queue for all scripts in ObjectID object
160 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "state_exit", EventQueueManager.llDetectNull, new object[] { });
160 } 161 }
161 162
162 public void touch(uint localID, LLUUID itemID) 163 public void touch(uint localID, LLUUID itemID)
@@ -166,22 +167,22 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
166 167
167 public void touch_end(uint localID, LLUUID itemID) 168 public void touch_end(uint localID, LLUUID itemID)
168 { 169 {
169 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull); 170 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) });
170 } 171 }
171 172
172 public void collision_start(uint localID, LLUUID itemID) 173 public void collision_start(uint localID, LLUUID itemID)
173 { 174 {
174 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start", EventQueueManager.llDetectNull, new object[] { (int)1 }); 175 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) });
175 } 176 }
176 177
177 public void collision(uint localID, LLUUID itemID) 178 public void collision(uint localID, LLUUID itemID)
178 { 179 {
179 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision", EventQueueManager.llDetectNull, new object[] { (int)1 }); 180 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) });
180 } 181 }
181 182
182 public void collision_end(uint localID, LLUUID itemID) 183 public void collision_end(uint localID, LLUUID itemID)
183 { 184 {
184 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end", EventQueueManager.llDetectNull, new object[] { (int)1 }); 185 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(1) });
185 } 186 }
186 187
187 public void land_collision_start(uint localID, LLUUID itemID) 188 public void land_collision_start(uint localID, LLUUID itemID)
@@ -237,7 +238,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
237 238
238 public void at_target(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos) 239 public void at_target(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos)
239 { 240 {
240 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "at_target", EventQueueManager.llDetectNull, new object[] { (int)handle, new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }); 241 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "at_target", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(handle), new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) });
241 } 242 }
242 243
243 public void not_at_target(uint localID) 244 public void not_at_target(uint localID)
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
index 1c85646..1edd3bd 100644
--- a/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptServerInterfaces.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.ScriptEngine.Common
40 void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient); 40 void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient);
41 void OnRezScript(uint localID, LLUUID itemID, string script); 41 void OnRezScript(uint localID, LLUUID itemID, string script);
42 void OnRemoveScript(uint localID, LLUUID itemID); 42 void OnRemoveScript(uint localID, LLUUID itemID);
43 void state_exit(uint localID, LLUUID itemID); 43 void state_exit(uint localID);
44 void touch(uint localID, LLUUID itemID); 44 void touch(uint localID, LLUUID itemID);
45 void touch_end(uint localID, LLUUID itemID); 45 void touch_end(uint localID, LLUUID itemID);
46 void collision_start(uint localID, LLUUID itemID); 46 void collision_start(uint localID, LLUUID itemID);
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
index fc38ef2..dad1b23 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -319,6 +319,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
319 319
320 private static string CreateCSCompilerScript(string compileScript) 320 private static string CreateCSCompilerScript(string compileScript)
321 { 321 {
322 compileScript = EventReaderRewriter.ReWriteScriptWithPublishedEventsCS(compileScript);
323
322 compileScript = String.Empty + 324 compileScript = String.Empty +
323 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + 325 "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" +
324 String.Empty + "namespace SecondLife { " + 326 String.Empty + "namespace SecondLife { " +
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs
new file mode 100644
index 0000000..46ba850
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/EventReaderRewriter.cs
@@ -0,0 +1,488 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30using System.Collections.Generic;
31using System.Text.RegularExpressions;
32
33namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
34{
35 public static class EventReaderRewriter
36 {
37
38
39 public static string ReWriteScriptWithPublishedEventsCS(string Script)
40 {
41 Dictionary<string, scriptEvents> state_events = new Dictionary<string, scriptEvents>();
42 // Finds out which events are in the script and writes a method call with the events in each state_entry event
43
44 // Note the (?:)? block optional, and not returning a group. Less greedy then .*
45
46 string[] eventmatches = new string[0];
47 //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{");
48 eventmatches = Regex.Split(Script, @"public void\s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^\{]+)?\{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
49 for (int pos = 0; pos < eventmatches.GetUpperBound(0); pos++)
50 {
51 pos++; // garbage
52
53 string statea = eventmatches[pos]; pos++;
54 string eventa = eventmatches[pos];
55 scriptEvents storedEventsForState = scriptEvents.None;
56 if (state_events.ContainsKey(statea))
57 {
58 storedEventsForState = state_events[statea];
59 state_events[statea] |= convertnametoFlag(eventa);
60 }
61 else
62 {
63 state_events.Add(statea, convertnametoFlag(eventa));
64 }
65 Console.WriteLine("State:" + statea + ", event: " + eventa);
66 }
67 Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0));
68 // Add namespace, class name and inheritance
69
70 // Looking *ONLY* for state entry events
71 string scriptCopy = "";
72
73 //Only match State_Entry events now
74 // Note the whole regex is a group, then we have the state this entry belongs to.
75 eventmatches = Regex.Split(Script, @"(public void\s([^_]+)_event_state_entry[\(\)](?:[^\{]+)?\{)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
76 int endloop = eventmatches.GetUpperBound(0);
77
78 // Add all the states to a list of
79 List<string> unUsedStates = new List<string>();
80
81 foreach (string state in state_events.Keys)
82 {
83 unUsedStates.Add(state);
84 }
85
86 // If endloop is 0, then there are no state entry events in the entire script.
87 // Stick a default state entry in there.
88 if (endloop == 0)
89 {
90 if (state_events.ContainsKey("default"))
91 {
92 scriptCopy = "public void default_event_state_entry() {osSetStateEvents((int)" + (int)state_events["default"] + "); } " + Script;
93 unUsedStates.Remove("default");
94 }
95 else
96 {
97 throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details.");
98 }
99 }
100
101 // Loop over state entry events and rewrite the first line to define the events the state listens for.
102 for (int pos = 0; pos < endloop; pos++)
103 {
104 // Returns text before state entry match,
105 scriptCopy += eventmatches[pos]; pos++;
106
107 // Returns text of state entry match,
108 scriptCopy += eventmatches[pos]; pos++;
109
110 // Returns which state we're matching and writes a method call to the end of the above state_entry
111 scriptCopy += "osSetStateEvents((int)" + (int)state_events[eventmatches[pos]] + ");"; //pos++;
112
113 // Remove the state from the unused list. There might be more states matched then defined, so we
114 // check if the state was defined first
115 if (unUsedStates.Contains(eventmatches[pos]))
116 unUsedStates.Remove(eventmatches[pos]);
117
118 // adds the remainder of the script.
119 if ((pos + 1) == endloop)
120 {
121 pos++;
122 scriptCopy += eventmatches[pos++];
123 }
124
125 }
126
127 // states with missing state_entry blocks won't publish their events,
128 // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event
129 foreach (string state in unUsedStates)
130 {
131 // Write the remainder states out into a blank state entry with the event setting routine
132 scriptCopy = "public void " + state + "_event_state_entry() {tosSetStateEvents((int)" + (int)state_events[state] + ");} " + scriptCopy;
133 }
134
135 // save modified script.
136 unUsedStates.Clear();
137 state_events.Clear();
138 return scriptCopy;
139 }
140
141 public static string ReWriteScriptWithPublishedEventsJS(string Script)
142 {
143 Dictionary<string, scriptEvents> state_events = new Dictionary<string, scriptEvents>();
144 // Finds out which events are in the script and writes a method call with the events in each state_entry event
145
146 // Note the (?:)? block optional, and not returning a group. Less greedy then .*
147
148 string[] eventmatches = new string[0];
149 //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{");
150 eventmatches = Regex.Split(Script, @"function \s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^\{]+)?\{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
151 for (int pos = 0; pos < eventmatches.GetUpperBound(0); pos++)
152 {
153 pos++; // garbage
154
155 string statea = eventmatches[pos]; pos++;
156 string eventa = eventmatches[pos];
157 scriptEvents storedEventsForState = scriptEvents.None;
158 if (state_events.ContainsKey(statea))
159 {
160 storedEventsForState = state_events[statea];
161 state_events[statea] |= convertnametoFlag(eventa);
162 }
163 else
164 {
165 state_events.Add(statea, convertnametoFlag(eventa));
166 }
167 Console.WriteLine("State:" + statea + ", event: " + eventa);
168 }
169 Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0));
170 // Add namespace, class name and inheritance
171
172 // Looking *ONLY* for state entry events
173 string scriptCopy = "";
174
175 //Only match State_Entry events now
176 // Note the whole regex is a group, then we have the state this entry belongs to.
177 eventmatches = Regex.Split(Script, @"(function \s([^_]+)_event_state_entry[\(\)](?:[^\{]+)?\{)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
178 int endloop = eventmatches.GetUpperBound(0);
179
180 // Add all the states to a list of
181 List<string> unUsedStates = new List<string>();
182
183 foreach (string state in state_events.Keys)
184 {
185 unUsedStates.Add(state);
186 }
187
188 // If endloop is 0, then there are no state entry events in the entire script.
189 // Stick a default state entry in there.
190 if (endloop == 0)
191 {
192 if (state_events.ContainsKey("default"))
193 {
194 scriptCopy = "function default_event_state_entry() {osSetStateEvents(" + (int)state_events["default"] + "); } " + Script;
195 unUsedStates.Remove("default");
196 }
197 else
198 {
199 throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details.");
200 }
201 }
202
203 // Loop over state entry events and rewrite the first line to define the events the state listens for.
204 for (int pos = 0; pos < endloop; pos++)
205 {
206 // Returns text before state entry match,
207 scriptCopy += eventmatches[pos]; pos++;
208
209 // Returns text of state entry match,
210 scriptCopy += eventmatches[pos]; pos++;
211
212 // Returns which state we're matching and writes a method call to the end of the above state_entry
213 scriptCopy += "osSetStateEvents(" + (int)state_events[eventmatches[pos]] + ");"; //pos++;
214
215 // Remove the state from the unused list. There might be more states matched then defined, so we
216 // check if the state was defined first
217 if (unUsedStates.Contains(eventmatches[pos]))
218 unUsedStates.Remove(eventmatches[pos]);
219
220 // adds the remainder of the script.
221 if ((pos + 1) == endloop)
222 {
223 pos++;
224 scriptCopy += eventmatches[pos++];
225 }
226
227 }
228
229 // states with missing state_entry blocks won't publish their events,
230 // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event
231 foreach (string state in unUsedStates)
232 {
233 // Write the remainder states out into a blank state entry with the event setting routine
234 scriptCopy = "function " + state + "_event_state_entry() {tosSetStateEvents(" + (int)state_events[state] + ");} " + scriptCopy;
235 }
236
237 // save modified script.
238 unUsedStates.Clear();
239 state_events.Clear();
240 return scriptCopy;
241 }
242
243
244 public static string ReWriteScriptWithPublishedEventsVB(string Script)
245 {
246 Dictionary<string, scriptEvents> state_events = new Dictionary<string, scriptEvents>();
247 // Finds out which events are in the script and writes a method call with the events in each state_entry event
248
249 // Note the (?:)? block optional, and not returning a group. Less greedy then .*
250
251 string[] eventmatches = new string[0];
252 //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{");
253 eventmatches = Regex.Split(Script, @"Public Sub\s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^()])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
254 for (int pos = 0; pos < eventmatches.GetUpperBound(0); pos++)
255 {
256 pos++; // garbage
257
258 string statea = eventmatches[pos]; pos++;
259 string eventa = eventmatches[pos];
260 scriptEvents storedEventsForState = scriptEvents.None;
261 if (state_events.ContainsKey(statea))
262 {
263 storedEventsForState = state_events[statea];
264 state_events[statea] |= convertnametoFlag(eventa);
265 }
266 else
267 {
268 state_events.Add(statea, convertnametoFlag(eventa));
269 }
270 Console.WriteLine("State:" + statea + ", event: " + eventa);
271 }
272 Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0));
273 // Add namespace, class name and inheritance
274
275 // Looking *ONLY* for state entry events
276 string scriptCopy = "";
277
278 //Only match State_Entry events now
279 // Note the whole regex is a group, then we have the state this entry belongs to.
280 eventmatches = Regex.Split(Script, @"(Public Sub\s([^_]+)_event_state_entry(?:\s+)?\(\))", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
281 int endloop = eventmatches.GetUpperBound(0);
282
283 // Add all the states to a list of
284 List<string> unUsedStates = new List<string>();
285
286 foreach (string state in state_events.Keys)
287 {
288 unUsedStates.Add(state);
289 }
290
291 // If endloop is 0, then there are no state entry events in the entire script.
292 // Stick a default state entry in there.
293 if (endloop == 0)
294 {
295 if (state_events.ContainsKey("default"))
296 {
297 scriptCopy = "function default_event_state_entry() {osSetStateEvents(" + (int)state_events["default"] + "); } " + Script;
298 unUsedStates.Remove("default");
299 }
300 else
301 {
302 throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details.");
303 }
304 }
305
306 // Loop over state entry events and rewrite the first line to define the events the state listens for.
307 for (int pos = 0; pos < endloop; pos++)
308 {
309 // Returns text before state entry match,
310 scriptCopy += eventmatches[pos]; pos++;
311
312 // Returns text of state entry match,
313 scriptCopy += eventmatches[pos]; pos++;
314
315 // Returns which state we're matching and writes a method call to the end of the above state_entry
316 scriptCopy += "osSetStateEvents(" + (int)state_events[eventmatches[pos]] + ");"; //pos++;
317
318 // Remove the state from the unused list. There might be more states matched then defined, so we
319 // check if the state was defined first
320 if (unUsedStates.Contains(eventmatches[pos]))
321 unUsedStates.Remove(eventmatches[pos]);
322
323 // adds the remainder of the script.
324 if ((pos + 1) == endloop)
325 {
326 pos++;
327 scriptCopy += eventmatches[pos++];
328 }
329
330 }
331
332 // states with missing state_entry blocks won't publish their events,
333 // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event
334 foreach (string state in unUsedStates)
335 {
336 // Write the remainder states out into a blank state entry with the event setting routine
337 scriptCopy = "function " + state + "_event_state_entry() {tosSetStateEvents(" + (int)state_events[state] + ");} " + scriptCopy;
338 }
339
340 // save modified script.
341 unUsedStates.Clear();
342 state_events.Clear();
343 return scriptCopy;
344 }
345
346
347 private static scriptEvents convertnametoFlag(string eventname)
348 {
349 switch (eventname)
350 {
351 case "attach":
352 return scriptEvents.attach;
353 //break;
354 // case "at_rot_target":
355 //return (long)scriptEvents.at_rot_target;
356 //break;
357 case "at_target":
358 return scriptEvents.at_target;
359 //break;
360 //case "changed":
361 //return (long)scriptEvents.changed;
362 //break;
363 case "collision":
364 return scriptEvents.collision;
365 // break;
366 case "collision_end":
367 return scriptEvents.collision_end;
368 //break;
369 case "collision_start":
370 return scriptEvents.collision_start;
371 // break;
372 case "control":
373 return scriptEvents.control;
374 //break;
375 case "dataserver":
376 return scriptEvents.dataserver;
377 // break;
378 case "email":
379 return scriptEvents.email;
380 // break;
381 case "http_response":
382 return scriptEvents.http_response;
383 // break;
384 case "land_collision":
385 return scriptEvents.land_collision;
386 // break;
387 case "land_collision_end":
388 return scriptEvents.land_collision_end;
389 // break;
390 case "land_collision_start":
391 return scriptEvents.land_collision_start;
392 // break;
393 //case "link_message":
394 //return scriptEvents.link_message;
395 // break;
396 case "listen":
397 return scriptEvents.listen;
398 // break;
399 case "money":
400 return scriptEvents.money;
401 // break;
402 case "moving_end":
403 return scriptEvents.moving_end;
404 // break;
405 case "moving_start":
406 return scriptEvents.moving_start;
407 // break;
408 case "not_at_rot_target":
409 return scriptEvents.not_at_rot_target;
410 // break;
411 case "not_at_target":
412 return scriptEvents.not_at_target;
413 // break;
414 // case "no_sensor":
415 //return (long)scriptEvents.no_sensor;
416 //break;
417 //case "on_rez":
418 //return (long)scriptEvents.on_rez;
419 // break;
420 case "remote_data":
421 return scriptEvents.remote_data;
422 // break;
423 case "run_time_permissions":
424 return scriptEvents.run_time_permissions;
425 // break;
426 //case "sensor":
427 //return (long)scriptEvents.sensor;
428 // break;
429 case "state_entry":
430 return scriptEvents.state_entry;
431 // break;
432 case "state_exit":
433 return scriptEvents.state_exit;
434 // break;
435 case "timer":
436 return scriptEvents.timer;
437 // break;
438 case "touch":
439 return scriptEvents.touch;
440 // break;
441 case "touch_end":
442 return scriptEvents.touch_end;
443 // break;
444 case "touch_start":
445 return scriptEvents.touch_start;
446 // break;
447 case "object_rez":
448 return scriptEvents.object_rez;
449 default:
450 return 0;
451 //break;
452 }
453 //return 0;
454 }
455 }
456 [Flags]
457 public enum scriptEvents : int
458 {
459 None = 0,
460 attach = 1,
461 collision = 15,
462 collision_end = 32,
463 collision_start = 64,
464 control = 128,
465 dataserver = 256,
466 email = 512,
467 http_response = 1024,
468 land_collision = 2048,
469 land_collision_end = 4096,
470 land_collision_start = 8192,
471 at_target = 16384,
472 listen = 32768,
473 money = 65536,
474 moving_end = 131072,
475 moving_start = 262144,
476 not_at_rot_target = 524288,
477 not_at_target = 1048576,
478 remote_data = 8388608,
479 run_time_permissions = 268435456,
480 state_entry = 1073741824,
481 state_exit = 2,
482 timer = 4,
483 touch = 8,
484 touch_end = 536870912,
485 touch_start = 2097152,
486 object_rez = 4194304
487 }
488}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index f1e6ebf..06be20e 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -42,16 +42,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
42 //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); 42 //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled);
43 private Dictionary<string, string> dataTypes = new Dictionary<string, string>(); 43 private Dictionary<string, string> dataTypes = new Dictionary<string, string>();
44 private Dictionary<string, string> quotes = new Dictionary<string, string>(); 44 private Dictionary<string, string> quotes = new Dictionary<string, string>();
45 private Dictionary<string, scriptEvents> state_events = new Dictionary<string, scriptEvents>(); 45
46 46
47 public LSL2CSConverter() 47 public LSL2CSConverter()
48 { 48 {
49 // Only the types we need to convert 49 // Only the types we need to convert
50 dataTypes.Add("void", "void"); 50 dataTypes.Add("void", "void");
51 dataTypes.Add("integer", "int"); 51 dataTypes.Add("integer", "LSL_Types.LSLInteger");
52 dataTypes.Add("float", "double"); 52 dataTypes.Add("float", "double");
53 dataTypes.Add("string", "string"); 53 dataTypes.Add("string", "LSL_Types.LSLString");
54 dataTypes.Add("key", "string"); 54 dataTypes.Add("key", "LSL_Types.LSLString");
55 dataTypes.Add("vector", "LSL_Types.Vector3"); 55 dataTypes.Add("vector", "LSL_Types.Vector3");
56 dataTypes.Add("rotation", "LSL_Types.Quaternion"); 56 dataTypes.Add("rotation", "LSL_Types.Quaternion");
57 dataTypes.Add("list", "LSL_Types.list"); 57 dataTypes.Add("list", "LSL_Types.list");
@@ -314,100 +314,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
314 } 314 }
315 315
316 316
317 // Finds out which events are in the script and writes a method call with the events in each state_entry event 317
318
319 // Note the (?:)? block optional, and not returning a group. Less greedy then .*
320
321 string[] eventmatches = new string[0];
322 //Regex stateevents = new Regex(@"(public void )([^_]+)(_event_)([^\(]+)[\(\)]+\s+[^\{]\{");
323 eventmatches = Regex.Split(Script, @"public void\s([^_]+)_event_([^\(]+)\((?:[a-zA-Z0-9\s_,\.\-]+)?\)(?:[^\{]+)?\{", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
324 for (int pos = 0; pos<eventmatches.GetUpperBound(0);pos++)
325 {
326 pos++; // garbage
327
328 string statea = eventmatches[pos]; pos++;
329 string eventa = eventmatches[pos];
330 scriptEvents storedEventsForState = scriptEvents.None;
331 if (state_events.ContainsKey(statea))
332 {
333 storedEventsForState = state_events[statea];
334 state_events[statea] |= convertnametoFlag(eventa);
335 }
336 else
337 {
338 state_events.Add(statea, convertnametoFlag(eventa));
339 }
340 Console.WriteLine("State:" + statea + ", event: " + eventa);
341 }
342 Console.WriteLine("Matches:" + eventmatches.GetUpperBound(0));
343 // Add namespace, class name and inheritance
344
345 // Looking *ONLY* for state entry events
346 string scriptCopy = "";
347
348 //Only match State_Entry events now
349 // Note the whole regex is a group, then we have the state this entry belongs to.
350 eventmatches = Regex.Split(Script, @"(public void\s([^_]+)_event_state_entry[\(\)](?:[^\{]+)?\{)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnoreCase);
351 int endloop = eventmatches.GetUpperBound(0);
352
353 // Add all the states to a list of
354 List<string> unUsedStates = new List<string>();
355 foreach (string state in state_events.Keys)
356 {
357 unUsedStates.Add(state);
358 }
359
360 // If endloop is 0, then there are no state entry events in the entire script.
361 // Stick a default state entry in there.
362 if (endloop == 0)
363 {
364 if (state_events.ContainsKey("default"))
365 {
366 scriptCopy = "\r\n// programmatically added this state entry event.\r\n\r\npublic void default_event_state_entry() {\r\n\tosSetStateEvents((int)" + (int)state_events["default"] + ");\r\n }\r\n\r\n " + Script;
367 unUsedStates.Remove("default");
368 }
369 else
370 {
371 throw new Exception("You must define a default state. Compile failed. See LSL documentation for more details.");
372 }
373 }
374
375 // Loop over state entry events and rewrite the first line to define the events the state listens for.
376 for (int pos = 0; pos < endloop; pos++)
377 {
378 // Returns text before state entry match,
379 scriptCopy += eventmatches[pos]; pos++;
380
381 // Returns text of state entry match,
382 scriptCopy += eventmatches[pos]; pos++;
383
384 // Returns which state we're matching and writes a method call to the end of the above state_entry
385 scriptCopy += "\r\n\t\tosSetStateEvents((int)" + (int)state_events[eventmatches[pos]] + ");"; //pos++;
386
387 // Remove the state from the unused list. There might be more states matched then defined, so we
388 // check if the state was defined first
389 if (unUsedStates.Contains(eventmatches[pos]))
390 unUsedStates.Remove(eventmatches[pos]);
391
392 // adds the remainder of the script.
393 if ((pos + 1) == endloop)
394 {
395 pos++;
396 scriptCopy += eventmatches[pos++];
397 }
398
399 }
400
401 // states with missing state_entry blocks won't publish their events,
402 // so, to fix that we write a state entry with only the event publishing method for states missing a state_entry event
403 foreach (string state in unUsedStates)
404 {
405 // Write the remainder states out into a blank state entry with the event setting routine
406 scriptCopy = "\r\n// programmatically added this state entry event.\r\n\r\npublic void " + state + "_event_state_entry() {\r\n\tosSetStateEvents((int)" + (int)state_events[state] + ");\r\n}\r\n\r\n " + scriptCopy;
407 }
408
409 // save modified script.
410 Script = scriptCopy;
411 //System.Console.WriteLine(Script); 318 //System.Console.WriteLine(Script);
412 Return = String.Empty;// + 319 Return = String.Empty;// +
413 //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;"; 320 //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;";
@@ -421,152 +328,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
421 //Return += @"public Script() { } "; 328 //Return += @"public Script() { } ";
422 Return += Script; 329 Return += Script;
423 //Return += "} }\r\n"; 330 //Return += "} }\r\n";
424 unUsedStates.Clear(); 331
425 state_events.Clear();
426 quotes.Clear(); 332 quotes.Clear();
427 333
428 return Return; 334 return Return;
429 } 335 }
430 public scriptEvents convertnametoFlag(string eventname) 336
431 {
432 switch (eventname)
433 {
434 case "attach":
435 return scriptEvents.attach;
436 //break;
437 // case "at_rot_target":
438 //return (long)scriptEvents.at_rot_target;
439 //break;
440 case "at_target":
441 return scriptEvents.at_target;
442 //break;
443 //case "changed":
444 //return (long)scriptEvents.changed;
445 //break;
446 case "collision":
447 return scriptEvents.collision;
448 // break;
449 case "collision_end":
450 return scriptEvents.collision_end;
451 //break;
452 case "collision_start":
453 return scriptEvents.collision_start;
454 // break;
455 case "control":
456 return scriptEvents.control;
457 //break;
458 case "dataserver":
459 return scriptEvents.dataserver;
460 // break;
461 case "email":
462 return scriptEvents.email;
463 // break;
464 case "http_response":
465 return scriptEvents.http_response;
466 // break;
467 case "land_collision":
468 return scriptEvents.land_collision;
469 // break;
470 case "land_collision_end":
471 return scriptEvents.land_collision_end;
472 // break;
473 case "land_collision_start":
474 return scriptEvents.land_collision_start;
475 // break;
476 //case "link_message":
477 //return scriptEvents.link_message;
478 // break;
479 case "listen":
480 return scriptEvents.listen;
481 // break;
482 case "money":
483 return scriptEvents.money;
484 // break;
485 case "moving_end":
486 return scriptEvents.moving_end;
487 // break;
488 case "moving_start":
489 return scriptEvents.moving_start;
490 // break;
491 case "not_at_rot_target":
492 return scriptEvents.not_at_rot_target;
493 // break;
494 case "not_at_target":
495 return scriptEvents.not_at_target;
496 // break;
497 // case "no_sensor":
498 //return (long)scriptEvents.no_sensor;
499 //break;
500 //case "on_rez":
501 //return (long)scriptEvents.on_rez;
502 // break;
503 case "remote_data":
504 return scriptEvents.remote_data;
505 // break;
506 case "run_time_permissions":
507 return scriptEvents.run_time_permissions;
508 // break;
509 //case "sensor":
510 //return (long)scriptEvents.sensor;
511 // break;
512 case "state_entry":
513 return scriptEvents.state_entry;
514 // break;
515 case "state_exit":
516 return scriptEvents.state_exit;
517 // break;
518 case "timer":
519 return scriptEvents.timer;
520 // break;
521 case "touch":
522 return scriptEvents.touch;
523 // break;
524 case "touch_end":
525 return scriptEvents.touch_end;
526 // break;
527 case "touch_start":
528 return scriptEvents.touch_start;
529 // break;
530 case "object_rez":
531 return scriptEvents.object_rez;
532 default:
533 return 0;
534 //break;
535 }
536 //return 0;
537 }
538 } 337 }
539 338
540 [Flags] 339
541 public enum scriptEvents : int 340}
542 {
543 None = 0,
544 attach = 1,
545 collision = 15,
546 collision_end = 32,
547 collision_start = 64,
548 control = 128,
549 dataserver = 256,
550 email = 512,
551 http_response = 1024,
552 land_collision = 2048,
553 land_collision_end = 4096,
554 land_collision_start = 8192,
555 at_target = 16384,
556 listen = 32768,
557 money = 65536,
558 moving_end = 131072,
559 moving_start = 262144,
560 not_at_rot_target = 524288,
561 not_at_target = 1048576,
562 remote_data = 8388608,
563 run_time_permissions = 268435456,
564 state_entry = 1073741824,
565 state_exit = 2,
566 timer = 4,
567 touch = 8,
568 touch_end = 536870912,
569 touch_start = 2097152,
570 object_rez = 4194304
571 }
572} \ No newline at end of file