aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorTedd Hansen2008-01-01 11:41:07 +0000
committerTedd Hansen2008-01-01 11:41:07 +0000
commit86a38dfd0f65fad2eca455c3f145d4cf4629068f (patch)
tree2a9c2ca9737a4e91b6a134278c31731651ec7080 /OpenSim/Region/ScriptEngine
parentFixed string issue in compiler (diff)
downloadopensim-SC-86a38dfd0f65fad2eca455c3f145d4cf4629068f.zip
opensim-SC-86a38dfd0f65fad2eca455c3f145d4cf4629068f.tar.gz
opensim-SC-86a38dfd0f65fad2eca455c3f145d4cf4629068f.tar.bz2
opensim-SC-86a38dfd0f65fad2eca455c3f145d4cf4629068f.tar.xz
Adrianas 0000272 -- I think we need to implement standard string/integer/float functions too.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs304
1 files changed, 304 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index 612dae1..a3bbced 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -27,6 +27,7 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Text.RegularExpressions;
30 31
31namespace OpenSim.Region.ScriptEngine.Common 32namespace OpenSim.Region.ScriptEngine.Common
32{ 33{
@@ -35,6 +36,309 @@ namespace OpenSim.Region.ScriptEngine.Common
35 { 36 {
36 37
37 // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain 38 // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain
39 [Serializable]
40 public struct key
41 {
42 public string value;
43
44 #region Constructors
45 public key(string s)
46 {
47 value = s;
48 }
49
50 #endregion
51
52 #region Methods
53
54 static public bool Parse2Key(string s)
55 {
56 Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled);
57 if (isuuid.IsMatch(s))
58 {
59 return true;
60 }
61 else
62 {
63 return false;
64 }
65 }
66
67 #endregion
68
69 #region Operators
70
71 static public implicit operator System.Boolean(key k)
72 {
73 if (k.value.Length == 0)
74 {
75 return false;
76 }
77
78 if (k.value == "00000000-0000-0000-0000-000000000000")
79 {
80 return false;
81 }
82 Regex isuuid = new Regex(@"^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$", RegexOptions.Compiled);
83 if (isuuid.IsMatch(k.value))
84 {
85 return true;
86 }
87 else
88 {
89 return false;
90 }
91 }
92
93 static public implicit operator key(string s)
94 {
95 return new key(s);
96 }
97
98 static public implicit operator System.String(key k)
99 {
100 return k.value;
101 }
102
103 public static bool operator ==(key k1, key k2)
104 {
105 return k1.value == k2.value;
106 }
107 public static bool operator !=(key k1, key k2)
108 {
109 return k1.value != k2.value;
110 }
111
112 #endregion
113
114 #region Overriders
115
116 public override bool Equals(object o)
117 {
118 if (o is String)
119 {
120 string s = (string)o;
121 return s == this.value;
122 }
123 if (o is key)
124 {
125 key k = (key)o;
126 return this.value == k.value;
127 }
128 return false;
129 }
130
131 public override int GetHashCode()
132 {
133 return value.GetHashCode();
134 }
135
136 #endregion
137 }
138
139 [Serializable]
140 public struct LSLString
141 {
142 public string value;
143
144 #region Constructors
145
146 public LSLString(string s)
147 {
148 value = s;
149 }
150
151 #endregion
152
153 #region Operators
154 static public implicit operator System.Boolean(LSLString s)
155 {
156 if (s.value.Length == 0)
157 {
158 return false;
159 }
160 else
161 {
162 return true;
163 }
164 }
165
166 static public implicit operator System.String(LSLString s)
167 {
168 return s.value;
169 }
170
171 static public implicit operator LSLString(string s)
172 {
173 return new LSLString(s);
174 }
175
176 public static bool operator ==(LSLString s1, LSLString s2)
177 {
178 return s1.value == s2.value;
179 }
180 public static bool operator !=(LSLString s1, LSLString s2)
181 {
182 return s1.value != s2.value;
183 }
184 #endregion
185
186 #region Overriders
187 public override bool Equals(object o)
188 {
189 if (o is String)
190 {
191 string s = (string)o;
192 return s == this.value;
193 }
194 if (o is key)
195 {
196 key k = (key)o;
197 return this.value == k.value;
198 }
199 if (o is LSLString)
200 {
201 LSLString s = (string)o;
202 return this.value == s.value;
203 }
204 return false;
205 }
206
207 public override int GetHashCode()
208 {
209 return value.GetHashCode();
210 }
211
212 #endregion
213 }
214
215 [Serializable]
216 public struct LSLInteger
217 {
218 public int value;
219
220 #region Constructors
221 public LSLInteger(int i)
222 {
223 value = i;
224 }
225
226 public LSLInteger(double d)
227 {
228 value = (int)d;
229 }
230
231 #endregion
232 static public implicit operator System.Int32(LSLInteger i)
233 {
234 return i.value;
235 }
236
237 static public implicit operator System.Boolean(LSLInteger i)
238 {
239 if (i.value == 0)
240 {
241 return false;
242 }
243 else
244 {
245 return true;
246 }
247 }
248
249 static public implicit operator LSLInteger(int i)
250 {
251 return new LSLInteger(i);
252 }
253
254 static public implicit operator LSLInteger(double d)
255 {
256 return new LSLInteger(d);
257 }
258
259 static public LSLInteger operator &(LSLInteger i1, LSLInteger i2)
260 {
261 int ret = i1.value & i2.value;
262 return ret;
263 }
264
265
266 //static public implicit operator System.Double(LSLInteger i)
267 //{
268 // return (double)i.value;
269 //}
270
271 #region Overriders
272
273 public override string ToString()
274 {
275 return this.value.ToString();
276 }
277
278 #endregion
279 }
280
281 [Serializable]
282 public struct LSLFloat
283 {
284 public double value;
285
286 #region Constructors
287 public LSLFloat(int i)
288 {
289 this.value = (double)i;
290 }
291
292 public LSLFloat(double d)
293 {
294 this.value = d;
295 }
296
297 #endregion
298
299 #region Operators
300
301 static public implicit operator System.Double(LSLFloat f)
302 {
303 return f.value;
304 }
305
306 //static public implicit operator System.Int32(LSLFloat f)
307 //{
308 // return (int)f.value;
309 //}
310
311
312 static public implicit operator System.Boolean(LSLFloat f)
313 {
314 if (f.value == 0)
315 {
316 return false;
317 }
318 else
319 {
320 return true;
321 }
322 }
323
324 static public implicit operator LSLFloat(int i)
325 {
326 return new LSLFloat(i);
327 }
328
329 static public implicit operator LSLFloat(double d)
330 {
331 return new LSLFloat(d);
332 }
333 #endregion
334
335 #region Overriders
336 public override string ToString()
337 {
338 return this.value.ToString();
339 }
340 #endregion
341 }
38 342
39 [Serializable] 343 [Serializable]
40 public struct Vector3 344 public struct Vector3