[pypy-svn] r45715 - in pypy/branch/pypy-more-rtti-inprogress/rpython/tool: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Aug 16 13:48:44 CEST 2007
Author: fijal
Date: Thu Aug 16 13:48:43 2007
New Revision: 45715
Modified:
pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py
pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py
Log:
Another test passes
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/tool/rffi_platform.py Thu Aug 16 13:48:43 2007
@@ -173,7 +173,7 @@
offset = info['fldofs ' + fieldname]
size = info['fldsize ' + fieldname]
sign = info.get('fldunsigned ' + fieldname, False)
- if (size, sign) != size_and_sign(fieldtype):
+ if (size, sign) != rffi.size_and_sign(fieldtype):
fieldtype = fixup_ctype(fieldtype, fieldname, (size, sign))
layout_addfield(layout, offset, fieldtype, fieldname)
@@ -232,7 +232,7 @@
size = info['size']
sign = info.get('unsigned', False)
ctype = self.ctype_hint
- if (size, sign) != size_and_sign(ctype):
+ if (size, sign) != rffi.size_and_sign(ctype):
ctype = fixup_ctype(ctype, self.name, (size, sign))
return ctype
@@ -375,7 +375,7 @@
LAST[0] += 1
return udir.join('platcheck_%d.c' % i)
-integer_class = [rffi.SIGNEDCHAR, rffi.CHAR,
+integer_class = [rffi.CHAR, rffi.UCHAR,
rffi.SHORT, rffi.USHORT,
rffi.INT, rffi.UINT,
rffi.LONG, rffi.ULONG,
@@ -392,7 +392,7 @@
return '<field %s: %s>' % (self.name, self.ctype)
def layout_addfield(layout, offset, ctype, prefix):
- size = _sizeof(ctype)
+ size = rffi.sizeof(ctype)
name = prefix
i = 0
while name in layout:
@@ -404,22 +404,11 @@
layout[i] = field
return field
-def _sizeof(ctype):
- return ctype._type.BITS / 8
-
-def size_and_sign(ctype):
- # XXX uh, dirty hack
- if ctype is lltype.Char:
- return 1, 1
- assert isinstance(ctype, lltype.Number)
- r_type = ctype._type
- return _sizeof(ctype), not r_type.SIGNED
-
def fixup_ctype(fieldtype, fieldname, expected_size_and_sign):
for typeclass in [integer_class, float_class]:
if fieldtype in typeclass:
for ctype in typeclass:
- if size_and_sign(ctype) == expected_size_and_sign:
+ if rffi.size_and_sign(ctype) == expected_size_and_sign:
return ctype
xxxx
if (hasattr(fieldtype, '_length_')
Modified: pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py (original)
+++ pypy/branch/pypy-more-rtti-inprogress/rpython/tool/test/test_rffi_platform.py Thu Aug 16 13:48:43 2007
@@ -37,8 +37,7 @@
assert dirent._flds['c_d_reclen'] is rffi.USHORT
def test_fit_type():
- py.test.skip("Next to go")
- S = ctypes_platform.getstruct("struct S",
+ S = rffi_platform.getstruct("struct S",
"""
struct S {
signed char c;
@@ -51,36 +50,35 @@
unsigned long ul;
long long ll;
unsigned long long ull;
- float f;
double d;
};
""",
- [("c", ctypes.c_int),
- ("uc", ctypes.c_int),
- ("s", ctypes.c_uint),
- ("us", ctypes.c_int),
- ("i", ctypes.c_int),
- ("ui", ctypes.c_int),
- ("l", ctypes.c_int),
- ("ul", ctypes.c_int),
- ("ll", ctypes.c_int),
- ("ull", ctypes.c_int),
- ("f", ctypes.c_double),
- ("d", ctypes.c_float)])
- assert issubclass(S, ctypes.Structure)
- fields = dict(S._fields_)
- assert fields["c"] == ctypes.c_byte
- assert fields["uc"] == ctypes.c_ubyte
- assert fields["s"] == ctypes.c_short
- assert fields["us"] == ctypes.c_ushort
- assert fields["i"] == ctypes.c_int
- assert fields["ui"] == ctypes.c_uint
- assert fields["l"] == ctypes.c_long
- assert fields["ul"] == ctypes.c_ulong
- assert fields["ll"] == ctypes.c_longlong
- assert fields["ull"] == ctypes.c_ulonglong
- assert fields["f"] == ctypes.c_float
- assert fields["d"] == ctypes.c_double
+ [("c", rffi.INT),
+ ("uc", rffi.INT),
+ ("s", rffi.UINT),
+ ("us", rffi.INT),
+ ("i", rffi.INT),
+ ("ui", rffi.INT),
+ ("l", rffi.INT),
+ ("ul", rffi.INT),
+ ("ll", rffi.INT),
+ ("ull", rffi.INT),
+ ("d", rffi.DOUBLE)])
+ # XXX we need to have a float here as well as soon as we'll
+ # have support
+ assert isinstance(S, lltype.Struct)
+ fields = dict(S._flds)
+ assert fields["c_c"] == rffi.CHAR
+ assert fields["c_uc"] == rffi.UCHAR
+ assert fields["c_s"] == rffi.SHORT
+ assert fields["c_us"] == rffi.USHORT
+ assert fields["c_i"] == rffi.INT
+ assert fields["c_ui"] == rffi.UINT
+ assert fields["c_l"] == rffi.LONG
+ assert fields["c_ul"] == rffi.ULONG
+ assert fields["c_ll"] == rffi.LONGLONG
+ assert fields["c_ull"] == rffi.ULONGLONG
+ assert fields["c_d"] == rffi.DOUBLE
def test_simple_type():
py.test.skip("Next to go")
More information about the Pypy-commit
mailing list