[pypy-svn] r47146 - in pypy/branch/kill-keepalives-again/pypy: rpython/lltypesystem translator/c/src
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Oct 4 12:59:50 CEST 2007
Author: cfbolz
Date: Thu Oct 4 12:59:49 2007
New Revision: 47146
Modified:
pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/rstr.py
pypy/branch/kill-keepalives-again/pypy/translator/c/src/support.h
Log:
make rstr not look into internal structures
Modified: pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/rstr.py (original)
+++ pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/rstr.py Thu Oct 4 12:59:49 2007
@@ -87,10 +87,7 @@
cflags = inputconst(Void, {'flavor': 'gc'})
v_result = llops.genop('malloc_varsize', [cstr, cflags, 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
@@ -101,15 +98,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):
debug_assert(length >= 0, "negative string length")
Modified: pypy/branch/kill-keepalives-again/pypy/translator/c/src/support.h
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/translator/c/src/support.h (original)
+++ pypy/branch/kill-keepalives-again/pypy/translator/c/src/support.h Thu Oct 4 12:59:49 2007
@@ -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))
/* Extra checks can be enabled with the RPY_ASSERT or RPY_LL_ASSERT
* macros. They differ in the level at which the tests are made.
More information about the pypy-svn
mailing list