Commit b12a56a3 authored by Stefan Behnel's avatar Stefan Behnel

replace plain '#define CYTHON_PEP393_ENABLED' by flag #define as 1 or 0 to...

replace plain '#define CYTHON_PEP393_ENABLED' by flag #define as 1 or 0 to make it usable from Cython code
parent 8966bfba
...@@ -1510,7 +1510,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) { ...@@ -1510,7 +1510,7 @@ static CYTHON_INLINE Py_UCS4 __Pyx_PyObject_AsPy_UCS4(PyObject* x) {
long ival; long ival;
if (PyUnicode_Check(x)) { if (PyUnicode_Check(x)) {
Py_ssize_t length; Py_ssize_t length;
#ifdef CYTHON_PEP393_ENABLED #if CYTHON_PEP393_ENABLED
length = PyUnicode_GET_LENGTH(x); length = PyUnicode_GET_LENGTH(x);
if (likely(length == 1)) { if (likely(length == 1)) {
return PyUnicode_READ_CHAR(x, 0); return PyUnicode_READ_CHAR(x, 0);
...@@ -1580,7 +1580,7 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*); ...@@ -1580,7 +1580,7 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject*);
impl=''' impl='''
static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) { static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
long ival; long ival;
#ifdef CYTHON_PEP393_ENABLED #if CYTHON_PEP393_ENABLED
const long maxval = 1114111; const long maxval = 1114111;
#else #else
static long maxval = 0; static long maxval = 0;
...@@ -1592,13 +1592,13 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) { ...@@ -1592,13 +1592,13 @@ static CYTHON_INLINE Py_UNICODE __Pyx_PyObject_AsPy_UNICODE(PyObject* x) {
"got length %" PY_FORMAT_SIZE_T "d", __Pyx_PyUnicode_GET_LENGTH(x)); "got length %" PY_FORMAT_SIZE_T "d", __Pyx_PyUnicode_GET_LENGTH(x));
return (Py_UNICODE)-1; return (Py_UNICODE)-1;
} }
#ifdef CYTHON_PEP393_ENABLED #if CYTHON_PEP393_ENABLED
ival = PyUnicode_READ_CHAR(x, 0); ival = PyUnicode_READ_CHAR(x, 0);
#else #else
return PyUnicode_AS_UNICODE(x)[0]; return PyUnicode_AS_UNICODE(x)[0];
#endif #endif
} else { } else {
#ifndef CYTHON_PEP393_ENABLED #if CYTHON_PEP393_ENABLED
if (unlikely(!maxval)) if (unlikely(!maxval))
maxval = (long)PyUnicode_GetMax(); maxval = (long)PyUnicode_GetMax();
#endif #endif
......
...@@ -124,10 +124,11 @@ ...@@ -124,10 +124,11 @@
/* new Py3.3 unicode representation (PEP 393) */ /* new Py3.3 unicode representation (PEP 393) */
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH) #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_GET_LENGTH)
#define CYTHON_PEP393_ENABLED #define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#else #else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#endif #endif
......
...@@ -28,7 +28,7 @@ static CYTHON_INLINE int __Pyx_PyUnicodeBufferContainsUCS4(Py_UNICODE* buffer, P ...@@ -28,7 +28,7 @@ static CYTHON_INLINE int __Pyx_PyUnicodeBufferContainsUCS4(Py_UNICODE* buffer, P
//////////////////// PyUCS4InUnicode //////////////////// //////////////////// PyUCS4InUnicode ////////////////////
static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) { static CYTHON_INLINE int __Pyx_UnicodeContainsUCS4(PyObject* unicode, Py_UCS4 character) {
#ifdef CYTHON_PEP393_ENABLED #if CYTHON_PEP393_ENABLED
Py_ssize_t i; Py_ssize_t i;
int kind; int kind;
void* udata; void* udata;
...@@ -94,7 +94,7 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int ...@@ -94,7 +94,7 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int
/* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */ /* as done by PyObject_RichCompareBool(); also catches the (interned) empty string */
return (equals == Py_EQ); return (equals == Py_EQ);
} else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) { } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
#ifdef CYTHON_PEP393_ENABLED #if CYTHON_PEP393_ENABLED
if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0)) if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0))
return -1; return -1;
if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) { if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment