[pypy-svn] r32165 - in pypy/branch/more-gckinds/pypy: rpython/lltypesystem translator/c/src
mwh at codespeak.net
mwh at codespeak.net
Mon Sep 11 17:18:42 CEST 2006
Author: mwh
Date: Mon Sep 11 17:18:41 2006
New Revision: 32165
Modified:
pypy/branch/more-gckinds/pypy/rpython/lltypesystem/rstr.py
pypy/branch/more-gckinds/pypy/translator/c/src/support.h
Log:
redefine the pyobject <-> rpython string functions to not trade in interior
pointers.
Modified: pypy/branch/more-gckinds/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/branch/more-gckinds/pypy/rpython/lltypesystem/rstr.py (original)
+++ pypy/branch/more-gckinds/pypy/rpython/lltypesystem/rstr.py Mon Sep 11 17:18:41 2006
@@ -85,10 +85,7 @@
cstr = inputconst(Void, STR)
v_result = llops.genop('malloc_varsize', [cstr, v_len],
resulttype=Ptr(STR))
- cchars = inputconst(Void, "chars")
- v_chars = llops.genop('getsubstruct', [v_result, cchars],
- resulttype=Ptr(STR.chars))
- llops.gencapicall('PyString_ToLLCharArray', [v, v_chars])
+ llops.gencapicall('PyString_ToRPyString', [v, v_result])
string_repr = llops.rtyper.type_system.rstr.string_repr
v_result = llops.convertvar(v_result, string_repr, r_to)
return v_result
@@ -99,15 +96,11 @@
string_repr = llops.rtyper.type_system.rstr.string_repr
v = llops.convertvar(v, r_from, string_repr)
cchars = inputconst(Void, "chars")
- v_chars = llops.genop('getsubstruct', [v, cchars],
- resulttype=Ptr(STR.chars))
- v_size = llops.genop('getarraysize', [v_chars],
- resulttype=Signed)
# xxx put in table
- return llops.gencapicall('PyString_FromLLCharArrayAndSize',
- [v_chars, v_size],
+ return llops.gencapicall('PyString_FromRPyString',
+ [v],
resulttype=pyobj_repr,
- _callable= lambda chars, sz: pyobjectptr(''.join(chars)))
+ _callable= lambda v: pyobjectptr(''.join(v.chars)))
def mallocstr(length):
r = malloc(STR, length)
Modified: pypy/branch/more-gckinds/pypy/translator/c/src/support.h
==============================================================================
--- pypy/branch/more-gckinds/pypy/translator/c/src/support.h (original)
+++ pypy/branch/more-gckinds/pypy/translator/c/src/support.h Mon Sep 11 17:18:41 2006
@@ -18,12 +18,12 @@
#define FAIL_ZER(msg) FAIL_EXCEPTION(PyExc_ZeroDivisionError, msg)
#define CFAIL() RPyConvertExceptionFromCPython()
-#define PyString_FromLLCharArrayAndSize(itemsarray, size) \
- PyString_FromStringAndSize(itemsarray->items, size)
+#define PyString_FromRPyString(rpystr) \
+ PyString_FromStringAndSize(RPyString_AsString(rpystr), RPyString_Size(rpystr))
-#define PyString_ToLLCharArray(s, itemsarray) \
- memcpy(itemsarray->items, PyString_AS_STRING(s), \
- itemsarray->length)
+#define PyString_ToRPyString(s, rpystr) \
+ memcpy(RPyString_AsString(rpystr), PyString_AS_STRING(s), \
+ RPyString_Size(rpystr))
#ifndef PYPY_STANDALONE
More information about the Pypy-commit
mailing list