[pypy-svn] r14841 - in pypy/dist/pypy: module/posix module/posix/test rpython rpython/module

ale at codespeak.net ale at codespeak.net
Thu Jul 21 03:12:23 CEST 2005


Author: ale
Date: Thu Jul 21 03:12:19 2005
New Revision: 14841

Modified:
   pypy/dist/pypy/module/posix/__init__.py
   pypy/dist/pypy/module/posix/interp_posix.py
   pypy/dist/pypy/module/posix/test/test_posix.py
   pypy/dist/pypy/rpython/extfunctable.py
   pypy/dist/pypy/rpython/module/ll_os.py
Log:
It seems that the only remaining thing to do is exceptionhandling

Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py	(original)
+++ pypy/dist/pypy/module/posix/__init__.py	Thu Jul 21 03:12:19 2005
@@ -3,8 +3,9 @@
     
 class Module(MixedModule):
     appleveldefs = {
-    'error'     : 'app_posix.error'
+    'error'     : 'app_posix.error',
     }
+    
     interpleveldefs = {
     'open'      : 'interp_posix.open',
     'lseek'     : 'interp_posix.lseek',
@@ -14,6 +15,8 @@
     'close'     : 'interp_posix.close',
     'ftruncate' : 'interp_posix.ftruncate',
     'fstat'     : 'interp_posix.fstat',
+    'stat'      : 'interp_posix.stat',
     'dup'       : 'interp_posix.dup',
     '__doc__'   : "space.wrap('Posix module')",
+    '__name__'  : "space.wrap('The builtin posix module')",
     }

Modified: pypy/dist/pypy/module/posix/interp_posix.py
==============================================================================
--- pypy/dist/pypy/module/posix/interp_posix.py	(original)
+++ pypy/dist/pypy/module/posix/interp_posix.py	Thu Jul 21 03:12:19 2005
@@ -40,6 +40,10 @@
     return os.fstat(fd)
 fstat.unwrap_spec = [ObjSpace, int]
 
+def stat(space, path):
+    return os.stat(path)
+stat.unwrap_spec = [ObjSpace, str]
+
 def getcwd(space):
     return os.getcwd()
 getcwd.unwrap_spec = [ObjSpace]

Modified: pypy/dist/pypy/module/posix/test/test_posix.py
==============================================================================
--- pypy/dist/pypy/module/posix/test/test_posix.py	(original)
+++ pypy/dist/pypy/module/posix/test/test_posix.py	Thu Jul 21 03:12:19 2005
@@ -91,7 +91,7 @@
     text = 'This is a test'
     os.write(fi,text)
     res = interpret(f,[fi])
-    raises(OSError, os.fstat, fi)
+    raises( OSError, os.fstat, fi)
 
 def test_ftruncate():
     def f(fi,len):

Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py	(original)
+++ pypy/dist/pypy/rpython/extfunctable.py	Thu Jul 21 03:12:19 2005
@@ -3,8 +3,9 @@
 """
 import os
 import time
+import math
 import types
-from pypy.annotation.model import SomeInteger, SomeTuple
+from pypy.annotation.model import SomeInteger, SomeTuple, SomeFloat
 
 
 class ExtFuncInfo:
@@ -51,6 +52,7 @@
 
 nonefactory = lambda *args: None
 tuplefactory = lambda *args: SomeTuple((SomeInteger(),)*10)
+frexpfactory = lambda *args: SomeTuple((SomeFloat(),SomeInteger()))
 
 # external function declarations
 declare(os.open     , int        , 'll_os/open')
@@ -63,6 +65,11 @@
 declare(os.isatty   , bool       , 'll_os/isatty')
 declare(os.ftruncate, nonefactory, 'll_os/ftruncate')
 declare(os.fstat    , tuplefactory, 'll_os/fstat')
+declare(os.stat     , tuplefactory, 'll_os/stat')
 declare(time.time   , float      , 'll_time/time')
 declare(time.clock  , float      , 'll_time/clock')
 declare(time.sleep  , nonefactory, 'll_time/sleep')
+declare(math.log10  , float      , 'll_math/log10')
+declare(math.ceil   , float      , 'll_math/ceil')
+declare(math.frexp  , frexpfactory, 'll_math/frexp')
+declare(math.atan2  , float      , 'll_math/atan2')

Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py	(original)
+++ pypy/dist/pypy/rpython/module/ll_os.py	Thu Jul 21 03:12:19 2005
@@ -97,12 +97,9 @@
 
 from pypy.rpython.rarithmetic import intmask
 
-def ll_os_fstat(fd):
-    
-    stat = os.fstat(fd)
-    i = 0
-    n = len(stat)
-    tup.item0 = stat[0]
+def stat_to_rtuple(stat):
+    #n = len(stat)
+    tup.item0 = intmask(stat[0])
     tup.item1 = intmask(stat[1])
     tup.item2 = intmask(stat[2])
     tup.item3 = intmask(stat[3])
@@ -112,9 +109,15 @@
     tup.item7 = intmask(stat[7])
     tup.item8 = intmask(stat[8])
     tup.item9 = intmask(stat[9])
-##    while i<n:
-##        itemname = 'item%d' % i
-##        setattr(tup,itemname,stat[i])
-##        i += 1
+    
+def ll_os_fstat(fd):
+    stat = os.fstat(fd)
+    stat_to_rtuple(stat)
+    return tup
+ll_os_fstat.suggested_primitive = True
+
+def ll_os_stat(path):
+    stat = os.fstat(path)
+    stat_to_tuple(stat)
     return tup
-ll_os_fstat.suggested_primitive = True
\ No newline at end of file
+ll_os_stat.suggested_primitive = True
\ No newline at end of file



More information about the Pypy-commit mailing list