2007-08-17 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / Mono / DataConverter.cs
index f212d684fb5785595311345210b22db84e47e0ea..34ff82ee1d9b02c98a6f6da8078a4f6ada0218f2 100644 (file)
@@ -46,6 +46,10 @@ namespace Mono {
        unsafe public abstract class DataConverter {
 #else
        unsafe internal abstract class DataConverter {
+
+// Disables the warning: CLS compliance checking will not be performed on
+//  `XXXX' because it is not visible from outside this assembly
+#pragma warning disable  3019
 #endif
                static DataConverter SwapConv = new SwapConverter ();
                static DataConverter CopyConv = new CopyConverter ();
@@ -341,6 +345,8 @@ namespace Mono {
                //
                static bool PackOne (PackContext b, object oarg)
                {
+                       int n;
+                       
                        switch (b.description [b.i]){
                        case '^':
                                b.conv = BigEndian;
@@ -421,7 +427,7 @@ namespace Mono {
                                for (j = b.i+1; j < b.description.Length; j++){
                                        if (b.description [j] == ']')
                                                break;
-                                       int n = ((short) b.description [j]) - ((short) '0');
+                                       n = ((short) b.description [j]) - ((short) '0');
                                        if (n >= 0 && n <= 9){
                                                if (count == -1)
                                                        count = n;
@@ -437,7 +443,6 @@ namespace Mono {
                                
                        case '$': case 'z':
                                bool add_null = b.description [b.i] == 'z';
-                               int n;
                                b.i++;
                                if (b.i >= b.description.Length)
                                        throw new ArgumentException ("$ description needs a type specified", "description");
@@ -504,7 +509,7 @@ namespace Mono {
                        ArrayList result = new ArrayList ();
                        int idx = startIndex;
                        bool align = false;
-                       int repeat = 0;
+                       int repeat = 0, n;
                        
                        for (int i = 0; i < description.Length && idx < buffer.Length; ){
                                int save = i;
@@ -621,7 +626,7 @@ namespace Mono {
                                        for (j = i+1; j < description.Length; j++){
                                                if (description [j] == ']')
                                                        break;
-                                               int n = ((short) description [j]) - ((short) '0');
+                                               n = ((short) description [j]) - ((short) '0');
                                                if (n >= 0 && n <= 9){
                                                        if (count == -1)
                                                                count = n;
@@ -637,7 +642,6 @@ namespace Mono {
                                
                                case '$': case 'z':
                                        // bool with_null = description [i] == 'z';
-                                       int n;
                                        i++;
                                        if (i >= description.Length)
                                                throw new ArgumentException ("$ description needs a type specified", "description");
@@ -893,7 +897,7 @@ namespace Mono {
                        public override void PutBytes (byte [] dest, int destIdx, double value)
                        {
                                Check (dest, destIdx, 8);
-                               fixed (byte *target = (&dest [destIdx])){
+                               fixed (byte *target = &dest [destIdx]){
                                        long *source = (long *) &value;
 
                                        *((long *)target) = *source;
@@ -1222,8 +1226,9 @@ namespace Mono {
                                for (; i < count; i++)
                                        *dest++ = *src++;
                        } else {
+                               dest += count;
                                for (; i < count; i++)
-                                       dest [i-count] = *src++;
+                                       *(--dest) = *src++;
                        }
                }
 
@@ -1232,8 +1237,9 @@ namespace Mono {
                        int i = 0;
                        
                        if (BitConverter.IsLittleEndian){
+                               dest += count;
                                for (; i < count; i++)
-                                       dest [i-count] = *src++;
+                                       *(--dest) = *src++;
                        } else {
                                for (; i < count; i++)
                                        *dest++ = *src++;