[pypy-svn] r30230 - in pypy/dist/pypy/translator/cli: . src test

antocuni at codespeak.net antocuni at codespeak.net
Wed Jul 19 16:02:58 CEST 2006


Author: antocuni
Date: Wed Jul 19 16:02:57 2006
New Revision: 30230

Modified:
   pypy/dist/pypy/translator/cli/rte.py
   pypy/dist/pypy/translator/cli/src/pypylib.cs
   pypy/dist/pypy/translator/cli/test/test_builtin.py
Log:
Disable use of Mono.Posix to let things work on windows.



Modified: pypy/dist/pypy/translator/cli/rte.py
==============================================================================
--- pypy/dist/pypy/translator/cli/rte.py	(original)
+++ pypy/dist/pypy/translator/cli/rte.py	Wed Jul 19 16:02:57 2006
@@ -43,7 +43,7 @@
 def compile(source, dll):
     log.red("Compiling pypylib.dll")
     csc = SDK.csc()
-    compiler = subprocess.Popen([csc, '/r:Mono.Posix', '/unsafe', '/t:library', '/out:%s' % dll, source],
+    compiler = subprocess.Popen([csc, '/unsafe', '/t:library', '/out:%s' % dll, source],
                                 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     stdout, stderr = compiler.communicate()
     retval = compiler.wait()

Modified: pypy/dist/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/pypylib.cs	(original)
+++ pypy/dist/pypy/translator/cli/src/pypylib.cs	Wed Jul 19 16:02:57 2006
@@ -2,8 +2,8 @@
 using System.Collections.Generic;
 using System.IO;
 using System.Runtime.InteropServices;
-using Mono.Unix;
-using Mono.Unix.Native;
+//using Mono.Unix;
+//using Mono.Unix.Native;
 using pypy.runtime;
 
 namespace pypy.test
@@ -451,16 +451,18 @@
 
         public static int ll_os_open(string name, int flag, int mode)
         {
-            OpenFlags f = NativeConvert.ToOpenFlags(flag);
-            FilePermissions perm = NativeConvert.ToFilePermissions((uint)mode);
-            return Syscall.open(name, f, perm);
+            return 2; // ENOENT
+            //OpenFlags f = NativeConvert.ToOpenFlags(flag);
+            //            FilePermissions perm = NativeConvert.ToFilePermissions((uint)mode);
+            //            return Syscall.open(name, f, perm);
         }
 
         public static void ll_os_close(int fd)
         {
-            Syscall.close(fd);
+            //Syscall.close(fd);
         }
 
+        /*
         public static int ll_os_write(int fd, string buffer)
         {
             // TODO: this is very inefficient
@@ -470,17 +472,8 @@
             w.Flush();
             return buffer.Length;
         }
+        */
 
-        public static string ll_os_read(int fd, int count)
-        {
-            UnixStream fs = new UnixStream (fd);
-            StreamReader r = new StreamReader(fs);
-            char[] buf = new char[count];
-            int n = r.Read(buf, 0, count);
-            return new string(buf, 0, n);
-        }
-
-        /*
         // XXX: very hackish, refactoring needed
         public static int ll_os_write(int fd, string buffer)
         {
@@ -492,7 +485,25 @@
                 throw new ApplicationException(string.Format("Wrong file descriptor: {0}", fd));
             return buffer.Length;
         }
-        */
+
+        public static string ll_os_read(int fd, int count)
+        {
+            /*
+            UnixStream fs = new UnixStream (fd);
+            StreamReader r = new StreamReader(fs);
+            char[] buf = new char[count];
+            int n = r.Read(buf, 0, count);
+            return new string(buf, 0, n);
+            */
+
+            if (fd == 0) {
+                char[] buf = new char[count];
+                int n = Console.In.Read(buf, 0, count);
+                return new string(buf, 0, n);
+            }
+            else
+                throw new ApplicationException(string.Format("Wrong file descriptor: {0}", fd));
+        }
 
         public static double ll_math_floor(double x)
         {

Modified: pypy/dist/pypy/translator/cli/test/test_builtin.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_builtin.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_builtin.py	Wed Jul 19 16:02:57 2006
@@ -25,6 +25,7 @@
         pass
 
     def test_os_open_write(self):
+        py.test.skip("Temporarily disabled")
         tmpdir = str(udir.udir.join("os_write_test"))
         def fn():
             fd = os.open(tmpdir, os.O_WRONLY|os.O_CREAT, 0777)            



More information about the Pypy-commit mailing list