diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index e0cf1e5..136b613 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | |||
@@ -252,5 +252,119 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
252 | return c; | 252 | return c; |
253 | } | 253 | } |
254 | } | 254 | } |
255 | |||
256 | [Serializable] | ||
257 | public class list | ||
258 | { | ||
259 | private object[] m_data; | ||
260 | public list(params object[] args) | ||
261 | { | ||
262 | m_data = new object[args.Length]; | ||
263 | m_data = args; | ||
264 | } | ||
265 | public int Length | ||
266 | { | ||
267 | get { return m_data.Length; } | ||
268 | } | ||
269 | public object[] Data | ||
270 | { | ||
271 | get { return m_data; } | ||
272 | } | ||
273 | public static list operator +(list a, list b) | ||
274 | { | ||
275 | object[] tmp; | ||
276 | tmp = new object[a.Length + b.Length]; | ||
277 | a.Data.CopyTo(tmp, 0); | ||
278 | b.Data.CopyTo(tmp, a.Length); | ||
279 | return new list(tmp); | ||
280 | } | ||
281 | public list GetSublist(int start, int end) | ||
282 | { | ||
283 | Console.WriteLine("GetSublist(" + start.ToString() + "," + end.ToString() + ")"); | ||
284 | object[] ret; | ||
285 | // Take care of neg start or end's | ||
286 | if (start < 0) | ||
287 | { | ||
288 | start = m_data.Length + start; | ||
289 | } | ||
290 | if (end < 0) | ||
291 | { | ||
292 | end = m_data.Length + end; | ||
293 | } | ||
294 | |||
295 | // Case start < end | ||
296 | |||
297 | if (start <= end) | ||
298 | { | ||
299 | if (start >= m_data.Length) | ||
300 | { | ||
301 | return new list(); | ||
302 | } | ||
303 | if (end >= m_data.Length) | ||
304 | { | ||
305 | end = m_data.Length - 1; | ||
306 | } | ||
307 | ret = new object[end - start + 1]; | ||
308 | Array.Copy(m_data, start, ret, 0, end - start + 1); | ||
309 | return new list(ret); | ||
310 | } | ||
311 | else | ||
312 | { | ||
313 | if (start >= m_data.Length) | ||
314 | { | ||
315 | return this.GetSublist(0, end); | ||
316 | } | ||
317 | if (end >= m_data.Length) | ||
318 | { | ||
319 | return new list(); | ||
320 | } | ||
321 | // end < start | ||
322 | //ret = new object[m_data.Length - Math.Abs(end - start + 1)]; | ||
323 | //Array.Copy(m_data, 0, ret, m_data.Length - start, end + 1); | ||
324 | //Array.Copy(m_data, start, ret, 0, m_data.Length - start); | ||
325 | return this.GetSublist(0, end) + this.GetSublist(start, this.Data.Length - 1); | ||
326 | //return new list(ret); | ||
327 | } | ||
328 | } | ||
329 | |||
330 | public string ToPrettyString() | ||
331 | { | ||
332 | string output; | ||
333 | if (m_data.Length == 0) | ||
334 | { | ||
335 | return "[]"; | ||
336 | } | ||
337 | output = "["; | ||
338 | foreach (object o in m_data) | ||
339 | { | ||
340 | if (o.GetType().ToString() == "System.String") | ||
341 | { | ||
342 | output = output + "\"" + o + "\", "; | ||
343 | } | ||
344 | else | ||
345 | { | ||
346 | output = output + o.ToString() + ", "; | ||
347 | } | ||
348 | } | ||
349 | output = output.Substring(0, output.Length - 2); | ||
350 | output = output + "]"; | ||
351 | return output; | ||
352 | } | ||
353 | public override string ToString() | ||
354 | { | ||
355 | string output; | ||
356 | output = ""; | ||
357 | if (m_data.Length == 0) | ||
358 | { | ||
359 | return ""; | ||
360 | } | ||
361 | foreach (object o in m_data) | ||
362 | { | ||
363 | output = output + o.ToString(); | ||
364 | } | ||
365 | return output; | ||
366 | } | ||
367 | } | ||
255 | } | 368 | } |
369 | |||
256 | } | 370 | } |