[pypy-svn] r74012 - in pypy/branch/cpython-extension/pypy/module/cpyext: . include
afa at codespeak.net
afa at codespeak.net
Fri Apr 23 13:33:19 CEST 2010
Author: afa
Date: Fri Apr 23 13:33:18 2010
New Revision: 74012
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h
pypy/branch/cpython-extension/pypy/module/cpyext/structmember.py
Log:
Add T_BYTE in structmember
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/include/structmember.h Fri Apr 23 13:33:18 2010
@@ -27,6 +27,7 @@
#define T_STRING 5
#define T_OBJECT 6
#define T_CHAR 7 /* 1-character string */
+#define T_BYTE 8 /* 8-bit signed int */
#define T_USHORT 10
#define T_UINT 11
#define T_ULONG 12
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/structmember.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/structmember.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/structmember.py Fri Apr 23 13:33:18 2010
@@ -34,6 +34,9 @@
elif member_type == structmemberdefs.T_ULONG:
result = rffi.cast(rffi.ULONGP, addr)
w_result = space.wrap(result[0])
+ elif member_type == structmemberdefs.T_BYTE:
+ result = rffi.cast(rffi.CCHARP, addr)
+ w_result = space.wrap(result[0])
elif member_type == structmemberdefs.T_STRING:
result = rffi.cast(rffi.CCHARPP, addr)
if result[0]:
@@ -107,6 +110,10 @@
w_long_value = PyInt_AsUnsignedLong(space, w_value)
array = rffi.cast(rffi.ULONGP, addr)
array[0] = rffi.cast(rffi.ULONG, w_long_value)
+ elif member_type == structmemberdefs.T_BYTE:
+ w_long_value = PyInt_AsLong(space, w_value)
+ array = rffi.cast(rffi.CCHARP, addr)
+ array[0] = rffi.cast(rffi.CHAR, w_long_value)
elif member_type == structmemberdefs.T_CHAR:
str_value = space.str_w(w_value)
if len(str_value) != 1:
More information about the Pypy-commit
mailing list