[pypy-svn] r25939 - in pypy/dist/pypy/rpython/rctypes: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Apr 18 12:37:05 CEST 2006
Author: arigo
Date: Tue Apr 18 12:37:04 2006
New Revision: 25939
Modified:
pypy/dist/pypy/rpython/rctypes/aprimitive.py
pypy/dist/pypy/rpython/rctypes/rprimitive.py
pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py
Log:
c_wchar support. No c_wchar_p so far.
Modified: pypy/dist/pypy/rpython/rctypes/aprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/aprimitive.py (original)
+++ pypy/dist/pypy/rpython/rctypes/aprimitive.py Tue Apr 18 12:37:04 2006
@@ -1,12 +1,13 @@
from ctypes import c_char, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint
from ctypes import c_long, c_ulong, c_longlong, c_ulonglong, c_float
-from ctypes import c_double, c_char_p
+from ctypes import c_double, c_wchar, c_char_p
from pypy.annotation import model as annmodel
from pypy.rpython import extregistry
from pypy.rpython.lltypesystem import lltype
ctypes_annotation_list = {
c_char: lltype.Char,
+ c_wchar: lltype.UniChar,
c_byte: lltype.Signed,
c_ubyte: lltype.Unsigned,
c_short: lltype.Signed,
Modified: pypy/dist/pypy/rpython/rctypes/rprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/rprimitive.py (original)
+++ pypy/dist/pypy/rpython/rctypes/rprimitive.py Tue Apr 18 12:37:04 2006
@@ -1,7 +1,7 @@
from pypy.rpython.rmodel import inputconst
from pypy.rpython.lltypesystem import lltype
from pypy.annotation.pairtype import pairtype
-from pypy.rpython.rmodel import IntegerRepr, FloatRepr, CharRepr
+from pypy.rpython.rmodel import IntegerRepr, FloatRepr, CharRepr, UniCharRepr
from pypy.rpython.error import TyperError
from pypy.rpython.rctypes.rmodel import CTypesValueRepr
@@ -37,7 +37,8 @@
class __extend__(pairtype(IntegerRepr, PrimitiveRepr),
pairtype(FloatRepr, PrimitiveRepr),
- pairtype(CharRepr, PrimitiveRepr)):
+ pairtype(CharRepr, PrimitiveRepr),
+ pairtype(UniCharRepr, PrimitiveRepr)):
def convert_from_to((r_from, r_to), v, llops):
# first convert 'v' to the precise expected low-level type
r_input = r_to.rtyper.primitive_to_repr[r_to.ll_type]
Modified: pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py
==============================================================================
--- pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py (original)
+++ pypy/dist/pypy/rpython/rctypes/test/test_rprimitive.py Tue Apr 18 12:37:04 2006
@@ -20,7 +20,7 @@
from ctypes import c_char, c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint
from ctypes import c_long, c_ulong, c_longlong, c_ulonglong, c_float
-from ctypes import c_double, c_char_p, pointer
+from ctypes import c_double, c_wchar, c_char_p, pointer
class Test_annotation:
def test_simple(self):
@@ -224,6 +224,9 @@
assert x.value == 2.75
x.value -= 1
assert x.value == 1.75
+ x = c_wchar(u'A')
+ x.value = unichr(ord(x.value) + 1)
+ assert x.value == u'B'
interpret(func, [])
def test_convert_from_llvalue(self):
@@ -250,6 +253,9 @@
assert x.value == 2.75
pointer(x)[0] -= 1
assert x.value == 1.75
+ x = c_wchar(u'A')
+ pointer(x)[0] = unichr(ord(pointer(x)[0]) + 1)
+ assert x.value == u'B'
interpret(func, [])
class Test_compilation:
More information about the Pypy-commit
mailing list