Author: atsushi
Date: 2005-11-28 07:25:41 -0500 (Mon, 28 Nov 2005)
New Revision: 53548

Modified:
   trunk/mcs/class/corlib/System.Text/ChangeLog
   trunk/mcs/class/corlib/System.Text/Decoder.cs
   trunk/mcs/class/corlib/System.Text/Encoder.cs
Log:
2005-11-28  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * Encoder.cs : added new GetByteCount()/GetBytes() overloads.
          Added FallbackBuffer.
        * Decoder.cs : added new GetCharCount()/GetChars() overloads.



Modified: trunk/mcs/class/corlib/System.Text/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Text/ChangeLog        2005-11-28 12:14:07 UTC 
(rev 53547)
+++ trunk/mcs/class/corlib/System.Text/ChangeLog        2005-11-28 12:25:41 UTC 
(rev 53548)
@@ -1,5 +1,11 @@
 2005-11-28  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * Encoder.cs : added new GetByteCount()/GetBytes() overloads.
+         Added FallbackBuffer.
+       * Decoder.cs : added new GetCharCount()/GetChars() overloads.
+
+2005-11-28  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * EncodingInfo.cs : new file.
 
 2005-11-28  Atsushi Enomoto  <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/corlib/System.Text/Decoder.cs
===================================================================
--- trunk/mcs/class/corlib/System.Text/Decoder.cs       2005-11-28 12:14:07 UTC 
(rev 53547)
+++ trunk/mcs/class/corlib/System.Text/Decoder.cs       2005-11-28 12:25:41 UTC 
(rev 53548)
@@ -26,6 +26,7 @@
 {
 
 using System;
+using System.Runtime.InteropServices;
 
 [Serializable]
 public abstract class Decoder
@@ -64,6 +65,49 @@
        public abstract int GetChars (byte[] bytes, int byteIndex, int 
byteCount,
                                                                 char[] chars, 
int charIndex);
 
+#if NET_2_0
+       public virtual int GetCharCount (byte [] bytes, int index, int count, 
bool flush)
+       {
+               if (flush)
+                       Reset ();
+               return GetCharCount (bytes, index, count);
+       }
+
+       [CLSCompliant (false)]
+       public unsafe virtual int GetCharCount (byte* bytes, int count, bool 
flush)
+       {
+               byte [] barr = new byte [count];
+               Marshal.Copy ((IntPtr) bytes, barr, 0, count);
+               return GetCharCount (barr, 0, count, flush);
+       }
+
+       public virtual int GetChars (
+               byte[] bytes, int byteIndex, int byteCount,
+               char[] chars, int charIndex, bool flush)
+       {
+               if (flush)
+                       Reset ();
+               return GetChars (bytes, byteIndex, byteCount, chars, charIndex);
+       }
+
+       [CLSCompliant (false)]
+       public unsafe virtual int GetChars (byte* bytes, int byteCount,
+               char* chars, int charCount, bool flush)
+       {
+               char [] carr = new char [charCount];
+               Marshal.Copy ((IntPtr) chars, carr, 0, charCount);
+               byte [] barr = new byte [byteCount];
+               Marshal.Copy ((IntPtr) bytes, barr, 0, byteCount);
+               return GetChars (barr, 0, byteCount, carr, 0, flush);
+       }
+
+       public virtual void Reset ()
+       {
+               if (fallback_buffer != null)
+                       fallback_buffer.Reset ();
+       }
+#endif
+
 }; // class Decoder
 
 }; // namespace System.Text

Modified: trunk/mcs/class/corlib/System.Text/Encoder.cs
===================================================================
--- trunk/mcs/class/corlib/System.Text/Encoder.cs       2005-11-28 12:14:07 UTC 
(rev 53547)
+++ trunk/mcs/class/corlib/System.Text/Encoder.cs       2005-11-28 12:25:41 UTC 
(rev 53548)
@@ -26,6 +26,7 @@
 {
 
 using System;
+using System.Runtime.InteropServices;
 
 [Serializable]
 public abstract class Encoder
@@ -36,6 +37,7 @@
 
 #if NET_2_0
        EncoderFallback fallback;
+       EncoderFallbackBuffer fallback_buffer;
 
        public EncoderFallback Fallback {
                get { return fallback; }
@@ -43,8 +45,17 @@
                        if (value == null)
                                throw new ArgumentNullException ();
                        fallback = value;
+                       fallback_buffer = null;
                }
        }
+
+       public EncoderFallbackBuffer FallbackBuffer {
+               get {
+                       if (fallback_buffer == null)
+                               fallback_buffer = fallback.CreateFallbackBuffer 
();
+                       return fallback_buffer;
+               }
+       }
 #endif
 
        // Get the number of bytes needed to encode a buffer.
@@ -55,6 +66,33 @@
        public abstract int GetBytes(char[] chars, int charIndex, int charCount,
                                                                 byte[] bytes, 
int byteIndex, bool flush);
 
+#if NET_2_0
+       [CLSCompliant (false)]
+       public unsafe virtual int GetByteCount (char* chars, int charCount, 
bool flush)
+       {
+               char [] carr = new char [charCount];
+               Marshal.Copy ((IntPtr) chars, carr, 0, charCount);
+               return GetByteCount (carr, 0, charCount, flush);
+       }
+
+       [CLSCompliant (false)]
+       public unsafe virtual int GetBytes (char* chars, int charCount,
+               byte* bytes, int byteCount, bool flush)
+       {
+               char [] carr = new char [charCount];
+               Marshal.Copy ((IntPtr) chars, carr, 0, charCount);
+               byte [] barr = new byte [byteCount];
+               Marshal.Copy ((IntPtr) bytes, barr, 0, byteCount);
+               return GetBytes (carr, 0, charCount, barr, 0, flush);
+       }
+
+       public virtual void Reset ()
+       {
+               if (fallback_buffer != null)
+                       fallback_buffer.Reset ();
+       }
+#endif
+
 }; // class Encoder
 
 }; // namespace System.Text

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to