diff druntime/src/compiler/dmd/util/console.d @ 759:d3eb054172f9

Added copy of druntime from DMD 2.020 modified for LDC.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 11 Nov 2008 01:52:37 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/druntime/src/compiler/dmd/util/console.d	Tue Nov 11 01:52:37 2008 +0100
@@ -0,0 +1,49 @@
+/**
+ * The console module contains some simple routines for console output.
+ *
+ * Copyright: Public Domain
+ * License:   Public Domain
+ * Authors:   Sean Kelly
+ */
+module rt.util.console;
+
+
+private
+{
+    version (Windows)
+    {
+        import sys.windows.windows;
+    }
+    else version( Posix )
+    {
+        import stdc.posix.unistd;
+    }
+    import util.string;
+}
+
+
+struct Console
+{
+    Console opCall( in char[] val )
+    {
+        version( Windows )
+        {
+            uint count = void;
+            WriteFile( GetStdHandle( 0xfffffff5 ), val.ptr, val.length, &count, null );
+        }
+        else version( Posix )
+        {
+            write( 2, val.ptr, val.length );
+        }
+        return *this;
+    }
+
+
+    Console opCall( uint val )
+    {
+            char[10] tmp = void;
+            return opCall( tmp.intToString( val ) );
+    }
+}
+
+Console console;