diff --git a/trunk/SecondLife/Float.cs b/trunk/SecondLife/Float.cs index e4bf32e..16bc30c 100644 --- a/trunk/SecondLife/Float.cs +++ b/trunk/SecondLife/Float.cs @@ -20,7 +20,7 @@ // ******** // * LSLEditor, a External editor for the LSL Language. // * Copyright (C) 2010 The LSLEditor Group. -// +// // * This program is free software; you can redistribute it and/or // * modify it under the terms of the GNU General Public License // * as published by the Free Software Foundation; either version 2 @@ -36,7 +36,7 @@ // * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // ******** // * -// * The above copyright notice and this permission notice shall be included in all +// * The above copyright notice and this permission notice shall be included in all // * copies or substantial portions of the Software. // * // ******** @@ -47,227 +47,371 @@ using System.Text.RegularExpressions; namespace LSLEditor { + /// + /// This part of the SecondLife class defines the Float struct. + /// + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText", Justification = "Reviewed.")] public partial class SecondLife { + /// + /// A struct for Float objects. + /// public struct Float { - private object m_value; + /// + /// Stores the Float value. + /// + private object objValue; + + /// + /// Gets or sets the value of the Float. + /// + /// Gets or sets the objValue data member. private Double value { get { - if (m_value == null) - m_value = (Double)0; - return (Double)m_value; + if (objValue == null) { + objValue = (Double)0; + } + return (Double)objValue; } + set { - m_value = value; + objValue = value; } } + + /// + /// Initialises a new instance of the struct. + /// + /// public Float(Double a) { - this.m_value = a; + this.objValue = a; } #region public Float(string s) + /// + /// Initialises a new instance of the struct. + /// + /// public Float(string s) { - Regex r = new Regex(@"\A[ ]*(?[+-]?) - (?: - (?: - 0x - (?: - (?: - (?[0-9a-f]*) - (?: - (?:\. - (?[0-9a-f]*) - ) - | - ) - ) - (?: - (?:p - (?[-+]?[\d]*) - ) - | - ) - ) - ) - | - (? - [\d]*[.]?[\d]* - (?: - (?: - e[+-]?[\d]* - ) - | - ) - ) - )", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); + Regex r = new Regex( + @"\A[ ]*(?[+-]?) + (?: + (?: + 0x + (?: + (?: + (?[0-9a-f]*) + (?: + (?:\. + (?[0-9a-f]*) + ) + | + ) + ) + (?: + (?:p + (?[-+]?[\d]*) + ) + | + ) + ) + ) + | + (? + [\d]*[.]?[\d]* + (?: + (?: + e[+-]?[\d]* + ) + | + ) + ) + )", + RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace); Match m = r.Match(s); Double mantissa = 0.0; - if (r.Match(s).Groups["dec"].Value.Length > 0) + if (r.Match(s).Groups["dec"].Value.Length > 0) { mantissa = Convert.ToDouble(r.Match(s).Groups["dec"].Value); - if (m.Groups["int"].Success) - { - if (m.Groups["int"].Value.Length > 0) - { - // System.Console.WriteLine("i:\t" + m.Groups["int"].Value); + } + if (m.Groups["int"].Success) { + if (m.Groups["int"].Value.Length > 0) { + ////System.Console.WriteLine("i:\t" + m.Groups["int"].Value); mantissa = Convert.ToInt64(m.Groups["int"].Value, 16); } - if (m.Groups["frac"].Value.Length > 0) - { - // System.Console.WriteLine("f:\t"+m.Groups["frac"].Value); + if (m.Groups["frac"].Value.Length > 0) { + ////System.Console.WriteLine("f:\t"+m.Groups["frac"].Value); mantissa += Convert.ToInt64(m.Groups["frac"].Value, 16) / Math.Pow(16.0, m.Groups["frac"].Value.Length); } - if (m.Groups["exp"].Value.Length > 0) - { - // System.Console.WriteLine("e:\t" + m.Groups["exp"].Value); + if (m.Groups["exp"].Value.Length > 0) { + ////System.Console.WriteLine("e:\t" + m.Groups["exp"].Value); mantissa *= Math.Pow(2.0, Convert.ToInt64(m.Groups["exp"].Value, 10)); } } - if (m.Groups["sign"].Value == "-") - this.m_value = -mantissa; - else - this.m_value = mantissa; + if (m.Groups["sign"].Value == "-") { + this.objValue = -mantissa; + } else { + this.objValue = mantissa; + } } -#endregion + #endregion + /// + /// No idea of the intention here ;-). + /// + /// The Float value as a 32 bit number. public override int GetHashCode() { return (int)this.value % System.Int32.MaxValue; } + /// + /// Converts the Float to a string representation. + /// + /// String representation of the Float. public override string ToString() { - return string.Format("{0:0.000000}",this.value); + return string.Format("{0:0.000000}", this.value); } + /// + /// Converts the Float to a string representation. + /// + /// + /// String representation of the Float. public static explicit operator String(Float x) { return x.ToString(); } + /// + /// Converts the Float to a string representation. + /// + /// + /// String representation of the Float. public static implicit operator Double(Float x) { return x.value; } - //public static implicit operator integer(Float x) - //{ - // return (int)x.value; - //} + ////public static implicit operator integer(Float x) + ////{ + //// return (int)x.value; + ////} + /// + /// Creates a new instance of a Float from a string. + /// + /// + /// A new Float instance. public static explicit operator Float(string s) { return new Float(s); } + /// + /// Creates a new instance of a Float from a String. + /// + /// + /// A new Float instance. public static explicit operator Float(String s) { return new Float(s.ToString()); } + /// + /// Creates a new instance of a Float from an Int32 . + /// + /// + /// A new Float instance. public static implicit operator Float(Int32 x) { return new Float((Double)x); } - // 6 jan 2008 , does this work???? + /// + /// Creates a new instance of a Float from a long. + /// + /// + /// A new Float instance. public static implicit operator Float(long x) { - return new Float((int)(uint)x); + return new Float((int)(uint)x); // 6 jan 2008 , does this work???? } + /// + /// Creates a new instance of a Float from a Double. + /// + /// + /// A new Float instance. public static implicit operator Float(Double x) { return new Float(x); } + /// + /// Creates a new instance of a Float from an integer type. + /// + /// + /// A new Float instance. public static implicit operator Float(integer x) { return new Float((Double)x); } + /// + /// Calculates the result of multiplying a and b. + /// + /// + /// + /// The product of a and b. public static Float operator *(Float a, Float b) { return new Float(a.value * b.value); } + /// + /// Calculates the result of dividing a by b. + /// + /// + /// + /// The result of dividing a by b. public static Float operator /(Float a, Float b) { return new Float(a.value / b.value); } + /// + /// Calculates the result of incrementing the Float's value. + /// + /// + /// The result of incrementing the Float's value. public static Float operator ++(Float a) { return new Float(a.value + 1.0); } + /// + /// Calculates the result of decrementing the Float's value. + /// + /// + /// The result of decrementing the Float's value. public static Float operator --(Float a) { return new Float(a.value - 1.0); } + /// + /// Calculates the result of adding a to b. + /// + /// + /// + /// The result of adding a to b. public static Float operator +(Float a, Float b) { return new Float(a.value + b.value); } + /// + /// Calculates the result of subtracting a from b. + /// + /// + /// + /// The result of subtracting a from b. public static Float operator -(Float a, Float b) { return new Float(a.value - b.value); } + /// + /// Casts the Float to a boolean. + /// + /// + /// A boolean value. public static explicit operator bool(Float a) { - return (Math.Abs(a.value) >= Double.Epsilon); + return Math.Abs(a.value) >= Double.Epsilon; } + /// + /// Defines a boolean true value. + /// + /// + /// A boolean indicating whether the value is considered true. public static bool operator true(Float a) { - return (Math.Abs(a.value) >= Double.Epsilon); + return Math.Abs(a.value) >= Double.Epsilon; } + /// + /// Defines a boolean false value. + /// + /// + /// A boolean indicating whether the value is considered false. public static bool operator false(Float a) { - return (Math.Abs(a.value) < Double.Epsilon); + return Math.Abs(a.value) < Double.Epsilon; } + /// + /// Defines the equality operator. + /// + /// First operand. + /// Second operand. + /// A boolean value indicating equality. public static bool operator ==(Float x, Float y) { - return (Math.Abs(x.value - y.value) < Double.Epsilon); + return Math.Abs(x.value - y.value) < Double.Epsilon; } + /// + /// Defines the inequality operator. + /// + /// First operand. + /// Second operand. + /// A boolean value indicating inequality. public static bool operator !=(Float x, Float y) { return !(x == y); } + /// + /// Compares two Floats. + /// + /// First operand. + /// Second operand. + /// An integer (-1, 0, or 1), indicating whether the first item is less than, same as, or greater than the second. public static int Compare(Float a, Float b) { - if (a.value < b.value) - return -1; - if (a.value > b.value) - return 1; - return 0; + int intResult = 0; + if (a.value < b.value) { + intResult = -1; + } else if (a.value > b.value) { + intResult = 1; + } + return intResult; } - + /// + /// Defines the Equals operator. + /// + /// + /// A boolean value indicating equality. public override bool Equals(object o) { - try - { - return (bool)(this == (Float)o); - } - catch - { - return false; + bool blnResult; + try { + blnResult = (bool)(this == (Float)o); + } catch { + blnResult = false; } + return blnResult; } - } } } diff --git a/trunk/SecondLife/LSL_Events.cs b/trunk/SecondLife/LSL_Events.cs index 4494b09..ef762be 100644 --- a/trunk/SecondLife/LSL_Events.cs +++ b/trunk/SecondLife/LSL_Events.cs @@ -51,7 +51,7 @@ namespace LSLEditor /// /// This part of the SecondLife class contains the Event definitions. /// - [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1502:ElementMustNotBeOnASingleLine", Justification = "Reviewed.")] + [SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1502:ElementMustNotBeOnSingleLine", Justification = "Reviewed.")] [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "These are all LSL functions, the documentation is in the LSL Wiki.")] public partial class SecondLife {