[pypy-svn] r48364 - in pypy/branch/pypy-rpython-unicode/rpython: . lltypesystem test

fijal at codespeak.net fijal at codespeak.net
Wed Nov 7 16:15:09 CET 2007


Author: fijal
Date: Wed Nov  7 16:15:08 2007
New Revision: 48364

Modified:
   pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py
Log:
Eventual future support for unichar.isxxx, right now disabled (+ disable
test)


Modified: pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py	Wed Nov  7 16:15:08 2007
@@ -801,6 +801,8 @@
 StringRepr.repr = string_repr
 UnicodeRepr.repr = unicode_repr
 UniCharRepr.repr = unicode_repr
+UniCharRepr.char_repr = unichar_repr
+CharRepr.char_repr = char_repr
 
 class BaseStringIteratorRepr(AbstractStringIteratorRepr):
 

Modified: pypy/branch/pypy-rpython-unicode/rpython/rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/rstr.py	Wed Nov  7 16:15:08 2007
@@ -369,7 +369,8 @@
         return r_str.ll.do_stringformat(hop, sourcevars)
                 
 
-class __extend__(AbstractCharRepr):
+class __extend__(AbstractCharRepr,
+                 AbstractUniCharRepr):
 
     def convert_const(self, value):
         if not isinstance(value, str) or len(value) != 1:
@@ -395,13 +396,13 @@
         return hop.inputconst(Bool, True)
 
     def rtype_ord(_, hop):
-        rstr = hop.rtyper.type_system.rstr
-        vlist = hop.inputargs(rstr.char_repr)
+        repr = hop.args_r[0].char_repr
+        vlist = hop.inputargs(repr)
         return hop.genop('cast_char_to_int', vlist, resulttype=Signed)
 
     def _rtype_method_isxxx(_, llfn, hop):
-        rstr = hop.rtyper.type_system.rstr
-        vlist = hop.inputargs(rstr.char_repr)
+        repr = hop.args_r[0].char_repr
+        vlist = hop.inputargs(repr)
         hop.exception_cannot_occur()
         return hop.gendirectcall(llfn, vlist[0])
 
@@ -581,7 +582,7 @@
         c = ord(ch)
         return 65 <= c <= 90
 
-    def ll_char_islower(ch):   
+    def ll_char_islower(ch):
         c = ord(ch)
         return 97 <= c <= 122
 

Modified: pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py	Wed Nov  7 16:15:08 2007
@@ -100,6 +100,7 @@
         assert res[1] == const('.')
 
     def test_char_isxxx(self):
+        constchar = self.constchar
         def fn(s):
             return (s.isspace()      |
                     s.isdigit() << 1 |
@@ -108,7 +109,7 @@
                     s.isupper() << 4 |
                     s.islower() << 5)
         for i in range(128):
-            ch = chr(i)
+            ch = constchar(i)
             res = self.interpret(fn, [ch])
             assert res == fn(ch)
 
@@ -790,6 +791,7 @@
 
 class BaseTestRstr(AbstractTestRstr):
     const = str
+    constchar = chr
 
 class TestLLtype(BaseTestRstr, LLRtypeMixin):
 

Modified: pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py	Wed Nov  7 16:15:08 2007
@@ -2,11 +2,16 @@
 
 from pypy.rpython.test.tool import LLRtypeMixin
 from pypy.rpython.test.test_rstr import AbstractTestRstr
+import py
 
 # ====> test_rstr.py
 
 class BaseTestRUnicode(AbstractTestRstr):
     const = unicode
+    constchar = unichr
+
+    def test_char_isxxx(self):
+        py.test.skip("not supported")
 
 class TestLLtype(BaseTestRUnicode, LLRtypeMixin):
     pass



More information about the Pypy-commit mailing list