[pypy-svn] r45724 - in pypy/branch/pypy-more-rtti-inprogress: rpython rpython/module translator/c translator/c/src

arigo at codespeak.net arigo at codespeak.net
Thu Aug 16 16:06:43 CEST 2007


Author: arigo
Date: Thu Aug 16 16:06:42 2007
New Revision: 45724

Modified:
   pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py
   pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
   pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py
   pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h
Log:
os.unlink()...


Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/extfunctable.py	Thu Aug 16 16:06:42 2007
@@ -150,7 +150,6 @@
 
 # external function declarations
 posix = __import__(os.name)
-declare(os.unlink   , noneannotation, 'll_os/unlink')
 declare(os.chdir    , noneannotation, 'll_os/chdir')
 declare(os.mkdir    , noneannotation, 'll_os/mkdir')
 declare(os.rmdir    , noneannotation, 'll_os/rmdir')

Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/module/ll_os.py	Thu Aug 16 16:06:42 2007
@@ -642,6 +642,20 @@
         self.register(os.system, [str], int, llimpl=system_lltypeimpl,
                       export_name="ll_os.ll_os_system")
 
+    @registering(os.unlink)
+    def register_os_unlink(self):
+        os_unlink = rffi.llexternal('unlink', [rffi.CCHARP], rffi.INT)
+
+        def unlink_lltypeimpl(pathname):
+            l_pathname = rffi.str2charp(pathname)
+            res = os_unlink(l_pathname)
+            rffi.free_charp(l_pathname)
+            if res < 0:
+                raise OSError(rffi.get_errno(), "os_unlink failed")
+
+        self.register(os.unlink, [str], s_None, llimpl=unlink_lltypeimpl,
+                      export_name="ll_os.ll_os_unlink")
+
 # --------------------------- os.stat & variants ---------------------------
 
     @registering(os.fstat)
@@ -731,10 +745,6 @@
     # XXX deprecated style, this is all waiting to be converted to rffi
     __metaclass__ = ClassMethods
 
-    def ll_os_unlink(cls, path):
-        os.unlink(cls.from_rstr(path))
-    ll_os_unlink.suggested_primitive = True
-
     def ll_os_chdir(cls, path):
         os.chdir(cls.from_rstr(path))
     ll_os_chdir.suggested_primitive = True

Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/extfunc.py	Thu Aug 16 16:06:42 2007
@@ -20,7 +20,6 @@
 # references to functions, so we cannot insert classmethods here.
 
 EXTERNALS = {
-    impl.ll_os_unlink.im_func:  'LL_os_unlink',
     impl.ll_os_chdir.im_func:   'LL_os_chdir',
     impl.ll_os_mkdir.im_func:   'LL_os_mkdir',
     impl.ll_os_rmdir.im_func:   'LL_os_rmdir',

Modified: pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/translator/c/src/ll_os.h	Thu Aug 16 16:06:42 2007
@@ -68,13 +68,6 @@
 
 #include "ll_osdefs.h"
 
-void LL_os_unlink(RPyString * fname) {
-    int error = unlink(RPyString_AsString(fname));
-    if (error != 0) {
-	RPYTHON_RAISE_OSERROR(errno);
-    }
-}
-
 void LL_os_chdir(RPyString * path) {
     int error = chdir(RPyString_AsString(path));
     if (error != 0) {



More information about the Pypy-commit mailing list