diff options
author | 2014-06-02 09:35:42 +0200 | |
---|---|---|
committer | 2014-06-02 09:35:42 +0200 | |
commit | 33f83ddb94cdd6989ed65905d1b77a266756d773 (patch) | |
tree | 86518cfe341489b0a114608b7c1adbc500374cd7 | |
parent | remove misleading _freeze_() (diff) | |
download | pypy-33f83ddb94cdd6989ed65905d1b77a266756d773.tar.gz pypy-33f83ddb94cdd6989ed65905d1b77a266756d773.tar.bz2 pypy-33f83ddb94cdd6989ed65905d1b77a266756d773.zip |
A way to get an address from str
-rw-r--r-- | rpython/rtyper/lltypesystem/rffi.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py index b7d11c857c..4d7e2c2039 100644 --- a/rpython/rtyper/lltypesystem/rffi.py +++ b/rpython/rtyper/lltypesystem/rffi.py @@ -1136,3 +1136,12 @@ c_memcpy = llexternal("memcpy", 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) |