From: Lisandro Dalcin Date: Thu, 12 Feb 2009 20:22:15 +0000 (-0200) Subject: try handle missing T_PYSSIZET and T_SIZET definitions across Python versions (related... X-Git-Tag: 0.11.rc~80^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3dc5ccb1041cc3bebd6dba6b3ec7e3b080c61735;p=cython.git try handle missing T_PYSSIZET and T_SIZET definitions across Python versions (related to #207) --- diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 140852b7..c118e15e 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1196,8 +1196,8 @@ c_sint_type = CIntType(2, 2, "T_INT") c_slong_type = CIntType(3, 2, "T_LONG") c_slonglong_type = CLongLongType(6, 2, "T_LONGLONG") -c_py_ssize_t_type = CPySSizeTType(4, 2) -c_size_t_type = CSizeTType(5, 0) +c_py_ssize_t_type = CPySSizeTType(4, 2, "T_PYSSIZET") +c_size_t_type = CSizeTType(5, 0, "T_SIZET") c_float_type = CFloatType(7, "T_FLOAT") c_double_type = CFloatType(8, "T_DOUBLE") @@ -1400,8 +1400,36 @@ type_conversion_predeclarations = """ static INLINE int __Pyx_PyObject_IsTrue(PyObject* x); static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x); static INLINE unsigned PY_LONG_LONG __pyx_PyInt_AsUnsignedLongLong(PyObject* x); -static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b); +#if !defined(T_PYSSIZET) +#if PY_VERSION_HEX < 0x02050000 +#define T_PYSSIZET T_INT +#elif !defined(T_LONGLONG) +#define T_PYSSIZET \\ + ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \\ + ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1)) +#else +#define T_PYSSIZET \\ + ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \\ + ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : \\ + ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1))) +#endif +#endif + +#if !defined(T_SIZET) +#if !defined(T_ULONGLONG) +#define T_SIZET \\ + ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \\ + ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1)) +#else +#define T_SIZET \\ + ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \\ + ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : \\ + ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1))) +#endif +#endif + +static INLINE Py_ssize_t __pyx_PyIndex_AsSsize_t(PyObject* b); static INLINE PyObject * __pyx_PyInt_FromSize_t(size_t); static INLINE size_t __pyx_PyInt_AsSize_t(PyObject*);