1. Pypy
  2. Untitled project
  3. pypy

Commits

Armin Rigo  committed 4ffc3ff

Fix for translating with refcounting (for tests)

  • Participants
  • Parent commits d45f5a3
  • Branches stringbuilder-perf

Comments (0)

Files changed (2)

File rpython/rtyper/lltypesystem/rbuilder.py

View file
  • Ignore whitespace
     if piece.raw_ptr:
         lltype.free(piece.raw_ptr, flavor='raw')
 
+_SbRtti = lltype.getRuntimeTypeInfo(STRINGPIECE)
+def ll_string_piece_rtti(piece):
+    return _SbRtti
+
 STRINGBUILDER = lltype.GcStruct('stringbuilder',
     ('current_buf', lltype.Ptr(STR)),
     ('current_ofs', lltype.Signed),
     def rtyper_new(self, hop):
         destrptr = hop.rtyper.annotate_helper_fn(
             ll_destroy_string_piece, [SomePtr(lltype.Ptr(STRINGPIECE))])
-        lltype.attachRuntimeTypeInfo(STRINGPIECE, destrptr=destrptr)
+        hop.rtyper.attachRuntimeTypeInfoFunc(STRINGPIECE, ll_string_piece_rtti,
+                                             STRINGPIECE, destrptr)
         return AbstractStringBuilderRepr.rtyper_new(self, hop)
 
     def empty(self):

File rpython/translator/c/test/test_standalone.py

View file
  • Ignore whitespace
 
         self.compile(entry_point)
         # assert did not explode
+    
+    def test_unicode_builder(self):
+        from rpython.rlib.rstring import UnicodeBuilder
+
+        def entry_point(argv):
+            b = UnicodeBuilder()
+            b.append_multiple_char(u"\u1234", 9999)
+            u = b.build()
+            for unic in u:
+                print ord(unic)
+            return 0
+
+        t, cbuilder = self.compile(entry_point)
+        out = cbuilder.cmdexec('')
+        assert out.split() == [str(0x1234)] * 9999
+
 
 class TestMaemo(TestStandalone):
     def setup_class(cls):