[runtime] Move pending_exception from InternalThread to Thread to avoid crashing...
[mono.git] / mcs / class / corlib / Mono / DataConverter.cs
index d0bf0476f602cb04b521e2f24848f65a4a62eedf..daf8eb72322c4afb80c2da740219ce0ba5f0d2db 100644 (file)
 using System;
 using System.Collections;
 using System.Text;
+using System.Collections.Generic;
 
 #pragma warning disable 3021
 
 namespace Mono {
 
 #if MONO_DATACONVERTER_PUBLIC
-       unsafe public abstract class DataConverter {
-#else
-       unsafe internal abstract class DataConverter {
+       public
+#endif
+       unsafe 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 ();
+               static readonly DataConverter SwapConv = new SwapConverter ();
+               static readonly DataConverter CopyConv = new CopyConverter ();
 
                public static readonly bool IsLittleEndian = BitConverter.IsLittleEndian;
                        
@@ -463,7 +463,11 @@ namespace Mono {
                                        n = 2;
                                        break;
                                case '7':
+#if PCL
+                                       e = Encoding.GetEncoding ("utf-7");
+#else
                                        e = Encoding.UTF7;
+#endif
                                        n = 1;
                                        break;
                                case 'b':
@@ -471,11 +475,19 @@ namespace Mono {
                                        n = 2;
                                        break;
                                case '3':
+#if PCL
+                                       e = Encoding.GetEncoding ("utf-32");
+#else
                                        e = Encoding.GetEncoding (12000);
+#endif
                                        n = 4;
                                        break;
                                case '4':
+#if PCL
+                                       e = Encoding.GetEncoding ("utf-32BE");
+#else
                                        e = Encoding.GetEncoding (12001);
+#endif
                                        n = 4;
                                        break;
                                        
@@ -511,7 +523,7 @@ namespace Mono {
                static public IList Unpack (string description, byte [] buffer, int startIndex)
                {
                        DataConverter conv = CopyConv;
-                       ArrayList result = new ArrayList ();
+                       var result = new List<object> ();
                        int idx = startIndex;
                        bool align = false;
                        int repeat = 0, n;
@@ -582,7 +594,7 @@ namespace Mono {
                                
                                case 'f':
                                        if (Prepare (buffer, ref idx, 4, ref align)){
-                                               result.Add (conv.GetDouble (buffer, idx));
+                                               result.Add (conv.GetFloat (buffer, idx));
                                                idx += 4;
                                        }
                                        break;
@@ -643,6 +655,7 @@ namespace Mono {
                                        if (count == -1)
                                                throw new ArgumentException ("invalid size specification");
                                        i = j;
+                                       save = i + 1;
                                        repeat = count;
                                        break;
                                
@@ -1193,7 +1206,7 @@ namespace Mono {
                                fixed (byte *target = &dest [destIdx]){
                                        byte *source = (byte *) &value;
 
-                                       for (int i = 0; i < 4; i++)
+                                       for (int i = 0; i < 8; i++)
                                                target [i] = source [7-i];
                                }
                        }