Author: Michal Bendowski <[email protected]>
Branch: jvm-improvements
Changeset: r51375:90cb8d420991
Date: 2012-01-11 22:26 +0100
http://bitbucket.org/pypy/pypy/changeset/90cb8d420991/
Log: Fix userspace builders in ootype
Implement the getlength() method of StringBuilders in ootype.
diff --git a/pypy/rpython/ootypesystem/ootype.py
b/pypy/rpython/ootypesystem/ootype.py
--- a/pypy/rpython/ootypesystem/ootype.py
+++ b/pypy/rpython/ootypesystem/ootype.py
@@ -512,6 +512,7 @@
"ll_append_char": Meth([CHARTP], Void),
"ll_append": Meth([STRINGTP], Void),
"ll_build": Meth([], STRINGTP),
+ "ll_getlength": Meth([], Signed),
})
self._setup_methods({})
@@ -1543,6 +1544,9 @@
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
diff --git a/pypy/rpython/ootypesystem/rbuilder.py
b/pypy/rpython/ootypesystem/rbuilder.py
--- a/pypy/rpython/ootypesystem/rbuilder.py
+++ b/pypy/rpython/ootypesystem/rbuilder.py
@@ -21,6 +21,10 @@
builder.ll_append_char(char)
@staticmethod
+ def ll_getlength(builder):
+ return builder.ll_getlength()
+
+ @staticmethod
def ll_append(builder, string):
builder.ll_append(string)
diff --git a/pypy/rpython/test/test_rbuilder.py
b/pypy/rpython/test/test_rbuilder.py
--- a/pypy/rpython/test/test_rbuilder.py
+++ b/pypy/rpython/test/test_rbuilder.py
@@ -124,9 +124,5 @@
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")
diff --git a/pypy/translator/jvm/builtin.py b/pypy/translator/jvm/builtin.py
--- a/pypy/translator/jvm/builtin.py
+++ b/pypy/translator/jvm/builtin.py
@@ -84,6 +84,9 @@
(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),
diff --git a/pypy/translator/jvm/test/test_builder.py
b/pypy/translator/jvm/test/test_builder.py
new file mode 100644
--- /dev/null
+++ b/pypy/translator/jvm/test/test_builder.py
@@ -0,0 +1,7 @@
+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")
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit