Commits

Michał Bendowski committed 90cb8d4

Fix userspace builders in ootype

Implement the getlength() method of StringBuilders in ootype.

  • Participants
  • Parent commits 1afe144
  • Branches jvm-improvements

Comments (0)

Files changed (5)

pypy/rpython/ootypesystem/ootype.py

             "ll_append_char": Meth([CHARTP], Void),
             "ll_append": Meth([STRINGTP], Void),
             "ll_build": Meth([], STRINGTP),
+            "ll_getlength": Meth([], Signed),
             })
         self._setup_methods({})
 
         else:
             return make_unicode(u''.join(self._buf))
 
+    def ll_getlength(self):
+        return self.ll_build().ll_strlen()
+
 class _null_string_builder(_null_mixin(_string_builder), _string_builder):
     def __init__(self, STRING_BUILDER):
         self.__dict__["_TYPE"] = STRING_BUILDER

pypy/rpython/ootypesystem/rbuilder.py

         builder.ll_append_char(char)
 
     @staticmethod
+    def ll_getlength(builder):
+        return builder.ll_getlength()
+
+    @staticmethod
     def ll_append(builder, string):
         builder.ll_append(string)
 

pypy/rpython/test/test_rbuilder.py

     pass
 
 class TestOOtype(BaseTestStringBuilder, OORtypeMixin):
-    def test_string_getlength(self):
-        py.test.skip("getlength(): not implemented on ootype")
-    def test_unicode_getlength(self):
-        py.test.skip("getlength(): not implemented on ootype")
     def test_append_charpsize(self):
         py.test.skip("append_charpsize(): not implemented on ootype")

pypy/translator/jvm/builtin.py

     (ootype.StringBuilder.__class__, "ll_build"):
     jvm.Method.v(jStringBuilder, "toString", (), jString),
 
+    (ootype.StringBuilder.__class__, "ll_getlength"):
+    jvm.Method.v(jStringBuilder, "length", (), jInt),
+
     (ootype.String.__class__, "ll_hash"):
     jvm.Method.v(jString, "hashCode", (), jInt),
 

pypy/translator/jvm/test/test_builder.py

+from pypy.translator.jvm.test.runtest import JvmTest
+from pypy.rpython.test.test_rbuilder import BaseTestStringBuilder
+import py
+
+class TestJvmStringBuilder(JvmTest, BaseTestStringBuilder):
+    def test_append_charpsize(self):
+        py.test.skip("append_charpsize(): not implemented on ootype")