dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/csupport Crt0.cs,1.2,1.3


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/csupport Crt0.cs,1.2,1.3
Date: Fri, 30 May 2003 23:32:04 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/csupport
In directory subversions:/tmp/cvs-serv32646/csupport

Modified Files:
        Crt0.cs 
Log Message:


Add the CONFIG_SMALL_CONSOLE profile option, which strips
System.Console down to a smaller size.


Index: Crt0.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/csupport/Crt0.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Crt0.cs     9 Dec 2002 04:52:56 -0000       1.2
--- Crt0.cs     31 May 2003 03:32:02 -0000      1.3
***************
*** 24,27 ****
--- 24,28 ----
  
  using System;
+ using System.IO;
  using System.Collections;
  using System.Runtime.InteropServices;
***************
*** 134,141 ****
--- 135,149 ----
                                        if(ptrSize < sizeof(IntPtr))
                                        {
+                                       #if CONFIG_SMALL_CONSOLE
+                                               Console.Write(args[0]);
+                                               Console.WriteLine
+                                                 (": application is {0}-bit, 
but platform is {1}-bit",
+                                                  (Object)(ptrSize * 8), 
(Object)(sizeof(IntPtr) * 8));
+                                       #else
                                                Console.Error.Write(args[0]);
                                                Console.Error.WriteLine
                                                  (": application is {0}-bit, 
but platform is {1}-bit",
                                                   (Object)(ptrSize * 8), 
(Object)(sizeof(IntPtr) * 8));
+                                       #endif
                                                Environment.Exit(1);
                                        }
***************
*** 299,305 ****
--- 307,319 ----
  
                                // Initialize the stdin, stdout, and stderr 
file descriptors.
+                       #if CONFIG_SMALL_CONSOLE
+                               FileTable.SetFileDescriptor(0, Stream.Null);
+                               FileTable.SetFileDescriptor(1, new 
ConsoleStream());
+                               FileTable.SetFileDescriptor(2, new 
ConsoleStream());
+                       #else
                                FileTable.SetFileDescriptor(0, 
Console.OpenStandardInput());
                                FileTable.SetFileDescriptor(1, 
Console.OpenStandardOutput());
                                FileTable.SetFileDescriptor(2, 
Console.OpenStandardError());
+                       #endif
  
                                // Invoke the application's ".init" function, 
if present.
***************
*** 372,375 ****
--- 386,474 ----
                                }
                        }
+ 
+ #if CONFIG_SMALL_CONSOLE
+ 
+       // Helper class for writing to stdout when the System.Console
+       // class does not have "OpenStandardOutput".
+       private sealed class ConsoleStream : Stream
+       {
+               // Constructor.
+               public ConsoleStream() {}
+ 
+               // Stub out all stream functionality.
+               public override void Flush() {}
+               public override int Read(byte[] buffer, int offset, int count)
+                               {
+                                       throw new NotSupportedException();
+                               }
+               public override int ReadByte()
+                               {
+                                       throw new NotSupportedException();
+                               }
+               public override long Seek(long offset, SeekOrigin origin)
+                               {
+                                       throw new NotSupportedException();
+                               }
+               public override void SetLength(long value)
+                               {
+                                       throw new NotSupportedException();
+                               }
+               public override void Write(byte[] buffer, int offset, int count)
+                               {
+                                       // Validate the buffer argument.
+                                       if(buffer == null)
+                                       {
+                                               throw new 
ArgumentNullException("buffer");
+                                       }
+                                       else if(offset < 0 || offset > 
buffer.Length)
+                                       {
+                                               throw new 
ArgumentOutOfRangeException();
+                                       }
+                                       else if(count < 0)
+                                       {
+                                               throw new 
ArgumentOutOfRangeException();
+                                       }
+                                       else if((buffer.Length - offset) < 
count)
+                                       {
+                                               throw new ArgumentException();
+                                       }
+ 
+                                       // Write the contents of the buffer.
+                                       while(count > 0)
+                                       {
+                                               
Console.Write((char)(buffer[offset]));
+                                               ++offset;
+                                               --count;
+                                       }
+                               }
+               public override void WriteByte(byte value)
+                               {
+                                       Console.Write((char)value);
+                               }
+               public override bool CanRead { get { return false; } }
+               public override bool CanSeek { get { return false; } }
+               public override bool CanWrite { get { return true; } }
+               public override long Length
+                               {
+                                       get
+                                       {
+                                               throw new 
NotSupportedException();
+                                       }
+                               }
+               public override long Position
+                               {
+                                       get
+                                       {
+                                               throw new 
NotSupportedException();
+                                       }
+                                       set
+                                       {
+                                               throw new 
NotSupportedException();
+                                       }
+                               }
+ 
+       }; // class ConsoleStream
+ 
+ #endif // !CONFIG_SMALL_CONSOLE
  
  } // class Crt0





reply via email to

[Prev in Thread] Current Thread [Next in Thread]