[pypy-svn] r76254 - pypy/branch/unicode_filename-2/pypy/rpython/module

afa at codespeak.net afa at codespeak.net
Fri Jul 16 13:57:18 CEST 2010


Author: afa
Date: Fri Jul 16 13:57:16 2010
New Revision: 76254

Modified:
   pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py
   pypy/branch/unicode_filename-2/pypy/rpython/module/ll_win32file.py
Log:
Fix translation, and use the new "registering" decorator


Modified: pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/rpython/module/ll_os.py	Fri Jul 16 13:57:16 2010
@@ -88,6 +88,7 @@
     str = str
     CHAR = rffi.CHAR
     CCHARP = rffi.CCHARP
+    str2charp = rffi.str2charp
 
     @staticmethod
     def posix_function_name(name):
@@ -101,6 +102,7 @@
     str = unicode
     CHAR = rffi.WCHAR_T
     CCHARP = rffi.CWCHARP
+    str2charp = rffi.wcharp2unicode
 
     @staticmethod
     def posix_function_name(name):
@@ -1227,13 +1229,14 @@
         return extdef([], unicode,
                       "ll_os.ll_os_wgetcwd", llimpl=os_getcwd_llimpl)
 
-    @registering(os.listdir)
-    def register_os_listdir(self):
+    @registering_str_unicode(os.listdir)
+    def register_os_listdir(self, traits):
         # we need a different approach on Windows and on Posix
         if sys.platform.startswith('win'):
             from pypy.rpython.module.win32file import make_listdir_impl
-            os_listdir_llimpl = make_listdir_impl(StringTraits())
+            os_listdir_llimpl = make_listdir_impl(traits)
         else:
+            assert traits.str is str
             compilation_info = ExternalCompilationInfo(
                 includes = ['sys/types.h', 'dirent.h']
             )
@@ -1273,20 +1276,11 @@
                     raise OSError(error, "os_readdir failed")
                 return result
 
-        return extdef([str],  # a single argument which is a str
-                      [str],  # returns a list of strings
-                      "ll_os.ll_os_listdir",
+        return extdef([traits.str],  # a single argument which is a str
+                      [traits.str],  # returns a list of strings
+                      traits.ll_os_name('listdir'),
                       llimpl=os_listdir_llimpl)
 
-    @registering_unicode_version(os.listdir, [unicode], sys.platform=='win32')
-    def register_os_listdir_unicode(self):
-        from pypy.rpython.module.win32file import make_listdir_impl
-
-        return extdef([unicode],  # a single argument which is a unicode
-                      [unicode],  # returns a list of unicodes
-                      "ll_os.ll_os_wlistdir",
-                      llimpl=make_listdir_impl(UnicodeTraits()))
-
     @registering(os.pipe)
     def register_os_pipe(self):
         # we need a different approach on Windows and on Posix

Modified: pypy/branch/unicode_filename-2/pypy/rpython/module/ll_win32file.py
==============================================================================
--- pypy/branch/unicode_filename-2/pypy/rpython/module/ll_win32file.py	(original)
+++ pypy/branch/unicode_filename-2/pypy/rpython/module/ll_win32file.py	Fri Jul 16 13:57:16 2010
@@ -79,7 +79,8 @@
         def skip_listdir(path):
             return name == "." or name == "..":
 
-    def listdir_llimpl(path):
+    @func_renamer('listdir_llimpl_%s' % traits.str.__name__)
+    def os_listdir_llimpl(path):
         mask = make_listdir_mask(path)
         filedata = lltype.malloc(win32traits.WIN32_FIND_DATA, flavor='raw')
         try:
@@ -92,8 +93,8 @@
                 else:
                     raise WindowsError(error,  "FindFirstFile failed")
             while True:
-                name = rffi.wcharp2unicode(rffi.cast(rffi.CWCHARP,
-                                                     filedata.c_cFileName))
+                name = traits.str2charp(rffi.cast(traits.CCHARP,
+                                                  filedata.c_cFileName))
                 if not skip_listdir(name):
                     result.append(name)
                 if not win32traits.FindNextFile(hFindFile, filedata):



More information about the Pypy-commit mailing list