Bug 757469 - Implement ctypes.off_t. r=jorendorff

This commit is contained in:
David Rajchenbach-Teller 2012-05-26 09:33:52 -04:00
parent 92dd78a294
commit 35d32fe331
2 changed files with 14 additions and 0 deletions

View File

@ -64,6 +64,7 @@
#define CTYPES_FFI_ULONG (sizeof(long) == 4 ? ffi_type_uint32 : ffi_type_uint64)
#define CTYPES_FFI_SIZE_T (sizeof(size_t) == 4 ? ffi_type_uint32 : ffi_type_uint64)
#define CTYPES_FFI_SSIZE_T (sizeof(size_t) == 4 ? ffi_type_sint32 : ffi_type_sint64)
#define CTYPES_FFI_OFF_T (sizeof(off_t) == 4 ? ffi_type_sint32 : ffi_type_sint64)
#define CTYPES_FFI_INTPTR_T (sizeof(uintptr_t) == 4 ? ffi_type_sint32 : ffi_type_sint64)
#define CTYPES_FFI_UINTPTR_T (sizeof(uintptr_t) == 4 ? ffi_type_uint32 : ffi_type_uint64)
@ -87,6 +88,7 @@ DEFINE_WRAPPED_INT_TYPE(long_long, long long, ffi_type_sint64)
DEFINE_WRAPPED_INT_TYPE(unsigned_long_long, unsigned long long, ffi_type_uint64)
DEFINE_WRAPPED_INT_TYPE(size_t, size_t, CTYPES_FFI_SIZE_T)
DEFINE_WRAPPED_INT_TYPE(ssize_t, CTYPES_SSIZE_T, CTYPES_FFI_SSIZE_T)
DEFINE_WRAPPED_INT_TYPE(off_t, off_t, CTYPES_FFI_OFF_T)
DEFINE_WRAPPED_INT_TYPE(intptr_t, intptr_t, CTYPES_FFI_INTPTR_T)
DEFINE_WRAPPED_INT_TYPE(uintptr_t, uintptr_t, CTYPES_FFI_UINTPTR_T)
DEFINE_FLOAT_TYPE (float32_t, float, ffi_type_float)

View File

@ -131,6 +131,18 @@ function run_test()
run_wrapped_integer_tests(library, ctypes.intptr_t, "intptr_t", ctypes.size_t.size, true,
ctypes.Int64, "ctypes.Int64", slimits);
if (ctypes.off_t.size == 8) {
slimits = s64limits;
ulimits = u64limits;
} else if (ctypes.off_t.size == 4) {
slimits = s32limits;
ulimits = u32limits;
} else {
do_throw("ctypes.off_t is not 4 or 8 bytes");
}
run_wrapped_integer_tests(library, ctypes.off_t, "off_t", ctypes.off_t.size, true,
ctypes.Int64, "ctypes.Int64", slimits);
// Test the character types.
run_char_tests(library, ctypes.char, "char", 1, true, [-0x80, 0x7f]);
run_char_tests(library, ctypes.signed_char, "signed_char", 1, true, [-0x80, 0x7f]);