Hello again, Attached is a patch that continues with the idea of declaring constants using their corresponding type.
Great work on Cython, by the way. It's very useful. Mansour
From 4f537f477d845468f36ac7b9370185124250520a Mon Sep 17 00:00:00 2001 From: Mansour Moufid <mansourmou...@gmail.com> Date: Fri, 20 Jan 2012 13:48:41 -0500 Subject: [PATCH] Continue defining constants using corresponding types. Mimic glibc when uncertain. For the new wchar.pxd: - wint_t is defined as typedef unsigned int in glibc. For stdint.pxd: - ptrdiff_t, wchar_t, and size_t are defined in stddef.pxd; - wint_t is defined in wchar.pxd; and - sig_atomic_t is defined in signal.pxd. For limits.pxd: - CHAR_BIT is always 8; and - MB_LEN_MAX is 16 in glibc. --- Cython/Includes/libc/limits.pxd | 36 ++++++++++++++++++------------------ Cython/Includes/libc/stdint.pxd | 32 ++++++++++++++++++-------------- Cython/Includes/libc/wchar.pxd | 5 +++++ 3 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 Cython/Includes/libc/wchar.pxd diff --git a/Cython/Includes/libc/limits.pxd b/Cython/Includes/libc/limits.pxd index 3951dde..17cb640 100644 --- a/Cython/Includes/libc/limits.pxd +++ b/Cython/Includes/libc/limits.pxd @@ -1,29 +1,29 @@ # 5.2.4.2.1 Sizes of integer types <limits.h> -cdef extern from "limits.h": +cdef extern from "limits.h" nogil: enum: CHAR_BIT enum: MB_LEN_MAX - enum: CHAR_MIN - enum: CHAR_MAX + char CHAR_MIN + char CHAR_MAX - enum: SCHAR_MIN - enum: SCHAR_MAX - enum: UCHAR_MAX + signed char SCHAR_MIN + signed char SCHAR_MAX + unsigned char UCHAR_MAX - enum: SHRT_MIN - enum: SHRT_MAX - enum: USHRT_MAX + short SHRT_MIN + short SHRT_MAX + unsigned short USHRT_MAX - enum: INT_MIN - enum: INT_MAX - enum: UINT_MAX + int INT_MIN + int INT_MAX + unsigned int UINT_MAX - enum: LONG_MIN - enum: LONG_MAX - enum: ULONG_MAX + long int LONG_MIN + long int LONG_MAX + unsigned long int ULONG_MAX - enum: LLONG_MIN - enum: LLONG_MAX - enum: ULLONG_MAX + long long int LLONG_MIN + long long int LLONG_MAX + unsigned long long int ULLONG_MAX diff --git a/Cython/Includes/libc/stdint.pxd b/Cython/Includes/libc/stdint.pxd index 4d791a1..1237eb8 100644 --- a/Cython/Includes/libc/stdint.pxd +++ b/Cython/Includes/libc/stdint.pxd @@ -1,6 +1,10 @@ # Longness only used for type promotion. # Actual compile time size used for conversions. +from libc.stddef cimport ptrdiff_t, wchar_t, size_t +from libc.wchar cimport wint_t +from libc.signal cimport sig_atomic_t + # 7.18 Integer types <stdint.h> cdef extern from "stdint.h" nogil: @@ -80,26 +84,26 @@ cdef extern from "stdint.h" nogil: uint_fast32_t UINT_FAST32_MAX uint_fast64_t UINT_FAST64_MAX #7.18.2.4 Limits of integer types capable of holding object pointers - enum: INTPTR_MIN - enum: INTPTR_MAX - enum: UINTPTR_MAX + intptr_t INTPTR_MIN + intptr_t INTPTR_MAX + uintptr_t UINTPTR_MAX # 7.18.2.5 Limits of greatest-width integer types - enum: INTMAX_MAX - enum: INTMAX_MIN - enum: UINTMAX_MAX + intmax_t INTMAX_MAX + intmax_t INTMAX_MIN + uintmax_t UINTMAX_MAX # 7.18.3 Limits of other integer types # ptrdiff_t - enum: PTRDIFF_MIN - enum: PTRDIFF_MAX + ptrdiff_t PTRDIFF_MIN + ptrdiff_t PTRDIFF_MAX # sig_atomic_t - enum: SIG_ATOMIC_MIN - enum: SIG_ATOMIC_MAX + sig_atomic_t SIG_ATOMIC_MIN + sig_atomic_t SIG_ATOMIC_MAX # size_t size_t SIZE_MAX # wchar_t - enum: WCHAR_MIN - enum: WCHAR_MAX + wchar_t WCHAR_MIN + wchar_t WCHAR_MAX # wint_t - enum: WINT_MIN - enum: WINT_MAX + wint_t WINT_MIN + wint_t WINT_MAX diff --git a/Cython/Includes/libc/wchar.pxd b/Cython/Includes/libc/wchar.pxd new file mode 100644 index 0000000..4c01390 --- /dev/null +++ b/Cython/Includes/libc/wchar.pxd @@ -0,0 +1,5 @@ +cdef extern from "wchar.h" nogil: + + ctypedef unsigned int wint_t + + wint_t WEOF -- 1.7.5.4
_______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel