[pypy-svn] r53830 - in pypy/branch/io-improvements/pypy/rpython: lltypesystem lltypesystem/test module

fijal at codespeak.net fijal at codespeak.net
Thu Apr 17 11:49:05 CEST 2008


Author: fijal
Date: Thu Apr 17 11:49:05 2008
New Revision: 53830

Modified:
   pypy/branch/io-improvements/pypy/rpython/lltypesystem/rffi.py
   pypy/branch/io-improvements/pypy/rpython/lltypesystem/test/test_rffi.py
   pypy/branch/io-improvements/pypy/rpython/module/ll_os.py
Log:
A bit of renaming. hlstr is just an obscure helper.


Modified: pypy/branch/io-improvements/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/lltypesystem/rffi.py	(original)
+++ pypy/branch/io-improvements/pypy/rpython/lltypesystem/rffi.py	Thu Apr 17 11:49:05 2008
@@ -503,7 +503,7 @@
         keepalive_until_here(data)
 
 
-def alloc_buffer_for_hlstr(count):
+def alloc_buffer(count):
     str_chars_offset = offsetof(STR, 'chars') + itemoffsetof(STR.chars, 0)
     gc_buf = rgc.malloc_nonmovable(STR, count)
     if gc_buf:
@@ -514,7 +514,7 @@
         raw_buf = lltype.malloc(CCHARP.TO, count, flavor='raw')
         return raw_buf, lltype.nullptr(STR)
 
-def hlstr_from_buffer(raw_buf, gc_buf, allocated_size, needed_size):
+def str_from_buffer(raw_buf, gc_buf, allocated_size, needed_size):
     str_chars_offset = offsetof(STR, 'chars') + itemoffsetof(STR.chars, 0)
     if gc_buf:
         if allocated_size != needed_size:
@@ -540,7 +540,7 @@
         finally:
             keepalive_until_here(new_buf)
         
-def keep_buffer_for_hlstr_alive_until_here(raw_buf, gc_buf):
+def keep_buffer_alive_until_here(raw_buf, gc_buf):
     if gc_buf:
         keepalive_until_here(gc_buf)
     else:

Modified: pypy/branch/io-improvements/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/lltypesystem/test/test_rffi.py	(original)
+++ pypy/branch/io-improvements/pypy/rpython/lltypesystem/test/test_rffi.py	Thu Apr 17 11:49:05 2008
@@ -431,18 +431,18 @@
         unregister_keepalive(pos, TP)
         assert res == 8
 
-    def test_nonmoving_hlstr(self):
+    def test_nonmoving(self):
         d = 'non-moving data stuff'
         def f():
             gc_buf = lltype.nullptr(STR)
             raw_buf = lltype.nullptr(CCHARP.TO)
             try:
-                raw_buf, gc_buf = alloc_buffer_for_hlstr(len(d))
+                raw_buf, gc_buf = alloc_buffer(len(d))
                 for i in range(len(d)):
                     raw_buf[i] = d[i]
-                return hlstr_from_buffer(raw_buf, gc_buf, len(d), len(d)-1)
+                return str_from_buffer(raw_buf, gc_buf, len(d), len(d)-1)
             finally:
-                keep_buffer_for_hlstr_alive_until_here(raw_buf, gc_buf)
+                keep_buffer_alive_until_here(raw_buf, gc_buf)
         fn = self.compile(f, [], gcpolicy='ref')
         assert fn() == d[:-1]
     
@@ -702,7 +702,7 @@
     def test_nonmovingbuffer(self):
         py.test.skip("Somewhat buggy...")
 
-    test_nonmoving_hlstr = test_nonmovingbuffer
+    test_nonmoving = test_nonmovingbuffer
 
     def test_nonmovingbuffer_semispace(self):
         py.test.skip("LLVM backend error - unsupported operator")

Modified: pypy/branch/io-improvements/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rpython/module/ll_os.py	(original)
+++ pypy/branch/io-improvements/pypy/rpython/module/ll_os.py	Thu Apr 17 11:49:05 2008
@@ -490,14 +490,14 @@
             raw_buf = lltype.nullptr(rffi.CCHARP.TO)    
             gc_buf = lltype.nullptr(STR)
             try:
-                raw_buf, gc_buf = rffi.alloc_buffer_for_hlstr(count)
+                raw_buf, gc_buf = rffi.alloc_buffer(count)
                 void_buf = rffi.cast(rffi.VOIDP, raw_buf)
                 got = rffi.cast(lltype.Signed, os_read(fd, void_buf, count))
                 if got < 0:
                     raise OSError(rposix.get_errno(), "os_read failed")
-                return rffi.hlstr_from_buffer(raw_buf, gc_buf, count, got)
+                return rffi.str_from_buffer(raw_buf, gc_buf, count, got)
             finally:
-                rffi.keep_buffer_for_hlstr_alive_until_here(raw_buf, gc_buf)
+                rffi.keep_buffer_alive_until_here(raw_buf, gc_buf)
             
         def os_read_oofakeimpl(fd, count):
             return OOSupport.to_rstr(os.read(fd, count))



More information about the Pypy-commit mailing list