Author: Maciej Fijalkowski <[email protected]>
Branch: 
Changeset: r71800:ac52eb7bbbb0
Date: 2014-06-02 09:35 +0200
http://bitbucket.org/pypy/pypy/changeset/ac52eb7bbbb0/

Log:    A way to get an address from str

diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1136,3 +1136,12 @@
             lltype.Void,
             releasegil=False
         )
+
+from rpython.rtyper.annlowlevel import llstr
+from rpython.rtyper.lltypesystem.rstr import STR
+
+def get_buffer_from_str(data):
+    lldata = llstr(data)
+    data_start = cast_ptr_to_adr(lldata) + \
+      offsetof(STR, 'chars') + itemoffsetof(STR.chars, 0)
+    return cast(CCHARP, data_start)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to