Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r65316:07d4ffd55e14
Date: 2013-07-10 14:04 +0200
http://bitbucket.org/pypy/pypy/changeset/07d4ffd55e14/
Log: fix test_rbytearray.py, which was broken by the improve-str2charp
branch
diff --git a/rpython/rtyper/lltypesystem/rbytearray.py
b/rpython/rtyper/lltypesystem/rbytearray.py
--- a/rpython/rtyper/lltypesystem/rbytearray.py
+++ b/rpython/rtyper/lltypesystem/rbytearray.py
@@ -8,13 +8,13 @@
def mallocbytearray(size):
return lltype.malloc(BYTEARRAY, size)
-copy_bytearray_contents = rstr._new_copy_contents_fun(BYTEARRAY, BYTEARRAY,
- lltype.Char,
- 'bytearray')
-copy_bytearray_contents_from_str = rstr._new_copy_contents_fun(rstr.STR,
- BYTEARRAY,
- lltype.Char,
-
'bytearray_from_str')
+_, copy_bytearray_contents = rstr._new_copy_contents_fun(BYTEARRAY, BYTEARRAY,
+ lltype.Char,
+ 'bytearray')
+_, copy_bytearray_contents_from_str = rstr._new_copy_contents_fun(rstr.STR,
+ BYTEARRAY,
+ lltype.Char,
+
'bytearray_from_str')
BYTEARRAY.become(lltype.GcStruct('rpy_bytearray',
('chars', lltype.Array(lltype.Char)), adtmeths={
diff --git a/rpython/rtyper/lltypesystem/rstr.py
b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -49,17 +49,19 @@
def emptyunicodefun():
return emptyunicode
-def _new_copy_contents_fun(STR_TP, CHAR_TP, name):
- def _str_ofs(item):
- return (llmemory.offsetof(STR_TP, 'chars') +
- llmemory.itemoffsetof(STR_TP.chars, 0) +
+def _new_copy_contents_fun(SRC_TP, DST_TP, CHAR_TP, name):
+ @specialize.arg(0)
+ def _str_ofs(TP, item):
+ return (llmemory.offsetof(TP, 'chars') +
+ llmemory.itemoffsetof(TP.chars, 0) +
llmemory.sizeof(CHAR_TP) * item)
- @signature(types.any(), types.int(), returns=types.any())
- def _get_raw_buf(src, ofs):
- assert typeOf(src).TO == STR_TP
+ @signature(types.any(), types.any(), types.int(), returns=types.any())
+ @specialize.arg(0)
+ def _get_raw_buf(TP, src, ofs):
+ assert typeOf(src).TO == TP
assert ofs >= 0
- return llmemory.cast_ptr_to_adr(src) + _str_ofs(ofs)
+ return llmemory.cast_ptr_to_adr(src) + _str_ofs(TP, ofs)
_get_raw_buf._always_inline_ = True
@jit.oopspec('stroruni.copy_contents(src, dst, srcstart, dststart,
length)')
@@ -75,8 +77,8 @@
# longer than the raw_memcopy().
assert length >= 0
# from here, no GC operations can happen
- src = _get_raw_buf(src, srcstart)
- dst = _get_raw_buf(dst, dststart)
+ src = _get_raw_buf(SRC_TP, src, srcstart)
+ dst = _get_raw_buf(DST_TP, dst, dststart)
llmemory.raw_memcopy(src, dst, llmemory.sizeof(CHAR_TP) * length)
# end of "no GC" section
keepalive_until_here(src)
@@ -95,7 +97,7 @@
# xxx Warning: same note as above apply: don't do this at home
assert length >= 0
# from here, no GC operations can happen
- src = _get_raw_buf(src, srcstart)
+ src = _get_raw_buf(SRC_TP, src, srcstart)
adr = llmemory.cast_ptr_to_adr(ptrdst)
dstbuf = adr + llmemory.itemoffsetof(typeOf(ptrdst).TO, 0)
llmemory.raw_memcopy(src, dstbuf, llmemory.sizeof(CHAR_TP) * length)
@@ -106,8 +108,8 @@
return copy_string_to_raw, copy_string_contents
-copy_string_to_raw, copy_string_contents = _new_copy_contents_fun(STR, Char,
'string')
-copy_unicode_to_raw, copy_unicode_contents = _new_copy_contents_fun(UNICODE,
+copy_string_to_raw, copy_string_contents = _new_copy_contents_fun(STR, STR,
Char, 'string')
+copy_unicode_to_raw, copy_unicode_contents = _new_copy_contents_fun(UNICODE,
UNICODE,
UniChar,
'unicode')
CONST_STR_CACHE = WeakValueDictionary()
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit