[pypy-svn] r62495 - in pypy/trunk/pypy: rpython/module translator/cli/src translator/jvm/src/pypy

afa at codespeak.net afa at codespeak.net
Tue Mar 3 19:40:36 CET 2009


Author: afa
Date: Tue Mar  3 19:40:36 2009
New Revision: 62495

Modified:
   pypy/trunk/pypy/rpython/module/ll_os_stat.py
   pypy/trunk/pypy/translator/cli/src/pypylib.cs
   pypy/trunk/pypy/translator/jvm/src/pypy/StatResult.java
   pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java
Log:
It seems that oo backends can't insert a int into a float struct member:
The specific implementation of structures (in C# and Java) 
must match the STAT_FIELDS description.

(I considered changing rpython.module.r_os_stat.specialize_make_stat_result,
but I could not get it to work)

So:
- st_mtime is a lltype.Float all the time.
- we turn it into a lltype.Signed to build the "struct stat" for the C backend
- structures in C# and Java now hold float times.

Tested with the cli backend, I hope I did not break Java.


Modified: pypy/trunk/pypy/rpython/module/ll_os_stat.py
==============================================================================
--- pypy/trunk/pypy/rpython/module/ll_os_stat.py	(original)
+++ pypy/trunk/pypy/rpython/module/ll_os_stat.py	Tue Mar  3 19:40:36 2009
@@ -26,11 +26,6 @@
 else:
     TIMESPEC = None
 
-if sys.platform == 'win32' or TIMESPEC is not None:
-    ModTime = lltype.Float
-else:
-    ModTime = lltype.Signed
-
 # all possible fields - some of them are not available on all platforms
 ALL_STAT_FIELDS = [
     ("st_mode",      lltype.Signed),
@@ -40,15 +35,15 @@
     ("st_uid",       lltype.Signed),
     ("st_gid",       lltype.Signed),
     ("st_size",      lltype.SignedLongLong),
-    ("st_atime",     ModTime),
-    ("st_mtime",     ModTime),
-    ("st_ctime",     ModTime),
+    ("st_atime",     lltype.Float),
+    ("st_mtime",     lltype.Float),
+    ("st_ctime",     lltype.Float),
     ("st_blksize",   lltype.Signed),
     ("st_blocks",    lltype.Signed),
     ("st_rdev",      lltype.Signed),
     ("st_flags",     lltype.Signed),
     #("st_gen",       lltype.Signed),     -- new in CPy 2.5, not implemented
-    #("st_birthtime", ModTime),           -- new in CPy 2.5, not implemented
+    #("st_birthtime", lltype.Float),      -- new in CPy 2.5, not implemented
     ]
 N_INDEXABLE_FIELDS = 10
 
@@ -169,7 +164,14 @@
         _expand(LL_STAT_FIELDS, 'st_ctime', 'st_ctim')
 
         del _expand
-    
+    else:
+        # Replace float fields with integers
+        for name in ('st_atime', 'st_mtime', 'st_ctime', 'st_birthtime'):
+            for i, (_name, _TYPE) in enumerate(LL_STAT_FIELDS):
+                if _name == name:
+                    LL_STAT_FIELDS[i] = (_name, lltype.Signed)
+                    break
+
     class CConfig:
         _compilation_info_ = compilation_info
         STAT_STRUCT = platform.Struct('struct %s' % _name_struct_stat, LL_STAT_FIELDS)

Modified: pypy/trunk/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/trunk/pypy/translator/cli/src/pypylib.cs	(original)
+++ pypy/trunk/pypy/translator/cli/src/pypylib.cs	Tue Mar  3 19:40:36 2009
@@ -712,8 +712,9 @@
     }
 
     public class Record_Stat_Result {
-        public int item0, item3, item4, item5, item7, item8, item9;
+        public int item0, item3, item4, item5;
         public long item1, item2, item6;
+        public double item7, item8, item9;
         public override string ToString() 
         { 
             return string.Format("({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9},)", 

Modified: pypy/trunk/pypy/translator/jvm/src/pypy/StatResult.java
==============================================================================
--- pypy/trunk/pypy/translator/jvm/src/pypy/StatResult.java	(original)
+++ pypy/trunk/pypy/translator/jvm/src/pypy/StatResult.java	Tue Mar  3 19:40:36 2009
@@ -9,10 +9,11 @@
  * <p>The actual stat() function is defined in PyPy.java.
  */
 class StatResult {
-    public int item0, item3, item4, item5, item7, item8, item9;
+    public int item0, item3, item4, item5;
     public long item1, item2, item6;
+    public double item7, item8, item9;
 
     public void setMode(int value)  { item0 = value; }
     public void setSize(long value)  { item6 = value; }
-    public void setMtime(int value) { item8 = value; }
+    public void setMtime(double value) { item8 = value; }
 }

Modified: pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java
==============================================================================
--- pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java	(original)
+++ pypy/trunk/pypy/translator/jvm/src/pypy/ll_os.java	Tue Mar  3 19:40:36 2009
@@ -496,7 +496,7 @@
             else {
                 res.setMode(S_IFREG);
                 res.setSize(f.length());
-                res.setMtime((int)f.lastModified());
+                res.setMtime((double)f.lastModified());
             }
             return res;
         }



More information about the Pypy-commit mailing list