aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTedd Hansen2008-01-01 14:23:14 +0000
committerTedd Hansen2008-01-01 14:23:14 +0000
commit8d79a5d93cddd55de86646ed7a7f3baa95778fee (patch)
treee49b3cd4a1cb209053e7f8ab16f143ab8b10d80e /OpenSim
parentAdrianas 0000272 -- I think we need to implement standard string/integer/floa... (diff)
downloadopensim-SC_OLD-8d79a5d93cddd55de86646ed7a7f3baa95778fee.zip
opensim-SC_OLD-8d79a5d93cddd55de86646ed7a7f3baa95778fee.tar.gz
opensim-SC_OLD-8d79a5d93cddd55de86646ed7a7f3baa95778fee.tar.bz2
opensim-SC_OLD-8d79a5d93cddd55de86646ed7a7f3baa95778fee.tar.xz
Minor changes. Changed Prebuild.xml to avoid first-time-compile error because of dependencies. Made some changes to new LSLString.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_Types.cs636
1 files changed, 330 insertions, 306 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
index a3bbced..aee1f5a 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs
@@ -36,310 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Common
36 { 36 {
37 37
38 // 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] 39
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 }
342
343 [Serializable] 40 [Serializable]
344 public struct Vector3 41 public struct Vector3
345 { 42 {
@@ -745,11 +442,23 @@ namespace OpenSim.Region.ScriptEngine.Common
745 442
746 } 443 }
747 444
748 public struct String 445
446
447
448 //
449 // BELOW IS WORK IN PROGRESS... IT WILL CHANGE, SO DON'T USE YET! :)
450 //
451
452
453
454
455
456
457 public struct StringTest
749 { 458 {
750 // Our own little string 459 // Our own little string
751 internal string actualString; 460 internal string actualString;
752 public static implicit operator bool(String mString) 461 public static implicit operator bool(StringTest mString)
753 { 462 {
754 if (mString.actualString.Length == 0) 463 if (mString.actualString.Length == 0)
755 return true; 464 return true;
@@ -762,6 +471,321 @@ namespace OpenSim.Region.ScriptEngine.Common
762 471
763 } 472 }
764 473
474 [Serializable]
475 public struct key
476 {
477 public string value;
478
479 #region Constructors
480 public key(string s)
481 {
482 value = s;
483 }
484
485 #endregion
486
487 #region Methods
488
489 static public bool Parse2Key(string s)
490 {
491 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);
492 if (isuuid.IsMatch(s))
493 {
494 return true;
495 }
496 else
497 {
498 return false;
499 }
500 }
501
502 #endregion
503
504 #region Operators
505
506 static public implicit operator System.Boolean(key k)
507 {
508 if (k.value.Length == 0)
509 {
510 return false;
511 }
512
513 if (k.value == "00000000-0000-0000-0000-000000000000")
514 {
515 return false;
516 }
517 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);
518 if (isuuid.IsMatch(k.value))
519 {
520 return true;
521 }
522 else
523 {
524 return false;
525 }
526 }
527
528 static public implicit operator key(string s)
529 {
530 return new key(s);
531 }
532
533 static public implicit operator System.String(key k)
534 {
535 return k.value;
536 }
537
538 public static bool operator ==(key k1, key k2)
539 {
540 return k1.value == k2.value;
541 }
542 public static bool operator !=(key k1, key k2)
543 {
544 return k1.value != k2.value;
545 }
546
547 #endregion
548
549 #region Overriders
550
551 public override bool Equals(object o)
552 {
553 if (o is String)
554 {
555 string s = (string)o;
556 return s == this.value;
557 }
558 if (o is key)
559 {
560 key k = (key)o;
561 return this.value == k.value;
562 }
563 return false;
564 }
565
566 public override int GetHashCode()
567 {
568 return value.GetHashCode();
569 }
570
571 #endregion
572 }
573
574 [Serializable]
575 public struct LSLString
576 {
577 public string m_string;
578 #region Constructors
579 public LSLString(string s)
580 {
581 m_string = s;
582 }
583 #endregion
584
585 #region Operators
586 static public implicit operator System.Boolean(LSLString s)
587 {
588 if (s.m_string.Length == 0)
589 {
590 return false;
591 }
592 else
593 {
594 return true;
595 }
596 }
597
598 static public implicit operator System.String(LSLString s)
599 {
600 return s.m_string;
601 }
602
603 static public implicit operator LSLString(string s)
604 {
605 return new LSLString(s);
606 }
607
608 public static bool operator ==(LSLString s1, LSLString s2)
609 {
610 return s1.m_string == s2.m_string;
611 }
612 public static bool operator !=(LSLString s1, LSLString s2)
613 {
614 return s1.m_string != s2.m_string;
615 }
616 #endregion
617
618 #region Overriders
619 public override bool Equals(object o)
620 {
621 if (o is String)
622 {
623 string s = (string)o;
624 return s == this.m_string;
625 }
626 if (o is key)
627 {
628 key k = (key)o;
629 return this.m_string == k.value;
630 }
631 if (o is LSLString)
632 {
633 LSLString s = (string)o;
634 return this.m_string == s;
635 }
636 return false;
637 }
638
639 public override int GetHashCode()
640 {
641 return m_string.GetHashCode();
642 }
643
644 #endregion
645
646 #region " Standard string functions "
647 //Clone,CompareTo,Contains
648 //CopyTo,EndsWith,Equals,GetEnumerator,GetHashCode,GetType,GetTypeCode
649 //IndexOf,IndexOfAny,Insert,IsNormalized,LastIndexOf,LastIndexOfAny
650 //Length,Normalize,PadLeft,PadRight,Remove,Replace,Split,StartsWith,Substring,ToCharArray,ToLowerInvariant
651 //ToString,ToUpper,ToUpperInvariant,Trim,TrimEnd,TrimStart
652 public bool Contains(string value) { return m_string.Contains(value); }
653 public int IndexOf(string value) { return m_string.IndexOf(value); }
654 public int Length { get { return m_string.Length; } }
655
656
657 #endregion
658 }
659
660 [Serializable]
661 public struct LSLInteger
662 {
663 public int value;
664
665 #region Constructors
666 public LSLInteger(int i)
667 {
668 value = i;
669 }
670
671 public LSLInteger(double d)
672 {
673 value = (int)d;
674 }
675
676 #endregion
677 static public implicit operator System.Int32(LSLInteger i)
678 {
679 return i.value;
680 }
681
682 static public implicit operator System.Boolean(LSLInteger i)
683 {
684 if (i.value == 0)
685 {
686 return false;
687 }
688 else
689 {
690 return true;
691 }
692 }
693
694 static public implicit operator LSLInteger(int i)
695 {
696 return new LSLInteger(i);
697 }
698
699 static public implicit operator LSLInteger(double d)
700 {
701 return new LSLInteger(d);
702 }
703
704 static public LSLInteger operator &(LSLInteger i1, LSLInteger i2)
705 {
706 int ret = i1.value & i2.value;
707 return ret;
708 }
709
710
711 //static public implicit operator System.Double(LSLInteger i)
712 //{
713 // return (double)i.value;
714 //}
715
716 #region Overriders
717
718 public override string ToString()
719 {
720 return this.value.ToString();
721 }
722
723 #endregion
724 }
725
726 [Serializable]
727 public struct LSLFloat
728 {
729 public double value;
730
731 #region Constructors
732 public LSLFloat(int i)
733 {
734 this.value = (double)i;
735 }
736
737 public LSLFloat(double d)
738 {
739 this.value = d;
740 }
741
742 #endregion
743
744 #region Operators
745
746 static public implicit operator System.Double(LSLFloat f)
747 {
748 return f.value;
749 }
750
751 //static public implicit operator System.Int32(LSLFloat f)
752 //{
753 // return (int)f.value;
754 //}
755
756
757 static public implicit operator System.Boolean(LSLFloat f)
758 {
759 if (f.value == 0)
760 {
761 return false;
762 }
763 else
764 {
765 return true;
766 }
767 }
768
769 static public implicit operator LSLFloat(int i)
770 {
771 return new LSLFloat(i);
772 }
773
774 static public implicit operator LSLFloat(double d)
775 {
776 return new LSLFloat(d);
777 }
778 #endregion
779
780 #region Overriders
781 public override string ToString()
782 {
783 return this.value.ToString();
784 }
785 #endregion
786 }
787
788
765 } 789 }
766 } 790 }
767} 791}